diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /korganizer/koeventviewer.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'korganizer/koeventviewer.cpp')
-rw-r--r-- | korganizer/koeventviewer.cpp | 106 |
1 files changed, 86 insertions, 20 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 47ac5b7a4..83534d6aa 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -23,24 +23,62 @@ */ #include "koeventviewer.h" - +#include "koglobals.h" #include "urihandler.h" +#include <libkcal/attachmenthandler.h> +#include <libkcal/calendar.h> #include <libkcal/incidence.h> #include <libkcal/incidenceformatter.h> + #include <kdebug.h> -#include <koglobals.h> +#include <klocale.h> +#include <kpopupmenu.h> + +#include <tqcursor.h> +#include <tqregexp.h> +#include <tqtooltip.h> -KOEventViewer::KOEventViewer( TQWidget *parent, const char *name ) - : TQTextBrowser( parent, name ), mDefaultText("") +KOEventViewer::KOEventViewer( Calendar *calendar, TQWidget *parent, const char *name ) + : TQTextBrowser( parent, name ), mCalendar( calendar ), mDefaultText("") { mIncidence = 0; + connect( this, TQT_SIGNAL(highlighted(const TQString &)), TQT_SLOT(message(const TQString &)) ); } KOEventViewer::~KOEventViewer() { } +void KOEventViewer::message( const TQString &link ) +{ + mAttachLink = TQString(); + if ( link.isEmpty() ) { + TQToolTip::remove( this ); + return; + } + + TQString ttStr; + if ( link.startsWith( "kmail:" ) ) { + ttStr = i18n( "Open the message in KMail" ); + } else if ( link.startsWith( "mailto:" ) ) { + ttStr = i18n( "Send an email message to %1" ).arg( link.mid( 7 ) ); + } else if ( link.startsWith( "uid:" ) ) { + ttStr = i18n( "Lookup the contact in KAddressbook" ); + } else if ( link.startsWith( "ATTACH:" ) ) { + TQString tmp = link; + tmp.remove( TQRegExp( "^ATTACH://" ) ); + TQString uid = tmp.section( ':', 0, 0 ); + TQString name = tmp.section( ':', -1, -1 ); + ttStr = i18n( "View attachment \"%1\"" ).arg( name ); + mAttachLink = link; + } else { // no special URI, let KDE handle it + ttStr = i18n( "Launch a viewer on the link" ); + } + + TQToolTip::add( this, ttStr ); +} + void KOEventViewer::readSettings( KConfig * config ) { if ( config ) { @@ -50,7 +88,7 @@ void KOEventViewer::readSettings( KConfig * config ) config->setGroup( TQString("EventViewer-%1").arg( name() ) ); int zoomFactor = config->readNumEntry("ZoomFactor", pointSize() ); zoomTo( zoomFactor/2 ); - kdDebug(5850) << " KOEventViewer: restoring the pointSize: "<< pointSize() + kdDebug(5850) << " KOEventViewer: restoring the pointSize: "<< pointSize() << ", zoomFactor: " << zoomFactor << endl; #endif } @@ -67,20 +105,25 @@ void KOEventViewer::writeSettings( KConfig * config ) void KOEventViewer::setSource( const TQString &n ) { - UriHandler::process( n ); + UriHandler::process( parentWidget(), n ); } -bool KOEventViewer::appendIncidence( Incidence *incidence ) +bool KOEventViewer::appendIncidence( Incidence *incidence, const TQDate &date ) { - addText( IncidenceFormatter::extensiveDisplayString( incidence ) ); + addText( IncidenceFormatter::extensiveDisplayStr( mCalendar, incidence, date ) ); return true; } -void KOEventViewer::setIncidence( Incidence *incidence ) +void KOEventViewer::setCalendar( Calendar *calendar ) +{ + mCalendar = calendar; +} + +void KOEventViewer::setIncidence( Incidence *incidence, const TQDate &date ) { clearEvents(); if( incidence ) { - appendIncidence( incidence ); + appendIncidence( incidence, date ); mIncidence = incidence; } else { clearEvents( true ); @@ -105,20 +148,43 @@ void KOEventViewer::setDefaultText( const TQString &text ) mDefaultText = text; } -void KOEventViewer::changeIncidenceDisplay( Incidence *incidence, int action ) +void KOEventViewer::changeIncidenceDisplay( Incidence *incidence, const TQDate &date, int action ) { if ( mIncidence && ( incidence->uid() == mIncidence->uid() ) ) { - switch (action ) { - case KOGlobals::INCIDENCEEDITED:{ - setIncidence( incidence ); - break; - } - case KOGlobals::INCIDENCEDELETED: { - setIncidence( 0 ); - break; - } + switch ( action ) { + case KOGlobals::INCIDENCEEDITED: + setIncidence( incidence, date ); + break; + case KOGlobals::INCIDENCEDELETED: + setIncidence( 0, date ); + break; } } } +void KOEventViewer::contentsContextMenuEvent( TQContextMenuEvent *e ) +{ + TQString name = UriHandler::attachmentNameFromUri( mAttachLink ); + TQString uid = UriHandler::uidFromUri( mAttachLink ); + if ( name.isEmpty() || uid.isEmpty() ) { + TQTextBrowser::contentsContextMenuEvent( e ); + return; + } + + KPopupMenu *menu = new KPopupMenu(); + menu->insertItem( i18n( "Open Attachment" ), 0 ); + menu->insertItem( i18n( "Save Attachment As..." ), 1 ); + + switch( menu->exec( TQCursor::pos(), 0 ) ) { + case 0: // open + AttachmentHandler::view( parentWidget(), name, uid ); + break; + case 1: // save as + AttachmentHandler::saveAs( parentWidget(), name, uid ); + break; + default: + break; + } +} + #include "koeventviewer.moc" |