]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/TocModel.h
fix completion painting for RTL (inline completion and completion list)
[lyx.git] / src / frontends / qt4 / TocModel.h
index 4d36213d72a3be97cce3086c21d5d5c084009455..2bf4c43282ac4f593b0718666f71f6c0f415714e 100644 (file)
 #include <QStandardItemModel>
 
 #include <map>
-#include <string>
 
 namespace lyx {
-namespace frontend {
 
-typedef TocBackend::Toc::const_iterator TocIterator;
+class BufferView;
 
-class TocModel: public QStandardItemModel {
-       Q_OBJECT
+namespace frontend {
 
+class TocModel : public QStandardItemModel
+{
 public:
        ///
        TocModel() {}
        ///
-       TocModel(TocBackend::Toc const & toc);
-       ///
-       ~TocModel() {}
-       ///
-       TocModel const & operator=(TocBackend::Toc const & toc);
+       TocModel(Toc const & toc) { populate(toc); }
        ///
        void clear();
        ///
-       void populate(TocBackend::Toc const & toc);
+       void populate(Toc const & toc);
+       ///
+       TocIterator tocIterator(QModelIndex const & index) const;
        ///
-       TocIterator const tocIterator(QModelIndex const & index) const;
+       QModelIndex modelIndex(TocIterator const & it) const;
        ///
-       QModelIndex const modelIndex(TocIterator const & it) const;
+       int modelDepth() const;
 
 private:
        ///
-       void populate(TocIterator & it,
-               TocIterator const & end,
+       void populate(TocIterator & it, TocIterator const & end,
                QModelIndex const & parent);
        ///
        typedef std::map<QModelIndex, TocIterator> TocMap;
        ///
-       typedef std::pair<QModelIndex, TocIterator> TocPair;
-       ///
        typedef std::map<TocIterator, QModelIndex> ModelMap;
        ///
        TocMap toc_map_;
        ///
        ModelMap model_map_;
+       ///
+       int maxdepth_;
+       int mindepth_;
+};
+
+
+class TocModels: public QObject
+{
+       Q_OBJECT
+public:
+       ///
+       TocModels(): bv_(0) {}
+       ///
+       ~TocModels() { clear(); }
+       ///
+       void reset(BufferView const * bv);
+       ///
+       int depth(int type);
+       ///
+       QStandardItemModel * model(int type);
+       ///
+       QModelIndex currentIndex(int type) const;
+       ///
+       void goTo(int type, QModelIndex const & index) const;
+       ///
+       void init(Buffer const & buffer);
+       /// Test if outlining operation is possible
+       bool canOutline(int type) const;
+       /// Return the list of types available
+       QStringList const & typeNames() const { return type_names_; }
+       ///
+       void updateBackend() const;
+       ///
+       int decodeType(QString const & str) const;
+
+Q_SIGNALS:
+       /// Signal that the internal toc_models_ has been reset.
+       void modelReset();
+
+private:
+       ///
+       void clear();
+       ///
+       BufferView const * bv_;
+       ///
+       std::vector<TocModel *> models_;
+       ///
+       QStringList types_;
+       ///
+       QStringList type_names_;
 };
 
 } // namespace frontend