27 #include <tqtooltip.h>
29 #include <dcopclient.h>
31 #include <tdeapplication.h>
33 #include <tdeglobal.h>
34 #include <kiconloader.h>
35 #include <tdelocale.h>
36 #include <kurllabel.h>
37 #include <kstandarddirs.h>
39 #include <knotes/resourcenotes.h>
40 #include <knotes/resourcemanager.h>
45 #include "summarywidget.h"
48 TQWidget *parent,
const char *name )
49 : Kontact::Summary( parent, name ), mLayout( 0 ), mPlugin( plugin )
51 TQVBoxLayout *mainLayout =
new TQVBoxLayout(
this, 3, 3 );
53 TQPixmap icon = TDEGlobal::iconLoader()->loadIcon(
"kontact_notes",
54 TDEIcon::Desktop, TDEIcon::SizeMedium );
55 TQWidget* header = createHeader(
this, icon, i18n(
"Notes" ) );
56 mainLayout->addWidget( header );
58 mLayout =
new TQGridLayout( mainLayout, 7, 3, 3 );
59 mLayout->setRowStretch( 6, 1 );
62 KNotesResourceManager *manager =
new KNotesResourceManager();
64 TQObject::connect( manager, TQ_SIGNAL( sigRegisteredNote(
KCal::Journal* ) ),
66 TQObject::connect( manager, TQ_SIGNAL( sigDeregisteredNote(
KCal::Journal* ) ),
74 void KNotesSummaryWidget::updateView()
76 mNotes = mCalendar->journals();
79 for ( label = mLabels.first(); label; label = mLabels.next() )
83 TDEIconLoader loader(
"knotes" );
86 TQPixmap pm = loader.loadIcon(
"knotes", TDEIcon::Small );
88 KCal::Journal::List::Iterator it;
89 if ( mNotes.count() ) {
90 for (it = mNotes.begin(); it != mNotes.end(); ++it) {
93 label =
new TQLabel(
this );
94 label->setPixmap( pm );
95 label->setMaximumWidth( label->minimumSizeHint().width() );
96 label->setAlignment( AlignVCenter );
97 mLayout->addWidget( label, counter, 0 );
98 mLabels.append( label );
101 TQString newtext = (*it)->summary();
103 KURLLabel *urlLabel =
new KURLLabel( (*it)->uid(), newtext,
this );
104 urlLabel->installEventFilter(
this );
105 urlLabel->setTextFormat(RichText);
106 urlLabel->setAlignment( urlLabel->alignment() | TQt::WordBreak );
107 mLayout->addWidget( urlLabel, counter, 1 );
108 mLabels.append( urlLabel );
110 if ( !(*it)->description().isEmpty() ) {
111 TQToolTip::add( urlLabel, (*it)->description().left( 80 ) );
114 connect( urlLabel, TQ_SIGNAL( leftClickedURL(
const TQString& ) ),
115 this, TQ_SLOT( urlClicked(
const TQString& ) ) );
120 TQLabel *noNotes =
new TQLabel( i18n(
"No Notes Available" ),
this );
121 noNotes->setAlignment( AlignHCenter | AlignVCenter );
122 mLayout->addWidget( noNotes, 0, 1 );
123 mLabels.append( noNotes );
126 for ( label = mLabels.first(); label; label = mLabels.next() )
130 void KNotesSummaryWidget::urlClicked(
const TQString & )
132 if ( !mPlugin->isRunningStandalone() )
133 mPlugin->core()->selectPlugin( mPlugin );
135 mPlugin->bringToForeground();
138 bool KNotesSummaryWidget::eventFilter( TQObject *obj, TQEvent* e )
140 if ( obj->inherits(
"KURLLabel" ) ) {
141 KURLLabel* label =
static_cast<KURLLabel*
>( obj );
142 if ( e->type() == TQEvent::Enter )
143 emit message( i18n(
"Read Note: \"%1\"" ).arg( label->text() ) );
144 if ( e->type() == TQEvent::Leave )
145 emit message( TQString() );
148 return Kontact::Summary::eventFilter( obj, e );
153 mCalendar->addJournal( j );
159 mCalendar->deleteJournal( j );
164 #include "summarywidget.moc"
Base class for all Plugins in Kontact.