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 
35 class KFind;
36 class KNote;
37 class TDEPopupMenu;
38 class TDEAction;
39 class TDEActionMenu;
40 class TDEGlobalAccel;
41 class KXMLGUIFactory;
42 class KXMLGUIBuilder;
43 class KNotesAlarm;
44 class KNotesResourceManager;
45 
46 namespace KCal {
47  class Journal;
48 }
49 
50 namespace KNetwork {
51  class TDEServerSocket;
52 }
53 
54 
55 class KNotesApp : public TQLabel, public KSessionManaged, virtual public KXMLGUIClient,
56  virtual public KNotesAppIface
57 {
58  Q_OBJECT
59 
60 public:
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 
94  bool commitData( TQSessionManager& );
95 
96 public slots:
97  TQString newNote( const TQString& name = TQString(),
98  const TQString& text = TQString() );
99  TQString newNoteFromClipboard( const TQString& name = TQString() );
100 
101  void hideAllNotes() const;
102  void showAllNotes() const;
103 
104 protected:
105  void mousePressEvent( TQMouseEvent* );
106  void resizeEvent ( TQResizeEvent * );
107  void showEvent ( TQShowEvent * );
108 
109 protected slots:
110  void slotShowNote();
111  void slotWalkThroughNotes();
112 
113  void slotOpenFindDialog();
114  void slotFindNext();
115 
116  void slotPreferences();
117  void slotConfigureAccels();
118 
119  void slotNoteKilled( KCal::Journal *journal );
120 
121  void slotQuit();
122 
123 private:
124  void showNote( KNote *note ) const;
125  void saveConfigs();
126  void resizeTrayIcon();
127 
128 private slots:
129  void acceptConnection();
130  void saveNotes();
131  void saveNotes( const TQString & uid );
132  void updateNoteActions();
133  void updateGlobalAccels();
134  void updateNetworkListener();
135  void updateStyle();
136 
137  void createNote( KCal::Journal *journal );
138  void killNote( KCal::Journal *journal );
139 
140 private:
141  class KNoteActionList : public TQPtrList<TDEAction>
142  {
143  public:
144  virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
145  };
146 
147  KNotesResourceManager *m_manager;
148 
149  KNotesAlarm *m_alarm;
150  KNetwork::TDEServerSocket *m_listener;
151 
152  TQDict<KNote> m_noteList;
153  KNoteActionList m_noteActions;
154 
155  KFind *m_find;
156  TQDictIterator<KNote> *m_findPos;
157 
158  TDEPopupMenu *m_note_menu;
159  TDEPopupMenu *m_context_menu;
160 
161  TDEGlobalAccel *m_globalAccel;
162  KXMLGUIFactory *m_guiFactory;
163  KXMLGUIBuilder *m_guiBuilder;
164 
165  TQDomDocument m_noteGUI;
166  TDEAction *m_findAction;
167  TQString m_noteUidModify;
168 };
169 
170 #endif