• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

korganizer

koeventviewer.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of KOrganizer.
00003 
00004   Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
00005   Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
00006 
00007   This program is free software; you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation; either version 2 of the License, or
00010   (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License along
00018   with this program; if not, write to the Free Software Foundation, Inc.,
00019   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021   As a special exception, permission is given to link this program
00022   with any edition of Qt, and distribute the resulting executable,
00023   without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include "koeventviewer.h"
00027 #include "urihandler.h"
00028 #include "korganizerinterface.h"
00029 #include "koglobals.h"
00030 
00031 #include <libkdepim/kdepimprotocols.h>
00032 
00033 #include <kcal/incidence.h>
00034 #include <kcal/incidenceformatter.h>
00035 
00036 #include <kapplication.h>
00037 #include <kdebug.h>
00038 #include <ktoolinvocation.h>
00039 #include <kconfiggroup.h>
00040 
00041 #include <QRegExp>
00042 
00043 KOEventViewer::KOEventViewer( QWidget *parent )
00044   : KTextBrowser( parent ), mDefaultText( "" )
00045 {
00046   mIncidence = 0;
00047   setNotifyClick( true );
00048 }
00049 
00050 KOEventViewer::~KOEventViewer()
00051 {
00052 }
00053 
00054 void KOEventViewer::readSettings( KConfig *config )
00055 {
00056   if ( config ) {
00057 // With each restart of KOrganizer the font site gets halfed. What should this
00058 // be good for?
00059 #if 0
00060     config->setGroup( QString( "EventViewer-%1" ).arg( name() ) );
00061     int zoomFactor = config->readEntry( "ZoomFactor", fontPointSize() );
00062     zoomTo( zoomFactor / 2 );
00063     kDebug(5850) << " KOEventViewer: restoring the fontPointSize:" << fontPointSize()
00064                  << ", zoomFactor: " << zoomFactor;
00065 #endif
00066   }
00067 }
00068 
00069 void KOEventViewer::writeSettings( KConfig *config )
00070 {
00071   if ( config ) {
00072     kDebug() << "saving the zoomFactor:" << fontPointSize();
00073     KConfigGroup configGroup( config, QString( "EventViewer-%1" ).arg( objectName() ) );
00074     configGroup.writeEntry( "ZoomFactor", fontPointSize() );
00075   }
00076 }
00077 
00078 void KOEventViewer::setSource( const QUrl &name )
00079 {
00080   QString uri = name.toString();
00081   // QTextBrowser for some reason insists on putting // or / in links,
00082   // this is a crude workaround
00083   if ( uri.startsWith( KDEPIMPROTOCOL_CONTACT ) ||
00084        uri.startsWith( KDEPIMPROTOCOL_EMAIL ) ||
00085        uri.startsWith( QString( KDEPIMPROTOCOL_INCIDENCE ).section( ':', 0, 0 ) ) ||
00086        uri.startsWith( KDEPIMPROTOCOL_NEWSARTICLE ) ||
00087        uri.startsWith( "mailto:" ) )
00088   {
00089     uri.replace( QRegExp( "^([^:]+:)/+" ), "\\1" );
00090   }
00091 
00092   UriHandler::process( uri );
00093 }
00094 
00095 bool KOEventViewer::appendIncidence( Incidence *incidence )
00096 {
00097   QString codeForIncidence = IncidenceFormatter::extensiveDisplayString( incidence );
00098   addText( codeForIncidence );
00099   return true;
00100 }
00101 
00102 void KOEventViewer::setIncidence( Incidence *incidence )
00103 {
00104   clearEvents();
00105   if( incidence ) {
00106     appendIncidence( incidence );
00107     mIncidence = incidence;
00108   } else {
00109     clearEvents( true );
00110     mIncidence = 0;
00111   }
00112 }
00113 
00114 void KOEventViewer::clearEvents( bool now )
00115 {
00116   mText = "";
00117   if ( now ) {
00118     setText( mDefaultText );
00119   }
00120 }
00121 
00122 void KOEventViewer::addText( const QString &text )
00123 {
00124   mText.append( text );
00125   setText( mText );
00126 }
00127 
00128 void KOEventViewer::setDefaultText( const QString &text )
00129 {
00130   mDefaultText = text;
00131 }
00132 
00133 void KOEventViewer::changeIncidenceDisplay( Incidence *incidence, int action )
00134 {
00135   if ( mIncidence && ( incidence->uid() == mIncidence->uid() ) ) {
00136     switch ( action ) {
00137     case KOGlobals::INCIDENCEEDITED:
00138     {
00139       setIncidence( incidence );
00140       break;
00141     }
00142     case KOGlobals::INCIDENCEDELETED:
00143     {
00144       setIncidence( 0 );
00145       break;
00146     }
00147     }
00148   }
00149 }
00150 
00151 void KOEventViewer::editIncidence()
00152 {
00153   if ( mIncidence ) {
00154     // make sure korganizer is running or the part is shown
00155     KToolInvocation::startServiceByDesktopPath( "korganizer" );
00156 
00157     OrgKdeKorganizerKorganizerInterface korganizerIface(
00158       "org.kde.korganizer", "/Korganizer", QDBusConnection::sessionBus() );
00159     korganizerIface.editIncidence( mIncidence->uid() );
00160   }
00161 }
00162 
00163 void KOEventViewer::showIncidenceContext()
00164 {
00165   if ( mIncidence ) {
00166     // make sure korganizer is running or the part is shown
00167     KToolInvocation::startServiceByDesktopPath( "korganizer" );
00168 
00169     OrgKdeKorganizerKorganizerInterface korganizerIface(
00170       "org.kde.korganizer", "/Korganizer", QDBusConnection::sessionBus() );
00171     korganizerIface.showIncidenceContext( mIncidence->uid() );
00172   }
00173 }
00174 
00175 #include "koeventviewer.moc"

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal