korganizer

koeventviewer.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
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 Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include "koeventviewer.h"
00026 
00027 #include "urihandler.h"
00028 
00029 #include <libkcal/incidence.h>
00030 #include <libkcal/incidenceformatter.h>
00031 #include <kdebug.h>
00032 #include <koglobals.h>
00033 
00034 KOEventViewer::KOEventViewer( QWidget *parent, const char *name )
00035   : QTextBrowser( parent, name ), mDefaultText("")
00036 {
00037   mIncidence = 0;
00038 }
00039 
00040 KOEventViewer::~KOEventViewer()
00041 {
00042 }
00043 
00044 void KOEventViewer::readSettings( KConfig * config )
00045 {
00046   if ( config ) {
00047 // With each restart of KOrganizer the font site gets halfed. What should this
00048 // be good for?
00049 #if 0
00050     config->setGroup( QString("EventViewer-%1").arg( name() )  );
00051     int zoomFactor = config->readNumEntry("ZoomFactor", pointSize() );
00052     zoomTo( zoomFactor/2 );
00053     kdDebug(5850) << " KOEventViewer: restoring the pointSize:  "<< pointSize() 
00054       << ", zoomFactor: " << zoomFactor << endl;
00055 #endif
00056   }
00057 }
00058 
00059 void KOEventViewer::writeSettings( KConfig * config )
00060 {
00061   if ( config ) {
00062     kdDebug(5850) << " KOEventViewer: saving the zoomFactor: "<< pointSize() << endl;
00063     config->setGroup( QString("EventViewer-%1").arg( name() ) );
00064     config->writeEntry("ZoomFactor", pointSize() );
00065   }
00066 }
00067 
00068 void KOEventViewer::setSource( const QString &n )
00069 {
00070   UriHandler::process( n );
00071 }
00072 
00073 bool KOEventViewer::appendIncidence( Incidence *incidence )
00074 {
00075   addText( IncidenceFormatter::extensiveDisplayString( incidence ) );
00076   return true;
00077 }
00078 
00079 void KOEventViewer::setIncidence( Incidence *incidence )
00080 {
00081   clearEvents();
00082   if( incidence ) {
00083     appendIncidence( incidence );
00084     mIncidence = incidence;
00085   } else {
00086     clearEvents( true );
00087     mIncidence = 0;
00088   }
00089 }
00090 
00091 void KOEventViewer::clearEvents( bool now )
00092 {
00093   mText = "";
00094   if ( now ) setText( mDefaultText );
00095 }
00096 
00097 void KOEventViewer::addText( const QString &text )
00098 {
00099   mText.append( text );
00100   setText( mText );
00101 }
00102 
00103 void KOEventViewer::setDefaultText( const QString &text )
00104 {
00105   mDefaultText = text;
00106 }
00107 
00108 void KOEventViewer::changeIncidenceDisplay( Incidence *incidence, int action )
00109 {
00110   if ( mIncidence && ( incidence->uid() == mIncidence->uid() ) ) {
00111     switch (action ) {
00112       case KOGlobals::INCIDENCEEDITED:{
00113         setIncidence( incidence );
00114         break;
00115       }
00116       case KOGlobals::INCIDENCEDELETED: {
00117         setIncidence( 0 );
00118         break;
00119       } 
00120     }
00121   }
00122 }
00123 
00124 #include "koeventviewer.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys