1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
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. *
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. *
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 ***************************************************************************/
24 #include <klistview.h>
25 #include <kxmlguiclient.h>
27 #include <qclipboard.h>
28 #include <qsplitter.h>
29 #include <q3listview.h>
31 #include <Q3ValueList>
35 #include <Q3PopupMenu>
40 #include "basketdcopiface.h"
53 class DesktopColorPicker
;
57 class DecoratedBasket
;
58 class BasketListViewItem
;
60 class BasketStatusBar
;
65 class BNPView
: public QSplitter
, virtual public BasketDcopInterface
69 /// CONSTRUCTOR AND DESTRUCTOR:
70 BNPView(QWidget
*parent
, const char *name
, KXMLGUIClient
*aGUIClient
,
71 KActionCollection
*actionCollection
, BasketStatusBar
*bar
);
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
);
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();
89 BasketListViewItem
* lastListViewItem();
90 int basketCount(Q3ListViewItem
*parent
= 0);
96 QDomElement
basketElement(Q3ListViewItem
*item
, QDomDocument
&document
, QDomElement
&parentElement
);
98 void countsChanged(Basket
*basket
);
99 void notesStateChanged();
102 void updateBasketListViewItem(Basket
*basket
);
104 void save(Q3ListViewItem
*firstItem
, QDomDocument
&document
, QDomElement
&parentElement
);
105 void saveSubHierarchy(Q3ListViewItem
*item
, QDomDocument
&document
, QDomElement
&parentElement
, bool recursive
);
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();
113 void closeAllEditors();
115 void toggleFilterAllBaskets(bool doFilter
);
117 void newFilterFromFilterBar();
118 bool isFilteringAllBaskets();
123 void importTuxCards();
124 void importStickyNotes();
126 void importTextFile();
127 void backupRestore();
130 void activatedTagShortcut();
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 */
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
);
170 void setFiltering(bool filtering
);
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);
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
);
187 void askNewBasket(Basket
*parent
, Basket
*pickProperties
);
188 void askNewSubBasket();
189 void askNewSiblingBasket();
190 void aboutToHideNewBasketPopup();
191 void setNewBasketPopup();
192 void cancelNewBasketPopup();
195 void doBasketDeletion(Basket
*basket
);
197 void saveAsArchive();
199 void delayedOpenArchive();
203 void changedSelectedNotes();
204 void timeoutTryHide();
208 static QString s_fileToOpen
;
211 void addWelcomeBaskets();
213 void updateNotesActions();
214 void slotBasketNumberChanged(int number
);
215 void slotBasketChanged();
216 void currentBasketChanged();
217 void isLockedChanged();
220 void showGlobalShortcutsSettingsDialog();
223 KAction
*m_actEditNote
;
224 KAction
*m_actOpenNote
;
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
;
241 KAction
*m_actSaveAsArchive
;
242 KAction
*m_actOpenArchive
;
244 KAction
*m_actOpenNoteWith
;
245 KAction
*m_actSaveNoteAs
;
247 KAction
*m_actUngroup
;
248 KAction
*m_actMoveOnTop
;
249 KAction
*m_actMoveNoteUp
;
250 KAction
*m_actMoveNoteDown
;
251 KAction
*m_actMoveOnBottom
;
255 KAction
*m_actCutNote
;
256 KAction
*m_actCopyNote
;
257 KAction
*m_actDelNote
;
258 KAction
*m_actSelectAll
;
259 KAction
*m_actUnselectAll
;
260 KAction
*m_actInvertSelection
;
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
;
273 KToggleAction
*m_actShowFilter
;
274 KAction
*m_actResetFilter
;
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
;
284 void setupGlobalShortcuts();
285 DecoratedBasket
* currentDecoratedBasket();
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
);
295 bool isMainWindowActive();
296 void showMainWindow();
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
);
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();
324 void showEvent(QShowEvent
*);
325 void hideEvent(QHideEvent
*);
327 KPopupMenu
*m_lastOpenedTagsMenu
;
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);
338 void basketNumberChanged(int number
);
339 void basketChanged();
340 void setWindowCaption(const QString
&s
);
344 void enterEvent(QEvent
*);
345 void leaveEvent(QEvent
*);
349 Q3WidgetStack
*m_stack
;
351 bool m_newBasketPopup
;
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
;