2006-04-18 09:57:47 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file TocModel.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOCMODEL_H
|
|
|
|
#define TOCMODEL_H
|
|
|
|
|
2006-04-22 18:48:28 +00:00
|
|
|
#include "TocBackend.h"
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
class TocModel: public QStandardItemModel {
|
|
|
|
Q_OBJECT
|
2006-04-28 09:16:48 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
TocModel() {}
|
|
|
|
///
|
2006-11-13 16:53:49 +00:00
|
|
|
TocModel(Toc const & toc);
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
|
|
|
~TocModel() {}
|
|
|
|
///
|
2006-11-13 16:53:49 +00:00
|
|
|
TocModel const & operator=(Toc const & toc);
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
|
|
|
void clear();
|
|
|
|
///
|
2006-11-13 16:53:49 +00:00
|
|
|
void populate(Toc const & toc);
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2006-04-22 18:48:28 +00:00
|
|
|
TocIterator const tocIterator(QModelIndex const & index) const;
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2006-04-22 18:48:28 +00:00
|
|
|
QModelIndex const modelIndex(TocIterator const & it) const;
|
2006-11-25 22:16:22 +00:00
|
|
|
///
|
|
|
|
int modelDepth();
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
2006-04-22 18:48:28 +00:00
|
|
|
void populate(TocIterator & it,
|
|
|
|
TocIterator const & end,
|
2006-04-28 09:16:48 +00:00
|
|
|
QModelIndex const & parent);
|
2006-04-22 18:48:28 +00:00
|
|
|
///
|
|
|
|
typedef std::map<QModelIndex, TocIterator> TocMap;
|
|
|
|
///
|
2006-11-09 13:13:28 +00:00
|
|
|
typedef std::pair<QModelIndex, TocIterator> TocPair;
|
|
|
|
///
|
2006-04-22 18:48:28 +00:00
|
|
|
typedef std::map<TocIterator, QModelIndex> ModelMap;
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2006-04-28 09:16:48 +00:00
|
|
|
TocMap toc_map_;
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2006-04-22 18:48:28 +00:00
|
|
|
ModelMap model_map_;
|
2006-11-25 22:16:22 +00:00
|
|
|
///
|
|
|
|
int maxdepth_;
|
|
|
|
int mindepth_;
|
2006-04-18 09:57:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // TOCMODEL_H
|