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 
33 class TQLabel;
34 
35 class KXMLGUIBuilder;
36 
37 class KFind;
38 class TDEPopupMenu;
39 class KNoteButton;
40 class KNoteEdit;
41 class KNoteConfig;
42 class TDEToolBar;
43 class TDEListAction;
44 class TDEToggleAction;
45 
46 namespace KCal {
47  class Journal;
48 }
49 
50 
51 class KNote : public TQFrame, virtual public KXMLGUIClient
52 {
53  Q_OBJECT
54 
55 public:
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 
81  void sync( const TQString& app );
82  bool isNew( const TQString& app ) const;
83  bool isModified( const TQString& app ) const;
84 
85  static void setStyle( int style );
86 
87  void deleteWhenIdle();
88  void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;}
89 public slots:
90  void slotKill( bool force = false );
91 
92 signals:
93  void sigRequestNewNote();
94  void sigShowNextNote();
95  void sigNameChanged();
96  void sigDataChanged(const TQString &);
97  void sigColorChanged();
98  void sigKillNote( KCal::Journal* );
99 
100  void sigFindFinished();
101 
102 protected:
103  virtual void drawFrame( TQPainter* );
104  virtual void showEvent( TQShowEvent* );
105  virtual void resizeEvent( TQResizeEvent* );
106  virtual void closeEvent( TQCloseEvent* );
107  virtual void dropEvent( TQDropEvent* );
108  virtual void dragEnterEvent( TQDragEnterEvent* );
109 
110  virtual bool event( TQEvent* );
111  virtual bool eventFilter( TQObject*, TQEvent* );
112 
113  virtual bool focusNextPrevChild( bool );
114 
116  void aboutToEnterEventLoop();
117  void eventLoopLeft();
118 
119 private slots:
120  void slotRename();
121  void slotUpdateReadOnly();
122  void slotClose();
123 
124  void slotSend();
125  void slotMail();
126  void slotPrint();
127  void slotSaveAs();
128 
129  void slotInsDate();
130  void slotSetAlarm();
131 
132  void slotPreferences();
133  void slotPopupActionToDesktop( int id );
134 
135  void slotFindNext();
136  void slotHighlight( const TQString& txt, int idx, int len );
137 
138  void slotApplyConfig();
139  void slotUpdateKeepAboveBelow();
140  void slotUpdateShowInTaskbar();
141  void slotUpdateDesktopActions();
142 
143  void slotUpdateViewport( int, int );
144  void slotRequestNewNote();
145  void slotSaveData();
146 private:
147  void updateFocus();
148  void updateMask();
149  void updateLayout();
150  void updateLabelAlignment();
151  void updateBackground( int offset = -1 );
152 
153  void createFold();
154 
155  void toDesktop( int desktop );
156 
157  TQString toPlainText( const TQString& );
158 
159 private:
160  TQLabel *m_label, *m_pushpin, *m_fold;
161  KNoteButton *m_button;
162  TDEToolBar *m_tool;
163  KNoteEdit *m_editor;
164 
165  KNoteConfig *m_config;
166  KCal::Journal *m_journal;
167 
168  KFind *m_find;
169 
170  TDEPopupMenu *m_menu;
171  TDEPopupMenu *m_edit_menu;
172 
173  TDEToggleAction *m_readOnly;
174 
175  TDEListAction *m_toDesktop;
176  TDEToggleAction *m_keepAbove;
177  TDEToggleAction *m_keepBelow;
178 
179  TDESharedConfig::Ptr m_twinConf;
180 
181  static int s_ppOffset;
182 
183  int m_busy;
184  bool m_deleteWhenIdle;
185  bool m_blockEmitDataChanged;
186 };
187 
188 #endif