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 <kapplication.h>
31 #include <kxmlguiclient.h>
32 
33 #include "KNotesAppIface.h"
34 
35 class KFind;
36 class KNote;
37 class KPopupMenu;
38 class KAction;
39 class KActionMenu;
40 class KGlobalAccel;
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 KServerSocket;
52 }
53 
54 
55 class KNotesApp : public TQLabel, public KSessionManaged, virtual public KXMLGUIClient,
56  virtual public KNotesAppIface
57 {
58  Q_OBJECT
59  TQ_OBJECT
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 
108 protected slots:
109  void slotShowNote();
110  void slotWalkThroughNotes();
111 
112  void slotOpenFindDialog();
113  void slotFindNext();
114 
115  void slotPreferences();
116  void slotConfigureAccels();
117 
118  void slotNoteKilled( KCal::Journal *journal );
119 
120  void slotQuit();
121 
122 private:
123  void showNote( KNote *note ) const;
124  void saveConfigs();
125 
126 private slots:
127  void acceptConnection();
128  void saveNotes();
129  void saveNotes( const TQString & uid );
130  void updateNoteActions();
131  void updateGlobalAccels();
132  void updateNetworkListener();
133  void updateStyle();
134 
135  void createNote( KCal::Journal *journal );
136  void killNote( KCal::Journal *journal );
137 
138 private:
139  class KNoteActionList : public TQPtrList<KAction>
140  {
141  public:
142  virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
143  };
144 
145  KNotesResourceManager *m_manager;
146 
147  KNotesAlarm *m_alarm;
148  KNetwork::KServerSocket *m_listener;
149 
150  TQDict<KNote> m_noteList;
151  KNoteActionList m_noteActions;
152 
153  KFind *m_find;
154  TQDictIterator<KNote> *m_findPos;
155 
156  KPopupMenu *m_note_menu;
157  KPopupMenu *m_context_menu;
158 
159  KGlobalAccel *m_globalAccel;
160  KXMLGUIFactory *m_guiFactory;
161  KXMLGUIBuilder *m_guiBuilder;
162 
163  TQDomDocument m_noteGUI;
164  KAction *m_findAction;
165  TQString m_noteUidModify;
166 };
167 
168 #endif