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

kontact

  • sources
  • kde-4.12
  • kdepim
  • kontact
  • plugins
  • knotes
knotes/summarywidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "summarywidget.h"
26 #include "knotes_plugin.h"
27 
28 #include <KCal/CalendarLocal>
29 
30 #include <KontactInterface/Core>
31 #include <KontactInterface/Plugin>
32 
33 #include <KIconLoader>
34 #include <KLocale>
35 #include <KUrlLabel>
36 
37 #include <QEvent>
38 #include <QGridLayout>
39 #include <QLabel>
40 #include <QVBoxLayout>
41 
42 KNotesSummaryWidget::KNotesSummaryWidget(KCal::CalendarLocal *calendar, KNotesPlugin *plugin, QWidget *parent )
43  : KontactInterface::Summary( parent ),
44  mLayout( 0 ),
45  mPlugin( plugin ),
46  mCalendar(calendar)
47 {
48  QVBoxLayout *mainLayout = new QVBoxLayout( this );
49  mainLayout->setSpacing( 3 );
50  mainLayout->setMargin( 3 );
51 
52  QWidget *header = createHeader( this, QLatin1String("view-pim-notes"), i18n( "Popup Notes" ) );
53  mainLayout->addWidget( header );
54 
55  mLayout = new QGridLayout();
56  mainLayout->addItem( mLayout );
57  mLayout->setSpacing( 3 );
58  mLayout->setRowStretch( 6, 1 );
59 
60  KIconLoader loader( QLatin1String("knotes") );
61 
62  mPixmap = loader.loadIcon( QLatin1String("knotes"), KIconLoader::Small );
63  updateView();
64 }
65 
66 KNotesSummaryWidget::~KNotesSummaryWidget()
67 {
68 }
69 
70 void KNotesSummaryWidget::updateSummary( bool force )
71 {
72  Q_UNUSED( force );
73  updateView();
74 }
75 
76 void KNotesSummaryWidget::updateView()
77 {
78  const Journal::List notes = mCalendar->journals();
79  QLabel *label = 0;
80 
81  Q_FOREACH ( label, mLabels ) {
82  label->deleteLater();
83  }
84  mLabels.clear();
85  Journal::List::ConstIterator it;
86  Journal::List::ConstIterator end(notes.constEnd());
87  if ( notes.count() ) {
88  int counter = 0;
89  for ( it = notes.constBegin(); it != end; ++it ) {
90 
91  // Fill Note Pixmap Field
92  label = new QLabel( this );
93  label->setPixmap( mPixmap );
94  label->setMaximumWidth( label->minimumSizeHint().width() );
95  label->setAlignment( Qt::AlignVCenter );
96  mLayout->addWidget( label, counter, 0 );
97  mLabels.append( label );
98 
99  // File Note Summary Field
100  const QString newtext = (*it)->summary();
101 
102  KUrlLabel *urlLabel = new KUrlLabel( (*it)->uid(), newtext, this );
103  urlLabel->installEventFilter( this );
104  urlLabel->setTextFormat( Qt::RichText );
105  urlLabel->setAlignment( Qt::AlignLeft );
106  urlLabel->setWordWrap( true );
107  mLayout->addWidget( urlLabel, counter, 1 );
108  mLabels.append( urlLabel );
109 
110  if ( !(*it)->description().isEmpty() ) {
111  urlLabel->setToolTip( (*it)->description() );
112  }
113 
114  connect( urlLabel, SIGNAL(leftClickedUrl(QString)),
115  this, SLOT(urlClicked(QString)) );
116  ++counter;
117  }
118 
119  } else {
120  QLabel *noNotes = new QLabel( i18n( "No Notes Available" ), this );
121  noNotes->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
122  mLayout->addWidget( noNotes, 0, 0 );
123  mLabels.append( noNotes );
124  }
125 
126  Q_FOREACH ( label, mLabels ) { //krazy:exclude=foreach as label is a pointer
127  label->show();
128  }
129 }
130 
131 void KNotesSummaryWidget::urlClicked( const QString &/*uid*/ )
132 {
133  if ( !mPlugin->isRunningStandalone() ) {
134  mPlugin->core()->selectPlugin( mPlugin );
135  } else {
136  mPlugin->bringToForeground();
137  }
138 }
139 
140 bool KNotesSummaryWidget::eventFilter( QObject *obj, QEvent *e )
141 {
142  if ( obj->inherits( "KUrlLabel" ) ) {
143  KUrlLabel* label = static_cast<KUrlLabel*>( obj );
144  if ( e->type() == QEvent::Enter ) {
145  emit message( i18n( "Read Popup Note: \"%1\"", label->text() ) );
146  } else if ( e->type() == QEvent::Leave ) {
147  emit message( QString::null ); //krazy:exclude=nullstrassign for old broken gcc
148  }
149  }
150 
151  return KontactInterface::Summary::eventFilter( obj, e );
152 }
153 
154 #include "summarywidget.moc"
QWidget
KNotesSummaryWidget::urlClicked
void urlClicked(const QString &)
Definition: knotes/summarywidget.cpp:131
QObject
KNotesSummaryWidget::KNotesSummaryWidget
KNotesSummaryWidget(KCal::CalendarLocal *calendar, KNotesPlugin *plugin, QWidget *parent)
Definition: knotes/summarywidget.cpp:42
knotes_plugin.h
KNotesPlugin::isRunningStandalone
bool isRunningStandalone() const
Definition: knotes_plugin.cpp:98
KNotesPlugin
Definition: knotes_plugin.h:47
KNotesSummaryWidget::eventFilter
virtual bool eventFilter(QObject *obj, QEvent *e)
Definition: knotes/summarywidget.cpp:140
QLabel
KNotesSummaryWidget::~KNotesSummaryWidget
~KNotesSummaryWidget()
Definition: knotes/summarywidget.cpp:66
KNotesSummaryWidget::updateSummary
void updateSummary(bool force=false)
Definition: knotes/summarywidget.cpp:70
KNotesSummaryWidget::updateView
void updateView()
Definition: knotes/summarywidget.cpp:76
summarywidget.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:30 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal