}
-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()
{
accept();
void QTocDialog::on_moveUpPB_clicked()
{
- move(toc::UP);
+ enableButtons(false);
+ QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
+ form_->goTo(index);
+ form_->outlineUp();
+ update();
}
void QTocDialog::on_moveDownPB_clicked()
{
- move(toc::DOWN);
+ enableButtons(false);
+ QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
+ form_->goTo(index);
+ form_->outlineDown();
+ update();
}
void QTocDialog::on_moveInPB_clicked()
{
- move(toc::IN);
+ enableButtons(false);
+ QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
+ form_->goTo(index);
+ form_->outlineIn();
+ update();
}
void QTocDialog::on_moveOutPB_clicked()
-{
- move(toc::OUT);
-}
-
-
-void QTocDialog::move(toc::OutlineOp const operation)
{
enableButtons(false);
QModelIndex index = tocTV->selectionModel()->selectedIndexes()[0];
form_->goTo(index);
- form_->move(operation);
- updateGui();
-// select(index);
-// enableButtons();
+ form_->outlineOut();
+ update();
}
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_updatePB_clicked();
void on_depthSL_valueChanged(int depth);
protected:
///
void enableButtons(bool enable = true);
- ///
- void move(toc::OutlineOp const operation);
- ///
private:
namespace lyx {
namespace frontend {
-\r
+
TocModel::TocModel(TocBackend::Toc const & toc)
{
populate(toc);
return *this;
}
-\r
+
TocIterator const TocModel::tocIterator(QModelIndex const & index) const
{
BOOST_ASSERT(map_it != toc_map_.end());
return map_it->second;
}
-\r
+
QModelIndex const TocModel::modelIndex(TocIterator const & it) const
{
return map_it->second;
}
-\r
+
void TocModel::clear()
{
TocIterator iter = toc.begin();
TocIterator end = toc.end();
- insertColumns(0, 1);
+ insertColumns(0, 1);
while (iter != end) {
- if (iter->depth() >= 0) {
+ if (iter->isValid()) {
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);
- toc_map_.insert(make_pair(top_level_item, iter));
- model_map_.insert(make_pair(iter, top_level_item));
+ toc_map_[top_level_item] = iter;
+ model_map_[iter] = top_level_item;
lyxerr[Debug::GUI]
<< "Toc: at depth " << iter->depth()
int current_row;
QModelIndex child_item;
- insertColumns(0, 1, parent);
+ insertColumns(0, 1, parent);
while (iter != end) {
++iter;
--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);
- toc_map_.insert(make_pair(child_item, iter));
- model_map_.insert(make_pair(iter, child_item));
-
-// lyxerr[Debug::GUI]
-// << "Toc: at depth " << iter->depth()
-// << ", added item " << iter->str()
-// << endl;
-
+ toc_map_[child_item] = iter;
+ model_map_[iter] = child_item;
populate(iter, end, child_item);
}
}
-\r
+
} // namespace frontend
} // namespace lyx
namespace lyx {
namespace frontend {
-typedef TocBackend::Toc::const_iterator TocIterator;\r
-\r
+typedef TocBackend::Toc::const_iterator TocIterator;
+
class TocModel: public QStandardItemModel {
Q_OBJECT
-\r
+
public:
///
TocModel() {}
///
void populate(TocIterator & it,
TocIterator const & end,
- QModelIndex const & parent);\r
+ QModelIndex const & parent);
///
typedef std::map<QModelIndex, TocIterator> TocMap;
///
typedef std::map<TocIterator, QModelIndex> ModelMap;
///
- TocMap toc_map_;\r
+ TocMap toc_map_;
///
ModelMap model_map_;
};