~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to src/core/kexi.h

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
Import upstream version 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2003-2012 Jarosław Staniek <staniek@kde.org>
 
3
 
 
4
   This program is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this program; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#ifndef KEXI_H
 
21
#define KEXI_H
 
22
 
 
23
#include <QPointer>
 
24
 
 
25
#include <KexiVersion.h>
 
26
#include "kexiprojectdata.h"
 
27
#include "kexidbconnectionset.h"
 
28
#include "kexiprojectset.h"
 
29
 
 
30
class QLabel;
 
31
class KDbDriverManager;
 
32
class KexiRecentProjects;
 
33
 
 
34
namespace KexiPart
 
35
{
 
36
class Manager;
 
37
}
 
38
 
 
39
namespace Kexi
 
40
{
 
41
/*! Modes of view for the dialogs. Used mostly for parts and KexiWindow. */
 
42
enum ViewMode {
 
43
    AllViewModes = 0, //!< Usable primarily in KexiPart::initInstanceActions()
 
44
    NoViewMode = 0,   //!< In KexiView::afterSwitchFrom() and KexiView::beforeSwitchTo()
 
45
                      //!< means that parent dialog of the view has not been defined yet.
 
46
    DataViewMode = 1,
 
47
    DesignViewMode = 2,
 
48
    TextViewMode = 4  //!< Also known as SQL View Mode
 
49
};
 
50
Q_DECLARE_FLAGS(ViewModes, ViewMode)
 
51
 
 
52
/*! @return i18n'ed name of view mode @a mode. If @a withAmpersand is true,
 
53
 ampersands used for accelerators are included, e.g. "&Data View".*/
 
54
KEXICORE_EXPORT QString nameForViewMode(ViewMode mode, bool withAmpersand = false);
 
55
 
 
56
/*! @return icon name of view mode @a mode. */
 
57
KEXICORE_EXPORT QString iconNameForViewMode(ViewMode mode);
 
58
 
 
59
//! A set of known connections
 
60
KEXICORE_EXPORT KexiDBConnectionSet& connset();
 
61
 
 
62
//! A set available of project information
 
63
KEXICORE_EXPORT KexiRecentProjects* recentProjects();
 
64
 
 
65
//! shared driver manager
 
66
KEXICORE_EXPORT KDbDriverManager& driverManager();
 
67
 
 
68
//! shared part manager
 
69
KEXICORE_EXPORT KexiPart::Manager& partManager();
 
70
 
 
71
//! can be called to delete global objects like driverManager and partManager
 
72
//! (and thus, all loaded factories/plugins)
 
73
//! before KLibrary::~KLibrary() do this for us
 
74
KEXICORE_EXPORT void deleteGlobalObjects();
 
75
 
 
76
//some temporary flags
 
77
 
 
78
//! false by default, flag loaded on main window startup
 
79
KEXICORE_EXPORT bool& tempShowMacros();
 
80
 
 
81
//! false by default, flag loaded on main window startup
 
82
KEXICORE_EXPORT bool& tempShowScripts();
 
83
 
 
84
//! false by default, flag loaded on main window startup
 
85
KEXICORE_EXPORT bool& tempShowScripts();
 
86
 
 
87
/*! Helper class for storing object status. */
 
88
class KEXICORE_EXPORT ObjectStatus
 
89
{
 
90
public:
 
91
    ObjectStatus();
 
92
 
 
93
    ObjectStatus(const QString& message, const QString& description);
 
94
 
 
95
    ObjectStatus(const KDbResultable* resultable, const QString& message, const QString& description);
 
96
 
 
97
    ~ObjectStatus();
 
98
 
 
99
    const ObjectStatus& status() const;
 
100
 
 
101
    bool error() const;
 
102
 
 
103
    void setStatus(const QString& message, const QString& description);
 
104
 
 
105
    //! Note: for safety, \a dbObject needs to be derived from QObject,
 
106
    //! otherwise it won't be assigned
 
107
    void setStatus(const KDbResultable* resultable,
 
108
                   const QString& message = QString(), const QString& description = QString());
 
109
 
 
110
    void setStatus(KDbResultInfo* resultInfo,
 
111
                   const QString& message = QString(), const QString& description = QString());
 
112
 
 
113
    void setStatus(const KDbResultable* resultable, KDbResultInfo* resultInfo,
 
114
                   const QString& message = QString(), const QString& description = QString());
 
115
 
 
116
    void setStatus(const KDbResult& result, KDbResultInfo* resultInfo,
 
117
                   const QString& message = QString(), const QString& description = QString());
 
118
 
 
119
    void clearStatus();
 
120
 
 
121
    QString singleStatusString() const;
 
122
 
 
123
    void append(const ObjectStatus& otherStatus);
 
124
 
 
125
    const KDbResultable* resultable() const { return m_resultable; }
 
126
 
 
127
    //! Helper returning pseudo handler that just updates this ObjectStatus object
 
128
    //! by receiving a message
 
129
    operator KDbMessageHandler*();
 
130
 
 
131
    QString message, description;
 
132
protected:
 
133
    const KDbResultable* m_resultable;
 
134
    KDbMessageHandler* m_msgHandler;
 
135
};
 
136
 
 
137
/*! \return icon name for default file-based driver
 
138
 (typically icon for something like "application/x-kexiproject-sqlite").
 
139
 @see KDb::defaultFileBasedDriverMimeType() */
 
140
KEXICORE_EXPORT QString defaultFileBasedDriverIconName();
 
141
 
 
142
/*! \return icon for default file-based driver
 
143
 (typically icon for something like "application/x-kexiproject-sqlite").
 
144
 If contains special workaround to properly load mimetype icon according to current theme,
 
145
 at least needed for Breeze.
 
146
 @see KDb::defaultFileBasedDriverIconName() */
 
147
KEXICORE_EXPORT QIcon defaultFileBasedDriverIcon();
 
148
 
 
149
/*! \return icon name for database servers. */
 
150
KEXICORE_EXPORT QString serverIconName();
 
151
 
 
152
/*! \return icon for database servers. */
 
153
KEXICORE_EXPORT QIcon serverIcon();
 
154
 
 
155
/*! @return message text "Kexi could have been incorrectly installed or started.
 
156
            The application will be closed." useful for critical errors. */
 
157
KEXICORE_EXPORT QString appIncorrectlyInstalledMessage();
 
158
 
 
159
//! @return base path (without the filename for file-based connection data @a connectionData.
 
160
//! Empty string is returned if @a connectionData does not point to a file-based connection with
 
161
//! database name specified.
 
162
KEXICORE_EXPORT QString basePathForProject(const KDbConnectionData& connectionData);
 
163
 
 
164
}//namespace Kexi
 
165
 
 
166
Q_DECLARE_OPERATORS_FOR_FLAGS(Kexi::ViewModes)
 
167
 
 
168
//! Displays information that feature "feature_name" is not availabe in the current application version
 
169
KEXICORE_EXPORT void KEXI_UNFINISHED(
 
170
    const QString& feature_name, const QString& extra_text = QString());
 
171
 
 
172
//! Like KEXI_UNFINISHED but returns new label instance with expected text
 
173
KEXICORE_EXPORT QLabel *KEXI_UNFINISHED_LABEL(
 
174
    const QString& feature_name, const QString& extra_text = QString());
 
175
 
 
176
//! Like above - for use inside KexiActionProxy subclass - reuses feature name from shared action's text
 
177
#define KEXI_UNFINISHED_SHARED_ACTION(action_name) \
 
178
    KEXI_UNFINISHED(sharedAction(action_name) ? sharedAction(action_name)->text() : QString())
 
179
 
 
180
//! Implementation of plugin's entry point
 
181
#define KEXI_PLUGIN_FACTORY(class_name, name) \
 
182
    K_PLUGIN_FACTORY_WITH_JSON(class_name ## Factory, name, registerPlugin<class_name>();)
 
183
 
 
184
#endif