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 <qstring.h>
00025 #include <qevent.h>
00026 #include <qframe.h>
00027 #include <qpoint.h>
00028 #include <qcolor.h>
00029 
00030 #include <kconfig.h>
00031 #include <kxmlguiclient.h>
00032 
00033 class QLabel;
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 QFrame, virtual public KXMLGUIClient
00052 {
00053     Q_OBJECT
00054 public:
00055     KNote( QDomDocument buildDoc, KCal::Journal *journal, QWidget *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     QString noteId() const;
00064 
00065     QString name() const;
00066     QString text() const;
00067     QString plainText() const;
00068 
00069     void setName( const QString& name );
00070     void setText( const QString& text );
00071 
00072     QColor fgColor() const;
00073     QColor bgColor() const;
00074     void setColor( const QColor& fg, const QColor& bg );
00075 
00076     void find( const QString& pattern, long options );
00077 
00078     bool isModified() const;
00079 
00080     void sync( const QString& app );
00081     bool isNew( const QString& app ) const;
00082     bool isModified( const QString& 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 QString &);
00096     void sigColorChanged();
00097     void sigKillNote( KCal::Journal* );
00098 
00099     void sigFindFinished();
00100 
00101 protected:
00102     virtual void drawFrame( QPainter* );
00103     virtual void showEvent( QShowEvent* );
00104     virtual void resizeEvent( QResizeEvent* );
00105     virtual void closeEvent( QCloseEvent* );
00106     virtual void dropEvent( QDropEvent* );
00107     virtual void dragEnterEvent( QDragEnterEvent* );
00108 
00109     virtual bool event( QEvent* );
00110     virtual bool eventFilter( QObject*, QEvent* );
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 QString& 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 slotEmitCreateNewNote();
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     QString toPlainText( const QString& );
00158 
00159 private:
00160     QLabel        *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