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 <qstring.h>
00025 #include <qdict.h>
00026 #include <qptrlist.h>
00027 #include <qlabel.h>
00028 #include <qdom.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 QLabel, public KSessionManaged, virtual public KXMLGUIClient,
00056     virtual public KNotesAppIface
00057 {
00058     Q_OBJECT
00059 public:
00060     KNotesApp();
00061     ~KNotesApp();
00062 
00063     void showNote( const QString& id ) const;
00064     void hideNote( const QString& id ) const;
00065 
00066     void killNote( const QString& id );
00067     void killNote( const QString& id, bool force );
00068 
00069     QString name( const QString& id ) const;
00070     QString text( const QString& id ) const;
00071 
00072     void setName( const QString& id, const QString& newName );
00073     void setText( const QString& id, const QString& newText );
00074 
00075     QMap<QString,QString> notes() const;
00076 
00077     void sync( const QString& app );
00078     bool isNew( const QString& app, const QString& id ) const;
00079     bool isModified( const QString& app, const QString& id ) const;
00080 
00081     bool commitData( QSessionManager& );
00082 
00083 public slots:
00084     QString newNote( const QString& name = QString::null,
00085                      const QString& text = QString::null );
00086     QString newNoteFromClipboard( const QString& name = QString::null );
00087 
00088     void hideAllNotes() const;
00089     void showAllNotes() const;
00090 
00091 protected:
00092     void mousePressEvent( QMouseEvent* );
00093 
00094 protected slots:
00095     void slotShowNote();
00096     void slotWalkThroughNotes();
00097 
00098     void slotOpenFindDialog();
00099     void slotFindNext();
00100 
00101     void slotPreferences();
00102     void slotConfigureAccels();
00103 
00104     void slotNoteKilled( KCal::Journal *journal );
00105 
00106     void slotQuit();
00107 
00108 private:
00109     void showNote( KNote *note ) const;
00110     void saveConfigs();
00111 
00112 private slots:
00113     void acceptConnection();
00114     void saveNotes();
00115     void updateNoteActions();
00116     void updateGlobalAccels();
00117     void updateNetworkListener();
00118     void updateStyle();
00119 
00120     void createNote( KCal::Journal *journal );
00121     void killNote( KCal::Journal *journal );
00122 
00123 private:
00124     class KNoteActionList : public QPtrList<KAction>
00125     {
00126     public:
00127         virtual int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 );
00128     };
00129 
00130     KNotesResourceManager *m_manager;
00131 
00132     KNotesAlarm     *m_alarm;
00133     KNetwork::KServerSocket   *m_listener;
00134 
00135     QDict<KNote>    m_noteList;
00136     KNoteActionList m_noteActions;
00137 
00138     KFind           *m_find;
00139     QDictIterator<KNote> *m_findPos;
00140 
00141     KPopupMenu      *m_note_menu;
00142     KPopupMenu      *m_context_menu;
00143 
00144     KGlobalAccel    *m_globalAccel;
00145     KXMLGUIFactory  *m_guiFactory;
00146     KXMLGUIBuilder  *m_guiBuilder;
00147 
00148     QDomDocument    m_noteGUI;
00149 };
00150 
00151 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys