summaryrefslogtreecommitdiffstats
path: root/kexi/core/kexipartinfo.h
blob: 43cf5b871d4711c3d25426816352692aec3051c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* This file is part of the KDE project
   Copyright (C) 2003 Lucijan Busch <[email protected]>
   Copyright (C) 2003,2005 Jaroslaw Staniek <[email protected]>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KEXIPARTINFO_H
#define KEXIPARTINFO_H

#include "kexipartmanager.h"

class KexiMainWindowImpl;
class KexiProject;
class KexiDialogBase;

namespace KexiPart
{

	class Manager;
	class Item;
	class Part;

/**
 * @short Information about a Kexi Part (plugin).
 */
class KEXICORE_EXPORT Info
{
	public:
		Info(KService::Ptr service);
		~Info();

		/**
		 * @return a i18n'ed group name e.g. "Tables"
		 */
		QString groupName() const;

		/**
		 * @return the internal mime type of this part
		 */
		QCString mimeType() const;

//		/**
//		 * @return the icon for groups
//		 */
//		inline QString groupIcon() const { return m_groupIcon; }

		/**
		 * @return the icon for a item
		 */
		QString itemIcon() const;

		/**
		 * @return the icon for a item
		 */
		QString createItemIcon() const;

		/**
		 * @return the object name associated with this part (e.g. "table")
		 */
		QString objectName() const;

		/**
		 * @return the project-part-id
		 */
		int projectPartID() const;

		/**
		 * @return the KService::Ptr associated with this part
		 */
		KService::Ptr ptr() const;

		/**
		 * @return true if loading was tried but failed
		 */
		bool isBroken() const;

		/**
		 * \return true if the part should be visible in the Project Navigator (as a folder).
		 */
		bool isVisibleInNavigator() const;

		/**
		 * \return true if the part supports data exporting.
		 */
		bool isDataExportSupported() const;

		/**
		 * \return true if the part supports data printing.
		 */
		bool isPrintingSupported() const;

		/**
		 * \return true if the part supports execution. This is as
		 * example the case for the Macro and the Scripting plugins.
		 */
		bool isExecuteSupported() const;

	protected:
		/**
		 * Used in StaticInfo
		 */
		Info();

		friend class Manager;
		friend class ::KexiProject;
		friend class ::KexiMainWindowImpl;
		friend class ::KexiDialogBase;

		/**
		 * Sets the project-part-id.
		 */
		void setProjectPartID(int id);

		/**
		 * Sets the broken flag and error message. 
		 * Most likely to be called by @ref KexiPart::Manager
		 */
		void setBroken(bool broken, const QString& errorMessage);

		/**
		 * \return i18n'd error message set by setBroken().
		 */
		QString errorMessage() const;

		void setIdStoredInPartDatabase(bool set);

		/**
		 * \return true if ID of the part is stored in project's database
		 * false by default. This flag is updated in Manager::checkProject()
		 * and set to true on first successful execution of KexiDialogBase::storeNewData()
		 * @internal
		 */
		bool isIdStoredInPartDatabase() const;

		class Private;
		Private *d;
};

/*! \return "create" KAction's name for part defined by \a info. 
 The result is like "tablepart_create". Used in Part::createGUIClients() 
 and KexiBrowser. */
KEXICORE_EXPORT QCString nameForCreateAction(const Info& info);

}

#endif