* biblioExample.bib: correct title.
[lyx.git] / src / IndicesList.h
blob019c54835df336808cf935aa2324026992b2bbfa
1 // -*- C++ -*-
2 /**
3 * \file IndicesList.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
11 * \class Index
13 * A class describing an Index type, such as "Index of Names".
14 * Different Index types are used in splitted Indices
16 * An Index has a name and a shortcut notation. It uses a
17 * user-specifyable GUI colour. All these can be set and
18 * queried.
20 * \class IndicesList
22 * A class containing a vector of all defined indices within a
23 * document. Has methods for outputting a '|'-separated string
24 * of all elements, and for adding, removing and renaming elements.
28 #ifndef INDICESLIST_H
29 #define INDICESLIST_H
31 #include "ColorCode.h"
33 #include "support/docstring.h"
35 #include <list>
38 namespace lyx {
40 class Index {
41 public:
42 ///
43 Index();
44 ///
45 docstring const & index() const;
46 ///
47 void setIndex(docstring const &);
48 ///
49 docstring const & shortcut() const;
50 ///
51 void setShortcut(docstring const &);
52 ///
53 RGBColor const & color() const;
54 ///
55 void setColor(RGBColor const &);
56 /**
57 * Set color from a string "#rrggbb".
58 * Use Color:background if the string is no valid color.
59 * This ensures compatibility with LyX 1.4.0 that had the symbolic
60 * color "none" that was displayed as Color:background.
62 void setColor(std::string const &);
64 private:
65 ///
66 docstring index_;
67 ///
68 docstring shortcut_;
69 ///
70 RGBColor color_;
74 class IndicesList {
75 ///
76 typedef std::list<Index> List;
77 public:
78 typedef List::const_iterator const_iterator;
80 ///
81 IndicesList() : separator_(from_ascii("|")) {}
83 ///
84 bool empty() const { return list.empty(); }
85 ///
86 void clear() { list.clear(); }
87 ///
88 const_iterator begin() const { return list.begin(); }
89 const_iterator end() const { return list.end(); }
91 /** \returns the Index with \c name. If not found, returns 0.
93 Index * find(docstring const & name);
94 Index const * find(docstring const & name) const;
96 /** \returns the Index with the shortcut \c shortcut.
97 * If not found, returns 0.
99 Index * findShortcut(docstring const & shortcut);
100 Index const * findShortcut(docstring const & shortcut) const;
102 /** Add (possibly multiple (separated by separator())) indices to list
103 * \returns true if an index is added.
105 bool add(docstring const & n, docstring const & s = docstring());
106 /** Add the default index (if not already there)
107 * \returns true if an index is added.
109 bool addDefault(docstring const & n);
110 /** remove an index from list by name
111 * \returns true if an index is removed.
113 bool remove(docstring const &);
114 /** rename an index in list
115 * \returns true if renaming succeeded.
117 bool rename(docstring const &, docstring const &);
119 private:
121 List list;
123 docstring separator_;
126 } // namespace lyx
128 #endif // INDICESLIST_H