knotesapp.h
00001 /******************************************************************* 00002 KNotes -- Notes for the KDE project 00003 00004 Copyright (c) 1997-2006, The KNotes Developers 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 *******************************************************************/ 00020 00021 #ifndef KNOTESAPP_H 00022 #define KNOTESAPP_H 00023 00024 #include <tqstring.h> 00025 #include <tqdict.h> 00026 #include <tqptrlist.h> 00027 #include <tqlabel.h> 00028 #include <tqdom.h> 00029 00030 #include <tdeapplication.h> 00031 #include <kxmlguiclient.h> 00032 00033 #include "KNotesAppIface.h" 00034 00035 class KFind; 00036 class KNote; 00037 class TDEPopupMenu; 00038 class TDEAction; 00039 class TDEActionMenu; 00040 class TDEGlobalAccel; 00041 class KXMLGUIFactory; 00042 class KXMLGUIBuilder; 00043 class KNotesAlarm; 00044 class KNotesResourceManager; 00045 00046 namespace KCal { 00047 class Journal; 00048 } 00049 00050 namespace KNetwork { 00051 class TDEServerSocket; 00052 } 00053 00054 00055 class KNotesApp : public TQLabel, public KSessionManaged, virtual public KXMLGUIClient, 00056 virtual public KNotesAppIface 00057 { 00058 Q_OBJECT 00059 00060 public: 00061 KNotesApp(); 00062 ~KNotesApp(); 00063 00064 void showNote( const TQString& id ) const; 00065 void hideNote( const TQString& id ) const; 00066 00067 void killNote( const TQString& id ); 00068 void killNote( const TQString& id, bool force ); 00069 00070 TQString name( const TQString& id ) const; 00071 TQString text( const TQString& id ) const; 00072 00073 void setName( const TQString& id, const TQString& newName ); 00074 void setText( const TQString& id, const TQString& newText ); 00075 00076 TQString fgColor( const TQString& id ) const; 00077 TQString bgColor( const TQString& id ) const; 00078 00079 void setColor( const TQString& id, const TQString& fgColor, 00080 const TQString& bgColor ); 00081 00082 TQMap<TQString,TQString> notes() const; 00083 00084 int width( const TQString& noteId ) const; 00085 int height( const TQString& noteId ) const; 00086 00087 void move( const TQString& noteId, int x, int y ) const; 00088 void resize( const TQString& noteId, int width, int height ) const; 00089 00090 void sync( const TQString& app ); 00091 bool isNew( const TQString& app, const TQString& id ) const; 00092 bool isModified( const TQString& app, const TQString& id ) const; 00093 00094 bool commitData( TQSessionManager& ); 00095 00096 public slots: 00097 TQString newNote( const TQString& name = TQString(), 00098 const TQString& text = TQString() ); 00099 TQString newNoteFromClipboard( const TQString& name = TQString() ); 00100 00101 void hideAllNotes() const; 00102 void showAllNotes() const; 00103 00104 protected: 00105 void mousePressEvent( TQMouseEvent* ); 00106 void resizeEvent ( TQResizeEvent * ); 00107 void showEvent ( TQShowEvent * ); 00108 00109 protected slots: 00110 void slotShowNote(); 00111 void slotWalkThroughNotes(); 00112 00113 void slotOpenFindDialog(); 00114 void slotFindNext(); 00115 00116 void slotPreferences(); 00117 void slotConfigureAccels(); 00118 00119 void slotNoteKilled( KCal::Journal *journal ); 00120 00121 void slotQuit(); 00122 00123 private: 00124 void showNote( KNote *note ) const; 00125 void saveConfigs(); 00126 void resizeTrayIcon(); 00127 00128 private slots: 00129 void acceptConnection(); 00130 void saveNotes(); 00131 void saveNotes( const TQString & uid ); 00132 void updateNoteActions(); 00133 void updateGlobalAccels(); 00134 void updateNetworkListener(); 00135 void updateStyle(); 00136 00137 void createNote( KCal::Journal *journal ); 00138 void killNote( KCal::Journal *journal ); 00139 00140 private: 00141 class KNoteActionList : public TQPtrList<TDEAction> 00142 { 00143 public: 00144 virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 ); 00145 }; 00146 00147 KNotesResourceManager *m_manager; 00148 00149 KNotesAlarm *m_alarm; 00150 KNetwork::TDEServerSocket *m_listener; 00151 00152 TQDict<KNote> m_noteList; 00153 KNoteActionList m_noteActions; 00154 00155 KFind *m_find; 00156 TQDictIterator<KNote> *m_findPos; 00157 00158 TDEPopupMenu *m_note_menu; 00159 TDEPopupMenu *m_context_menu; 00160 00161 TDEGlobalAccel *m_globalAccel; 00162 KXMLGUIFactory *m_guiFactory; 00163 KXMLGUIBuilder *m_guiBuilder; 00164 00165 TQDomDocument m_noteGUI; 00166 TDEAction *m_findAction; 00167 TQString m_noteUidModify; 00168 }; 00169 00170 #endif