On Wed, 2006-04-19 at 14:32 +0200, Abdelrazak Younes wrote:
> Martin Vermeer a écrit :
> > On Wed, 2006-04-19 at 10:28 +0200, Abdelrazak Younes wrote:

...

> >> Martin, please have a look at the new ControlToc::canOutline() method. 
> >> Im 1.5svn you get a crash if you try to use outline with figure or 
> >> table. So you have to disable the buttons when a different type from TOC 
> >> is selected.
> > 
> > Like this?
> 
> Yes, I see you had a good inspiration ;-)
> Just a small question:
> 
> > +bool QToc::canOutline()
> > +{
> > +   string const & type = toc::getType(controller().params().getCmdName());
> 
> Did you test this? I mean are you sure the return type is the same as 
> the one selected in the type combo? (I haven't check the code so I don't 
> know.)

How right you are... I had forgotten about that combobox.

Improved patch attached. I also changed the movement routines, so that
they don't reset the list type to the inset type when you try to move.

When you press Update, it still does that; apparently has always been
that way.

- Martin

Index: QTocDialog.C
===================================================================
--- QTocDialog.C	(revision 13694)
+++ QTocDialog.C	(working copy)
@@ -63,6 +63,20 @@ void QTocDialog::select_adaptor(QListVie
 }
 
 
+void QTocDialog::enableButtons(bool enable)
+{
+	updatePB->setEnabled(enable);
+
+	if (!form_->canOutline())
+		enable = false;
+
+	moveupPB->setEnabled(enable);
+	movednPB->setEnabled(enable);
+	moveinPB->setEnabled(enable);
+	moveoutPB->setEnabled(enable);
+}
+
+
 void QTocDialog::update_adaptor()
 {
 	form_->update();
Index: QTocDialog.h
===================================================================
--- QTocDialog.h	(revision 13694)
+++ QTocDialog.h	(working copy)
@@ -24,6 +24,8 @@ class QTocDialog : public QTocDialogBase
 public:
 	QTocDialog(QToc * form);
 	~QTocDialog();
+	///
+	void enableButtons(bool enable = true);
 public slots:
 	void activate_adaptor(int);
 	void depth_adaptor(int);
Index: QToc.C
===================================================================
--- QToc.C	(revision 13694)
+++ QToc.C	(working copy)
@@ -48,6 +48,8 @@ void QToc::build_dialog()
 
 	// Manage the cancel/close button
 	bcview().setCancel(dialog_->closePB);
+	type_ = toc::getType(controller().params().getCmdName());
+	dialog_->enableButtons();
 }
 
 
@@ -67,6 +69,8 @@ void QToc::updateType()
 			setTitle(guiname);
 		}
 	}
+	type_ = type;
+	dialog_->enableButtons();
 }
 
 
@@ -83,6 +87,8 @@ void QToc::updateToc(int newdepth)
 	string type;
 	if (!choice.empty())
 		type = choice[dialog_->typeCO->currentItem()];
+	type_ = type;
+	dialog_->enableButtons();
 
 	toc::Toc const & contents = controller().getContents(type);
 
@@ -181,6 +187,12 @@ void QToc::updateToc(int newdepth)
 }
 
 
+bool QToc::canOutline()
+{
+	return controller().canOutline(type_);
+}
+
+
 void QToc::select(string const & text)
 {
 	toc::Toc::const_iterator iter = toclist.begin();
@@ -212,28 +224,28 @@ void QToc::set_depth(int depth)
 void QToc::moveup()
 {
 	controller().outline(toc::UP);
-	update_contents();
+	updateToc(depth_);
 }
 
 
 void QToc::movedn()
 {
 	controller().outline(toc::DOWN);
-	update_contents();
+	updateToc(depth_);
 }
 
 
 void QToc::movein()
 {
 	controller().outline(toc::IN);
-	update_contents();
+	updateToc(depth_);
 }
 
 
 void QToc::moveout()
 {
 	controller().outline(toc::OUT);
-	update_contents();
+	updateToc(depth_);
 }
 
 
Index: QToc.h
===================================================================
--- QToc.h	(revision 13694)
+++ QToc.h	(working copy)
@@ -33,6 +33,9 @@ private:
 	/// update the listview
 	void updateToc(int newdepth);
 
+	///
+	bool canOutline();
+
 	/// update the float types
 	void updateType();
 
@@ -67,6 +70,9 @@ private:
 
 	/// Store selected item's string
 	std::string text_;
+
+	/// Store ToC list type
+	std::string type_;
 };
 
 } // namespace frontend

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to