summaryrefslogtreecommitdiffstats
path: root/kexi/core/keximainwindow.h
blob: ec1db633348dac557b8b2a27686164816fcf9f44 (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* This file is part of the KDE project
   Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
   Copyright (C) 2003-2005 Jaroslaw Staniek <js@iidea.pl>

   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 KEXIMAINWINDOW_H
#define KEXIMAINWINDOW_H

#include <qmap.h>
#include <qintdict.h>

#include <kmdimainfrm.h>
#include <kexiutils/tristate.h>

#include "kexisharedactionhost.h"
#include "kexi.h"

class KexiDialogBase;
class KexiProject;
namespace KexiPart {
	class Item;
}

/**
 * @short Kexi's main window interface
 * This interface is implemented by KexiMainWindowImpl class.
 * KexiMainWindow offers simple features what lowers cross-dependency (and also avoids
 * circular dependencies between Kexi modules).
 */
class KEXICORE_EXPORT KexiMainWindow : public KMdiMainFrm, public KexiSharedActionHost
{
	Q_OBJECT
	public:
		//! Used by printActionForItem()
		enum PrintActionType {
			PrintItem,
			PreviewItem,
			PageSetupForItem
		};

		KexiMainWindow();
		virtual ~KexiMainWindow();

		//! Project data of currently opened project or NULL if no project here yet.
		virtual KexiProject *project() = 0;

		/*! Registers dialog \a dlg for watching and adds it to the main window's stack. */
		virtual void registerChild(KexiDialogBase *dlg) = 0;

		virtual QPopupMenu* findPopupMenu(const char *popupName) = 0;

		/*! Generates ID for private "document" like Relations window.
		 Private IDs are negative numbers (while ID regular part instance's IDs are >0)
		 Private means that the object is not stored as-is in the project but is somewhat
		 generated and in most cases there is at most one unique instance document of such type (part).
		 To generate this ID, just app-wide internal counter is used. */
		virtual int generatePrivateID() = 0;

		/*! \return a list of all actions defined by application.
		 Not all of them are shared. Don't use plug these actions
		 in your windows by hand but user methods from KexiViewBase! */
		virtual KActionPtrList allActions() const = 0;

		/*! \return currently active dialog (window) od 0 if there is no active dialog. */
		virtual KexiDialogBase* currentDialog() const = 0;

		/*! \return true if this window is in the User Mode. */
		virtual bool userMode() const = 0;

	signals:
		//! Emitted to make sure the project can be close. 
		//! Connect a slot here and set \a cancel to true to cancel the closing.
		void acceptProjectClosingRequested(bool& cancel);

		//! Emitted before closing the project (and destroying all it's data members).
		//! You can do you cleanup of your structures here. 
		void beforeProjectClosing();

		//! Emitted after closing the project. 
		void projectClosed();

	public slots:
		/*! Creates new object of type defined by \a info part info. 
		 \a openingCancelled is set to true is opening has been cancelled. 
		 \return true on success. */
		virtual bool newObject( KexiPart::Info *info, bool& openingCancelled ) = 0;

		//! Opens object pointed by \a item in a view \a viewMode
		virtual KexiDialogBase * openObject(KexiPart::Item *item, int viewMode,
			bool &openingCancelled, QMap<QString,QString>* staticObjectArgs = 0,
			QString* errorMessage = 0) = 0;

		//! For convenience
		virtual KexiDialogBase * openObject(const QCString& mime, const QString& name, 
			int viewMode, bool &openingCancelled, QMap<QString,QString>* staticObjectArgs = 0) = 0;

		/*! Closes the object for \a item. 
		 \return true on success (closing can be dealyed though), false on failure and cancelled 
		 if the object has "opening" job assigned. */
		virtual tristate closeObject(KexiPart::Item* item) = 0;

		/*! Called to accept property butter editing. */
		virtual void acceptPropertySetEditing() = 0;

		/*! Received information from active view that \a dlg has switched
		its property set, so property editor contents should be reloaded.
		 If \a force is true, property editor's data is reloaded even
		 if the currently pointed property set is the same as before.
		 If \a preservePrevSelection is true and there was a property set
		 set before call, previously selected item will be preselected
		 in the editor (if found). */
		virtual void propertySetSwitched(KexiDialogBase *dlg, bool force=false,
			bool preservePrevSelection = true, const QCString& propertyToSelect = QCString()) = 0;

		/*! Saves dialog's \a dlg data. If dialog's data is never saved,
		 user is asked for name and title, before saving (see getNewObjectInfo()).
		 \return true on successul saving or false on error.
		 If saving was cancelled by user, cancelled is returned.
		 \a messageWhenAskingForName is a i18n'ed text that will be visible
		 within name/caption dialog (see KexiNameDialog), which is popped
		 up for never saved objects. */
		virtual tristate saveObject( KexiDialogBase *dlg,
			const QString& messageWhenAskingForName = QString::null, bool dontAsk = false ) = 0;

		/*! Closes dialog \a dlg. If dialog's data (see KexiDialoBase::dirty()) is unsaved,
		 used will be asked if saving should be perforemed.
		 \return true on successull closing or false on closing error.
		 If closing was cancelled by user, cancelled is returned. */
		virtual tristate closeDialog(KexiDialogBase *dlg) = 0;

		/*! Displays a dialog for entering object's name and title.
		 Used on new object saving.
		 \return true on successul closing or cancelled on cancel returned.
		 It's unlikely to have false returned here.
		 \a messageWhenAskingForName is a i18n'ed text that will be visible
		 within name/caption dialog (see KexiNameDialog).
		 If \a allowOverwriting is true, user will be asked for existing
		 object's overwriting, else it will be impossible to enter
		 a name of existing object.
		 You can check \a allowOverwriting after calling this method.
		 If it's true, user agreed on overwriting, if it's false, user picked
		 nonexisting name, so no overwrite will be needed. */
		virtual tristate getNewObjectInfo( KexiPart::Item *partItem, KexiPart::Part *part,
			bool& allowOverwriting, const QString& messageWhenAskingForName = QString::null ) = 0;

		/*! Highlights object of mime \a mime and name \a name.
		 This can be done in the Project Navigator or so. 
		 If a window for the object is opened (in any mode), it should be raised. */
		virtual void highlightObject(const QCString& mime, const QCString& name) = 0;

		//! Shows "print" dialog for \a item.
		//! \return true on success.
		virtual tristate printItem(KexiPart::Item* item) = 0;

		//! Shows "print preview" dialog. 
		//! \return true on success.
		virtual tristate printPreviewForItem(KexiPart::Item* item) = 0;

		//! Shows "page setup" dialog for \a item.
		//! \return true on success and cancelled when the action was cancelled.
		virtual tristate showPageSetupForItem(KexiPart::Item* item) = 0;

		/*! Executes custom action for the main window, usually provided by a plugin. 
		 Also used by KexiFormEventAction. */
		virtual tristate executeCustomActionForObject(KexiPart::Item* item, const QString& actionName) = 0;

	protected slots:
		virtual void slotObjectRenamed(const KexiPart::Item &item, const QCString& oldName) = 0;

};


#endif