Bug 134514 - view object dialog menu actions are shown when zero objects exist
Summary: view object dialog menu actions are shown when zero objects exist
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-22 22:11 UTC by Adam Treat
Modified: 2006-10-06 18:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix for this bug (4.18 KB, patch)
2006-09-22 22:12 UTC, Adam Treat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Treat 2006-09-22 22:11:06 UTC
Version:           trunk (using KDE KDE 3.5.4)
Installed from:    Compiled From Sources
Compiler:          gcc 
OS:                Linux

The following menu actions are enabled and shown even when the objects they show do not exist:

'View Scalar Values'
'View Vector Values'
'View Matrix Values'
'View Fit Results'

These menu items should be disabled when the there exist no associated objects and re-enabled when they are created.

A patch is attached which fixes this.  Please review.
Comment 1 Adam Treat 2006-09-22 22:12:13 UTC
Created attachment 17882 [details]
Fix for this bug

Please review.
Comment 2 George Staikos 2006-09-28 22:23:16 UTC
  Looks good except hasContent() should be const.  Would be best to use a 
proper iterator too.
Comment 3 Adam Treat 2006-10-06 18:29:38 UTC
SVN commit 593050 by treat:

* Don't enable the 'view object' dialogs when they
contain no content.

BUG: 134514


 M  +6 -0      kst.cpp  
 M  +14 -0     kstviewfitsdialog_i.cpp  
 M  +2 -0      kstviewfitsdialog_i.h  
 M  +5 -0      kstviewmatricesdialog_i.cpp  
 M  +2 -0      kstviewmatricesdialog_i.h  
 M  +4 -0      kstviewscalarsdialog_i.cpp  
 M  +2 -0      kstviewscalarsdialog_i.h  
 M  +5 -0      kstviewvectorsdialog_i.cpp  
 M  +2 -0      kstviewvectorsdialog_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kst.cpp #593049:593050
@@ -2074,6 +2074,12 @@
 
 
 void KstApp::updateDataDialogs(bool dm, bool vm) {
+
+  ViewScalarsDialogAction->setEnabled(viewScalarsDialog->hasContent());
+  ViewVectorsDialogAction->setEnabled(viewVectorsDialog->hasContent());
+  ViewMatricesDialogAction->setEnabled(viewMatricesDialog->hasContent());
+  ViewFitsDialogAction->setEnabled(viewFitsDialog->hasContent());
+
   if (!viewScalarsDialog->isHidden()) {
     viewScalarsDialog->updateViewScalarsDialog();
   }
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewfitsdialog_i.cpp #593049:593050
@@ -53,6 +53,20 @@
 KstViewFitsDialogI::~KstViewFitsDialogI() {
 }
 
+
+bool KstViewFitsDialogI::hasContent() const {
+  bool content = false;
+  KstPluginList fits = kstObjectSubList<KstDataObject,KstPlugin>(KST::dataObjectList);
+  KstPluginList::ConstIterator it = fits.begin();
+  for (; it != fits.end(); ++it) {
+    (*it)->readLock();
+    content = (*it)->plugin()->data()._isFit ? true : content;
+    (*it)->unlock();
+  }
+  return content;
+}
+
+
 void KstViewFitsDialogI::fillComboBox(const QString& str) {
   QString fitName = str;
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewfitsdialog_i.h #593049:593050
@@ -30,6 +30,8 @@
     virtual ~KstViewFitsDialogI();
     KstFitTable* tableFits;
 
+    bool hasContent() const;
+
   public slots:
     void updateViewFitsDialog();
     void showViewFitsDialog();
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmatricesdialog_i.cpp #593049:593050
@@ -53,6 +53,11 @@
 }
 
 
+bool KstViewMatricesDialogI::hasContent() const {
+  return !KST::matrixList.isEmpty();
+}
+
+
 void KstViewMatricesDialogI::updateViewMatricesDialog() {
   matrixSelector->update();
   QString matrix = matrixSelector->selectedMatrix();
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmatricesdialog_i.h #593049:593050
@@ -30,6 +30,8 @@
     virtual ~KstViewMatricesDialogI();
     KstMatrixTable* _tableMatrices;
 
+    bool hasContent() const;
+
   public slots:
     void updateViewMatricesDialog();
     void updateViewMatricesDialog(const QString& strVector);
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewscalarsdialog_i.cpp #593049:593050
@@ -56,6 +56,10 @@
 }
 
 
+bool KstViewScalarsDialogI::hasContent() const {
+  return !KST::scalarList.isEmpty();
+}
+
 void KstViewScalarsDialogI::updateViewScalarsDialog() {
   KST::scalarList.lock().readLock();
   int needed = KST::scalarList.count();
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewscalarsdialog_i.h #593049:593050
@@ -30,6 +30,8 @@
     virtual ~KstViewScalarsDialogI();
     KstScalarTable* tableScalars;
 
+    bool hasContent() const;
+
   protected slots:
     virtual void languageChange();
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewvectorsdialog_i.cpp #593049:593050
@@ -57,6 +57,11 @@
 }
 
 
+bool KstViewVectorsDialogI::hasContent() const {
+  return !KST::vectorList.isEmpty();
+}
+
+
 void KstViewVectorsDialogI::updateViewVectorsDialog() {
   vectorSelector->update();
   QString vector = vectorSelector->selectedVector();
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewvectorsdialog_i.h #593049:593050
@@ -30,6 +30,8 @@
     virtual ~KstViewVectorsDialogI();
     KstVectorTable* tableVectors;
 
+    bool hasContent() const;
+
   public slots:
     void updateViewVectorsDialog();
     void updateViewVectorsDialog(const QString& strVector);