Ran am2cmake.
[basket4.git] / src / bnpview.h
blob7736007fdc8b9ae200bf3f4674de13d1cc0174c1
1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
3 * slaout@linux62.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef BNPVIEW_H
22 #define BNPVIEW_H
24 #include <klistview.h>
25 #include <kxmlguiclient.h>
26 #include <qtimer.h>
27 #include <qclipboard.h>
28 #include <qsplitter.h>
29 #include <q3listview.h>
30 //Added by qt3to4:
31 #include <Q3ValueList>
32 #include <Q3PtrList>
33 #include <QPixmap>
34 #include <QHideEvent>
35 #include <Q3PopupMenu>
36 #include <QEvent>
37 #include <QShowEvent>
38 #include <dcopref.h>
39 #include "global.h"
40 #include "basketdcopiface.h"
42 /// NEW:
44 class Q3WidgetStack;
45 class QDomDocument;
46 class QDomElement;
47 class KToggleAction;
48 class KPassivePopup;
49 class Q3PopupMenu;
50 class KPopupMenu;
51 class KTar;
53 class DesktopColorPicker;
54 class RegionGrabber;
56 class Basket;
57 class DecoratedBasket;
58 class BasketListViewItem;
59 class NoteSelection;
60 class BasketStatusBar;
61 class Tag;
62 class State;
63 class Note;
65 class BNPView : public QSplitter, virtual public BasketDcopInterface
67 Q_OBJECT
68 public:
69 /// CONSTRUCTOR AND DESTRUCTOR:
70 BNPView(QWidget *parent, const char *name, KXMLGUIClient *aGUIClient,
71 KActionCollection *actionCollection, BasketStatusBar *bar);
72 ~BNPView();
73 /// MANAGE CONFIGURATION EVENTS!:
74 void setTreePlacement(bool onLeft);
75 void relayoutAllBaskets();
76 void recomputeAllStyles();
77 void removedStates(const Q3ValueList<State*> &deletedStates);
78 void linkLookChanged();
79 void filterPlacementChanged(bool onTop);
80 /// MANAGE BASKETS:
81 BasketListViewItem* listViewItemForBasket(Basket *basket);
82 Basket* currentBasket();
83 Basket* parentBasketOf(Basket *basket);
84 void setCurrentBasket(Basket *basket);
85 void removeBasket(Basket *basket);
86 /// For NewBasketDialog (and later some other classes):
87 Q3ListViewItem* firstListViewItem();
88 ///
89 BasketListViewItem* lastListViewItem();
90 int basketCount(Q3ListViewItem *parent = 0);
91 bool canFold();
92 bool canExpand();
93 void enableActions();
95 private:
96 QDomElement basketElement(Q3ListViewItem *item, QDomDocument &document, QDomElement &parentElement);
97 public slots:
98 void countsChanged(Basket *basket);
99 void notesStateChanged();
100 bool convertTexts();
102 void updateBasketListViewItem(Basket *basket);
103 void save();
104 void save(Q3ListViewItem *firstItem, QDomDocument &document, QDomElement &parentElement);
105 void saveSubHierarchy(Q3ListViewItem *item, QDomDocument &document, QDomElement &parentElement, bool recursive);
106 void load();
107 void load(KListView *listView, Q3ListViewItem *item, const QDomElement &baskets);
108 void loadNewBasket(const QString &folderName, const QDomElement &properties, Basket *parent);
109 void goToPreviousBasket();
110 void goToNextBasket();
111 void foldBasket();
112 void expandBasket();
113 void closeAllEditors();
115 void toggleFilterAllBaskets(bool doFilter);
116 void newFilter();
117 void newFilterFromFilterBar();
118 bool isFilteringAllBaskets();
119 // From main window
120 void importKNotes();
121 void importKJots();
122 void importKnowIt();
123 void importTuxCards();
124 void importStickyNotes();
125 void importTomboy();
126 void importTextFile();
127 void backupRestore();
129 /** Note */
130 void activatedTagShortcut();
131 void exportToHTML();
132 void editNote();
133 void cutNote();
134 void copyNote();
135 void delNote();
136 void openNote();
137 void openNoteWith();
138 void saveNoteAs();
139 void noteGroup();
140 void noteUngroup();
141 void moveOnTop();
142 void moveOnBottom();
143 void moveNoteUp();
144 void moveNoteDown();
145 void slotSelectAll();
146 void slotUnselectAll();
147 void slotInvertSelection();
148 void slotResetFilter();
150 void slotColorFromScreen(bool global = false);
151 void slotColorFromScreenGlobal();
152 void colorPicked(const QColor &color);
153 void colorPickingCanceled();
154 void slotConvertTexts();
156 /** Global shortcuts */
157 void addNoteText();
158 void addNoteHtml();
159 void addNoteImage();
160 void addNoteLink();
161 void addNoteColor();
162 /** Passive Popups for Global Actions */
163 void showPassiveDropped(const QString &title);
164 void showPassiveDroppedDelayed(); // Do showPassiveDropped(), but delayed
165 void showPassiveContent(bool forceShow = false);
166 void showPassiveContentForced();
167 void showPassiveImpossible(const QString &message);
168 void showPassiveLoading(Basket *basket);
169 // For GUI :
170 void setFiltering(bool filtering);
171 /** Edit */
172 void undo();
173 void redo();
174 void globalPasteInCurrentBasket();
175 void pasteInCurrentBasket();
176 void pasteSelInCurrentBasket();
177 void pasteToBasket(int index, QClipboard::Mode mode = QClipboard::Clipboard);
178 void showHideFilterBar(bool show, bool switchFocus = true);
179 /** Insert **/
180 void insertEmpty(int type);
181 void insertWizard(int type);
182 void grabScreenshot(bool global = false);
183 void grabScreenshotGlobal();
184 void screenshotGrabbed(const QPixmap &pixmap);
185 /** Basket */
186 void askNewBasket();
187 void askNewBasket(Basket *parent, Basket *pickProperties);
188 void askNewSubBasket();
189 void askNewSiblingBasket();
190 void aboutToHideNewBasketPopup();
191 void setNewBasketPopup();
192 void cancelNewBasketPopup();
193 void propBasket();
194 void delBasket();
195 void doBasketDeletion(Basket *basket);
196 void password();
197 void saveAsArchive();
198 void openArchive();
199 void delayedOpenArchive();
200 void lockBasket();
201 void hideOnEscape();
203 void changedSelectedNotes();
204 void timeoutTryHide();
205 void timeoutHide();
207 public:
208 static QString s_fileToOpen;
210 public slots:
211 void addWelcomeBaskets();
212 private slots:
213 void updateNotesActions();
214 void slotBasketNumberChanged(int number);
215 void slotBasketChanged();
216 void currentBasketChanged();
217 void isLockedChanged();
218 void lateInit();
219 void onFirstShow();
220 void showGlobalShortcutsSettingsDialog();
222 public:
223 KAction *m_actEditNote;
224 KAction *m_actOpenNote;
225 KAction *m_actPaste;
226 KAction *m_actGrabScreenshot;
227 KAction *m_actColorPicker;
228 KAction *m_actLockBasket;
229 KAction *m_actPassBasket;
230 KAction *actNewBasket;
231 KAction *actNewSubBasket;
232 KAction *actNewSiblingBasket;
233 KAction *m_actHideWindow;
234 KAction *m_actExportToHtml;
235 KAction *m_actPropBasket;
236 KAction *m_actDelBasket;
237 KToggleAction *m_actFilterAllBaskets;
239 private:
240 // Basket actions:
241 KAction *m_actSaveAsArchive;
242 KAction *m_actOpenArchive;
243 // Notes actions :
244 KAction *m_actOpenNoteWith;
245 KAction *m_actSaveNoteAs;
246 KAction *m_actGroup;
247 KAction *m_actUngroup;
248 KAction *m_actMoveOnTop;
249 KAction *m_actMoveNoteUp;
250 KAction *m_actMoveNoteDown;
251 KAction *m_actMoveOnBottom;
252 // Edit actions :
253 KAction *m_actUndo;
254 KAction *m_actRedo;
255 KAction *m_actCutNote;
256 KAction *m_actCopyNote;
257 KAction *m_actDelNote;
258 KAction *m_actSelectAll;
259 KAction *m_actUnselectAll;
260 KAction *m_actInvertSelection;
261 // Insert actions :
262 // KAction *m_actInsertText;
263 KAction *m_actInsertHtml;
264 KAction *m_actInsertLink;
265 KAction *m_actInsertImage;
266 KAction *m_actInsertColor;
267 KAction *m_actImportKMenu;
268 KAction *m_actInsertLauncher;
269 KAction *m_actImportIcon;
270 KAction *m_actLoadFile;
271 Q3PtrList<KAction> m_insertActions;
272 // Basket actions :
273 KToggleAction *m_actShowFilter;
274 KAction *m_actResetFilter;
275 // Go actions :
276 KAction *m_actPreviousBasket;
277 KAction *m_actNextBasket;
278 KAction *m_actFoldBasket;
279 KAction *m_actExpandBasket;
280 // KAction *m_convertTexts; // FOR_BETA_PURPOSE
281 KAction *actConfigGlobalShortcuts;
283 void setupActions();
284 void setupGlobalShortcuts();
285 DecoratedBasket* currentDecoratedBasket();
287 public:
288 Basket* loadBasket(const QString &folderName); // Public only for class Archive
289 BasketListViewItem* appendBasket(Basket *basket, Q3ListViewItem *parentItem); // Public only for class Archive
291 Basket* basketForFolderName(const QString &folderName);
292 Note* noteForFileName(const QString &fileName, Basket &basket, Note* note = 0);
293 Q3PopupMenu* popupMenu(const QString &menuName);
294 bool isPart();
295 bool isMainWindowActive();
296 void showMainWindow();
298 // dcop calls
299 virtual void newBasket();
300 virtual void handleCommandLine();
301 virtual void reloadBasket(const QString &folderName);
302 virtual bool createNoteHtml(const QString content, const QString basket);
303 virtual QStringList listBaskets();
304 virtual bool createNoteFromFile(const QString url, const QString basket);
305 virtual bool changeNoteHtml(const QString content, const QString basket, const QString noteName);
307 public slots:
308 void setCaption(QString s);
309 void updateStatusBarHint();
310 void setSelectionStatus(QString s);
311 void setLockStatus(bool isLocked);
312 void postStatusbarMessage(const QString&);
313 void setStatusBarHint(const QString&);
314 void setUnsavedStatus(bool isUnsaved);
315 void setActive(bool active = true);
316 KActionCollection *actionCollection() { return m_actionCollection; };
318 void populateTagsMenu();
319 void populateTagsMenu(KPopupMenu &menu, Note *referenceNote);
320 void connectTagsMenu();
321 void disconnectTagsMenu();
322 void disconnectTagsMenuDelayed();
323 protected:
324 void showEvent(QShowEvent*);
325 void hideEvent(QHideEvent*);
326 private:
327 KPopupMenu *m_lastOpenedTagsMenu;
329 private slots:
330 void slotPressed(Q3ListViewItem *item, const QPoint &/*pos*/ = QPoint(), int /*column*/ = 0);
331 void needSave(Q3ListViewItem*);
332 void slotContextMenu(KListView *listView, Q3ListViewItem *item, const QPoint &pos);
333 void slotMouseButtonPressed(int button, Q3ListViewItem *item, const QPoint &pos, int column);
334 void slotShowProperties(Q3ListViewItem *item, const QPoint&, int);
335 void initialize();
337 signals:
338 void basketNumberChanged(int number);
339 void basketChanged();
340 void setWindowCaption(const QString &s);
341 void showPart();
343 protected:
344 void enterEvent(QEvent*);
345 void leaveEvent(QEvent*);
347 private:
348 KListView *m_tree;
349 Q3WidgetStack *m_stack;
350 bool m_loading;
351 bool m_newBasketPopup;
352 bool m_firstShow;
353 DesktopColorPicker *m_colorPicker;
354 bool m_colorPickWasShown;
355 bool m_colorPickWasGlobal;
356 RegionGrabber *m_regionGrabber;
357 QString m_passiveDroppedTitle;
358 NoteSelection *m_passiveDroppedSelection;
359 KPassivePopup *m_passivePopup;
360 static const int c_delayTooltipTime;
361 KActionCollection *m_actionCollection;
362 KXMLGUIClient *m_guiClient;
363 BasketStatusBar *m_statusbar;
364 QTimer *m_tryHideTimer;
365 QTimer *m_hideTimer;
368 #endif // BNPVIEW_H