[Kst] extragear/graphics/kst/src
George Staikos
staikos at kde.org
Tue Jan 23 21:17:01 CET 2007
SVN commit 626599 by staikos:
some cleanup for coding guidelines, add some const, and fix the API for
showDialog to be consistent with the API for view objects.
M +8 -9 libkstapp/kst.cpp
M +4 -12 libkstapp/kst2dplot.cpp
M +1 -1 libkstapp/kstdatamanager_i.cpp
M +1 -1 libkstapp/kstviewmanager_i.cpp
M +23 -21 libkstmath/kstdataobject.cpp
M +15 -15 libkstmath/kstdataobject.h
--- trunk/extragear/graphics/kst/src/libkstapp/kst.cpp #626598:626599
@@ -997,8 +997,7 @@
//The old C style plugins...
QStringList oldPlugins;
- const QMap<QString,QString> readable =
- PluginCollection::self()->readableNameList();
+ const QMap<QString,QString> readable = PluginCollection::self()->readableNameList();
{
QMap<QString,QString>::const_iterator it = readable.begin();
for (; it != readable.end(); ++it) {
@@ -1009,19 +1008,19 @@
l += oldPlugins;
bool ok = false;
- QStringList plugin =
- KInputDialog::getItemList( i18n( "Data Plugins" ), i18n( "Create..." ), l, 0, false, &ok, this );
+ QStringList plugin = KInputDialog::getItemList(i18n("Data Plugins"), i18n("Create..."), l, 0, false, &ok, this);
- if ( !ok || plugin.isEmpty() )
+ if (!ok || plugin.isEmpty()) {
return;
+ }
const QString p = plugin.join("");
- if ( newPlugins.contains( p ) ) {
+ if (newPlugins.contains(p)) {
KstDataObjectPtr ptr = KstDataObject::plugin(p);
- ptr->showDialog(true);
- } else if ( oldPlugins.contains( p ) ) {
- KstPluginDialogI::globalInstance()->showNew(readable[p]);
+ ptr->showDialog(false);
+ } else if (oldPlugins.contains(p)) {
+ KstPluginDialogI::globalInstance()->showNew(readable[p]);
}
}
--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #626598:626599
@@ -3243,7 +3243,7 @@
KstBaseCurvePtr curve = *(Curves.findTag(_curveEditMap[id]));
if (curve) {
curve->readLock();
- curve->showDialog(true);
+ curve->showDialog(false);
curve->unlock();
}
}
@@ -3253,7 +3253,7 @@
KstDataObjectPtr dop = *(KST::dataObjectList.findTag(_objectEditMap[id]));
if (dop) {
dop->readLock();
- dop->showDialog(true);
+ dop->showDialog(false);
dop->unlock();
}
}
@@ -6381,16 +6381,8 @@
if (curve && fabs(best_distance) <= dy) {
curve->readLock();
-/* KstDataObjectPtr provider = curve->providerDataObject();
- if (provider) {
- curve->unlock();
- provider->readLock();
- provider->showDialog();
- provider->unlock();
- } else {*/
- curve->showDialog(true);
- curve->unlock();
-// }
+ curve->showDialog(false);
+ curve->unlock();
}
e->accept();
--- trunk/extragear/graphics/kst/src/libkstapp/kstdatamanager_i.cpp #626598:626599
@@ -1002,7 +1002,7 @@
emit editStaticVector(qi->text(0));
break;
case RTTI_OBJ_OBJECT:
- static_cast<KstObjectItem*>(qi)->dataObject()->showDialog(true);
+ static_cast<KstObjectItem*>(qi)->dataObject()->showDialog(false);
break;
case RTTI_OBJ_DATA_MATRIX:
emit editDataMatrix(qi->text(0));
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmanager_i.cpp #626598:626599
@@ -534,7 +534,7 @@
Kst2DPlotPtr plot;
KstDataObjectPtr obj = koi->dataObject(plot);
if (obj) {
- obj->showDialog(true);
+ obj->showDialog(false);
}
}
} else {
--- trunk/extragear/graphics/kst/src/libkstmath/kstdataobject.cpp #626598:626599
@@ -93,8 +93,7 @@
}
-KstDataObjectPtr KstDataObject::createPlugin(KService::Ptr service)
-{
+KstDataObjectPtr KstDataObject::createPlugin(KService::Ptr service) {
int err = 0;
KstDataObject *object =
KParts::ComponentFactory::createInstanceFromService<KstDataObject>(service, 0, "",
@@ -118,16 +117,15 @@
KstDebug::self()->log(i18n("Loaded data-object plugin %1.").arg(service->name()));
return object;
- } else {
- KstDebug::self()->log(i18n("Could not load data-object plugin %1.").arg(service->name()), KstDebug::Error);
- return 0;
}
+
+ KstDebug::self()->log(i18n("Could not load data-object plugin %1.").arg(service->name()), KstDebug::Error);
+ return 0L;
}
// Scans for plugins and stores the information for them
void KstDataObject::scanPlugins() {
-
KstDebug::self()->log(i18n("Scanning for data-object plugins."));
pluginInfo.clear(); //FIXME?
@@ -135,7 +133,7 @@
KService::List sl = KServiceType::offers("Kst Data Object");
for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
if (KstDataObjectPtr object = createPlugin(*it)) {
- pluginInfo.insert(( *it) ->name(), KstDataObjectPtr(object));
+ pluginInfo.insert((*it)->name(), KstDataObjectPtr(object));
}
}
}
@@ -155,28 +153,27 @@
}
-KstDataObjectPtr KstDataObject::plugin(const QString &name) {
- if ( pluginInfo.contains(name) )
+KstDataObjectPtr KstDataObject::plugin(const QString& name) {
+ if (pluginInfo.contains(name)) {
return pluginInfo[name];
- else
- return 0;
+ }
+ return 0L;
}
-KstDataObjectPtr KstDataObject::createPlugin(const QString &name)
-{
+KstDataObjectPtr KstDataObject::createPlugin(const QString& name) {
KService::List sl = KServiceType::offers("Kst Data Object");
for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) {
- if (( *it )->name() != name) {
+ if ((*it)->name() != name) {
continue;
- }
- else if (KstDataObjectPtr object = createPlugin( *it )) {
+ } else if (KstDataObjectPtr object = createPlugin(*it)) {
return object;
}
}
- return 0;
+ return 0L;
}
+
double *KstDataObject::vectorRealloced(KstVectorPtr v, double *memptr, int newSize) const {
if (!v) {
return 0L;
@@ -189,14 +186,18 @@
return v->realloced(memptr, newSize);
}
+
void KstDataObject::load(const QDomElement &e) {
Q_UNUSED(e)
}
+
+
void KstDataObject::save(QTextStream& ts, const QString& indent) {
Q_UNUSED(ts)
Q_UNUSED(indent)
}
+
bool KstDataObject::loadInputs() {
bool rc = true;
QValueList<QPair<QString,QString> >::Iterator i;
@@ -261,6 +262,7 @@
return rc;
}
+
int KstDataObject::getUsage() const {
int rc = 0;
@@ -292,11 +294,12 @@
}
-void KstDataObject::showDialog( bool edit ) {
- if (!edit)
+void KstDataObject::showDialog(bool isNew) {
+ if (isNew) {
QTimer::singleShot(0, this, SLOT(showNewDialog()));
- else
+ } else {
QTimer::singleShot(0, this, SLOT(showEditDialog()));
+ }
}
@@ -630,7 +633,6 @@
bool KstDataObject::uses(KstObjectPtr p) const {
-
KstVectorPtr v = kst_cast<KstVector>(p);
if (v) {
for (KstVectorMap::ConstIterator j = _inputVectors.begin(); j != _inputVectors.end(); ++j) {
--- trunk/extragear/graphics/kst/src/libkstmath/kstdataobject.h #626598:626599
@@ -47,8 +47,8 @@
static void cleanupForExit();
/** Returns a list of object plugins found on the system. */
static KstPluginInfoList pluginInfoList();
- static KstDataObjectPtr plugin(const QString &name);
- static KstDataObjectPtr createPlugin(const QString &name);
+ static KstDataObjectPtr plugin(const QString& name);
+ static KstDataObjectPtr createPlugin(const QString& name);
virtual UpdateType update(int updateCounter = -1) = 0;
virtual const QString& typeString() const { return _typeString; }
@@ -80,7 +80,7 @@
KstMatrixMap& inputMatrices() { return _inputMatrices; }
KstMatrixMap& outputMatrices() { return _outputMatrices; }
- virtual void load(const QDomElement &e);
+ virtual void load(const QDomElement& e);
virtual void save(QTextStream& ts, const QString& indent = QString::null);
virtual bool loadInputs();
@@ -108,13 +108,13 @@
virtual bool uses(KstObjectPtr p) const;
//These are generally only valid for plugins...
- QString name() const { return _name; }
- QString author() const { return _author; }
- QString description() const { return _description; }
- QString version() const { return _version; }
- QString library() const { return _library; }
+ const QString& name() const { return _name; }
+ const QString& author() const { return _author; }
+ const QString& description() const { return _description; }
+ const QString& version() const { return _version; }
+ const QString& library() const { return _library; }
- void showDialog( bool edit );
+ void showDialog(bool isNew = true);
protected slots:
virtual void showNewDialog() = 0;
@@ -126,11 +126,11 @@
//The plugin infrastructure will read the desktop file and set these
//Other objects that inherit can set the ones that apply if desired...
- void setName(const QString &str) { _name = str; }
- void setAuthor(const QString &str) { _author = str; }
- void setDescription(const QString &str) { _description = str; }
- void setVersion(const QString &str) { _version = str; }
- void setLibrary(const QString &str) { _library = str; }
+ void setName(const QString& str) { _name = str; }
+ void setAuthor(const QString& str) { _author = str; }
+ void setDescription(const QString& str) { _description = str; }
+ void setVersion(const QString& str) { _version = str; }
+ void setLibrary(const QString& str) { _library = str; }
virtual void writeLockInputsAndOutputs() const;
virtual void unlockInputsAndOutputs() const;
@@ -162,7 +162,7 @@
private:
static void scanPlugins();
- static KstDataObjectPtr createPlugin( KService::Ptr );
+ static KstDataObjectPtr createPlugin(KService::Ptr);
};
More information about the Kst
mailing list