kexi
objectnamevariable.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KEXIMACRO_OBJECTNAMEVARIABLE_H
00022 #define KEXIMACRO_OBJECTNAMEVARIABLE_H
00023
00024 #include "../lib/variable.h"
00025
00026 #include "kexivariable.h"
00027
00028 #include <core/kexi.h>
00029 #include <core/kexiproject.h>
00030 #include <core/kexipartmanager.h>
00031 #include <core/kexipartinfo.h>
00032
00033 #include <klocale.h>
00034
00035 namespace KexiMacro {
00036
00041 template<class ACTIONIMPL>
00042 class ObjectNameVariable : public KexiVariable<ACTIONIMPL>
00043 {
00044 public:
00045 ObjectNameVariable(ACTIONIMPL* actionimpl, const QString& objectname = QString::null, const QString& name = QString::null)
00046 : KexiVariable<ACTIONIMPL>(actionimpl, "name", i18n("Name"))
00047 {
00048 if(! actionimpl->mainWin()->project())
00049 return;
00050
00051 QStringList namelist;
00052 KexiPart::Info* info = Kexi::partManager().infoForMimeType( QString("kexi/%1").arg(objectname) );
00053 if(info) {
00054 KexiPart::ItemDict* items = actionimpl->mainWin()->project()->items(info);
00055 if(items)
00056 for(KexiPart::ItemDictIterator item_it = *items; item_it.current(); ++item_it)
00057 namelist << item_it.current()->name();
00058 }
00059
00060 if(namelist.count() <= 0)
00061 namelist << "";
00062
00063 for(QStringList::Iterator it = namelist.begin(); it != namelist.end(); ++it)
00064 this->appendChild( KSharedPtr<KoMacro::Variable>(new KoMacro::Variable(*it)) );
00065
00066 this->setVariant( (name.isNull() || ! namelist.contains(name)) ? namelist[0] : name );
00067
00068 kdDebug()<<"##################### KexiActions::ObjectNameVariable() objectname="<<objectname<<" name="<<name<<" value="<<this->variant()<<" children="<<namelist<<endl;
00069 }
00070
00071 virtual ~ObjectNameVariable() {}
00072 };
00073
00074 }
00075
00076 #endif
|