On Wed, 2006-04-19 at 10:28 +0200, Abdelrazak Younes wrote:
> Martin Vermeer a écrit :
> > Attached, trying to take into account discussions since.
> > 
> > OK to commit? No document format change, and I don't expect the user
> > base will want to wait until 1.5 ;-)
> 
> 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?

- 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,7 @@ void QToc::build_dialog()
 
 	// Manage the cancel/close button
 	bcview().setCancel(dialog_->closePB);
+	dialog_->enableButtons();
 }
 
 
@@ -67,6 +68,7 @@ void QToc::updateType()
 			setTitle(guiname);
 		}
 	}
+	dialog_->enableButtons();
 }
 
 
@@ -181,6 +183,13 @@ void QToc::updateToc(int newdepth)
 }
 
 
+bool QToc::canOutline()
+{
+	string const & type = toc::getType(controller().params().getCmdName());
+	return controller().canOutline(type);
+}
+
+
 void QToc::select(string const & text)
 {
 	toc::Toc::const_iterator iter = toclist.begin();
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();
 

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

Reply via email to