korganizer Library API Documentation

kojournalview.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 // 00025 // View of Journal entries 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 // kdDebug(5850) << "KOJournalView::appendJournal(): "<< journal<<endl; 00068 // JournalEntry*j = new JournalEntry( calendar(), this ); 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 /*void KOJournalView::resizeEvent( QResizeEvent *event ) 00090 { 00091 // mSV->setSize( 00092 }*/ 00093 00094 Incidence::List KOJournalView::selectedIncidences() 00095 { 00096 // We don't have a selection in the journal view. 00097 Incidence::List eventList; 00098 return eventList; 00099 } 00100 00101 void KOJournalView::clearEntries() 00102 { 00103 // kdDebug(5850)<<"KOJournalView::clearEntries()"<<endl; 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 // kdDebug(5850) << "KOJournalView::flushView(): "<< endl; 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 // kdDebug(5850) << "KOJournalView::showDates(): "<<start.toString().latin1()<<" - "<<end.toString().latin1() << endl; 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 // kdDebug(5850) << "KOJournalView::showIncidences(): "<< endl; 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 // kdDebug(5850) << "KOJournalView::changeIncidenceDisplay(): "<< endl; 00160 Journal *journal = dynamic_cast<Journal*>(incidence); 00161 if (journal) { 00162 switch(action) { 00163 case KOGlobals::INCIDENCEADDED: 00164 //addIncidence( incidence ); 00165 break; 00166 case KOGlobals::INCIDENCEEDITED: 00167 /* 00168 item = getItemForEvent(incidence); 00169 if (item) { 00170 delete item; 00171 mUidDict.remove( incidence->uid() ); 00172 addIncidence( incidence ); 00173 } 00174 */ 00175 break; 00176 case KOGlobals::INCIDENCEDELETED: 00177 /* 00178 item = getItemForEvent(incidence); 00179 if (item) { 00180 delete item; 00181 } 00182 */ 00183 break; 00184 default: 00185 kdDebug(5850) << "KOListView::changeIncidenceDisplay(): Illegal action " << action << endl; 00186 } 00187 } 00188 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:46:57 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003