25 #include "koeventviewer.h"
26 #include "koglobals.h"
27 #include "urihandler.h"
31 #include <libkcal/incidence.h>
32 #include <libkcal/incidenceformatter.h>
35 #include <tdelocale.h>
36 #include <tdepopupmenu.h>
40 #include <tqtooltip.h>
42 KOEventViewer::KOEventViewer(
Calendar *calendar, TQWidget *parent,
const char *name )
43 : TQTextBrowser( parent, name ), mCalendar( calendar ), mDefaultText(
"")
46 connect(
this, TQ_SIGNAL(highlighted(
const TQString &)), TQ_SLOT(message(
const TQString &)) );
49 KOEventViewer::~KOEventViewer()
53 void KOEventViewer::message(
const TQString &link )
55 mAttachLink = TQString();
56 if ( link.isEmpty() ) {
57 TQToolTip::remove(
this );
62 if ( link.startsWith(
"kmail:" ) ) {
63 ttStr = i18n(
"Open the message in KMail" );
64 }
else if ( link.startsWith(
"mailto:" ) ) {
65 ttStr = i18n(
"Send an email message to %1" ).arg( link.mid( 7 ) );
66 }
else if ( link.startsWith(
"uid:" ) ) {
67 ttStr = i18n(
"Lookup the contact in KAddressbook" );
68 }
else if ( link.startsWith(
"ATTACH:" ) ) {
70 tmp.remove( TQRegExp(
"^ATTACH://" ) );
71 TQString uid = tmp.section(
':', 0, 0 );
72 TQString name = tmp.section(
':', -1, -1 );
73 ttStr = i18n(
"View attachment \"%1\"" ).arg( name );
76 ttStr = i18n(
"Launch a viewer on the link" );
79 TQToolTip::add(
this, ttStr );
82 void KOEventViewer::readSettings( TDEConfig * config )
88 config->setGroup( TQString(
"EventViewer-%1").arg( name() ) );
89 int zoomFactor = config->readNumEntry(
"ZoomFactor", pointSize() );
90 zoomTo( zoomFactor/2 );
91 kdDebug(5850) <<
" KOEventViewer: restoring the pointSize: "<< pointSize()
92 <<
", zoomFactor: " << zoomFactor << endl;
97 void KOEventViewer::writeSettings( TDEConfig * config )
100 kdDebug(5850) <<
" KOEventViewer: saving the zoomFactor: "<< pointSize() << endl;
101 config->setGroup( TQString(
"EventViewer-%1").arg( name() ) );
102 config->writeEntry(
"ZoomFactor", pointSize() );
108 UriHandler::process( parentWidget(), n );
111 bool KOEventViewer::appendIncidence(
Incidence *incidence,
const TQDate &date )
113 addText( IncidenceFormatter::extensiveDisplayStr( mCalendar, incidence, date ) );
119 mCalendar = calendar;
126 appendIncidence( incidence, date );
127 mIncidence = incidence;
137 if ( now ) setText( mDefaultText );
142 mText.append( text );
151 void KOEventViewer::changeIncidenceDisplay(
Incidence *incidence,
const TQDate &date,
int action )
153 if ( mIncidence && ( incidence->
uid() == mIncidence->
uid() ) ) {
155 case KOGlobals::INCIDENCEEDITED:
158 case KOGlobals::INCIDENCEDELETED:
165 void KOEventViewer::contentsContextMenuEvent( TQContextMenuEvent *e )
167 TQString name = UriHandler::attachmentNameFromUri( mAttachLink );
168 TQString uid = UriHandler::uidFromUri( mAttachLink );
169 if ( name.isEmpty() || uid.isEmpty() ) {
170 TQTextBrowser::contentsContextMenuEvent( e );
174 TDEPopupMenu *menu =
new TDEPopupMenu();
175 menu->insertItem( i18n(
"Open Attachment" ), 0 );
176 menu->insertItem( i18n(
"Save Attachment As..." ), 1 );
178 switch( menu->exec( TQCursor::pos(), 0 ) ) {
180 AttachmentHandler::view( parentWidget(), name, uid );
183 AttachmentHandler::saveAs( parentWidget(), name, uid );
190 #include "koeventviewer.moc"
void setIncidence(Incidence *incidence, const TQDate &date)
Show given incidence in viewer.
void clearEvents(bool now=false)
Clear viewer.
void setCalendar(Calendar *calendar)
Set the Calendar associated with this viewer.
void setSource(const TQString &)
Reimplemented from TQTextBrowser to handle links.
void setDefaultText(const TQString &text)
Set the default text that is showed when there aren't a incidence to show.
void addText(const TQString &text)
Add given text to currently shown content.