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

Mike Fenton mike at staikos.net
Fri Nov 28 23:05:19 CET 2008


SVN commit 890318 by fenton:

Create separate FileRequester / DataSourceSelector widgets.


 A             datasourceselector.cpp   [License: GPL (v2+)]
 A             datasourceselector.h   [License: GPL (v2+)]
 M  +6 -15     filerequester.cpp  
 M  +0 -1      filerequester.h  
 M  +1 -0      widgets.cpp  
 M  +14 -0     widgets.h  
 M  +2 -0      widgets.pro  


--- branches/work/kst/portto4/kst/src/widgets/filerequester.cpp #890317:890318
@@ -11,8 +11,6 @@
 
 #include "filerequester.h"
 
-#include "datasourceselectordialog.h"
-
 #include <QStyle>
 #include <QLineEdit>
 #include <QToolButton>
@@ -26,23 +24,16 @@
 namespace Kst {
 
 FileRequester::FileRequester(QWidget *parent)
-  : QWidget(parent), _mode(QFileDialog::ExistingFile) {
+  : QWidget(parent), _mode(QFileDialog::AnyFile) {
   setup();
 }
 
 
-FileRequester::FileRequester(const QString &file, QWidget *parent)
-  : QWidget(parent), _file(file) {
-  setup();
-}
-
-
 FileRequester::~FileRequester() {
 }
 
 
 void FileRequester::setup() {
-
   _fileEdit = new QLineEdit(this);
   _fileButton = new QToolButton(this);
 
@@ -87,12 +78,12 @@
 
 void FileRequester::chooseFile() {
   QString file;
+  if (_mode == QFileDialog::ExistingFile) {
+    file = QFileDialog::getOpenFileName(this, tr("Open File"), _file, tr("All Files (*)"));
+  } else {
+    file = QFileDialog::getSaveFileName(this, tr("Save File"), _file, tr("All Files (*)"));
+  }
 
-  DataSourceSelectorDialog dialog(_file);
-  dialog.exec();
-
-  file = dialog.selectedDataSource();
-
   if (!file.isEmpty()) {
     setFile(file);
   }
--- branches/work/kst/portto4/kst/src/widgets/filerequester.h #890317:890318
@@ -27,7 +27,6 @@
   Q_PROPERTY(QString file READ file WRITE setFile USER true)
   public:
     FileRequester(QWidget *parent = 0);
-    FileRequester(const QString &file, QWidget *parent = 0);
     virtual ~FileRequester();
 
     QString file() const;
--- branches/work/kst/portto4/kst/src/widgets/widgets.cpp #890317:890318
@@ -16,6 +16,7 @@
 Widgets::Widgets(QObject *parent)
     : QObject(parent) {
   _plugins.append(new ColorButtonPlugin(this));
+  _plugins.append(new DataSourceSelectorPlugin(this));
   _plugins.append(new GradientEditorPlugin(this));
   _plugins.append(new FileRequesterPlugin(this));
   _plugins.append(new ComboBoxPlugin(this));
--- branches/work/kst/portto4/kst/src/widgets/widgets.h #890317:890318
@@ -31,6 +31,7 @@
 #include "curveplacement.h"
 #include "fftoptions.h"
 #include "colorpalette.h"
+#include "datasourceselector.h"
 
 namespace Kst {
 
@@ -81,6 +82,19 @@
     }
 };
 
+class DataSourceSelectorPlugin : public WidgetPlugin {
+  Q_OBJECT
+  Q_INTERFACES(QDesignerCustomWidgetInterface)
+  public:
+    DataSourceSelectorPlugin(QObject *parent = 0) : WidgetPlugin(parent) {}
+    QString name() const {
+      return QLatin1String("DataSourceSelector");
+    } //do not translate
+    QWidget *createWidget(QWidget *parent) {
+      return new DataSourceSelector(parent);
+    }
+};
+
 class GradientEditorPlugin : public WidgetPlugin {
   Q_OBJECT
   Q_INTERFACES(QDesignerCustomWidgetInterface)
--- branches/work/kst/portto4/kst/src/widgets/widgets.pro #890317:890318
@@ -31,6 +31,7 @@
     curveselector.cpp \
     datarange.cpp \
     datasourceselectordialog.cpp \
+    datasourceselector.cpp \
     dialogdefaults.cpp \
     fftoptions.cpp \
     filerequester.cpp \
@@ -51,6 +52,7 @@
     curveselector.h \
     datarange.h \
     datasourceselectordialog.h \
+    datasourceselector.h \
     dialogdefaults.h \
     fftoptions.h \
     filerequester.h \


More information about the Kst mailing list