objectvariable.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * This file is part of the KDE project 00003 * copyright (C) 2006 by Sebastian Sauer (mail@dipe.org) 00004 * copyright (C) 2006 by Bernd Steindorff (bernd@itii.de) 00005 * copyright (C) 2006 by Sascha Kupper (kusato@kfnv.de) 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this program; see the file COPYING. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 ***************************************************************************/ 00020 00021 #ifndef KEXIMACRO_OBJECTVARIABLE_H 00022 #define KEXIMACRO_OBJECTVARIABLE_H 00023 00024 #include "../lib/action.h" 00025 #include "../lib/variable.h" 00026 00027 #include "kexivariable.h" 00028 00029 #include <core/kexi.h> 00030 #include <core/kexiproject.h> 00031 #include <core/kexipartmanager.h> 00032 #include <core/kexipartinfo.h> 00033 00034 #include <klocale.h> 00035 #include <kdebug.h> 00036 00037 namespace KexiMacro { 00038 00044 template<class ACTIONIMPL> 00045 class ObjectVariable : public KexiVariable<ACTIONIMPL> 00046 { 00047 public: 00048 00049 enum Conditions { 00050 VisibleInNav = 1, 00051 Executable = 2, 00052 DataExport = 4 00053 }; 00054 00055 ObjectVariable(ACTIONIMPL* actionimpl, int conditions = VisibleInNav, const QString& objectname = QString::null) 00056 : KexiVariable<ACTIONIMPL>(actionimpl, "object", i18n("Object")) 00057 { 00058 KexiPart::PartInfoList* parts = Kexi::partManager().partInfoList(); 00059 for(KexiPart::PartInfoListIterator it(*parts); it.current(); ++it) { 00060 KexiPart::Info* info = it.current(); 00061 00062 if(conditions & VisibleInNav && ! info->isVisibleInNavigator()) 00063 continue; 00064 if(conditions & Executable && ! info->isExecuteSupported()) 00065 continue; 00066 if(conditions & DataExport && ! info->isDataExportSupported()) 00067 continue; 00068 00069 const QString name = info->objectName(); //info->groupName(); 00070 this->appendChild( KSharedPtr<KoMacro::Variable>(new KoMacro::Variable(name)) ); 00071 } 00072 00073 if(! objectname.isNull()) 00074 this->setVariant( objectname ); 00075 else if(this->children().count() > 0) 00076 this->setVariant( this->children()[0]->variant() ); 00077 else 00078 this->setVariant( QString::null ); 00079 00080 kdDebug()<<"##################### KexiActions::ObjectVariable() variant="<<this->variant()<<endl; 00081 } 00082 00083 }; 00084 00085 } 00086 00087 #endif
