On 11/17/06, Abdelrazak Younes <[EMAIL PROTECTED]> wrote:
Ozgur Ugras BARAN wrote:
> attached patch implement slider in TOC dialog.
>
> I have implemented a getDepth function to get the model indices. In my
> opinion, somebody should derive a new qvariant class for tocModelItem
> which saves the string data and depth information. that will save the
> depth calculation.
>
> I'll be glad somebody see and commit the patch, please..
Dear Ugras,
I've applied the patch but there's some work remaining. Basically, the
main problem is that the slider state does not interact correctly with
the Toc navigation. Try to use the vertical scrollbar or a wheel mouse
and you'll see what I mean.
Abdel.
If I understood the problem correctly, this patch solves the problem.
Ugras
Index: frontends/qt4/QTocDialog.C
===================================================================
--- frontends/qt4/QTocDialog.C (revision 15963)
+++ frontends/qt4/QTocDialog.C (working copy)
@@ -98,15 +98,21 @@
{
if (depth == depth_)
return;
+ setTreeDepth(depth);
+}
- depth_ = depth;
+
+void QTocDialog::setTreeDepth(int depth)
+{
+ if(depth!=-1)
+ depth_ = depth;
// tocTV->expandAll(); //expanding and then collapsing is probably better, but my qt 4.1.2 doesn't have expandAll()..
QModelIndexList indices =
form_->tocModel()->match(form_->tocModel()->index(0,0),
Qt::DisplayRole, "*", -1,
Qt::MatchWildcard|Qt::MatchRecursive);
Q_FOREACH (QModelIndex index, indices) { // I had to use Q_FOREACH instead of foreach
- if(getIndexDepth(index) < depth) // because compile flag -DQT_NO_KEYWORDS doesn't allow me..
+ if(getIndexDepth(index) < depth_) // because compile flag -DQT_NO_KEYWORDS doesn't allow me..
tocTV->expand(index);
else
tocTV->collapse(index);
@@ -224,6 +230,7 @@
enableButtons();
reconnectSelectionModel();
+ setTreeDepth();
select(form_->getCurrentIndex());
lyxerr[Debug::GUI]
@@ -257,7 +264,8 @@
}
-void QTocDialog::show()
+void QTocDialog::show()
+
{
form_->update();
QDialog::show();
Index: frontends/qt4/QTocDialog.h
===================================================================
--- frontends/qt4/QTocDialog.h (revision 15963)
+++ frontends/qt4/QTocDialog.h (working copy)
@@ -75,6 +75,8 @@
void reconnectSelectionModel();
///
int getIndexDepth(QModelIndex const & index, int depth = -1);
+ ///
+ void setTreeDepth(int depth = -1);
private:
Index: frontends/qt4/ui/QTocUi.ui
===================================================================
--- frontends/qt4/ui/QTocUi.ui (revision 15963)
+++ frontends/qt4/ui/QTocUi.ui (working copy)
@@ -109,7 +109,7 @@
<number>1</number>
</property>
<property name="value" >
- <number>1</number>
+ <number>2</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>