kojournalview.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <qlayout.h>
00028 #include <qpopupmenu.h>
00029 #include <qvbox.h>
00030 #include <qlabel.h>
00031 #include <qscrollview.h>
00032
00033 #include <klocale.h>
00034 #include <kdebug.h>
00035
00036 #include <libkcal/calendar.h>
00037
00038 #include "journalentry.h"
00039
00040 #include "kojournalview.h"
00041 #include "koglobals.h"
00042 using namespace KOrg;
00043 #include "kojournalview.moc"
00044
00045 KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
00046 const char *name)
00047 : KOrg::BaseView(calendar, parent, name)
00048 {
00049 mEntries.setAutoDelete( true );
00050
00051 QVBoxLayout*topLayout = new QVBoxLayout( this );
00052 topLayout->setAutoAdd(true);
00053 mSV = new QScrollView( this, "JournalScrollView" );
00054 topLayout = new QVBoxLayout( mSV->viewport() );
00055 topLayout->setAutoAdd(true);
00056 mVBox = new QVBox( mSV->viewport() );
00057 mSV->setVScrollBarMode( QScrollView::Auto );
00058 mSV->setHScrollBarMode( QScrollView::AlwaysOff );
00059 }
00060
00061 KOJournalView::~KOJournalView()
00062 {
00063 }
00064
00065 void KOJournalView::appendJournal( Journal*journal, const QDate &dt)
00066 {
00067
00068
00069 JournalEntry*j = new JournalEntry( calendar(), mVBox );
00070 if ( j ) {
00071 j->show();
00072 j->setJournal( journal );
00073 j->setDate( dt );
00074 connect( j, SIGNAL( incidenceAdded( Incidence* )), SIGNAL( incidenceAdded( Incidence* )) );
00075 connect( j, SIGNAL( incidenceChanged( Incidence*, Incidence* )), SIGNAL( incidenceChanged( Incidence*, Incidence* )) );
00076 connect( j, SIGNAL( incidenceToBeDeleted( Incidence* )), SIGNAL( incidenceToBeDeleted( Incidence* )) );
00077 connect( j, SIGNAL( incidenceDeleted( Incidence* )), SIGNAL( incidenceDeleted( Incidence* )) );
00078
00079 mEntries.append( j );
00080 mSelectedDates.append( dt );
00081 }
00082 }
00083
00084 int KOJournalView::currentDateCount()
00085 {
00086 return mSelectedDates.size();
00087 }
00088
00089
00090
00091
00092
00093
00094 Incidence::List KOJournalView::selectedIncidences()
00095 {
00096
00097 Incidence::List eventList;
00098 return eventList;
00099 }
00100
00101 void KOJournalView::clearEntries()
00102 {
00103
00104 JournalEntry::List::iterator it;
00105 for (it=mEntries.begin(); it!=mEntries.end(); ++it ) {
00106 delete (*it);
00107 }
00108 mEntries.clear();
00109 mSelectedDates.clear();
00110 }
00111 void KOJournalView::updateView()
00112 {
00113 JournalEntry::List::iterator it;
00114 for ( it = mEntries.begin(); it != mEntries.end(); ++it ) {
00115 if ( (*it) ) {
00116 QDate dt((*it)->date());
00117 (*it)->setJournal( calendar()->journal( dt ) );
00118 }
00119 }
00120 }
00121
00122 void KOJournalView::flushView()
00123 {
00124
00125 JournalEntry::List::iterator it;
00126 for ( it = mEntries.begin(); it != mEntries.end(); ++it ) {
00127 if (*it) (*it)->flushEntry();
00128 }
00129 }
00130
00131 void KOJournalView::showDates(const QDate &start, const QDate &end)
00132 {
00133
00134 clearEntries();
00135 if ( end<start ) return;
00136
00137 QDate d=start;
00138 for ( QDate d=start; d<=end; d=d.addDays(1) ) {
00139 Journal *j = calendar()->journal( d );
00140 appendJournal( j, d );
00141 }
00142 }
00143
00144 void KOJournalView::showIncidences( const Incidence::List &incidences )
00145 {
00146
00147 clearEntries();
00148 Incidence::List::const_iterator it;
00149 for ( it=incidences.constBegin(); it!=incidences.constEnd(); ++it) {
00150 if ((*it) && ( (*it)->type()=="Journal" ) ) {
00151 Journal*j = (Journal*)(*it);
00152 if ( j ) appendJournal( j, j->dtStart().date() );
00153 }
00154 }
00155 }
00156
00157 void KOJournalView::changeIncidenceDisplay(Incidence *incidence, int action)
00158 {
00159
00160 Journal *journal = dynamic_cast<Journal*>(incidence);
00161 if (journal) {
00162 switch(action) {
00163 case KOGlobals::INCIDENCEADDED:
00164
00165 break;
00166 case KOGlobals::INCIDENCEEDITED:
00167
00168
00169
00170
00171
00172
00173
00174
00175 break;
00176 case KOGlobals::INCIDENCEDELETED:
00177
00178
00179
00180
00181
00182
00183 break;
00184 default:
00185 kdDebug(5850) << "KOListView::changeIncidenceDisplay(): Illegal action " << action << endl;
00186 }
00187 }
00188 }
This file is part of the documentation for korganizer Library Version 3.3.2.