kexi

kexipartinfo.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2003 Jaroslaw Staniek <js@iidea.pl>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "kexipartinfo_p.h"
22
23#include <kexidb/global.h>
24
25using namespace KexiPart;
26
27Info::Private::Private(const KService::Ptr& aPtr)
28 : ptr(aPtr)
29 , groupName(aPtr->name())
30 , mimeType(aPtr->property("X-Kexi-TypeMime").toCString())
31 , itemIcon(aPtr->property("X-Kexi-ItemIcon").toString())
32 , objectName(aPtr->property("X-Kexi-TypeName").toString())
33 , broken(false)
34 , idStoredInPartDatabase(false)
35{
36 TQVariant val = ptr->property("X-Kexi-NoObject");
37 isVisibleInNavigator = val.isValid() ? (val.toInt() != 1) : true;
38
40 if(objectName == "table")
41 projectPartID = KexiDB::TableObjectType;
42 else if(objectName == "query")
43 projectPartID = KexiDB::QueryObjectType;
44// else if(objectName == "html")
45// m_projectPartID = KexiDB::WebObjectType;
46 else
47 projectPartID = -1; //TODO!!
48}
49
50Info::Private::Private()
51 : projectPartID(-1) //OK?
52 , broken(false)
53 , isVisibleInNavigator(false)
54 , idStoredInPartDatabase(false)
55{
56}
57
58//------------------------------
59
60Info::Info(KService::Ptr ptr)
61 : d(new Private(ptr))
62{
63}
64
66 : d(new Private())
67{
68}
69
70Info::~Info()
71{
72 delete d;
73}
74
75TQString Info::groupName() const { return d->groupName; }
76
77TQCString Info::mimeType() const { return d->mimeType; }
78
79TQString Info::itemIcon() const { return d->itemIcon; }
80
81TQString Info::createItemIcon() const { return d->itemIcon+"_newobj"; }
82
83TQString Info::objectName() const { return d->objectName; }
84
85KService::Ptr Info::ptr() const { return d->ptr; }
86
87bool Info::isBroken() const { return d->broken; }
88
89bool Info::isVisibleInNavigator() const { return d->isVisibleInNavigator; }
90
91int Info::projectPartID() const { return d->projectPartID; }
92
93void Info::setProjectPartID(int id) { d->projectPartID=id; }
94
95void Info::setBroken(bool broken, const TQString& errorMessage)
96{ d->broken = broken; d->errorMessage = errorMessage; }
97
98TQString Info::errorMessage() const { return d->errorMessage; }
99
100void Info::setIdStoredInPartDatabase(bool set)
101{
102 d->idStoredInPartDatabase = set;
103}
104
106{
107 return d->idStoredInPartDatabase;
108}
109
111{
112 TQVariant val = d->ptr ? d->ptr->property("X-Kexi-SupportsDataExport") : TQVariant();
113 return val.isValid() ? val.toBool() : false;
114}
115
117{
118 TQVariant val = d->ptr ? d->ptr->property("X-Kexi-SupportsPrinting") : TQVariant();
119 return val.isValid() ? val.toBool() : false;
120}
121
123{
124 TQVariant val = d->ptr ? d->ptr->property("X-Kexi-SupportsExecution") : TQVariant();
125 return val.isValid() ? val.toBool() : false;
126}
127
128//--------------
129
130TQCString KexiPart::nameForCreateAction(const Info& info)
131{
132 return (info.objectName()+"part_create").latin1();
133}
Information about a Kexi Part (plugin).
bool isIdStoredInPartDatabase() const
void setBroken(bool broken, const TQString &errorMessage)
Sets the broken flag and error message.
TQString groupName() const
TQString createItemIcon() const
bool isDataExportSupported() const
int projectPartID() const
TQString errorMessage() const
KService::Ptr ptr() const
Info()
Used in StaticInfo.
TQCString mimeType() const
bool isBroken() const
bool isPrintingSupported() const
TQString itemIcon() const
TQString objectName() const
bool isExecuteSupported() const
bool isVisibleInNavigator() const
void setProjectPartID(int id)
Sets the project-part-id.