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 <tdeconfig.h> 00031 #include <kxmlguiclient.h> 00032 00033 class TQLabel; 00034 00035 class KXMLGUIBuilder; 00036 00037 class KFind; 00038 class TDEPopupMenu; 00039 class KNoteButton; 00040 class KNoteEdit; 00041 class KNoteConfig; 00042 class TDEToolBar; 00043 class TDEListAction; 00044 class TDEToggleAction; 00045 00046 namespace KCal { 00047 class Journal; 00048 } 00049 00050 00051 class KNote : public TQFrame, virtual public KXMLGUIClient 00052 { 00053 Q_OBJECT 00054 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 TQDateTime getLastModified() const; 00081 00082 void sync( const TQString& app ); 00083 bool isNew( const TQString& app ) const; 00084 bool isModified( const TQString& app ) const; 00085 00086 static void setStyle( int style ); 00087 00088 void deleteWhenIdle(); 00089 void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;} 00090 public slots: 00091 void slotKill( bool force = false ); 00092 00093 signals: 00094 void sigRequestNewNote(); 00095 void sigShowNextNote(); 00096 void sigNameChanged(); 00097 void sigDataChanged(const TQString &); 00098 void sigColorChanged(); 00099 void sigKillNote( KCal::Journal* ); 00100 00101 void sigFindFinished(); 00102 00103 protected: 00104 virtual void drawFrame( TQPainter* ); 00105 virtual void showEvent( TQShowEvent* ); 00106 virtual void resizeEvent( TQResizeEvent* ); 00107 virtual void closeEvent( TQCloseEvent* ); 00108 virtual void dropEvent( TQDropEvent* ); 00109 virtual void dragEnterEvent( TQDragEnterEvent* ); 00110 00111 virtual bool event( TQEvent* ); 00112 virtual bool eventFilter( TQObject*, TQEvent* ); 00113 00114 virtual bool focusNextPrevChild( bool ); 00115 00117 void aboutToEnterEventLoop(); 00118 void eventLoopLeft(); 00119 00120 private slots: 00121 void slotRename(); 00122 void slotUpdateReadOnly(); 00123 void slotClose(); 00124 00125 void slotSend(); 00126 void slotMail(); 00127 void slotPrint(); 00128 void slotSaveAs(); 00129 00130 void slotInsDate(); 00131 void slotSetAlarm(); 00132 00133 void slotPreferences(); 00134 void slotPopupActionToDesktop( int id ); 00135 00136 void slotFindNext(); 00137 void slotHighlight( const TQString& txt, int idx, int len ); 00138 00139 void slotApplyConfig(); 00140 void slotUpdateKeepAboveBelow(); 00141 void slotUpdateShowInTaskbar(); 00142 void slotUpdateDesktopActions(); 00143 00144 void slotUpdateViewport( int, int ); 00145 void slotRequestNewNote(); 00146 void slotSaveData(); 00147 private: 00148 void updateFocus(); 00149 void updateMask(); 00150 void updateLayout(); 00151 void updateLabelAlignment(); 00152 void updateBackground( int offset = -1 ); 00153 00154 void createFold(); 00155 00156 void toDesktop( int desktop ); 00157 00158 TQString toPlainText( const TQString& ); 00159 00160 private: 00161 TQLabel *m_label, *m_pushpin, *m_fold; 00162 KNoteButton *m_button; 00163 TDEToolBar *m_tool; 00164 KNoteEdit *m_editor; 00165 00166 KNoteConfig *m_config; 00167 KCal::Journal *m_journal; 00168 00169 KFind *m_find; 00170 00171 TDEPopupMenu *m_menu; 00172 TDEPopupMenu *m_edit_menu; 00173 00174 TDEToggleAction *m_readOnly; 00175 00176 TDEListAction *m_toDesktop; 00177 TDEToggleAction *m_keepAbove; 00178 TDEToggleAction *m_keepBelow; 00179 00180 TDESharedConfig::Ptr m_twinConf; 00181 00182 static int s_ppOffset; 00183 00184 int m_busy; 00185 bool m_deleteWhenIdle; 00186 bool m_blockEmitDataChanged; 00187 }; 00188 00189 #endif
