knotes

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 <kapplication.h>
00031 #include <kxmlguiclient.h>
00032 
00033 #include "KNotesAppIface.h"
00034 
00035 class KFind;
00036 class KNote;
00037 class KPopupMenu;
00038 class KAction;
00039 class KActionMenu;
00040 class KGlobalAccel;
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 KServerSocket;
00052 }
00053 
00054 
00055 class KNotesApp : public TQLabel, public KSessionManaged, virtual public KXMLGUIClient,
00056     virtual public KNotesAppIface
00057 {
00058     Q_OBJECT
00059 public:
00060     KNotesApp();
00061     ~KNotesApp();
00062 
00063     void showNote( const TQString& id ) const;
00064     void hideNote( const TQString& id ) const;
00065 
00066     void killNote( const TQString& id );
00067     void killNote( const TQString& id, bool force );
00068 
00069     TQString name( const TQString& id ) const;
00070     TQString text( const TQString& id ) const;
00071 
00072     void setName( const TQString& id, const TQString& newName );
00073     void setText( const TQString& id, const TQString& newText );
00074 
00075     TQString fgColor( const TQString& id ) const;
00076     TQString bgColor( const TQString& id ) const;
00077 
00078     void setColor( const TQString& id, const TQString& fgColor,
00079                                       const TQString& bgColor );
00080 
00081     TQMap<TQString,TQString> notes() const;
00082 
00083     int width( const TQString& noteId ) const;
00084     int height( const TQString& noteId ) const;
00085 
00086     void move( const TQString& noteId, int x, int y ) const;
00087     void resize( const TQString& noteId, int width, int height ) const;
00088 
00089     void sync( const TQString& app );
00090     bool isNew( const TQString& app, const TQString& id ) const;
00091     bool isModified( const TQString& app, const TQString& id ) const;
00092 
00093     bool commitData( QSessionManager& );
00094 
00095 public slots:
00096     TQString newNote( const TQString& name = TQString::null,
00097                      const TQString& text = TQString::null );
00098     TQString newNoteFromClipboard( const TQString& name = TQString::null );
00099 
00100     void hideAllNotes() const;
00101     void showAllNotes() const;
00102 
00103 protected:
00104     void mousePressEvent( TQMouseEvent* );
00105     void resizeEvent ( TQResizeEvent * );
00106 
00107 protected slots:
00108     void slotShowNote();
00109     void slotWalkThroughNotes();
00110 
00111     void slotOpenFindDialog();
00112     void slotFindNext();
00113 
00114     void slotPreferences();
00115     void slotConfigureAccels();
00116 
00117     void slotNoteKilled( KCal::Journal *journal );
00118 
00119     void slotQuit();
00120 
00121 private:
00122     void showNote( KNote *note ) const;
00123     void saveConfigs();
00124 
00125 private slots:
00126     void acceptConnection();
00127     void saveNotes();
00128     void saveNotes( const TQString & uid );
00129     void updateNoteActions();
00130     void updateGlobalAccels();
00131     void updateNetworkListener();
00132     void updateStyle();
00133 
00134     void createNote( KCal::Journal *journal );
00135     void killNote( KCal::Journal *journal );
00136 
00137 private:
00138     class KNoteActionList : public TQPtrList<KAction>
00139     {
00140     public:
00141         virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
00142     };
00143 
00144     KNotesResourceManager *m_manager;
00145 
00146     KNotesAlarm     *m_alarm;
00147     KNetwork::KServerSocket   *m_listener;
00148 
00149     TQDict<KNote>    m_noteList;
00150     KNoteActionList m_noteActions;
00151 
00152     KFind           *m_find;
00153     TQDictIterator<KNote> *m_findPos;
00154 
00155     KPopupMenu      *m_note_menu;
00156     KPopupMenu      *m_context_menu;
00157 
00158     KGlobalAccel    *m_globalAccel;
00159     KXMLGUIFactory  *m_guiFactory;
00160     KXMLGUIBuilder  *m_guiBuilder;
00161 
00162     TQDomDocument    m_noteGUI;
00163     KAction         *m_findAction;
00164     TQString m_noteUidModify;
00165 };
00166 
00167 #endif