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