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
|
|
|
|
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2008-06-12 15:31:10 +00:00
|
|
|
#include <QList>
|
2006-04-18 09:57:47 +00:00
|
|
|
#include <QStandardItemModel>
|
2008-06-12 15:31:10 +00:00
|
|
|
#include <QStringList>
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2008-05-02 12:09:51 +00:00
|
|
|
|
2008-06-12 15:31:10 +00:00
|
|
|
class Buffer;
|
2008-05-02 12:09:51 +00:00
|
|
|
class BufferView;
|
2008-06-12 15:31:10 +00:00
|
|
|
class DocIterator;
|
|
|
|
class Toc;
|
|
|
|
class TocItem;
|
2008-05-02 12:09:51 +00:00
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-14 00:21:31 +00:00
|
|
|
class TocModel : public QStandardItemModel
|
|
|
|
{
|
2006-04-18 09:57:47 +00:00
|
|
|
public:
|
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
TocModel(Toc const & toc);
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
TocItem const & tocItem(QModelIndex const & index) const;
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
QModelIndex modelIndex(DocIterator const & dit) const;
|
2006-11-25 22:16:22 +00:00
|
|
|
///
|
2007-11-14 00:21:31 +00:00
|
|
|
int modelDepth() const;
|
2006-04-18 09:57:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
void populate(size_t & index, QModelIndex const & parent);
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
QList<QModelIndex> toc_indexes_;
|
2006-04-18 09:57:47 +00:00
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
Toc const & toc_;
|
2006-11-25 22:16:22 +00:00
|
|
|
///
|
|
|
|
int maxdepth_;
|
|
|
|
int mindepth_;
|
2006-04-18 09:57:47 +00:00
|
|
|
};
|
|
|
|
|
2008-05-02 12:09:51 +00:00
|
|
|
|
|
|
|
class TocModels: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
TocModels(): bv_(0) {}
|
|
|
|
///
|
2008-05-02 15:54:41 +00:00
|
|
|
~TocModels() { clear(); }
|
2008-05-02 12:09:51 +00:00
|
|
|
///
|
|
|
|
void reset(BufferView const * bv);
|
|
|
|
///
|
|
|
|
int depth(int type);
|
|
|
|
///
|
|
|
|
QStandardItemModel * model(int type);
|
|
|
|
///
|
2008-05-02 15:54:41 +00:00
|
|
|
QModelIndex currentIndex(int type) const;
|
2008-05-02 12:09:51 +00:00
|
|
|
///
|
|
|
|
void goTo(int type, QModelIndex const & index) const;
|
|
|
|
///
|
2008-05-02 15:54:41 +00:00
|
|
|
void init(Buffer const & buffer);
|
2008-05-02 12:09:51 +00:00
|
|
|
/// 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_;
|
|
|
|
///
|
2008-06-12 15:31:10 +00:00
|
|
|
QList<TocModel *> models_;
|
2008-05-02 12:09:51 +00:00
|
|
|
///
|
|
|
|
QStringList types_;
|
|
|
|
///
|
|
|
|
QStringList type_names_;
|
|
|
|
};
|
|
|
|
|
2006-04-18 09:57:47 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // TOCMODEL_H
|