summaryrefslogtreecommitdiffstats
path: root/src/bnpview.h
blob: c987e35afed8180f8011073c8354a3bbb3605307 (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/***************************************************************************
 *   Copyright (C) 2003 by Sébastien Laoût                                 *
 *   [email protected]                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU 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 General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/

#ifndef BNPVIEW_H
#define BNPVIEW_H

#include <klistview.h>
#include <kxmlguiclient.h>
#include <tqtimer.h>
#include <clipboard.h>
#include <tqsplitter.h>
#include <tqlistview.h>
#include <dcopref.h>
#include "global.h"
#include "basketdcopiface.h"

 /// NEW:

class TQWidgetStack;
class TQDomDocument;
class TQDomElement;
class KToggleAction;
class KPassivePopup;
class TQPopupMenu;
class KPopupMenu;
class KTar;

class DesktopColorPicker;
class RegionGrabber;

class Basket;
class DecoratedBasket;
class BasketListViewItem;
class NoteSelection;
class BasketStatusBar;
class Tag;
class State;
class Note;

class BNPView : public TQSplitter, virtual public BasketDcopInterface
{
	Q_OBJECT
  TQ_OBJECT
	public:
	/// CONSTRUCTOR AND DESTRUCTOR:
		BNPView(TQWidget *parent, const char *name, KXMLGUIClient *aGUIClient,
				KActionCollection *actionCollection, BasketStatusBar *bar);
		~BNPView();
	/// MANAGE CONFIGURATION EVENTS!:
		void setTreePlacement(bool onLeft);
		void relayoutAllBaskets();
		void recomputeAllStyles();
		void removedStates(const TQValueList<State*> &deletedStates);
		void linkLookChanged();
		void filterPlacementChanged(bool onTop);
	/// MANAGE BASKETS:
		BasketListViewItem* listViewItemForBasket(Basket *basket);
		Basket* currentBasket();
		Basket* parentBasketOf(Basket *basket);
		void setCurrentBasket(Basket *basket);
		void removeBasket(Basket *basket);
	/// For NewBasketDialog (and later some other classes):
		TQListViewItem* firstListViewItem();
		///
		BasketListViewItem* lastListViewItem();
		int basketCount(TQListViewItem *parent = 0);
		bool canFold();
		bool canExpand();
		void enableActions();

	private:
		TQDomElement basketElement(TQListViewItem *item, TQDomDocument &document, TQDomElement &parentElement);
	public slots:
		void countsChanged(Basket *basket);
		void notesStateChanged();
		bool convertTexts();

		void updateBasketListViewItem(Basket *basket);
		void save();
		void save(TQListViewItem *firstItem, TQDomDocument &document, TQDomElement &parentElement);
		void saveSubHierarchy(TQListViewItem *item, TQDomDocument &document, TQDomElement &parentElement, bool recursive);
		void load();
		void load(KListView *listView, TQListViewItem *item, const TQDomElement &baskets);
		void loadNewBasket(const TQString &folderName, const TQDomElement &properties, Basket *parent);
		void goToPreviousBasket();
		void goToNextBasket();
		void foldBasket();
		void expandBasket();
		void closeAllEditors();
		///
		void toggleFilterAllBaskets(bool doFilter);
		void newFilter();
		void newFilterFromFilterBar();
		bool isFilteringAllBaskets();
		// From main window
		void importKNotes();
		void importKJots();
		void importKnowIt();
		void importTuxCards();
		void importStickyNotes();
		void importTomboy();
		void importTextFile();
		void backupRestore();

		/** Note */
		void activatedTagShortcut();
		void exportToHTML();
		void editNote();
		void cutNote();
		void copyNote();
		void delNote();
		void openNote();
		void openNoteWith();
		void saveNoteAs();
		void noteGroup();
		void noteUngroup();
		void moveOnTop();
		void moveOnBottom();
		void moveNoteUp();
		void moveNoteDown();
		void slotSelectAll();
		void slotUnselectAll();
		void slotInvertSelection();
		void slotResetFilter();

		void slotColorFromScreen(bool global = false);
		void slotColorFromScreenGlobal();
		void colorPicked(const TQColor &color);
		void colorPickingCanceled();
		void slotConvertTexts();

		/** Global shortcuts */
		void addNoteText();
		void addNoteHtml();
		void addNoteImage();
		void addNoteLink();
		void addNoteColor();
		/** Passive Popups for Global Actions */
		void showPassiveDropped(const TQString &title);
		void showPassiveDroppedDelayed(); // Do showPassiveDropped(), but delayed
		void showPassiveContent(bool forceShow = false);
		void showPassiveContentForced();
		void showPassiveImpossible(const TQString &message);
		void showPassiveLoading(Basket *basket);
		// For GUI :
		void setFiltering(bool filtering);
		/** Edit */
		void undo();
		void redo();
		void globalPasteInCurrentBasket();
		void pasteInCurrentBasket();
		void pasteSelInCurrentBasket();
		void pasteToBasket(int index, TQClipboard::Mode mode = TQClipboard::Clipboard);
		void showHideFilterBar(bool show, bool switchFocus = true);
		/** Insert **/
		void insertEmpty(int type);
		void insertWizard(int type);
		void grabScreenshot(bool global = false);
		void grabScreenshotGlobal();
		void screenshotGrabbed(const TQPixmap &pixmap);
		/** Basket */
		void askNewBasket();
		void askNewBasket(Basket *parent, Basket *pickProperties);
		void askNewSubBasket();
		void askNewSiblingBasket();
		void aboutToHideNewBasketPopup();
		void setNewBasketPopup();
		void cancelNewBasketPopup();
		void propBasket();
		void delBasket();
		void doBasketDeletion(Basket *basket);
		void password();
		void saveAsArchive();
		void openArchive();
		void delayedOpenArchive();
		void lockBasket();
		void hideOnEscape();

		void changedSelectedNotes();
		void timeoutTryHide();
		void timeoutHide();

	public:
		static TQString s_fileToOpen;

	public slots:
		void addWelcomeBaskets();
	private slots:
		void updateNotesActions();
		void slotBasketNumberChanged(int number);
		void slotBasketChanged();
		void currentBasketChanged();
		void isLockedChanged();
		void lateInit();
		void onFirstShow();
		void showGlobalShortcutsSettingsDialog();

	public:
		KAction       *m_actEditNote;
		KAction       *m_actOpenNote;
		KAction       *m_actPaste;
		KAction       *m_actGrabScreenshot;
		KAction       *m_actColorPicker;
		KAction       *m_actLockBasket;
		KAction       *m_actPassBasket;
		KAction       *actNewBasket;
		KAction       *actNewSubBasket;
		KAction       *actNewSiblingBasket;
		KAction       *m_actHideWindow;
		KAction       *m_actExportToHtml;
		KAction       *m_actPropBasket;
		KAction       *m_actDelBasket;
		KToggleAction *m_actFilterAllBaskets;

	private:
		// Basket actions:
		KAction       *m_actSaveAsArchive;
		KAction       *m_actOpenArchive;
		// Notes actions :
		KAction       *m_actOpenNoteWith;
		KAction       *m_actSaveNoteAs;
		KAction       *m_actGroup;
		KAction       *m_actUngroup;
		KAction       *m_actMoveOnTop;
		KAction       *m_actMoveNoteUp;
		KAction       *m_actMoveNoteDown;
		KAction       *m_actMoveOnBottom;
		// Edit actions :
		KAction       *m_actUndo;
		KAction       *m_actRedo;
		KAction       *m_actCutNote;
		KAction       *m_actCopyNote;
		KAction       *m_actDelNote;
		KAction       *m_actSelectAll;
		KAction       *m_actUnselectAll;
		KAction       *m_actInvertSelection;
		// Insert actions :
//		KAction       *m_actInsertText;
		KAction       *m_actInsertHtml;
		KAction       *m_actInsertLink;
		KAction       *m_actInsertImage;
		KAction       *m_actInsertColor;
		KAction       *m_actImportKMenu;
		KAction       *m_actInsertLauncher;
		KAction       *m_actImportIcon;
		KAction       *m_actLoadFile;
		TQPtrList<KAction> m_insertActions;
		// Basket actions :
		KToggleAction *m_actShowFilter;
		KAction       *m_actResetFilter;
		// Go actions :
		KAction       *m_actPreviousBasket;
		KAction       *m_actNextBasket;
		KAction       *m_actFoldBasket;
		KAction       *m_actExpandBasket;
//		KAction       *m_convertTexts; // FOR_BETA_PURPOSE
		KAction       *actConfigGlobalShortcuts;

		void setupActions();
		void setupGlobalShortcuts();
		DecoratedBasket* currentDecoratedBasket();

	public:
		Basket* loadBasket(const TQString &folderName); // Public only for class Archive
		BasketListViewItem* appendBasket(Basket *basket, TQListViewItem *parentItem); // Public only for class Archive

		Basket* basketForFolderName(const TQString &folderName);
		TQPopupMenu* popupMenu(const TQString &menuName);
		bool isPart();
		bool isMainWindowActive();
		void showMainWindow();

		// dcop calls
		virtual void newBasket();
		virtual void handleCommandLine();

	public slots:
		void setCaption(TQString s);
		void updateStatusBarHint();
		void setSelectionStatus(TQString s);
		void setLockStatus(bool isLocked);
		void postStatusbarMessage(const TQString&);
		void setStatusBarHint(const TQString&);
		void setUnsavedStatus(bool isUnsaved);
		void setActive(bool active = true);
		KActionCollection *actionCollection() { return m_actionCollection; };

		void populateTagsMenu();
		void populateTagsMenu(KPopupMenu &menu, Note *referenceNote);
		void connectTagsMenu();
		void disconnectTagsMenu();
		void disconnectTagsMenuDelayed();
	protected:
		void showEvent(TQShowEvent*);
		void hideEvent(TQHideEvent*);
	private:
		KPopupMenu *m_lastOpenedTagsMenu;

	private slots:
		void slotPressed(TQListViewItem *item, const TQPoint &/*pos*/ = TQPoint(), int /*column*/ = 0);
		void needSave(TQListViewItem*);
		void slotContextMenu(KListView *listView, TQListViewItem *item, const TQPoint &pos);
		void slotMouseButtonPressed(int button, TQListViewItem *item, const TQPoint &pos, int column);
		void slotShowProperties(TQListViewItem *item, const TQPoint&, int);
		void initialize();

	signals:
		void basketNumberChanged(int number);
		void basketChanged();
		void setWindowCaption(const TQString &s);
		void showPart();

	protected:
		void enterEvent(TQEvent*);
		void leaveEvent(TQEvent*);

	private:
		KListView    *m_tree;
		TQWidgetStack *m_stack;
		bool          m_loading;
		bool          m_newBasketPopup;
		bool          m_firstShow;
		DesktopColorPicker *m_colorPicker;
		bool                m_colorPickWasShown;
		bool                m_colorPickWasGlobal;
		RegionGrabber      *m_regionGrabber;
		TQString m_passiveDroppedTitle;
		NoteSelection *m_passiveDroppedSelection;
		KPassivePopup *m_passivePopup;
		static const int c_delayTooltipTime;
		KActionCollection *m_actionCollection;
		KXMLGUIClient *m_guiClient;
		BasketStatusBar *m_statusbar;
		TQTimer             *m_tryHideTimer;
		TQTimer             *m_hideTimer;
};

#endif // BNPVIEW_H