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     QString fgColor( const QString& id ) const;
00076     QString bgColor( const QString& id ) const;
00077 
00078     void setColor( const QString& id, const QString& fgColor,
00079                                       const QString& bgColor );
00080 
00081     QMap<QString,QString> notes() const;
00082 
00083     int width( const QString& noteId ) const;
00084     int height( const QString& noteId ) const;
00085 
00086     void move( const QString& noteId, int x, int y ) const;
00087     void resize( const QString& noteId, int width, int height ) const;
00088 
00089     void sync( const QString& app );
00090     bool isNew( const QString& app, const QString& id ) const;
00091     bool isModified( const QString& app, const QString& id ) const;
00092 
00093     bool commitData( QSessionManager& );
00094 
00095 public slots:
00096     QString newNote( const QString& name = QString::null,
00097                      const QString& text = QString::null );
00098     QString newNoteFromClipboard( const QString& name = QString::null );
00099 
00100     void hideAllNotes() const;
00101     void showAllNotes() const;
00102 
00103 protected:
00104     void mousePressEvent( QMouseEvent* );
00105 
00106 protected slots:
00107     void slotShowNote();
00108     void slotWalkThroughNotes();
00109 
00110     void slotOpenFindDialog();
00111     void slotFindNext();
00112 
00113     void slotPreferences();
00114     void slotConfigureAccels();
00115 
00116     void slotNoteKilled( KCal::Journal *journal );
00117 
00118     void slotQuit();
00119 
00120 private:
00121     void showNote( KNote *note ) const;
00122     void saveConfigs();
00123 
00124 private slots:
00125     void acceptConnection();
00126     void saveNotes();
00127     void saveNotes( const QString & uid );
00128     void updateNoteActions();
00129     void updateGlobalAccels();
00130     void updateNetworkListener();
00131     void updateStyle();
00132 
00133     void createNote( KCal::Journal *journal );
00134     void killNote( KCal::Journal *journal );
00135 
00136 private:
00137     class KNoteActionList : public QPtrList<KAction>
00138     {
00139     public:
00140         virtual int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 );
00141     };
00142 
00143     KNotesResourceManager *m_manager;
00144 
00145     KNotesAlarm     *m_alarm;
00146     KNetwork::KServerSocket   *m_listener;
00147 
00148     QDict<KNote>    m_noteList;
00149     KNoteActionList m_noteActions;
00150 
00151     KFind           *m_find;
00152     QDictIterator<KNote> *m_findPos;
00153 
00154     KPopupMenu      *m_note_menu;
00155     KPopupMenu      *m_context_menu;
00156 
00157     KGlobalAccel    *m_globalAccel;
00158     KXMLGUIFactory  *m_guiFactory;
00159     KXMLGUIBuilder  *m_guiBuilder;
00160 
00161     QDomDocument    m_noteGUI;
00162     KAction         *m_findAction;
00163     QString m_noteUidModify;
00164 };
00165 
00166 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys