[Kst] branches/work/kst/portto4/kst/src

Mike Fenton mike at staikos.net
Tue Sep 9 20:49:44 CEST 2008


SVN commit 859193 by fenton:

Implement DebugDialog functionality.


 M  +1 -0      datasources/ascii/ascii.cpp  
 M  +50 -4     libkstapp/debugdialog.cpp  
 M  +13 -0     libkstapp/debugdialog.h  
 M  +53 -46    libkstapp/debugdialog.ui  
 M  +2 -0      libkstapp/libkstapp.pro  
 A             libkstapp/logwidget.cpp   [License: GPL (v2+)]
 A             libkstapp/logwidget.h   [License: GPL (v2+)]
 M  +2 -1      libkstapp/mainwindow.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #859192:859193
@@ -174,6 +174,7 @@
   _valid = false;
   _haveHeader = false;
   _fieldListComplete = false;
+  _source = "ASCII File Reader";
   if (!type.isEmpty() && type != "ASCII") {
     return;
   }
--- branches/work/kst/portto4/kst/src/libkstapp/debugdialog.cpp #859192:859193
@@ -10,15 +10,33 @@
  ***************************************************************************/
 
 #include "debugdialog.h"
+#include "logwidget.h"
 #include <debug.h>
 #include <events.h>
 #include <logevents.h>
+#include <datasource.h>
 
+#include "kst_i18n.h"
+
+#include <QDebug>
+
 namespace Kst {
 
 DebugDialog::DebugDialog(QWidget *parent)
-  : QDialog(parent) {
+  : QDialog(parent), _store(0) {
   setupUi(this);
+
+  _log = new LogWidget(TabPage);
+
+  gridLayout2->addMultiCellWidget(_log, 0, 0, 0, 2);
+
+  connect(_clear, SIGNAL(clicked()), this, SLOT(clear()));
+  connect(_showDebug, SIGNAL(toggled(bool)), _log, SLOT(setShowDebug(bool)));
+  connect(_showWarning, SIGNAL(toggled(bool)), _log, SLOT(setShowWarning(bool)));
+  connect(_showNotice, SIGNAL(toggled(bool)), _log, SLOT(setShowNotice(bool)));
+  connect(_showError, SIGNAL(toggled(bool)), _log, SLOT(setShowError(bool)));
+
+  _buildInfo->setText(i18n("<h1>Kst</h1> Version %1 (%2)").arg(KSTVERSION).arg(Debug::self()->kstRevision()));
 }
 
 
@@ -32,7 +50,7 @@
     if (le) {
       switch (le->_eventType) {
         case LogEvent::LogAdded:
-          _log->append(le->_msg.msg);
+          _log->logAdded(le->_msg);
           if (le->_msg.level == Debug::Error) {
             emit notifyOfError();
           }
@@ -45,11 +63,39 @@
           break;
       }
     }
-    return true;
   }
-  return false;
+  return QDialog::event(e);
 }
 
+
+void DebugDialog::clear() {
+  Debug::self()->clear();
 }
 
+
+void DebugDialog::show() {
+  Q_ASSERT(_store);
+  _dataSources->clear();
+
+  const QStringList& pl = DataSource::pluginList();
+  foreach (QString pluginName, pl) {
+    new QTreeWidgetItem(_dataSources, QStringList(pluginName));
+  }
+
+  QTreeWidgetItemIterator it(_dataSources);
+  while (*it) {
+    foreach (DataSourcePtr dataSource, _store->dataSourceList()) {
+      if (dataSource->sourceName() == (*it)->text(0)) {
+        QStringList list(QString::null);
+        list += dataSource->fileName();
+        new QTreeWidgetItem(*it, list);
+      }
+    }
+    ++it;
+  }
+  QDialog::show();
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/debugdialog.h #859192:859193
@@ -17,9 +17,12 @@
 #include "ui_debugdialog.h"
 
 #include "kst_export.h"
+#include "objectstore.h"
 
 namespace Kst {
 
+class LogWidget;
+
 class KST_EXPORT DebugDialog : public QDialog, Ui::DebugDialog
 {
   Q_OBJECT
@@ -27,12 +30,22 @@
     DebugDialog(QWidget *parent);
     virtual ~DebugDialog();
 
+    void setObjectStore(ObjectStore* store) { _store = store; }
+
   Q_SIGNALS:
     void notifyOfError();
     void notifyAllClear();
 
+  public Q_SLOTS:
+    void clear();
+    void show();
+
   protected:
     bool event(QEvent *e);
+
+  private:
+    LogWidget *_log;
+    ObjectStore *_store;
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/debugdialog.ui #859192:859193
@@ -19,10 +19,33 @@
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item row="0" column="0" colspan="2" >
+   <item row="2" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>421</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="1" >
+    <widget class="QPushButton" name="_close" >
+     <property name="text" >
+      <string>&amp;Close</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" >
     <widget class="QTabWidget" name="_tabs" >
      <property name="currentIndex" >
-      <number>1</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="_buildInfoTab" >
       <attribute name="title" >
@@ -56,7 +79,7 @@
          <property name="sizeType" >
           <enum>QSizePolicy::Expanding</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>530</width>
            <height>250</height>
@@ -79,7 +102,7 @@
          <property name="sizeType" >
           <enum>QSizePolicy::Expanding</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>301</width>
            <height>21</height>
@@ -105,7 +128,7 @@
          <property name="orientation" >
           <enum>Qt::Horizontal</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>221</width>
            <height>20</height>
@@ -113,9 +136,6 @@
          </property>
         </spacer>
        </item>
-       <item row="0" column="0" colspan="3" >
-        <widget class="QTextBrowser" name="_log" />
-       </item>
        <item row="1" column="1" >
         <widget class="QGroupBox" name="groupBox" >
          <property name="title" >
@@ -128,16 +148,6 @@
           <property name="spacing" >
            <number>6</number>
           </property>
-          <item row="0" column="4" >
-           <widget class="QCheckBox" name="_showOther" >
-            <property name="text" >
-             <string>&amp;Other</string>
-            </property>
-            <property name="checked" >
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
           <item row="0" column="1" >
            <widget class="QCheckBox" name="_showNotice" >
             <property name="text" >
@@ -188,6 +198,19 @@
          </property>
         </widget>
        </item>
+       <item row="0" column="1" >
+        <spacer name="verticalSpacer" >
+         <property name="orientation" >
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
       </layout>
      </widget>
      <widget class="QWidget" name="tab" >
@@ -202,53 +225,37 @@
         <number>6</number>
        </property>
        <item row="0" column="0" >
-        <widget class="QTreeView" name="_dataSources" >
-         <property name="rootIsDecorated" >
+        <widget class="QTreeWidget" name="_dataSources" >
+         <property name="allColumnsShowFocus" >
           <bool>true</bool>
          </property>
+         <column>
+          <property name="text" >
+           <string>Plugin</string>
+          </property>
+         </column>
+         <column>
+          <property name="text" >
+           <string>Loaded Instance</string>
+          </property>
+         </column>
         </widget>
        </item>
       </layout>
      </widget>
     </widget>
    </item>
-   <item row="1" column="0" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Expanding</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>421</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="1" column="1" >
-    <widget class="QPushButton" name="_close" >
-     <property name="text" >
-      <string>&amp;Close</string>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11" />
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
  <tabstops>
-  <tabstop>_tabs</tabstop>
   <tabstop>_email</tabstop>
   <tabstop>_showDebug</tabstop>
   <tabstop>_showNotice</tabstop>
   <tabstop>_showWarning</tabstop>
   <tabstop>_showError</tabstop>
-  <tabstop>_showOther</tabstop>
   <tabstop>_clear</tabstop>
-  <tabstop>_dataSources</tabstop>
   <tabstop>_close</tabstop>
  </tabstops>
  <resources/>
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #859192:859193
@@ -79,6 +79,7 @@
     legenditemdialog.cpp \
     legendtab.cpp \
     lineitem.cpp \
+    logwidget.cpp \
     mainwindow.cpp \
     markerstab.cpp \
     matrixdialog.cpp \
@@ -175,6 +176,7 @@
     legenditemdialog.h \
     legendtab.h \
     lineitem.h \
+    logwidget.h \
     mainwindow.h \
     markerstab.h \
     matrixdialog.h \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #859192:859193
@@ -70,7 +70,7 @@
   _doc = new Document(this);
   _tabWidget = new TabWidget(this);
   _undoGroup = new QUndoGroup(this);
-  _debugDialog = new DebugDialog(this); // need this early for hookups
+  _debugDialog = new DebugDialog(this);
   Debug::self()->setHandler(_debugDialog);
 
   createActions();
@@ -924,6 +924,7 @@
   if (!_debugDialog) {
     _debugDialog = new DebugDialog(this);
   }
+  _debugDialog->setObjectStore(document()->objectStore());
   _debugDialog->show();
 }
 


More information about the Kst mailing list