[Kst] branches/work/kst/hierarchy/kst/src/libkstapp

Eli Fidler eli at staikos.net
Tue Nov 21 23:51:39 CET 2006


SVN commit 606829 by fidler:

changes view scalars dialog to use a list view (with search, zebra stripes, etc.)


 M  +1 -1      Makefile.am  
 A             kstscalarlistview.cpp   [License: GPL (v2+)]
 A             kstscalarlistview.h   [License: GPL (v2+)]
 M  +18 -23    kstviewscalarsdialog_i.cpp  
 M  +6 -2      kstviewscalarsdialog_i.h  
 M  +3 -3      viewscalarsdialog.ui  


--- branches/work/kst/hierarchy/kst/src/libkstapp/Makefile.am #606828:606829
@@ -29,7 +29,6 @@
 	plotmimesource.cpp \
 	kstplotdrag.cpp \
 	kstviewobjectimagedrag.cpp \
-	kstscalartable.cpp \
 	kstvectortable.cpp \
 	kstmatrixtable.cpp \
 	kstfittable.cpp \
@@ -121,6 +120,7 @@
 	monochromedialog.ui \
 	kstdebugnotifier.cpp \
 	kstdatanotifier.cpp \
+	kstscalarlistview.cpp \
 	kst.cpp
 
 
--- branches/work/kst/hierarchy/kst/src/libkstapp/kstviewscalarsdialog_i.cpp #606828:606829
@@ -15,6 +15,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <qheader.h>
 #include <qlayout.h>
 #include <qpushbutton.h>
 
@@ -28,23 +29,15 @@
                                            bool modal,
                                            WFlags fl)
 : KstViewScalarsDialog(parent, name, modal, fl) {
-  tableScalars = new KstScalarTable(this, "tableScalars");
-  tableScalars->setNumRows(0);
-  tableScalars->setNumCols(2);
-  tableScalars->setReadOnly(true);
-  tableScalars->setSorting(false);
-  tableScalars->setSelectionMode(QTable::Single);
+  listViewScalars = new KstScalarListView(this, &KST::scalarNameTree);
+  listViewScalars->setShowSortIndicator(false);
+  listViewScalars->setSelectionMode(QListView::NoSelection);
+  searchWidget = new KListViewSearchLineWidget(listViewScalars, this);
   QBoxLayout *box = dynamic_cast<QBoxLayout*>(layout());
   if (box) {
-    box->insertWidget(0, tableScalars);
-    if (tableScalars->numCols() != 2) {
-      for (; 0 < tableScalars->numCols(); ) {
-        tableScalars->removeColumn(0);
-      }
-      tableScalars->insertColumns(0, 2);
-    }
+    box->insertWidget(0, searchWidget);
+    box->insertWidget(1, listViewScalars);
 
-    tableScalars->setReadOnly(true);
     languageChange();
   }
 
@@ -61,14 +54,16 @@
 }
 
 void KstViewScalarsDialogI::updateViewScalarsDialog() {
-  KST::scalarList.lock().readLock();
-  int needed = KST::scalarList.count();
-  KST::scalarList.lock().unlock();
+  listViewScalars->update();
 
-  tableScalars->setNumRows(needed);
-  QRect rect = tableScalars->horizontalHeader()->rect();
-  tableScalars->setColumnWidth(0, rect.width()/2);
-  tableScalars->setColumnWidth(1, rect.width()/2);
+  // use whole width
+  int c0Width = listViewScalars->columnWidth(0);
+  int c1Width = listViewScalars->columnWidth(1);
+  int totalWidth = listViewScalars->header()->rect().width();
+  c0Width = totalWidth * c0Width/(c0Width + c1Width);
+  c1Width = totalWidth - c0Width;
+  listViewScalars->setColumnWidth(0, c0Width);
+  listViewScalars->setColumnWidth(1, c1Width);
 }
 
 
@@ -86,8 +81,8 @@
  */
 void KstViewScalarsDialogI::languageChange() {
   setCaption(i18n("View Scalar Values"));
-  tableScalars->horizontalHeader()->setLabel(0, i18n("Scalar"));
-  tableScalars->horizontalHeader()->setLabel(1, i18n("Value"));
+  listViewScalars->header()->setLabel(0, i18n("Scalar"));
+  listViewScalars->header()->setLabel(1, i18n("Value"));
   KstViewScalarsDialog::languageChange();      
 }
 
--- branches/work/kst/hierarchy/kst/src/libkstapp/kstviewscalarsdialog_i.h #606828:606829
@@ -18,8 +18,11 @@
 #ifndef KSTVIEWSCALARSDIALOGI_H
 #define KSTVIEWSCALARSDIALOGI_H
 
+#include <klistviewsearchline.h>
+
 #include "viewscalarsdialog.h"
-#include "kstscalartable.h"
+//#include "kstscalartable.h"
+#include "kstscalarlistview.h"
 
 class KstViewScalarsDialogI : public KstViewScalarsDialog {
   Q_OBJECT
@@ -28,7 +31,8 @@
         const char* name = 0,
         bool modal = false, WFlags fl = 0 );
     virtual ~KstViewScalarsDialogI();
-    KstScalarTable* tableScalars;
+    KListViewSearchLineWidget *searchWidget;
+    KstScalarListView *listViewScalars;
 
     bool hasContent() const;
 
--- branches/work/kst/hierarchy/kst/src/libkstapp/viewscalarsdialog.ui #606828:606829
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>KstViewScalarsDialog</class>
 <widget class="QDialog">
     <property name="name">
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>463</width>
-            <height>251</height>
+            <width>600</width>
+            <height>800</height>
         </rect>
     </property>
     <property name="caption">


More information about the Kst mailing list