knotes

knotesapp.h
1/*******************************************************************
2 KNotes -- Notes for the KDE project
3
4 Copyright (c) 1997-2006, The KNotes Developers
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*******************************************************************/
20
21#ifndef KNOTESAPP_H
22#define KNOTESAPP_H
23
24#include <tqstring.h>
25#include <tqdict.h>
26#include <tqptrlist.h>
27#include <tqlabel.h>
28#include <tqdom.h>
29
30#include <tdeapplication.h>
31#include <kxmlguiclient.h>
32
33#include "KNotesAppIface.h"
34
35class KFind;
36class KNote;
37class TDEPopupMenu;
38class TDEAction;
39class TDEActionMenu;
40class TDEGlobalAccel;
41class KXMLGUIFactory;
42class KXMLGUIBuilder;
43class KNotesAlarm;
44class KNotesResourceManager;
45
46namespace KCal {
47 class Journal;
48}
49
50namespace KNetwork {
51 class TDEServerSocket;
52}
53
54
55class KNotesApp : public TQLabel, public KSessionManaged, virtual public KXMLGUIClient,
56 virtual public KNotesAppIface
57{
58 TQ_OBJECT
59
60public:
61 KNotesApp();
62 ~KNotesApp();
63
64 void showNote( const TQString& id ) const;
65 void hideNote( const TQString& id ) const;
66
67 void killNote( const TQString& id );
68 void killNote( const TQString& id, bool force );
69
70 TQString name( const TQString& id ) const;
71 TQString text( const TQString& id ) const;
72
73 void setName( const TQString& id, const TQString& newName );
74 void setText( const TQString& id, const TQString& newText );
75
76 TQString fgColor( const TQString& id ) const;
77 TQString bgColor( const TQString& id ) const;
78
79 void setColor( const TQString& id, const TQString& fgColor,
80 const TQString& bgColor );
81
82 TQMap<TQString,TQString> notes() const;
83
84 int width( const TQString& noteId ) const;
85 int height( const TQString& noteId ) const;
86
87 void move( const TQString& noteId, int x, int y ) const;
88 void resize( const TQString& noteId, int width, int height ) const;
89
90 void sync( const TQString& app );
91 bool isNew( const TQString& app, const TQString& id ) const;
92 bool isModified( const TQString& app, const TQString& id ) const;
93 TQDateTime getLastModified( const TQString& noteId ) const;
94
95 bool commitData( TQSessionManager& );
96
97public slots:
98 TQString newNote( const TQString& name = TQString(),
99 const TQString& text = TQString() );
100 TQString newNoteFromClipboard( const TQString& name = TQString() );
101
102 void hideAllNotes() const;
103 void showAllNotes() const;
104
105protected:
106 void mousePressEvent( TQMouseEvent* );
107 void resizeEvent ( TQResizeEvent * );
108 void showEvent ( TQShowEvent * );
109
110protected slots:
111 void slotShowNote();
112 void slotWalkThroughNotes();
113
114 void slotOpenFindDialog();
115 void slotFindNext();
116
117 void slotPreferences();
118 void slotConfigureAccels();
119
120 void slotNoteKilled( KCal::Journal *journal );
121
122 void slotQuit();
123
124private:
125 void showNote( KNote *note ) const;
126 void saveConfigs();
127 void resizeTrayIcon();
128
129private slots:
130 void acceptConnection();
131 void saveNotes();
132 void saveNotes( const TQString & uid );
133 void updateNoteActions();
134 void updateGlobalAccels();
135 void updateNetworkListener();
136 void updateStyle();
137
138 void createNote( KCal::Journal *journal );
139 void killNote( KCal::Journal *journal );
140
141private:
142 class KNoteActionList : public TQPtrList<TDEAction>
143 {
144 public:
145 virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
146 };
147
148 KNotesResourceManager *m_manager;
149
150 KNotesAlarm *m_alarm;
151 KNetwork::TDEServerSocket *m_listener;
152
153 TQDict<KNote> m_noteList;
154 KNoteActionList m_noteActions;
155
156 KFind *m_find;
157 TQDictIterator<KNote> *m_findPos;
158
159 TDEPopupMenu *m_note_menu;
160 TDEPopupMenu *m_context_menu;
161
162 TDEGlobalAccel *m_globalAccel;
163 KXMLGUIFactory *m_guiFactory;
164 KXMLGUIBuilder *m_guiBuilder;
165
166 TQDomDocument m_noteGUI;
167 TDEAction *m_findAction;
168 TQString m_noteUidModify;
169};
170
171#endif