objectvariable.h
1/***************************************************************************
2 * This file is part of the KDE project
3 * copyright (C) 2006 by Sebastian Sauer (mail@dipe.org)
4 * copyright (C) 2006 by Bernd Steindorff (bernd@itii.de)
5 * copyright (C) 2006 by Sascha Kupper (kusato@kfnv.de)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this program; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 ***************************************************************************/
20
21#ifndef KEXIMACRO_OBJECTVARIABLE_H
22#define KEXIMACRO_OBJECTVARIABLE_H
23
24#include "../lib/action.h"
25#include "../lib/variable.h"
26
27#include "kexivariable.h"
28
29#include <core/kexi.h>
30#include <core/kexiproject.h>
31#include <core/kexipartmanager.h>
32#include <core/kexipartinfo.h>
33
34#include <tdelocale.h>
35#include <kdebug.h>
36
37namespace KexiMacro {
38
44 template<class ACTIONIMPL>
45 class ObjectVariable : public KexiVariable<ACTIONIMPL>
46 {
47 public:
48
49 enum Conditions {
50 VisibleInNav = 1,
51 Executable = 2,
52 DataExport = 4
53 };
54
55 ObjectVariable(ACTIONIMPL* actionimpl, int conditions = VisibleInNav, const TQString& objectname = TQString())
56 : KexiVariable<ACTIONIMPL>(actionimpl, "object", i18n("Object"))
57 {
58 KexiPart::PartInfoList* parts = Kexi::partManager().partInfoList();
59 for(KexiPart::PartInfoListIterator it(*parts); it.current(); ++it) {
60 KexiPart::Info* info = it.current();
61
62 if(conditions & VisibleInNav && ! info->isVisibleInNavigator())
63 continue;
64 if(conditions & Executable && ! info->isExecuteSupported())
65 continue;
66 if(conditions & DataExport && ! info->isDataExportSupported())
67 continue;
68
69 const TQString name = info->objectName(); //info->groupName();
70 this->appendChild( TDESharedPtr<KoMacro::Variable>(new KoMacro::Variable(name)) );
71 }
72
73 if(! objectname.isNull())
74 this->setVariant( objectname );
75 else if(this->children().count() > 0)
76 this->setVariant( this->children()[0]->variant() );
77 else
78 this->setVariant( TQString() );
79
80 kdDebug()<<"##################### KexiActions::ObjectVariable() variant="<<this->variant()<<endl;
81 }
82
83 };
84
85}
86
87#endif
Template class to offer common functionality needed by all KoMacro::Variable implementations Kexi pro...
The ObjectVariable class implements KoMacro::Variable to provide a variable list of Kexi-objects.
Information about a Kexi Part (plugin).
bool isDataExportSupported() const
TQString objectName() const
bool isExecuteSupported() const
bool isVisibleInNavigator() const
PartInfoList * partInfoList()
A variable value used to provide abstract access to variables.
Definition variable.h:39
TQString name() const
Definition variable.cpp:137
void appendChild(TDESharedPtr< Variable > variable)
Append a Variable to the list of children this Variable has.
Definition variable.cpp:221
void setVariant(const TQVariant &variant, bool detecttype=true)
Set the TQVariant.
Definition variable.cpp:165
const TQVariant variant() const
Definition variable.cpp:157
List children() const
Definition variable.cpp:216
KEXICORE_EXPORT KexiPart::Manager & partManager()
shared part manager
Definition kexi.cpp:97