knotes

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