]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/TocModel.h
Fix for bug 2975 (http://bugzilla.lyx.org/show_bug.cgi?id=2975) from Ozgur Ugras...
[lyx.git] / src / frontends / qt4 / TocModel.h
1 // -*- C++ -*-
2 /**
3  * \file TocModel.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef TOCMODEL_H
13 #define TOCMODEL_H
14
15 #include "TocBackend.h"
16
17 #include "qt_helpers.h"
18
19 #include <QStandardItemModel>
20
21 #include <map>
22 #include <string>
23
24 namespace lyx {
25 namespace frontend {
26
27 typedef TocBackend::Toc::const_iterator TocIterator;
28
29 class TocModel: public QStandardItemModel {
30         Q_OBJECT
31
32 public:
33         ///
34         TocModel() {}
35         ///
36         TocModel(TocBackend::Toc const & toc);
37         ///
38         ~TocModel() {}
39         ///
40         TocModel const & operator=(TocBackend::Toc const & toc);
41         ///
42         void clear();
43         ///
44         void populate(TocBackend::Toc const & toc);
45         ///
46         TocIterator const tocIterator(QModelIndex const & index) const;
47         ///
48         QModelIndex const modelIndex(TocIterator const & it) const;
49
50 private:
51         ///
52         void populate(TocIterator & it,
53                 TocIterator const & end,
54                 QModelIndex const & parent);
55         ///
56         typedef std::map<QModelIndex, TocIterator> TocMap;
57         ///
58         typedef std::pair<QModelIndex, TocIterator> TocPair;
59         ///
60         typedef std::map<TocIterator, QModelIndex> ModelMap;
61         ///
62         TocMap toc_map_;
63         ///
64         ModelMap model_map_;
65 };
66
67 } // namespace frontend
68 } // namespace lyx
69
70 #endif // TOCMODEL_H