korganizer

journalentry.h
00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (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     As a special exception, permission is given to link this program
00021     with any edition of TQt, and distribute the resulting executable,
00022     without including the source code for TQt in the source distribution.
00023 */
00024 #ifndef JOURNALENTRY_H
00025 #define JOURNALENTRY_H
00026 //
00027 // Widget showing one Journal entry
00028 
00029 #include <libkcal/resourcecalendar.h>
00030 #include <tqvbox.h>
00031 
00032 class TQLabel;
00033 class KActiveLabel;
00034 class TQCheckBox;
00035 class TQGridLayout;
00036 class KLineEdit;
00037 class KTextEdit;
00038 class KTimeEdit;
00039 class TQButton;
00040 namespace KOrg {
00041 class IncidenceChangerBase;
00042 }
00043 using namespace KOrg;
00044 namespace KCal {
00045   class Calendar;
00046   class Journal;
00047 }
00048 using namespace KCal;
00049 
00050 class JournalEntry : public TQWidget {
00051     Q_OBJECT
00052   TQ_OBJECT
00053   public:
00054     typedef ListBase<JournalEntry> List;
00055 
00056     JournalEntry( Journal* j, TQWidget *parent );
00057     virtual ~JournalEntry();
00058 
00059     void setJournal(Journal *);
00060     Journal *journal() const { return mJournal; }
00061 
00062     TQDate date() const { return mDate; }
00063 
00064     void clear();
00065     void readJournal( Journal *j );
00066 
00067     bool isReadOnly() const { return mReadOnly; }
00068     void setReadOnly( bool readonly );
00069 
00070   protected slots:
00071     void setDirty();
00072     void deleteItem();
00073     void editItem();
00074     void printItem();
00075     void timeCheckBoxToggled(bool on);
00076   public slots:
00077     void setIncidenceChanger( IncidenceChangerBase *changer ) { mChanger = changer; }
00078     void setDate(const TQDate &);
00079     void flushEntry();
00080 
00081   signals:
00082     void deleteIncidence( Incidence * );
00083     void editIncidence( Incidence *, const TQDate& );
00084 
00085   protected:
00086     void clearFields();
00087     bool eventFilter( TQObject *o, TQEvent *e );
00088 
00089     void writeJournal();
00090 
00091   private:
00092     void writeJournalPrivate( Journal *j );
00093 
00094     Journal *mJournal;
00095     TQDate mDate;
00096     bool mReadOnly;
00097 
00098     TQLabel *mTitleLabel;
00099     KLineEdit *mTitleEdit;
00100     KTextEdit *mEditor;
00101     TQCheckBox *mTimeCheck;
00102     KTimeEdit *mTimeEdit;
00103     TQButton *mDeleteButton;
00104     TQButton *mEditButton;
00105     TQButton *mPrintButton;
00106 
00107     TQGridLayout *mLayout;
00108 
00109     bool mDirty;
00110     bool mWriteInProgress;
00111     IncidenceChangerBase *mChanger;
00112 };
00113 
00114 
00115 class JournalDateEntry : public TQVBox {
00116     Q_OBJECT
00117   TQ_OBJECT
00118   public:
00119     typedef ListBase<JournalDateEntry> List;
00120 
00121     JournalDateEntry( Calendar *, TQWidget *parent );
00122     virtual ~JournalDateEntry();
00123 
00124     void addJournal( Journal * );
00125     Journal::List journals() const;
00126 
00127     void setDate( const TQDate & );
00128     TQDate date() const { return mDate; }
00129 
00130     void clear();
00131 
00132 
00133   signals:
00134     void setIncidenceChangerSignal( IncidenceChangerBase *changer );
00135     void setDateSignal( const TQDate & );
00136     void flushEntries();
00137     void editIncidence( Incidence *, const TQDate& );
00138     void deleteIncidence( Incidence * );
00139     void newJournal( ResourceCalendar *, const TQString &, const TQDate & );
00140 
00141   public slots:
00142     void emitNewJournal();
00143     void setIncidenceChanger( IncidenceChangerBase *changer );
00144     void journalEdited( Journal* );
00145     void journalDeleted( Journal* );
00146 
00147   private:
00148     Calendar *mCalendar;
00149     TQDate mDate;
00150     TQMap<Journal*,JournalEntry*> mEntries;
00151 
00152     KActiveLabel *mTitle;
00153     TQWidget *mAddBar;
00154     IncidenceChangerBase *mChanger;
00155 };
00156 
00157 
00158 #endif