knotes

knote.h

00001 /*******************************************************************
00002  KNotes -- Notes for the KDE project
00003 
00004  Copyright (c) 1997-2005, 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 saveData();
00060     void saveConfig() const;
00061 
00062     QString noteId() const;
00063     QString name() const;
00064     QString text() const;
00065     QString plainText() const;
00066 
00067     void setName( const QString& name );
00068     void setText( const QString& text );
00069 
00070     void find( const QString& pattern, long options );
00071 
00072     bool isModified() const;
00073 
00074     void sync( const QString& app );
00075     bool isNew( const QString& app ) const;
00076     bool isModified( const QString& app ) const;
00077 
00078     static void setStyle( int style );
00079 
00080 public slots:
00081     void slotKill( bool force = false );
00082 
00083 signals:
00084     void sigRequestNewNote();
00085     void sigShowNextNote();
00086     void sigNameChanged();
00087     void sigDataChanged();
00088     void sigColorChanged();
00089     void sigKillNote( KCal::Journal* );
00090 
00091     void sigFindFinished();
00092 
00093 protected:
00094     virtual void drawFrame( QPainter* );
00095     virtual void showEvent( QShowEvent* );
00096     virtual void resizeEvent( QResizeEvent* );
00097     virtual void closeEvent( QCloseEvent* );
00098     virtual void dropEvent( QDropEvent* );
00099     virtual void dragEnterEvent( QDragEnterEvent* );
00100 
00101     virtual bool event( QEvent* );
00102     virtual bool eventFilter( QObject*, QEvent* );
00103 
00104     virtual bool focusNextPrevChild( bool );
00105 
00106 private slots:
00107     void slotRename();
00108     void slotUpdateReadOnly();
00109     void slotClose();
00110 
00111     void slotSend();
00112     void slotMail();
00113     void slotPrint();
00114     void slotSaveAs();
00115 
00116     void slotInsDate();
00117     void slotSetAlarm();
00118 
00119     void slotPreferences();
00120     void slotPopupActionToDesktop( int id );
00121 
00122     void slotFindNext();
00123     void slotHighlight( const QString& txt, int idx, int len );
00124 
00125     void slotApplyConfig();
00126     void slotUpdateKeepAboveBelow();
00127     void slotUpdateShowInTaskbar();
00128     void slotUpdateDesktopActions();
00129 
00130     void slotUpdateViewport( int, int );
00131 
00132 private:
00133     void updateFocus();
00134     void updateMask();
00135     void updateLayout();
00136     void updateLabelAlignment();
00137     void updateBackground( int offset = -1 );
00138 
00139     void setColor( const QColor&, const QColor& );
00140 
00141     void createFold();
00142 
00143     void toDesktop( int desktop );
00144 
00145     QString toPlainText( const QString& );
00146 
00147 private:
00148     QLabel        *m_label, *m_pushpin, *m_fold;
00149     KNoteButton   *m_button;
00150     KToolBar      *m_tool;
00151     KNoteEdit     *m_editor;
00152 
00153     KNoteConfig   *m_config;
00154     KCal::Journal *m_journal;
00155 
00156     KFind         *m_find;
00157 
00158     KPopupMenu    *m_menu;
00159     KPopupMenu    *m_edit_menu;
00160 
00161     KToggleAction *m_readOnly;
00162 
00163     KListAction   *m_toDesktop;
00164     KToggleAction *m_keepAbove;
00165     KToggleAction *m_keepBelow;
00166 
00167     KSharedConfig::Ptr m_kwinConf;
00168 
00169     static int s_ppOffset;
00170 };
00171 
00172 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys