* QToc.[Ch], QTocDialog.[Ch]: adaptation to ControlToc changes in r13772

* TocModel.[Ch]: small cleanup + eol-style set to native


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13774 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-04-28 09:16:48 +00:00
parent 2219197cfe
commit ff83a99e94
6 changed files with 34 additions and 64 deletions

View File

@ -142,12 +142,5 @@ void QToc::updateToc(int type)
}
void QToc::move(toc::OutlineOp const operation)
{
outline(operation);
// updateToc(type_);
update();
}
} // namespace frontend
} // namespace lyx

View File

@ -48,8 +48,6 @@ public:
///
void goTo(QModelIndex const & index);
void move(toc::OutlineOp const operation);
private:
std::vector<TocModel *> toc_models_;

View File

@ -70,16 +70,6 @@ void QTocDialog::selectionChanged(const QModelIndex & 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()
{
accept();
@ -119,37 +109,41 @@ void QTocDialog::on_typeCO_activated(int value)
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();
}

View File

@ -59,9 +59,6 @@ protected slots:
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);
@ -74,9 +71,6 @@ protected slots:
protected:
///
void enableButtons(bool enable = true);
///
void move(toc::OutlineOp const operation);
///
private:

View File

@ -25,7 +25,7 @@ using std::make_pair;
namespace lyx {
namespace frontend {
TocModel::TocModel(TocBackend::Toc const & toc)
{
@ -38,7 +38,7 @@ TocModel const & TocModel::operator=(TocBackend::Toc const & toc)
populate(toc);
return *this;
}
TocIterator const TocModel::tocIterator(QModelIndex const & index) const
{
@ -46,7 +46,7 @@ TocIterator const TocModel::tocIterator(QModelIndex const & index) const
BOOST_ASSERT(map_it != toc_map_.end());
return map_it->second;
}
QModelIndex const TocModel::modelIndex(TocIterator const & it) const
{
@ -58,7 +58,7 @@ QModelIndex const TocModel::modelIndex(TocIterator const & it) const
return map_it->second;
}
void TocModel::clear()
{
@ -83,19 +83,19 @@ void TocModel::populate(TocBackend::Toc const & toc)
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()
@ -124,7 +124,7 @@ void TocModel::populate(TocIterator & iter,
int current_row;
QModelIndex child_item;
insertColumns(0, 1, parent);
insertColumns(0, 1, parent);
while (iter != end) {
++iter;
@ -136,27 +136,18 @@ void TocModel::populate(TocIterator & 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);
}
}
} // namespace frontend
} // namespace lyx

View File

@ -24,11 +24,11 @@
namespace lyx {
namespace frontend {
typedef TocBackend::Toc::const_iterator TocIterator;
typedef TocBackend::Toc::const_iterator TocIterator;
class TocModel: public QStandardItemModel {
Q_OBJECT
public:
///
TocModel() {}
@ -51,13 +51,13 @@ private:
///
void populate(TocIterator & it,
TocIterator const & end,
QModelIndex const & parent);
QModelIndex const & parent);
///
typedef std::map<QModelIndex, TocIterator> TocMap;
///
typedef std::map<TocIterator, QModelIndex> ModelMap;
///
TocMap toc_map_;
TocMap toc_map_;
///
ModelMap model_map_;
};