* ControlToc.[Ch]

- bool ControlToc::canOutline(): new method to test if outline is possible.
* TocModel: new class
* QToc is now the controller (inheriting ControlToc directly) and the model (using TocModel)
* QTocDialog is now only the view (inheriting Dialogs::View directly)
* Dialogs.C: updated toc controller and view correspondingly



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13692 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-04-18 09:57:47 +00:00
parent 4700431096
commit 9db70c5346
11 changed files with 498 additions and 226 deletions

View File

@ -37,6 +37,12 @@ void ControlToc::goTo(toc::TocItem const & item)
} }
bool ControlToc::canOutline(string const & type)
{
return type == "TOC";
}
void ControlToc::outline(toc::OutlineOp op) void ControlToc::outline(toc::OutlineOp op)
{ {
std::ostringstream o; std::ostringstream o;

View File

@ -41,6 +41,9 @@ public:
/// Apply the selected outlining operation /// Apply the selected outlining operation
void outline(toc::OutlineOp op); void outline(toc::OutlineOp op);
/// Test if outlining operation is possible
bool canOutline(std::string const & type);
}; };
} // namespace frontend } // namespace frontend

View File

@ -18,7 +18,6 @@
#include "ControlBranch.h" #include "ControlBranch.h"
#include "ControlChanges.h" #include "ControlChanges.h"
#include "ControlCharacter.h" #include "ControlCharacter.h"
#include "ControlCitation.h"
#include "ControlDocument.h" #include "ControlDocument.h"
#include "ControlErrorList.h" #include "ControlErrorList.h"
#include "ControlERT.h" #include "ControlERT.h"
@ -40,7 +39,6 @@
#include "ControlSpellchecker.h" #include "ControlSpellchecker.h"
#include "ControlTabular.h" #include "ControlTabular.h"
#include "ControlTabularCreate.h" #include "ControlTabularCreate.h"
#include "ControlToc.h"
#include "ControlVSpace.h" #include "ControlVSpace.h"
#include "ControlWrap.h" #include "ControlWrap.h"
@ -83,6 +81,7 @@
#include "QTabularCreate.h" #include "QTabularCreate.h"
#include "QTexinfo.h" #include "QTexinfo.h"
#include "QToc.h" #include "QToc.h"
#include "QTocDialog.h"
#include "q3url.h" #include "q3url.h"
#include "QVSpace.h" #include "QVSpace.h"
#include "QWrap.h" #include "QWrap.h"
@ -310,8 +309,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
#endif #endif
} else if (name == "toc") { } else if (name == "toc") {
dialog->setController(new ControlToc(*dialog)); QToc * qtoc = new QToc(*dialog);
dialog->setView(new QToc(*dialog)); dialog->setController(qtoc);
dialog->setView(new QTocDialog(*dialog, qtoc));
dialog->bc().bp(new OkCancelPolicy); dialog->bc().bp(new OkCancelPolicy);
} else if (name == "url") { } else if (name == "url") {
dialog->setController(new ControlCommand(*dialog, name)); dialog->setController(new ControlCommand(*dialog, name));

View File

@ -123,6 +123,7 @@ MOCFILES = \
QTabularDialog.C QTabularDialog.h \ QTabularDialog.C QTabularDialog.h \
QTexinfoDialog.C QTexinfoDialog.h \ QTexinfoDialog.C QTexinfoDialog.h \
QThesaurusDialog.C QThesaurusDialog.h \ QThesaurusDialog.C QThesaurusDialog.h \
TocModel.C TocModel.h \
QTocDialog.C QTocDialog.h \ QTocDialog.C QTocDialog.h \
QtView.C QtView.h \ QtView.C QtView.h \
QURLDialog.C QURLDialog.h \ QURLDialog.C QURLDialog.h \

View File

@ -12,7 +12,7 @@
#include <config.h> #include <config.h>
#include "QToc.h" #include "QToc.h"
#include "QTocDialog.h" #include "TocModel.h"
#include "Qt2BC.h" #include "Qt2BC.h"
#include "qt_helpers.h" #include "qt_helpers.h"
@ -20,6 +20,8 @@
#include "controllers/ControlToc.h" #include "controllers/ControlToc.h"
#include <algorithm>
using std::endl; using std::endl;
using std::pair; using std::pair;
@ -29,71 +31,119 @@ using std::string;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
typedef QController<ControlToc, QView<QTocDialog> > base_class;
QToc::QToc(Dialog & parent) QToc::QToc(Dialog & parent)
: base_class(parent, _("Table of Contents")) : ControlToc(parent)
{}
void QToc::build_dialog()
{ {
dialog_.reset(new QTocDialog(this)); update();
} }
void QToc::update_contents() bool QToc::canOutline()
{ {
dialog_->updateType(); vector<string> const & types = getTypes();
dialog_->updateToc();
BOOST_ASSERT(type_ >= 0 && type_ < int(types.size()));
return ControlToc::canOutline(types[type_]);
} }
void QToc::select(string const & text) QStandardItemModel * QToc::tocModel()
{ {
toc::Toc::const_iterator iter = toclist.begin(); lyxerr[Debug::GUI]
<< "QToc: type_ " << type_
<< " toc_models_.size() " << toc_models_.size()
<< endl;
for (; iter != toclist.end(); ++iter) { BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
if (iter->str == text) return toc_models_[type_];
break; }
}
if (iter == toclist.end()) {
lyxerr[Debug::GUI] << "Couldn't find highlighted TOC entry: " QStandardItemModel * QToc::setTocModel(int type)
<< text << endl; {
type_ = type;
lyxerr[Debug::GUI]
<< "QToc: type_ " << type_
<< " toc_models_.size() " << toc_models_.size()
<< endl;
BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size()));
return toc_models_[type_];
}
void QToc::goTo(QModelIndex const & index)
{
if (!index.isValid()) {
lyxerr[Debug::GUI]
<< "QToc::goTo(): QModelIndex is invalid!"
<< endl;
return; return;
} }
controller().goTo(*iter); lyxerr[Debug::GUI]
<< "QToc::goTo " << toc_models_[type_]->item(index).str
<< endl;
ControlToc::goTo(toc_models_[type_]->item(index));
} }
void QToc::moveUp()
void QToc::update()
{ {
controller().outline(toc::UP); toc_models_.clear();
update_contents();
QStringList type_list;
type_ = 0;
vector<string> const & types = getTypes();
string const & selected_type = toc::getType(params().getCmdName());
lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
QString gui_names_;
for (size_t i = 0; i != types.size(); ++i) {
string const & type_str = types[i];
type_list.append(toqstr(getGuiName(type_str)));
if (type_str == selected_type)
type_ = i;
lyxerr[Debug::GUI]
<< "QToc: new type " << type_str
<< "\ttoc_models_.size() " << toc_models_.size()
<< endl;
toc_models_.push_back(new TocModel(getContents(types[i])));
}
type_model_.setStringList(type_list);
} }
void QToc::moveDown() void QToc::updateToc(int type)
{ {
controller().outline(toc::DOWN); vector<string> const & choice = getTypes();
update_contents();
toc_models_[type] = new TocModel(getContents(choice[type]));
} }
void QToc::moveIn() void QToc::move(toc::OutlineOp const operation, QModelIndex & index)
{ {
controller().outline(toc::IN); int toc_id = toc_models_[type_]->item(index).id_;
update_contents(); string toc_str = toc_models_[type_]->item(index).str;
toc_str.erase(0, toc_str.find(' ') + 1);
outline(operation);
updateToc(type_);
lyxerr[Debug::GUI]
<< "Toc id " << toc_id
<< " Toc str " << toc_str
<< endl;
index = toc_models_[type_]->index(toc_str);
} }
void QToc::moveOut()
{
controller().outline(toc::OUT);
update_contents();
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -14,47 +14,47 @@
#ifndef QTOC_H #ifndef QTOC_H
#define QTOC_H #define QTOC_H
#include "QDialogView.h" #include "ControlToc.h"
#include "toc.h"
#include <QStandardItemModel>
#include <QStringListModel>
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class ControlToc; class ControlToc;
class QTocDialog; class TocModel;
//template<class W> class QToc : public ControlToc
class QToc :
public QController<ControlToc, QView<QTocDialog> >
{ {
public: public:
friend class QTocDialog;
QToc(Dialog &); QToc(Dialog &);
/// return the toc list void update();
lyx::toc::Toc & get_toclist() { return toclist;}
void moveUp(); void updateToc(int type);
void moveDown();
void moveIn(); bool canOutline();
void moveOut();
QStandardItemModel * tocModel();
QStandardItemModel * setTocModel(int type);
QStringListModel * typeModel()
{ return &type_model_; }
void goTo(QModelIndex const & index);
void move(toc::OutlineOp const operation, QModelIndex & index);
private: private:
/// select an entry std::vector<TocModel *> toc_models_;
void select(std::string const & text);
virtual void apply() {} QStringListModel type_model_;
/// update dialog int type_;
virtual void update_contents(); int outline_type_;
/// build dialog
virtual void build_dialog();
/// the toc list
lyx::toc::Toc toclist;
}; };
} // namespace frontend } // namespace frontend

View File

@ -19,11 +19,10 @@
#include "debug.h" #include "debug.h"
#include <QHeaderView>
#include <QTreeWidget>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QPushButton> #include <QPushButton>
#include <QCloseEvent> #include <QCloseEvent>
#include <QHeaderView>
#include <vector> #include <vector>
#include <string> #include <string>
@ -35,28 +34,22 @@ using std::stack;
using std::vector; using std::vector;
using std::string; using std::string;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
QTocDialog::QTocDialog(QToc * form) QTocDialog::QTocDialog(Dialog & dialog, QToc * form)
: form_(form), depth_(2) : Dialog::View(dialog, "Toc"), form_(form), depth_(2)
{ {
setupUi(this); setupUi(this);
// Manage the cancel/close button update();
form_->bcview().setCancel(closePB);
// disable sorting connect(tocTV->selectionModel(),
tocTW->setSortingEnabled(false); SIGNAL(currentChanged(const QModelIndex &,
tocTW->setColumnCount(1); const QModelIndex &)),
this, SLOT(selectionChanged(const QModelIndex &,
// hide the pointless QHeader const QModelIndex &)));
QHeaderView * w = static_cast<QHeaderView*>(tocTW->header());
if (w)
w->hide();
// connect(closePB, SIGNAL(clicked()),
// form, SLOT(slotClose()));
} }
@ -65,196 +58,174 @@ QTocDialog::~QTocDialog()
accept(); accept();
} }
void QTocDialog::on_tocTW_currentItemChanged(QTreeWidgetItem * current, void QTocDialog::selectionChanged(const QModelIndex & current,
QTreeWidgetItem * previous) const QModelIndex & previous)
{ {
form_->select(fromqstr(current->text(0))); lyxerr[Debug::GUI]
<< "selectionChanged index " << current.row() << ", " << current.column()
<< endl;
form_->goTo(current);
} }
void QTocDialog::on_tocTV_clicked(const QModelIndex & index )
{
lyxerr[Debug::GUI]
<< "on_tocTV_clicked index " << index.row() << ", " << index.column()
<< endl;
form_->goTo(index);
}
void QTocDialog::on_closePB_clicked() void QTocDialog::on_closePB_clicked()
{ {
accept(); accept();
} }
void QTocDialog::on_updatePB_clicked() void QTocDialog::on_updatePB_clicked()
{ {
form_->update(); form_->update();
update();
} }
void QTocDialog::on_depthSL_valueChanged(int depth) void QTocDialog::on_depthSL_valueChanged(int depth)
{ {
if (depth == depth_) if (depth == depth_)
return; return;
depth_ = depth; depth_ = depth;
updateToc(true);
/*
while (
tocTv->setExpanded();
if (iter->depth > depth_)
tocTV->collapseItem(topLevelItem);
else if (iter->depth <= depth_)
tocTV->expandItem(topLevelItem);
*/
} }
void QTocDialog::on_typeCO_activated(int value) void QTocDialog::on_typeCO_activated(int value)
{ {
updateToc(); form_->setTocModel(value);
enableButtons();
} }
void QTocDialog::on_moveUpPB_clicked() void QTocDialog::on_moveUpPB_clicked()
{ {
enableButtons(false); move(toc::UP);
form_->moveUp();
enableButtons();
} }
void QTocDialog::on_moveDownPB_clicked() void QTocDialog::on_moveDownPB_clicked()
{ {
enableButtons(false); move(toc::DOWN);
form_->moveDown();
enableButtons();
} }
void QTocDialog::on_moveInPB_clicked() void QTocDialog::on_moveInPB_clicked()
{ {
enableButtons(false); move(toc::IN);
form_->moveIn();
enableButtons();
} }
void QTocDialog::on_moveOutPB_clicked() void QTocDialog::on_moveOutPB_clicked()
{
move(toc::OUT);
}
void QTocDialog::move(toc::OutlineOp const operation)
{ {
enableButtons(false); enableButtons(false);
form_->moveOut(); QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
form_->move(operation, index);
select(index);
enableButtons(); enableButtons();
} }
void QTocDialog::select(QModelIndex const & index)
{
tocTV->setModel(form_->tocModel());
if (index.isValid()) {
tocTV->scrollTo(index);
tocTV->selectionModel()->select(index, QItemSelectionModel::Select);
}
}
void QTocDialog::enableButtons(bool enable) void QTocDialog::enableButtons(bool enable)
{ {
updatePB->setEnabled(enable);
if (!form_->canOutline())
enable = false;
moveUpPB->setEnabled(enable); moveUpPB->setEnabled(enable);
moveDownPB->setEnabled(enable); moveDownPB->setEnabled(enable);
moveInPB->setEnabled(enable); moveInPB->setEnabled(enable);
moveOutPB->setEnabled(enable); moveOutPB->setEnabled(enable);
updatePB->setEnabled(enable);
} }
void QTocDialog::updateType()
void QTocDialog::update()
{ {
typeCO->clear(); typeCO->setModel(form_->typeModel());
tocTV->setModel(form_->tocModel());
tocTV->showColumn(0);
// hide the pointless QHeader for now
// in the future, new columns may appear
// like labels, bookmarks, etc...
// tocTV->header()->hide();
tocTV->header()->setVisible(true);
enableButtons();
vector<string> const & choice = form_->controller().getTypes(); connect(tocTV->selectionModel(),
string const & type = toc::getType(form_->controller().params().getCmdName()); SIGNAL(currentChanged(const QModelIndex &,
const QModelIndex &)),
this, SLOT(selectionChanged(const QModelIndex &,
const QModelIndex &)));
for (vector<string>::const_iterator it = choice.begin(); lyxerr[Debug::GUI]
it != choice.end(); ++it) { << "form_->tocModel()->rowCount " << form_->tocModel()->rowCount()
string const & guiname = form_->controller().getGuiName(*it); << "\nform_->tocModel()->columnCount " << form_->tocModel()->columnCount()
typeCO->insertItem(toqstr(guiname)); << endl;
if (*it == type) { // setTitle(form_->guiname())
typeCO->setCurrentItem(it - choice.begin());
form_->setTitle(guiname);
}
}
} }
void QTocDialog::updateToc(bool newdepth)
void QTocDialog::apply()
{ {
vector<string> const & choice = form_->controller().getTypes(); // Nothing to do here... for now.
string type; // Ideas welcome... (Abdel, 17042006)
if (!choice.empty())
type = choice[typeCO->currentItem()];
toc::Toc const & contents = form_->controller().getContents(type);
// Check if all elements are the same.
if (!newdepth && form_->get_toclist() == contents) {
return;
}
tocTW->clear();
form_->get_toclist() = contents;
if (form_->get_toclist().empty())
return;
tocTW->setUpdatesEnabled(false);
QTreeWidgetItem * topLevelItem;
toc::Toc::const_iterator iter = form_->get_toclist().begin();
while (iter != form_->get_toclist().end()) {
if (iter->depth == 1) {
topLevelItem = new QTreeWidgetItem(tocTW);
topLevelItem->setText(0, toqstr(iter->str));
if (iter->depth > depth_)
tocTW->collapseItem(topLevelItem);
else if (iter->depth <= depth_)
tocTW->expandItem(topLevelItem);
lyxerr[Debug::GUI]
<< "Table of contents\n"
<< "Added Top Level item " << iter->str
<< " at depth " << iter->depth
<< endl;
populateItem(topLevelItem, iter);
}
if (iter == form_->get_toclist().end())
break;
++iter;
}
tocTW->setUpdatesEnabled(true);
tocTW->update();
form_->setTitle(fromqstr(typeCO->currentText()));
tocTW->show();
} }
void QTocDialog::populateItem(QTreeWidgetItem * parentItem, toc::Toc::const_iterator & iter)
void QTocDialog::hide()
{ {
int curdepth = iter->depth + 1; accept();
QTreeWidgetItem * item;
while (iter != form_->get_toclist().end()) {
++iter;
if (iter == form_->get_toclist().end())
break;
if (iter->depth < curdepth) {
--iter;
return;
}
if (iter->depth > curdepth) {
// --iter;
return;
}
item = new QTreeWidgetItem(parentItem);
item->setText(0, toqstr(iter->str));
if (iter->depth > depth_)
tocTW->collapseItem(item);
else if (iter->depth <= depth_)
tocTW->expandItem(item);
lyxerr[Debug::GUI]
<< "Table of contents: Added item " << iter->str
<< " at depth " << iter->depth
<< " \", parent \""
<< fromqstr(parentItem->text(0)) << '"'
<< "expanded: " << tocTW->isItemExpanded(item)
<< endl;
populateItem(item, iter);
}
} }
void QTocDialog::closeEvent(QCloseEvent * e) void QTocDialog::show()
{ {
form_->slotWMHide(); form_->update();
e->accept(); update();
QDialog::show();
} }
bool QTocDialog::isVisible() const
{
return QDialog::isVisible();
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -17,32 +17,47 @@
#include "controllers/ControlToc.h" #include "controllers/ControlToc.h"
#include <QDialog> #include <QDialog>
#include <QCloseEvent>
class QTreeWidget; class QTreeViewItem;
class QTreeWidgetItem;
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {
class QToc; class QToc;
class QTocDialog : public QDialog, public Ui::QTocUi { class QTocDialog : public QDialog, public Ui::QTocUi, public Dialog::View {
Q_OBJECT Q_OBJECT
public: public:
QTocDialog(QToc * form); QTocDialog(Dialog &, QToc * form);
~QTocDialog(); ~QTocDialog();
/// update the listview virtual void apply();
void updateToc(bool newdepth=false);
/// update the float types /// Hide the dialog from sight
void updateType(); void hide();
/// Redraw the dialog (e.g. if the colors have been remapped).
void redraw() {}
/// Create the dialog if necessary, update it and display it.
void show();
/// Update the display of the dialog whilst it is still visible.
void update();
/// \return true if the dialog is visible.
bool isVisible() const;
protected slots: protected slots:
/// ///
void on_tocTW_currentItemChanged(QTreeWidgetItem * current, void select(QModelIndex const & index);
QTreeWidgetItem * previous); ///
void selectionChanged(const QModelIndex & current,
const QModelIndex & previous);
/// Temporary until the slot above work.
void on_tocTV_clicked(const QModelIndex & index );
void on_closePB_clicked(); void on_closePB_clicked();
void on_updatePB_clicked(); void on_updatePB_clicked();
@ -54,13 +69,14 @@ protected slots:
void on_moveOutPB_clicked(); void on_moveOutPB_clicked();
protected: protected:
///
void enableButtons(bool enable = true); void enableButtons(bool enable = true);
void closeEvent(QCloseEvent * e); ///
void move(toc::OutlineOp const operation);
///
private: private:
void populateItem(QTreeWidgetItem * parentItem, toc::Toc::const_iterator& iter);
QToc * form_; QToc * form_;
/// depth of list shown /// depth of list shown

View File

@ -0,0 +1,161 @@
/**
* \file QTocDialog.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Abdelrazak Younes
*
* Full author contact details are available in file CREDITS.
*/
#include "TocModel.h"
#include "debug.h"
#include <vector>
#include <string>
using std::endl;
using std::pair;
using std::map;
using std::vector;
using std::string;
using std::make_pair;
namespace lyx {
namespace frontend {
TocModel::TocModel(toc::Toc const & toc_list)
{
populate(toc_list);
}
TocModel const & TocModel::operator=(toc::Toc const & toc_list)
{
populate(toc_list);
return *this;
}
toc::TocItem const TocModel::item(QModelIndex const & index) const
{
ItemMap::const_iterator it = item_map_.find(index);
BOOST_ASSERT(it != item_map_.end());
return it->second;
}
QModelIndex const TocModel::index(string const & toc_str) const
{
IndexMap::const_iterator it = index_map_.find(toc_str);
//BOOST_ASSERT(it != index_map_.end());
if (it == index_map_.end())
return QModelIndex();
return it->second;
}
void TocModel::clear()
{
QStandardItemModel::clear();
item_map_.clear();
index_map_.clear();
removeRows(0, rowCount());
removeColumns(0, columnCount());
}
void TocModel::populate(toc::Toc const & toc_list)
{
clear();
if (toc_list.empty())
return;
int current_row;
QModelIndex top_level_item;
toc::Toc::const_iterator iter = toc_list.begin();
toc::Toc::const_iterator end = toc_list.end();
insertColumns(0, 1);
while (iter != end) {
if (iter->depth == 1) {
current_row = rowCount();
insertRows(current_row, 1);
top_level_item = QStandardItemModel::index(current_row, 0);
//setData(top_level_item, toqstr(iter->str));
setData(top_level_item, toqstr(iter->str), Qt::DisplayRole);
item_map_.insert(make_pair(top_level_item, *iter));
index_map_.insert(make_pair(
iter->str.substr(iter->str.find(' ') + 1), top_level_item));
lyxerr[Debug::GUI]
<< "Toc: at depth " << iter->depth
<< ", added item " << iter->str
<< endl;
populate(iter, end, top_level_item);
}
if (iter == end)
break;
++iter;
}
setHeaderData(0, Qt::Horizontal, QVariant("title"), Qt::DisplayRole);
// emit headerDataChanged();
}
void TocModel::populate(toc::Toc::const_iterator & iter,
toc::Toc::const_iterator const & end,
QModelIndex const & parent)
{
int curdepth = iter->depth + 1;
int current_row;
QModelIndex child_item;
insertColumns(0, 1, parent);
while (iter != end) {
++iter;
if (iter == end)
break;
if (iter->depth < curdepth) {
--iter;
return;
}
if (iter->depth > curdepth) {
return;
}
current_row = rowCount(parent);
insertRows(current_row, 1, parent);
child_item = QStandardItemModel::index(current_row, 0, parent);
//setData(child_item, toqstr(iter->str));
setData(child_item, toqstr(iter->str), Qt::DisplayRole);
item_map_.insert(make_pair(child_item, *iter));
index_map_.insert(make_pair(
iter->str.substr(iter->str.find(' ') + 1), child_item));
// lyxerr[Debug::GUI]
// << "Toc: at depth " << iter->depth
// << ", added item " << iter->str
// << endl;
populate(iter, end, child_item);
}
}
} // namespace frontend
} // namespace lyx

View File

@ -0,0 +1,64 @@
// -*- 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 "toc.h"
#include "qt_helpers.h"
#include <QStandardItemModel>
#include <map>
#include <string>
namespace lyx {
namespace frontend {
class TocModel: public QStandardItemModel {
Q_OBJECT
public:
///
TocModel() {}
///
TocModel(toc::Toc const & toc_list);
///
~TocModel() {}
///
TocModel const & operator=(toc::Toc const & toc_list);
///
void clear();
///
void populate(toc::Toc const & toc_list);
///
toc::TocItem const item(QModelIndex const & index) const;
///
QModelIndex const index(std::string const & toc_str) const;
private:
///
void populate(toc::Toc::const_iterator & iter,
toc::Toc::const_iterator const & end,
QModelIndex const & parent);
typedef std::map<QModelIndex, toc::TocItem> ItemMap;
///
typedef std::map<std::string, QModelIndex> IndexMap;
///
ItemMap item_map_;
IndexMap index_map_;
};
} // namespace frontend
} // namespace lyx
#endif // TOCMODEL_H

View File

@ -63,9 +63,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" >
<widget class="QTreeWidget" name="tocTW" />
</item>
<item row="4" column="0" > <item row="4" column="0" >
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="margin" >
@ -170,6 +167,9 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0" >
<widget class="QTreeView" name="tocTV" />
</item>
</layout> </layout>
</widget> </widget>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction> <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>