kexi

kexipartinfo.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "kexipartinfo_p.h"
00022 
00023 #include <kexidb/global.h>
00024 
00025 using namespace KexiPart;
00026 
00027 Info::Private::Private(const KService::Ptr& aPtr)
00028  : ptr(aPtr)
00029  , groupName(aPtr->name())
00030  , mimeType(aPtr->property("X-Kexi-TypeMime").toCString())
00031  , itemIcon(aPtr->property("X-Kexi-ItemIcon").toString())
00032  , objectName(aPtr->property("X-Kexi-TypeName").toString())
00033  , broken(false)
00034  , idStoredInPartDatabase(false)
00035 {
00036     QVariant val = ptr->property("X-Kexi-NoObject");
00037     isVisibleInNavigator = val.isValid() ? (val.toInt() != 1) : true;
00038 
00040     if(objectName == "table")
00041         projectPartID = KexiDB::TableObjectType;
00042     else if(objectName == "query")
00043         projectPartID = KexiDB::QueryObjectType;
00044 //  else if(objectName == "html")
00045 //      m_projectPartID = KexiDB::WebObjectType;
00046     else
00047         projectPartID = -1; //TODO!!
00048 }
00049 
00050 Info::Private::Private()
00051  : projectPartID(-1) //OK?
00052  , broken(false)
00053  , isVisibleInNavigator(false)
00054  , idStoredInPartDatabase(false)
00055 {
00056 }
00057 
00058 //------------------------------
00059 
00060 Info::Info(KService::Ptr ptr)
00061  : d(new Private(ptr))
00062 {
00063 }
00064 
00065 Info::Info()
00066  : d(new Private())
00067 {
00068 }
00069 
00070 Info::~Info()
00071 {
00072     delete d;
00073 }
00074 
00075 QString Info::groupName() const { return d->groupName; }
00076 
00077 QCString Info::mimeType() const { return d->mimeType; }
00078 
00079 QString Info::itemIcon() const { return d->itemIcon; }
00080 
00081 QString Info::createItemIcon() const { return d->itemIcon+"_newobj"; }
00082 
00083 QString Info::objectName() const { return d->objectName; }
00084 
00085 KService::Ptr Info::ptr() const { return d->ptr; }
00086 
00087 bool Info::isBroken() const { return d->broken; }
00088 
00089 bool Info::isVisibleInNavigator() const { return d->isVisibleInNavigator; }
00090 
00091 int Info::projectPartID() const { return d->projectPartID; }
00092 
00093 void Info::setProjectPartID(int id) { d->projectPartID=id; }
00094 
00095 void Info::setBroken(bool broken, const QString& errorMessage) 
00096 { d->broken = broken; d->errorMessage = errorMessage; }
00097 
00098 QString Info::errorMessage() const { return d->errorMessage; }
00099 
00100 void Info::setIdStoredInPartDatabase(bool set)
00101 {
00102     d->idStoredInPartDatabase = set;
00103 }
00104 
00105 bool Info::isIdStoredInPartDatabase() const
00106 {
00107     return d->idStoredInPartDatabase;
00108 }
00109 
00110 bool Info::isDataExportSuppored() const
00111 {
00112     QVariant val = d->ptr ? d->ptr->property("X-Kexi-SupportsDataExport") : QVariant();
00113     return val.isValid() ? val.toBool() : false;
00114 }
00115 
00116 bool Info::isPrintingSuppored() const
00117 {
00118     QVariant val = d->ptr ? d->ptr->property("X-Kexi-SupportsPrinting") : QVariant();
00119     return val.isValid() ? val.toBool() : false;
00120 }
00121 
00122 //--------------
00123 
00124 QCString KexiPart::nameForCreateAction(const Info& info)
00125 {
00126     return (info.objectName()+"part_create").latin1();
00127 }
KDE Home | KDE Accessibility Home | Description of Access Keys