knotes

knote.h
1/*******************************************************************
2 KNotes -- Notes for the KDE project
3
4 Copyright (c) 1997-2006, The KNotes Developers
5
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.
10
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.
15
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*******************************************************************/
20
21#ifndef KNOTE_H
22#define KNOTE_H
23
24#include <tqstring.h>
25#include <tqevent.h>
26#include <tqframe.h>
27#include <tqpoint.h>
28#include <tqcolor.h>
29
30#include <tdeconfig.h>
31#include <kxmlguiclient.h>
32
33class TQLabel;
34
35class KXMLGUIBuilder;
36
37class KFind;
38class TDEPopupMenu;
39class KNoteButton;
40class KNoteEdit;
41class KNoteConfig;
42class TDEToolBar;
43class TDEListAction;
44class TDEToggleAction;
45
46namespace KCal {
47 class Journal;
48}
49
50
51class KNote : public TQFrame, virtual public KXMLGUIClient
52{
53 TQ_OBJECT
54
55public:
56 KNote( TQDomDocument buildDoc, KCal::Journal *journal, TQWidget *parent = 0,
57 const char *name = 0 );
58 ~KNote();
59
60 void changeJournal(KCal::Journal *);
61 void saveData( bool update = true);
62 void saveConfig() const;
63
64 TQString noteId() const;
65
66 TQString name() const;
67 TQString text() const;
68 TQString plainText() const;
69
70 void setName( const TQString& name );
71 void setText( const TQString& text );
72
73 TQColor fgColor() const;
74 TQColor bgColor() const;
75 void setColor( const TQColor& fg, const TQColor& bg );
76
77 void find( const TQString& pattern, long options );
78
79 bool isModified() const;
80 TQDateTime getLastModified() const;
81
82 void sync( const TQString& app );
83 bool isNew( const TQString& app ) const;
84 bool isModified( const TQString& app ) const;
85
86 static void setStyle( int style );
87
88 void deleteWhenIdle();
89 void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;}
90public slots:
91 void slotKill( bool force = false );
92
93signals:
94 void sigRequestNewNote();
95 void sigShowNextNote();
96 void sigNameChanged();
97 void sigDataChanged(const TQString &);
98 void sigColorChanged();
99 void sigKillNote( KCal::Journal* );
100
101 void sigFindFinished();
102
103protected:
104 virtual void drawFrame( TQPainter* );
105 virtual void showEvent( TQShowEvent* );
106 virtual void resizeEvent( TQResizeEvent* );
107 virtual void closeEvent( TQCloseEvent* );
108 virtual void dropEvent( TQDropEvent* );
109 virtual void dragEnterEvent( TQDragEnterEvent* );
110
111 virtual bool event( TQEvent* );
112 virtual bool eventFilter( TQObject*, TQEvent* );
113
114 virtual bool focusNextPrevChild( bool );
115
117 void aboutToEnterEventLoop();
118 void eventLoopLeft();
119
120private slots:
121 void slotRename();
122 void slotUpdateReadOnly();
123 void slotClose();
124
125 void slotSend();
126 void slotMail();
127 void slotPrint();
128 void slotSaveAs();
129
130 void slotInsDate();
131 void slotSetAlarm();
132
133 void slotPreferences();
134 void slotPopupActionToDesktop( int id );
135
136 void slotFindNext();
137 void slotHighlight( const TQString& txt, int idx, int len );
138
139 void slotApplyConfig();
140 void slotUpdateKeepAboveBelow();
141 void slotUpdateShowInTaskbar();
142 void slotUpdateDesktopActions();
143
144 void slotUpdateViewport( int, int );
145 void slotRequestNewNote();
146 void slotSaveData();
147private:
148 void updateFocus();
149 void updateMask();
150 void updateLayout();
151 void updateLabelAlignment();
152 void updateBackground( int offset = -1 );
153
154 void createFold();
155
156 void toDesktop( int desktop );
157
158 TQString toPlainText( const TQString& );
159
160private:
161 TQLabel *m_label, *m_pushpin, *m_fold;
162 KNoteButton *m_button;
163 TDEToolBar *m_tool;
164 KNoteEdit *m_editor;
165
166 KNoteConfig *m_config;
167 KCal::Journal *m_journal;
168
169 KFind *m_find;
170
171 TDEPopupMenu *m_menu;
172 TDEPopupMenu *m_edit_menu;
173
174 TDEToggleAction *m_readOnly;
175
176 TDEListAction *m_toDesktop;
177 TDEToggleAction *m_keepAbove;
178 TDEToggleAction *m_keepBelow;
179
180 TDESharedConfig::Ptr m_twinConf;
181
182 static int s_ppOffset;
183
184 int m_busy;
185 bool m_deleteWhenIdle;
186 bool m_blockEmitDataChanged;
187};
188
189#endif