Abdelrazak Younes a écrit :
Hello,
I am going to commit the following patch to trunk. I won't have the time
to finish the TOC dialog in the near future so if someone is interested,
please go ahead.
It seems that I found a bit of time to further fix the Qt4 TOC. Will
commit soon.
Abdel.
Log:
* convert to automatic connection
* fix TOC navigation
* delete non useful commented out code
Index: frontends/qt4/QTocDialog.C
===================================================================
--- frontends/qt4/QTocDialog.C (revision 13530)
+++ frontends/qt4/QTocDialog.C (working copy)
@@ -44,25 +44,54 @@
// disable sorting
tocTW->setSortingEnabled(false);
tocTW->setColumnCount(1);
+
// hide the pointless QHeader
// QWidget * w = static_cast<QWidget*>(tocTW->child("list view header"));
// if (w)
// w->hide();
- connect(closePB, SIGNAL(clicked()),
- form, SLOT(slotClose()));
-
- connect( tocTW, SIGNAL(itemClicked(QTreeWidgetItem*)), this,
SLOT(select_adaptor(QTreeWidgetItem*)));
- connect( typeCO, SIGNAL( activated(int) ), this, SLOT(
activate_adaptor(int) ) );
- connect( updatePB, SIGNAL( clicked() ), this, SLOT( update_adaptor() ) );
- connect( depthSL, SIGNAL( valueChanged(int) ), this, SLOT(
depth_adaptor(int) ) );
+// connect(closePB, SIGNAL(clicked()),
+// form, SLOT(slotClose()));
}
QTocDialog::~QTocDialog()
{
+ accept();
}
+void QTocDialog::on_tocTW_currentItemChanged(QTreeWidgetItem * current,
+
QTreeWidgetItem * previous)
+{
+ form_->select(fromqstr(current->text(0)));
+ lyxerr[Debug::GUI]
+ << fromqstr(current->text(0)) << " selected" << endl;
+}
+
+void QTocDialog::on_closePB_clicked()
+{
+ accept();
+}
+
+void QTocDialog::on_updatePB_clicked()
+{
+ form_->update();
+}
+
+void QTocDialog::on_depthSL_valueChanged(int depth)
+{
+ if (depth == depth_)
+ return;
+
+ depth_ = depth;
+ updateToc(true);
+}
+
+void QTocDialog::on_typeCO_activated(int value)
+{
+ updateToc();
+}
+
void QTocDialog::on_moveUpPB_clicked()
{
enableButtons(false);
@@ -149,7 +178,6 @@
if (iter->depth == 1) {
topLevelItem = new QTreeWidgetItem(tocTW);
-// tocTW->addTopLevelItem(topLevelItem);
topLevelItem->setText(0, toqstr(iter->str));
if (iter->depth < depth_)
tocTW->collapseItem(topLevelItem);
@@ -197,7 +225,6 @@
item = new QTreeWidgetItem(parentItem);
item->setText(0, toqstr(iter->str));
-// parentItem->addChild(item);
if (iter->depth < depth_) tocTW->collapseItem(item);
// else tocTW->expandItem(item);
@@ -212,34 +239,7 @@
}
}
-void QTocDialog::activate_adaptor(int)
-{
- updateToc();
-}
-
-void QTocDialog::depth_adaptor(int depth)
-{
- if (depth == depth_)
- return;
-
- depth_ = depth;
- updateToc(true);
-}
-
-
-void QTocDialog::select_adaptor(QTreeWidgetItem * item)
-{
- form_->select(fromqstr(item->text(0)));
-}
-
-
-void QTocDialog::update_adaptor()
-{
- form_->update();
-}
-
-
void QTocDialog::closeEvent(QCloseEvent * e)
{
form_->slotWMHide();
@@ -249,55 +249,3 @@
} // namespace frontend
} // namespace lyx
-
-/*
- stack<pair<QTreeWidgetItem *, QTreeWidgetItem *> > istack;
- QTreeWidgetItem * last = 0;
- QTreeWidgetItem * parent = 0;
- QTreeWidgetItem * item;
-
- // Yes, it is this ugly. Two reasons - root items must have
- // a QListView parent, rather than QListViewItem; and the
- // TOC can move in and out an arbitrary number of levels
-
- for (toc::Toc::const_iterator iter = form_->get_toclist().begin();
- iter != form_->get_toclist().end(); ++iter) {
-
- if (iter->depth == 0) {
- TocTW
-
- if (iter->depth == curdepth) {
- // insert it after the last one we processed
- if (!parent)
- item = (last ? new QTreeWidgetItem(tocTW,last)
: new QTreeWidgetItem(tocTW));
- else
- item = (last ? new QTreeWidgetItem(parent,last)
: new QTreeWidgetItem(parent));
- } else if (iter->depth > curdepth) {
- int diff = iter->depth - curdepth;
- // first save old parent and last
- while (diff--)
- istack.push(pair< QTreeWidgetItem *,
QTreeWidgetItem * >(parent,last));
- item = (last ? new QTreeWidgetItem(last) : new
QTreeWidgetItem(tocTW));
- parent = last;
- } else {
- int diff = curdepth - iter->depth;
- pair<QTreeWidgetItem *, QTreeWidgetItem * > top;
- // restore context
- while (diff--) {
- top = istack.top();
- istack.pop();
- }
- parent = top.first;
- last = top.second;
- // insert it after the last one we processed
- if (!parent)
- item = (last ? new QTreeWidgetItem(tocTW,last)
: new QTreeWidgetItem(tocTW));
- else
- item = (last ? new QTreeWidgetItem(parent,last)
: new QTreeWidgetItem(parent));
- }
- item->setText(0, toqstr(iter->str));
- item->setOpen(iter->depth < depth_);
- curdepth = iter->depth;
- last = item;
- }
-*/
\ No newline at end of file
Index: frontends/qt4/QTocDialog.h
===================================================================
--- frontends/qt4/QTocDialog.h (revision 13530)
+++ frontends/qt4/QTocDialog.h (working copy)
@@ -39,13 +39,15 @@
/// update the float types
void updateType();
-public slots:
- void activate_adaptor(int);
- void depth_adaptor(int);
- void select_adaptor(QTreeWidgetItem *);
- void update_adaptor();
+protected slots:
+ ///
+ void on_tocTW_currentItemChanged(QTreeWidgetItem * current,
+ QTreeWidgetItem * previous);
-protected slots:
+ void on_closePB_clicked();
+ void on_updatePB_clicked();
+ void on_depthSL_valueChanged(int depth);
+ void on_typeCO_activated(int value);
void on_moveUpPB_clicked();
void on_moveDownPB_clicked();
void on_moveInPB_clicked();