[Kst] branches/work/kst/pluginify/kst/src
Adam Treat
treat at kde.org
Mon Sep 18 19:53:20 CEST 2006
SVN commit 586104 by treat:
* Revamp the testplugin to inherit new kstbasicplugin
* trying to decide whether the basic dialog will programmatically
create the widgets, or if each plugin should provide own UI file..
M +26 -8 libkstapp/kstbasicdialog.cpp
M +0 -1 libkstapp/kstbasicdialog.h
M +45 -1 plugins/testplugin/testplugin.cpp
M +18 -21 plugins/testplugin/testplugin.h
--- branches/work/kst/pluginify/kst/src/libkstapp/kstbasicdialog.cpp #586103:586104
@@ -16,25 +16,25 @@
***************************************************************************/
// include files for Qt
+#include <qlineedit.h>
// include files for KDE
#include "kstbasicdialog.h"
// application specific includes
-#include <kst.h>
-#include <kstdoc.h>
-#include <scalarselector.h>
-#include <stringselector.h>
-#include <vectorselector.h>
-#include <kstdefaultnames.h>
-#include <kstdataobjectcollection.h>
+#include "kst.h"
+#include "kstdoc.h"
+#include "scalarselector.h"
+#include "stringselector.h"
+#include "vectorselector.h"
+#include "kstdefaultnames.h"
+#include "kstdataobjectcollection.h"
const QString& KstBasicDialog::defaultTag = KGlobal::staticQString("<Auto Name>");
KstBasicDialog::KstBasicDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
: KstDataDialog(parent, name, modal, fl) {
-/* _w = new QWidget(_contents);*/ //FIXME
setMultiple(false);
connect(this, SIGNAL(modified()), KstApp::inst()->document(), SLOT(wasModified())); //FIXME this should be in KstDataDialog constructor...
@@ -71,6 +71,21 @@
void KstBasicDialog::fillFieldsForEdit() {
+
+ KstBasicPluginPtr ptr = kst_cast<KstBasicPlugin>(_dp);
+ if (!ptr) {
+ return;
+ }
+
+ ptr->readLock();
+
+ _tagName->setText(ptr->tagName());
+ _legendText->setText(defaultTag); //FIXME?
+
+ //Update the various widgets...
+
+ ptr->unlock();
+
adjustSize();
resize(minimumSizeHint());
setFixedHeight(height());
@@ -78,6 +93,9 @@
void KstBasicDialog::fillFieldsForNew() {
+ _tagName->setText(defaultTag);
+ _legendText->setText(defaultTag);
+
adjustSize();
resize(minimumSizeHint());
setFixedHeight(height());
--- branches/work/kst/pluginify/kst/src/libkstapp/kstbasicdialog.h #586103:586104
@@ -40,7 +40,6 @@
private:
bool editSingleObject(KstBasicPluginPtr ptr);
static const QString& defaultTag;
- QWidget *_w;
};
#endif
--- branches/work/kst/pluginify/kst/src/plugins/testplugin/testplugin.cpp #586103:586104
@@ -19,14 +19,58 @@
#include <kdebug.h>
#include <kgenericfactory.h>
+static const QString& VECTOR_IN = KGlobal::staticQString("Vector In");
+static const QString& SCALAR_IN = KGlobal::staticQString("Scalar In");
+static const QString& STRING_IN = KGlobal::staticQString("String In");
+static const QString& VECTOR_OUT = KGlobal::staticQString("Vector Out");
+static const QString& SCALAR_OUT = KGlobal::staticQString("Scalar Out");
+static const QString& STRING_OUT = KGlobal::staticQString("String Out");
+
K_EXPORT_COMPONENT_FACTORY( kstobject_testplugin,
KGenericFactory<TestPlugin>( "kstobject_testplugin" ) )
TestPlugin::TestPlugin( QObject */*parent*/, const char */*name*/, const QStringList &/*args*/ )
- : KstDataObject() {
+ : KstBasicPlugin() {
}
+
TestPlugin::~TestPlugin() {
}
+
+bool TestPlugin::algorithm() {
+ //Do nothing
+ return true;
+}
+
+
+QStringList TestPlugin::inputVectors() const {
+ return QStringList( VECTOR_IN );
+}
+
+
+QStringList TestPlugin::inputScalars() const {
+ return QStringList( SCALAR_IN );
+}
+
+
+QStringList TestPlugin::inputStrings() const {
+ return QStringList( STRING_IN );
+}
+
+
+QStringList TestPlugin::outputVectors() const {
+ return QStringList( VECTOR_OUT );
+}
+
+
+QStringList TestPlugin::outputScalars() const {
+ return QStringList( SCALAR_OUT );
+}
+
+
+QStringList TestPlugin::outputStrings() const {
+ return QStringList( STRING_OUT );
+}
+
#include "testplugin.moc"
--- branches/work/kst/pluginify/kst/src/plugins/testplugin/testplugin.h #586103:586104
@@ -17,37 +17,34 @@
#ifndef TESTPLUGIN_H
#define TESTPLUGIN_H
-#include <kstdataobject.h>
+#include <kstbasicplugin.h>
#include <kmessagebox.h>
-class TestPlugin : public KstDataObject {
+class TestPlugin : public KstBasicPlugin {
Q_OBJECT
-public:
-
+ public:
TestPlugin(QObject *parent, const char *name, const QStringList &args);
virtual ~TestPlugin();
- virtual KstObject::UpdateType update(int)
- {
- return UPDATE;
- }
- virtual QString propertyString() const
- {
- return "";
- }
- virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap&)
- {
- return 0;
- }
+ virtual bool algorithm();
-protected slots:
- virtual void showNewDialog()
- {
+ virtual QStringList inputVectors() const;
+ virtual QStringList inputScalars() const;
+ virtual QStringList inputStrings() const;
+ virtual QStringList outputVectors() const;
+ virtual QStringList outputScalars() const;
+ virtual QStringList outputStrings() const;
+
+ virtual QString propertyString() const { return "Test Plugin"; }
+
+ virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap&) { return 0; }
+
+ protected slots:
+ virtual void showNewDialog() {
KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
}
- virtual void showEditDialog()
- {
+ virtual void showEditDialog() {
KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
}
};
More information about the Kst
mailing list