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..

By the way there are some items left in the Status15 concerning TOC dialog.

* TOC crashes (simply make a few sections, subsections, sections; then add TOC
 before all sections and click on the left button)
--- Is this happen anymore? In my case, only lot creates problem,
however, as I reported earlier, this has nothing to do with the TOC
dialog, but a cursor position bug.


* Items in the TOC cannot be moved using drag & drop (Joost 4/11/06).
--- Do we need this feature? and what will this feature supposed to
do? just replace the titles in the text, or, replace whole sections? I
think both are confusing and should be avoided..

* In TOC, the buttons "Up", "Down", "Promote", and "Demote" are not
 self-explaining. Why don't we group them in two pairs: Section Up/Down, Level
 Up/Down? The arrangement of the buttons may also give some hint to the user.
--- some arrow glyphs should be enough IMO. Or, If you have a mockup
showing what you want exactly, I can implement it.

* The items in the treeview are editable
--- There is something fishy there.. I'm trying to fix it..

* When content (sections/captions) is changed, the toc/lof/lot is not properly
 updated.
--- Ah yes, because, tocbackend is not updated while you are typing.
But the correct signal arrives to TOC dialog. The toc is updated only
when a new section etc. inserted. This change is immediately becomes
visible. Abdel, you were dealing with the TocBackend recently. Any
ideas on that?

Ugras
Index: Status.15x
===================================================================
--- Status.15x	(revision 15950)
+++ Status.15x	(working copy)
@@ -51,12 +51,6 @@
 
 TABLE OF CONTENTS
 
-* In the TOC dialog, switching between the different TOC types (TOC, Table,
-  Float, etc.) is broken.
-
-* In the TOC dialog, the slider for altering the display level is
-  non-functional (not implemented).
-
 * TOC crashes (simply make a few sections, subsections, sections; then add TOC
   before all sections and click on the left button)
 
@@ -66,12 +60,6 @@
   self-explaining. Why don't we group them in two pairs: Section Up/Down, Level
   Up/Down? The arrangement of the buttons may also give some hint to the user.
 
-* The correct list is not selected when right-clicking on a LOF or
-  LOT inset.
-
-* When selecting a type which *is* already selected, the content in the 
-  browser window vanishes
-
 * The items in the treeview are editable
 
 * When content (sections/captions) is changed, the toc/lof/lot is not properly 
@@ -382,3 +370,20 @@
   3. add a bibliography
   4. View Source ->crash
   FIXED (Peter 2006-11-14)
+
+* In the TOC dialog, switching between the different TOC types (TOC, Table,
+  Float, etc.) is broken.
+  FIXED (Ugras)
+
+* In the TOC dialog, the slider for altering the display level is
+  non-functional (not implemented).
+  FIXED (Ugras)
+
+* The correct list is not selected when right-clicking on a LOF or
+  LOT inset.
+  FIXED (Ugras)
+
+* When selecting a type which *is* already selected, the content in the 
+  browser window vanishes
+  FIXED (Ugras)
+
Index: src/frontends/qt4/QTocDialog.C
===================================================================
--- src/frontends/qt4/QTocDialog.C	(revision 15950)
+++ src/frontends/qt4/QTocDialog.C	(working copy)
@@ -79,25 +79,33 @@
 
 void QTocDialog::on_updatePB_clicked()
 {
-	form_->update();
+	update();
 }
 
 
+int QTocDialog::getIndexDepth(QModelIndex const & index, int depth){
+	++depth;
+	return (index.parent() == QModelIndex())? depth : getIndexDepth(index.parent(),depth);
+}
+
+
 void QTocDialog::on_depthSL_valueChanged(int depth)
 {
 	if (depth == depth_)
 		return;
 
 	depth_ = depth;
-
-/*
-	while (
-	tocTv->setExpanded();
-			if (iter->depth() > depth_)
-				tocTV->collapseItem(topLevelItem);
-			else if (iter->depth() <= depth_)
-				tocTV->expandItem(topLevelItem);
-*/
+//	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..
+   			tocTV->expand(index); 
+		else
+    			tocTV->collapse(index); 
+	}
 }
 
 
Index: src/frontends/qt4/QTocDialog.h
===================================================================
--- src/frontends/qt4/QTocDialog.h	(revision 15950)
+++ src/frontends/qt4/QTocDialog.h	(working copy)
@@ -73,6 +73,8 @@
 	void enableButtons(bool enable = true);
 	/// Reconnects the selection model change signal when TOC changed.
 	void reconnectSelectionModel();
+	///
+	int getIndexDepth(QModelIndex const & index, int depth = -1);
 
 private:
 

Reply via email to