+ed
[kdepim.git] / knotes / knote.h
blob7fabf477d29e2f33723be095aae47ee1ec494abf
1 /*******************************************************************
2 KNotes -- Notes for the KDE project
4 Copyright (c) 1997-2006, The KNotes Developers
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *******************************************************************/
21 #ifndef KNOTE_H
22 #define KNOTE_H
24 #include <QColor>
25 #include <QDomDocument>
26 #include <QEvent>
27 #include <QFrame>
28 #include <QString>
30 #include <kconfig.h>
31 #include <kxmlguiclient.h>
32 #include <KSharedConfig>
34 class QLabel;
35 class QLayout;
36 class QSizeGrip;
38 class KFind;
39 class KMenu;
40 class KNoteButton;
41 class KNoteConfig;
42 class KNoteEdit;
43 class KSelectAction;
44 class KToggleAction;
45 class KToolBar;
47 namespace KCal {
48 class Journal;
52 class KNote
53 : public QFrame, virtual public KXMLGUIClient
55 Q_OBJECT
56 public:
57 KNote( const QDomDocument& buildDoc, KCal::Journal *journal, QWidget *parent = 0 );
58 ~KNote();
60 void changeJournal(KCal::Journal *);
61 void saveData( bool update = true);
62 void saveConfig() const;
64 QString noteId() const;
65 QString name() const;
66 QString text() const;
68 void setName( const QString &name );
69 void setText( const QString &text );
71 void find( KFind* kfind );
73 bool isModified() const;
74 void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;}
75 void commitData();
77 public slots:
78 void slotRename();
79 void slotKill( bool force = false );
80 void slotClose();
81 signals:
82 void sigRequestNewNote();
83 void sigShowNextNote();
84 void sigNameChanged(const QString &);
85 void sigDataChanged(const QString &);
86 void sigColorChanged();
87 void sigKillNote( KCal::Journal * );
89 void sigFindFinished();
91 protected:
92 virtual void contextMenuEvent( QContextMenuEvent * );
93 virtual void showEvent( QShowEvent * );
94 virtual void resizeEvent( QResizeEvent * );
95 virtual void closeEvent( QCloseEvent * );
96 virtual void dropEvent( QDropEvent * );
97 virtual void dragEnterEvent( QDragEnterEvent * );
99 virtual bool event( QEvent * );
100 virtual bool eventFilter( QObject *, QEvent * );
102 private slots:
103 void slotUpdateReadOnly();
105 void slotSend();
106 void slotMail();
107 void slotPrint();
108 void slotSaveAs();
110 void slotInsDate();
111 void slotSetAlarm();
113 void slotPreferences();
114 void slotPopupActionToDesktop( int id );
116 void slotFindNext();
117 void slotHighlight( const QString &txt, int idx, int len );
119 void slotApplyConfig();
120 void slotUpdateKeepAboveBelow();
121 void slotUpdateShowInTaskbar();
122 void slotUpdateDesktopActions();
124 void slotKeepAbove();
125 void slotKeepBelow();
127 void slotRequestNewNote();
128 private:
129 void buildGui();
130 void createActions();
131 void createNoteEditor();
132 void createNoteFooter();
133 void createNoteHeader();
134 void prepare();
136 void updateFocus();
137 void updateLayout();
138 void updateLabelAlignment();
140 void setColor( const QColor &, const QColor & );
142 void toDesktop( int desktop );
144 private:
145 QLayout *m_noteLayout;
146 QLabel *m_label;
147 QSizeGrip *m_grip;
148 KNoteButton *m_button;
149 KToolBar *m_tool;
150 KNoteEdit *m_editor;
152 KNoteConfig *m_config;
153 KCal::Journal *m_journal;
155 KFind *m_find;
156 KMenu *m_menu;
158 KToggleAction *m_readOnly;
160 #ifdef Q_WS_X11
161 KSelectAction *m_toDesktop;
162 #endif
163 KToggleAction *m_keepAbove;
164 KToggleAction *m_keepBelow;
166 KSharedConfig::Ptr m_kwinConf;
167 bool m_blockEmitDataChanged;
168 bool mBlockWriteConfigDuringCommitData;
171 #endif