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 <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     TQDateTime getLastModified( const TQString& noteId ) const;
00094 
00095     bool commitData( TQSessionManager& );
00096 
00097 public slots:
00098     TQString newNote( const TQString& name = TQString(),
00099                      const TQString& text = TQString() );
00100     TQString newNoteFromClipboard( const TQString& name = TQString() );
00101 
00102     void hideAllNotes() const;
00103     void showAllNotes() const;
00104 
00105 protected:
00106     void mousePressEvent( TQMouseEvent* );
00107     void resizeEvent ( TQResizeEvent * );
00108     void showEvent ( TQShowEvent * );
00109 
00110 protected slots:
00111     void slotShowNote();
00112     void slotWalkThroughNotes();
00113 
00114     void slotOpenFindDialog();
00115     void slotFindNext();
00116 
00117     void slotPreferences();
00118     void slotConfigureAccels();
00119 
00120     void slotNoteKilled( KCal::Journal *journal );
00121 
00122     void slotQuit();
00123 
00124 private:
00125     void showNote( KNote *note ) const;
00126     void saveConfigs();
00127     void resizeTrayIcon();
00128 
00129 private slots:
00130     void acceptConnection();
00131     void saveNotes();
00132     void saveNotes( const TQString & uid );
00133     void updateNoteActions();
00134     void updateGlobalAccels();
00135     void updateNetworkListener();
00136     void updateStyle();
00137 
00138     void createNote( KCal::Journal *journal );
00139     void killNote( KCal::Journal *journal );
00140 
00141 private:
00142     class KNoteActionList : public TQPtrList<TDEAction>
00143     {
00144     public:
00145         virtual int compareItems( TQPtrCollection::Item s1, TQPtrCollection::Item s2 );
00146     };
00147 
00148     KNotesResourceManager *m_manager;
00149 
00150     KNotesAlarm     *m_alarm;
00151     KNetwork::TDEServerSocket   *m_listener;
00152 
00153     TQDict<KNote>    m_noteList;
00154     KNoteActionList m_noteActions;
00155 
00156     KFind           *m_find;
00157     TQDictIterator<KNote> *m_findPos;
00158 
00159     TDEPopupMenu      *m_note_menu;
00160     TDEPopupMenu      *m_context_menu;
00161 
00162     TDEGlobalAccel    *m_globalAccel;
00163     KXMLGUIFactory  *m_guiFactory;
00164     KXMLGUIBuilder  *m_guiBuilder;
00165 
00166     TQDomDocument    m_noteGUI;
00167     TDEAction         *m_findAction;
00168     TQString m_noteUidModify;
00169 };
00170 
00171 #endif