knote.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 KNOTE_H 00022 #define KNOTE_H 00023 00024 #include <tqstring.h> 00025 #include <tqevent.h> 00026 #include <tqframe.h> 00027 #include <tqpoint.h> 00028 #include <tqcolor.h> 00029 00030 #include <kconfig.h> 00031 #include <kxmlguiclient.h> 00032 00033 class TQLabel; 00034 00035 class KXMLGUIBuilder; 00036 00037 class KFind; 00038 class KPopupMenu; 00039 class KNoteButton; 00040 class KNoteEdit; 00041 class KNoteConfig; 00042 class KToolBar; 00043 class KListAction; 00044 class KToggleAction; 00045 00046 namespace KCal { 00047 class Journal; 00048 } 00049 00050 00051 class KNote : public TQFrame, virtual public KXMLGUIClient 00052 { 00053 Q_OBJECT 00054 TQ_OBJECT 00055 public: 00056 KNote( TQDomDocument buildDoc, KCal::Journal *journal, TQWidget *parent = 0, 00057 const char *name = 0 ); 00058 ~KNote(); 00059 00060 void changeJournal(KCal::Journal *); 00061 void saveData( bool update = true); 00062 void saveConfig() const; 00063 00064 TQString noteId() const; 00065 00066 TQString name() const; 00067 TQString text() const; 00068 TQString plainText() const; 00069 00070 void setName( const TQString& name ); 00071 void setText( const TQString& text ); 00072 00073 TQColor fgColor() const; 00074 TQColor bgColor() const; 00075 void setColor( const TQColor& fg, const TQColor& bg ); 00076 00077 void find( const TQString& pattern, long options ); 00078 00079 bool isModified() const; 00080 00081 void sync( const TQString& app ); 00082 bool isNew( const TQString& app ) const; 00083 bool isModified( const TQString& app ) const; 00084 00085 static void setStyle( int style ); 00086 00087 void deleteWhenIdle(); 00088 void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;} 00089 public slots: 00090 void slotKill( bool force = false ); 00091 00092 signals: 00093 void sigRequestNewNote(); 00094 void sigShowNextNote(); 00095 void sigNameChanged(); 00096 void sigDataChanged(const TQString &); 00097 void sigColorChanged(); 00098 void sigKillNote( KCal::Journal* ); 00099 00100 void sigFindFinished(); 00101 00102 protected: 00103 virtual void drawFrame( TQPainter* ); 00104 virtual void showEvent( TQShowEvent* ); 00105 virtual void resizeEvent( TQResizeEvent* ); 00106 virtual void closeEvent( TQCloseEvent* ); 00107 virtual void dropEvent( TQDropEvent* ); 00108 virtual void dragEnterEvent( TQDragEnterEvent* ); 00109 00110 virtual bool event( TQEvent* ); 00111 virtual bool eventFilter( TQObject*, TQEvent* ); 00112 00113 virtual bool focusNextPrevChild( bool ); 00114 00116 void aboutToEnterEventLoop(); 00117 void eventLoopLeft(); 00118 00119 private slots: 00120 void slotRename(); 00121 void slotUpdateReadOnly(); 00122 void slotClose(); 00123 00124 void slotSend(); 00125 void slotMail(); 00126 void slotPrint(); 00127 void slotSaveAs(); 00128 00129 void slotInsDate(); 00130 void slotSetAlarm(); 00131 00132 void slotPreferences(); 00133 void slotPopupActionToDesktop( int id ); 00134 00135 void slotFindNext(); 00136 void slotHighlight( const TQString& txt, int idx, int len ); 00137 00138 void slotApplyConfig(); 00139 void slotUpdateKeepAboveBelow(); 00140 void slotUpdateShowInTaskbar(); 00141 void slotUpdateDesktopActions(); 00142 00143 void slotUpdateViewport( int, int ); 00144 void slotRequestNewNote(); 00145 void slotSaveData(); 00146 private: 00147 void updateFocus(); 00148 void updateMask(); 00149 void updateLayout(); 00150 void updateLabelAlignment(); 00151 void updateBackground( int offset = -1 ); 00152 00153 void createFold(); 00154 00155 void toDesktop( int desktop ); 00156 00157 TQString toPlainText( const TQString& ); 00158 00159 private: 00160 TQLabel *m_label, *m_pushpin, *m_fold; 00161 KNoteButton *m_button; 00162 KToolBar *m_tool; 00163 KNoteEdit *m_editor; 00164 00165 KNoteConfig *m_config; 00166 KCal::Journal *m_journal; 00167 00168 KFind *m_find; 00169 00170 KPopupMenu *m_menu; 00171 KPopupMenu *m_edit_menu; 00172 00173 KToggleAction *m_readOnly; 00174 00175 KListAction *m_toDesktop; 00176 KToggleAction *m_keepAbove; 00177 KToggleAction *m_keepBelow; 00178 00179 KSharedConfig::Ptr m_kwinConf; 00180 00181 static int s_ppOffset; 00182 00183 int m_busy; 00184 bool m_deleteWhenIdle; 00185 bool m_blockEmitDataChanged; 00186 }; 00187 00188 #endif