summaryrefslogtreecommitdiffstats
path: root/kexi/core/kexi.h
blob: 921db42bef61226880dfbaaee9990f33dfbddfdc (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
/* This file is part of the KDE project
   Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>

   This program 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 program 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 program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KEXI_H
#define KEXI_H

#include <tqguardedptr.h>
#include <tqfont.h>

#include <kexi_version.h>
#include "kexiprojectdata.h"
#include "kexipartmanager.h"
#include "kexidbconnectionset.h"
#include "kexiprojectset.h"
#include <kexidb/drivermanager.h>
#include <kexidb/driver.h>

#include <klocale.h>
#include <kmessagebox.h>

namespace Kexi
{
	KEXICORE_EXPORT void initCmdLineArgs(int argc, char *argv[], TDEAboutData* aboutData = 0);

	/*! Modes of view for the dialogs. Used mostly for parts and KexiDialogBase. */
	enum ViewMode { 
		AllViewModes = 0, //!< Usable primarily in KexiPart::initInstanceActions()
		NoViewMode = 0, //!< In KexiViewBase::afterSwitchFrom() and KexiViewBase::beforeSwitchTo() 
		                //!< means that parent dialog of the view has not yet view defined.
		DataViewMode = 1,
		DesignViewMode = 2,
		TextViewMode = 4 //!< Also known as SQL View Mode
	};
	//! i18n'ed name of view mode \a m
	KEXICORE_EXPORT TQString nameForViewMode(int m);

	//! A set of known connections
	KEXICORE_EXPORT KexiDBConnectionSet& connset();
	
	//! A set avaiulable of project infos
	KEXICORE_EXPORT KexiProjectSet& recentProjects();
	
	//! shared driver manager
	KEXICORE_EXPORT KexiDB::DriverManager& driverManager();
	
	//! shared part manager
	KEXICORE_EXPORT KexiPart::Manager& partManager();
	
	//! can be called to delete global objects like driverManager and partManager
	//! (and thus, all loaded factories/plugins)
	//! before KLibrary::~KLibrary() do this for us
	KEXICORE_EXPORT void deleteGlobalObjects();

	//some temporary flags

	//! false by default, flag loaded on main window startup
	KEXICORE_EXPORT bool& tempShowForms(); 

	//! false by default, flag loaded on main window startup
	KEXICORE_EXPORT bool& tempShowReports(); 

	//! false by default, flag loaded on main window startup
	KEXICORE_EXPORT bool& tempShowMacros();

	//! false by default, flag loaded on main window startup
	KEXICORE_EXPORT bool& tempShowScripts(); 

	/*! A global setting for minimal readable font.
	 Note: this is defined because KDE has no such setting yet.
	 \a init is a widget that should be passed if no tqApp->mainWidget() is available yet. */
	KEXICORE_EXPORT TQFont smallFont(TQWidget *init = 0);

	/*! Helper class for storing object status. */
	class KEXICORE_EXPORT ObjectStatus
	{
		public:
			ObjectStatus();

			ObjectStatus(const TQString& message, const TQString& description);

			ObjectStatus(KexiDB::Object* dbObject, const TQString& message, const TQString& description);

			~ObjectStatus();

			const ObjectStatus& status() const;

			bool error() const;

			void setStatus(const TQString& message, const TQString& description);

			//! Note: for safety, \a dbObject needs to be derived from TQObject, 
			//! otherwise it won't be assigned
			void setStatus(KexiDB::Object* dbObject, 
				const TQString& message = TQString(), const TQString& description = TQString());

			void setStatus(KexiDB::ResultInfo* result, 
				const TQString& message = TQString(), const TQString& description = TQString());

			void setStatus(KexiDB::Object* dbObject, KexiDB::ResultInfo* result, 
				const TQString& message = TQString(), const TQString& description = TQString());

			void clearStatus();

			TQString singleStatusString() const;

			void append( const ObjectStatus& otherStatus );

			KexiDB::Object *dbObject() const { return dynamic_cast<KexiDB::Object*>((TQObject*)dbObj); }

			//! Helper returning pseudo handler that just updates this ObjectStatus object 
			//! by receiving a message
			operator KexiDB::MessageHandler*();

			TQString message, description;
		protected:
			TQGuardedPtr<TQObject> dbObj; //! This is in fact KexiDB::Object
			KexiDB::MessageHandler* msgHandler;
	};

	KEXICORE_EXPORT TQString msgYouCanImproveData();

}//namespace Kexi

//! Displays information that feature "feature_name" is not availabe in the current application version
KEXICORE_EXPORT void KEXI_UNFINISHED(const TQString& feature_name, const TQString& extra_text = TQString());

//! Like above - for use inside KexiActionProxy subclass - reuses feature name from shared action's text
#define KEXI_UNFINISHED_SHARED_ACTION(action_name) \
	KEXI_UNFINISHED(sharedAction(action_name) ? sharedAction(action_name)->text() : TQString())

#endif