korganizer
koeventviewer.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "koeventviewer.h"
00026
00027 #include "urihandler.h"
00028
00029 #include <libkcal/calendar.h>
00030 #include <libkcal/incidence.h>
00031 #include <libkcal/incidenceformatter.h>
00032 #include <kdebug.h>
00033 #include <koglobals.h>
00034
00035 KOEventViewer::KOEventViewer( Calendar *calendar, QWidget *parent, const char *name )
00036 : QTextBrowser( parent, name ), mCalendar( calendar ), mDefaultText("")
00037 {
00038 mIncidence = 0;
00039 }
00040
00041 KOEventViewer::~KOEventViewer()
00042 {
00043 }
00044
00045 void KOEventViewer::readSettings( KConfig * config )
00046 {
00047 if ( config ) {
00048
00049
00050 #if 0
00051 config->setGroup( QString("EventViewer-%1").arg( name() ) );
00052 int zoomFactor = config->readNumEntry("ZoomFactor", pointSize() );
00053 zoomTo( zoomFactor/2 );
00054 kdDebug(5850) << " KOEventViewer: restoring the pointSize: "<< pointSize()
00055 << ", zoomFactor: " << zoomFactor << endl;
00056 #endif
00057 }
00058 }
00059
00060 void KOEventViewer::writeSettings( KConfig * config )
00061 {
00062 if ( config ) {
00063 kdDebug(5850) << " KOEventViewer: saving the zoomFactor: "<< pointSize() << endl;
00064 config->setGroup( QString("EventViewer-%1").arg( name() ) );
00065 config->writeEntry("ZoomFactor", pointSize() );
00066 }
00067 }
00068
00069 void KOEventViewer::setSource( const QString &n )
00070 {
00071 UriHandler::process( n );
00072 }
00073
00074 bool KOEventViewer::appendIncidence( Incidence *incidence, const QDate &date )
00075 {
00076 addText( IncidenceFormatter::extensiveDisplayStr( mCalendar, incidence, date ) );
00077 return true;
00078 }
00079
00080 void KOEventViewer::setCalendar( Calendar *calendar )
00081 {
00082 mCalendar = calendar;
00083 }
00084
00085 void KOEventViewer::setIncidence( Incidence *incidence, const QDate &date )
00086 {
00087 clearEvents();
00088 if( incidence ) {
00089 appendIncidence( incidence, date );
00090 mIncidence = incidence;
00091 } else {
00092 clearEvents( true );
00093 mIncidence = 0;
00094 }
00095 }
00096
00097 void KOEventViewer::clearEvents( bool now )
00098 {
00099 mText = "";
00100 if ( now ) setText( mDefaultText );
00101 }
00102
00103 void KOEventViewer::addText( const QString &text )
00104 {
00105 mText.append( text );
00106 setText( mText );
00107 }
00108
00109 void KOEventViewer::setDefaultText( const QString &text )
00110 {
00111 mDefaultText = text;
00112 }
00113
00114 void KOEventViewer::changeIncidenceDisplay( Incidence *incidence, const QDate &date, int action )
00115 {
00116 if ( mIncidence && ( incidence->uid() == mIncidence->uid() ) ) {
00117 switch (action ) {
00118 case KOGlobals::INCIDENCEEDITED:{
00119 setIncidence( incidence, date );
00120 break;
00121 }
00122 case KOGlobals::INCIDENCEDELETED: {
00123 setIncidence( 0, date );
00124 break;
00125 }
00126 }
00127 }
00128 }
00129
00130 #include "koeventviewer.moc"
|