/[packages]/cauldron/kdepim4/current/SOURCES/kdepim-4.3.2-kmail-nepomuk.patch
ViewVC logotype

Contents of /cauldron/kdepim4/current/SOURCES/kdepim-4.3.2-kmail-nepomuk.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1436 - (show annotations) (download)
Sat Jan 8 23:30:56 2011 UTC (13 years, 3 months ago) by dmorgan
File size: 31965 byte(s)
imported package kdepim4
1 Index: kmail/proxyobject.h
2 ===================================================================
3 --- kmail/proxyobject.h (revision 0)
4 +++ kmail/proxyobject.h (revision 0)
5 @@ -0,0 +1,21 @@
6 +#ifndef _PROXYOBJECT_H_
7 +#define _PROXYOBJECT_H_
8 +
9 +#include <QObject>
10 +
11 +class proxyObject : public QObject
12 +{
13 + Q_OBJECT
14 + unsigned long msgSerNum;
15 +
16 +public:
17 + proxyObject( unsigned long serNum, QObject* parent = 0 ) :
18 + QObject( parent ), msgSerNum( serNum)
19 + {
20 + }
21 +
22 +public slots:
23 + void Proxy();
24 +};
25 +
26 +#endif
27 Index: kmail/messageactions.h
28 ===================================================================
29 --- kmail/messageactions.h (revision 1129091)
30 +++ kmail/messageactions.h (working copy)
31 @@ -34,6 +34,9 @@
32 class KMMessage;
33 class KXMLGUIClient;
34
35 +namespace Nepomuk {
36 +class AnnotationMenu;
37 +}
38 namespace KMail {
39
40 /**
41 @@ -44,6 +47,7 @@
42 Q_OBJECT
43 public:
44 MessageActions( KActionCollection* ac, QWidget *parent );
45 + ~MessageActions();
46 void setMessageView( KMReaderWin *msgView );
47
48 /**
49 @@ -76,6 +80,8 @@
50
51 KActionMenu* mailingListActionMenu() const { return mMailingListActionMenu; }
52
53 + KActionMenu* annotationActionMenu() const { return mAnnotationActionMenu; }
54 +
55 public slots:
56 void editCurrentMessage();
57
58 @@ -126,6 +132,8 @@
59 KToggleAction *mToggleFlagAction, *mToggleToActAction;
60 KAction *mEditAction;
61 bool mKorganizerIsOnSystem;
62 + Nepomuk::AnnotationMenu* mAnnotationMenu;
63 + KActionMenu* mAnnotationActionMenu;
64 };
65
66 }
67 Index: kmail/messagelistview/widget.cpp
68 ===================================================================
69 --- kmail/messagelistview/widget.cpp (revision 1129091)
70 +++ kmail/messagelistview/widget.cpp (working copy)
71 @@ -688,6 +688,10 @@
72
73 menu.addAction( mMainWidget->messageActions()->createTodoAction() );
74
75 + menu.addSeparator();
76 +
77 + menu.addAction( mMainWidget->messageActions()->annotationActionMenu() );
78 +
79 KAcceleratorManager::manage( &menu );
80 kmkernel->setContextMenuShown( true );
81 menu.exec( globalPos );
82 Index: kmail/kmmessage.h
83 ===================================================================
84 --- kmail/kmmessage.h (revision 1129091)
85 +++ kmail/kmmessage.h (working copy)
86 @@ -51,7 +51,9 @@
87 namespace KMail {
88 }
89
90 -
91 +namespace Nepomuk {
92 + class Resource;
93 +}
94 // Real code starts here :)
95
96 namespace KMail {
97 @@ -841,6 +843,11 @@
98
99 DwBodyPart* findPart( int index );
100
101 + /**
102 + * Create a Nepomuk resource representing the message.
103 + */
104 + Nepomuk::Resource nepomukResource() const;
105 +
106 private:
107
108 /** Initialization shared by the ctors. */
109 Index: kmail/kmreadermainwin.cpp
110 ===================================================================
111 --- kmail/kmreadermainwin.cpp (revision 1129091)
112 +++ kmail/kmreadermainwin.cpp (working copy)
113 @@ -56,6 +56,9 @@
114 #include <akonadi/contact/contactsearchjob.h>
115 #include <kpimutils/email.h>
116
117 +#include <nepomuk/resource.h>
118 +#include <nepomuk/annotationmenu.h>
119 +
120 KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool htmlLoadExtOverride,
121 char *name )
122 : KMail::SecondaryWindow( name ? name : "readerwindow#" ),
123 @@ -459,6 +462,8 @@
124 menu->addAction( mSaveAtmAction );
125 menu->addSeparator();
126 menu->addAction( mMsgActions->createTodoAction() );
127 + menu->addSeparator();
128 + menu->addAction( mMsgActions->annotationActionMenu() );
129 }
130 menu->exec( aPoint, 0 );
131 delete menu;
132 Index: kmail/kmreaderwin.cpp
133 ===================================================================
134 --- kmail/kmreaderwin.cpp (revision 1129091)
135 +++ kmail/kmreaderwin.cpp (working copy)
136 @@ -161,6 +161,12 @@
137 #include <QTextDocument>
138 #endif
139
140 +#include "nepomukwidget.h"
141 +#include "annotationwidget.h"
142 +#include <nepomuk/resourcemanager.h>
143 +#include <nepomuk/variant.h>
144 +#include <QCheckBox>
145 +
146 using namespace KMail;
147
148 // This function returns the complete data that were in this
149 @@ -348,9 +354,9 @@
150
151
152
153 +#include <nepomuk/resourceeditor.h>
154 +#include <nepomuk/thing.h>
155
156 -
157 -
158 void KMReaderWin::createWidgets() {
159 QVBoxLayout * vlay = new QVBoxLayout( this );
160 vlay->setMargin( 0 );
161 @@ -367,8 +373,22 @@
162 mColorBar->setObjectName( "mColorBar" );
163 connect( mColorBar, SIGNAL( clicked() ),
164 this, SLOT( slotToggleHtmlMode() ) );
165 - mViewer = new KHTMLPart( mBox );
166 + KVBox* viewerBox = new KVBox(mBox);
167 + QSplitter* viewerSplitter = new QSplitter(viewerBox);
168 + mViewer = new KHTMLPart(viewerSplitter);
169 mViewer->setObjectName( "mViewer" );
170 + m_annotationWidget = new AnnotationWidget;
171 + viewerSplitter->addWidget(mViewer->widget());
172 + viewerSplitter->addWidget(m_annotationWidget);
173 + viewerSplitter->setStretchFactor(0, 2);
174 +
175 + connect(m_annotationWidget, SIGNAL(newAnnotation(Nepomuk::Annotation*)), m_annotationWidget, SLOT(show()));
176 + // m_annotationWidget->hide();
177 + m_nepomukWidget = new NepomukWidget( viewerBox );
178 + m_nepomukWidget->setKMReaderWin( this );
179 + viewerBox->setStretchFactor(viewerSplitter, 1);
180 + connect(m_nepomukWidget, SIGNAL(changed()), this, SLOT(slotNepomukDataChanged()));
181 + connect(m_annotationWidget, SIGNAL(annotationCreated()), this, SLOT(slotNepomukDataChanged()));
182 // Remove the shortcut for the selectAll action from khtml part. It's redefined to
183 // CTRL-SHIFT-A in kmail and clashes with kmails CTRL-A action.
184 KAction *selectAll = qobject_cast<KAction*>(
185 @@ -1210,6 +1230,7 @@
186 //-----------------------------------------------------------------------------
187 void KMReaderWin::setMsg( KMMessage* aMsg, bool force )
188 {
189 + kDebug() << aMsg << force;
190 if ( aMsg ) {
191 kDebug() << "(" << aMsg->getMsgSerNum() <<", last" << mLastSerNum <<")" << aMsg->subject()
192 << aMsg->fromStrip() << ", readyToShow" << (aMsg->readyToShow());
193 @@ -1289,6 +1310,18 @@
194 }
195 }
196
197 + if ( GlobalSettings::self()->showAnnotationControls() &&
198 + Nepomuk::ResourceManager::instance()->initialized() && aMsg ) {
199 + m_nepomukWidget->setResource( aMsg->nepomukResource().pimoThing() );
200 + m_annotationWidget->setResource( aMsg->nepomukResource().pimoThing(), aMsg->bodyToUnicode() );
201 + m_nepomukWidget->show();
202 + m_annotationWidget->show();
203 + }
204 + else {
205 + m_nepomukWidget->hide();
206 + m_annotationWidget->hide();
207 + }
208 +
209 if ( aMsg && (aMsg->status().isUnread() || aMsg->status().isNew())
210 && GlobalSettings::self()->delayedMarkAsRead() ) {
211 if ( GlobalSettings::self()->delayedMarkTime() != 0 )
212 @@ -3137,6 +3170,19 @@
213 mShowFullCcAddressList = showFullCcAddressList;
214 }
215
216 +void KMReaderWin::slotNepomukDataChanged()
217 +{
218 + Nepomuk::Resource res = message()->nepomukResource();
219 + if(res.label().isEmpty()) {
220 + res.setLabel(message()->subject());
221 + res.setProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent"), message()->bodyToUnicode());
222 + res.addType(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email"));
223 + res.addProperty(QUrl::fromEncoded("http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#messageId"), QString::number( message()->getMsgSerNum()));
224 + }
225 + // to update the tags
226 + m_nepomukWidget->setResource(res.pimoThing());
227 +}
228 +
229 #include "kmreaderwin.moc"
230
231
232 Index: kmail/kmmessage.cpp
233 ===================================================================
234 --- kmail/kmmessage.cpp (revision 1129091)
235 +++ kmail/kmmessage.cpp (working copy)
236 @@ -76,6 +76,21 @@
237 #include "util.h"
238 #endif
239
240 +#include <Nepomuk/Resource>
241 +#include <Nepomuk/Variant>
242 +
243 +Nepomuk::Resource KMMessage::nepomukResource() const
244 +{
245 + // This is an evil hack which should be fixed as soon as we are ported to Akonadi
246 + //QString id = "nepomuk:/emails/" + parent()->prettyUrl() + '/' + fileName();
247 +
248 + //This is a less-evil hack
249 + QString msgSerNum = QString::number( getMsgSerNum());
250 + Nepomuk::Resource mail("XYkmail_msg_" + msgSerNum);//, QUrl( nmoEmail) );
251 +
252 + return mail;
253 +}
254 +
255 using namespace KMail;
256 using namespace KMime;
257
258 Index: kmail/configuredialog_p.h
259 ===================================================================
260 --- kmail/configuredialog_p.h (revision 1129091)
261 +++ kmail/configuredialog_p.h (working copy)
262 @@ -464,6 +464,7 @@
263 QCheckBox *mShrinkQuotesCheck;
264 KComboBox *mCharsetCombo;
265 KComboBox *mOverrideCharsetCombo;
266 + QCheckBox *mShowAnnotations;
267 };
268
269
270 Index: kmail/messageactions.cpp
271 ===================================================================
272 --- kmail/messageactions.cpp (revision 1129091)
273 +++ kmail/messageactions.cpp (working copy)
274 @@ -38,6 +38,9 @@
275 #include <QVariant>
276 #include <qwidget.h>
277
278 +#include <nepomuk/annotationmenu.h>
279 +#include <nepomuk/resource.h>
280 +
281 using namespace KMail;
282
283 MessageActions::MessageActions( KActionCollection *ac, QWidget* parent ) :
284 @@ -185,9 +188,21 @@
285 this, SLOT(slotRunUrl(QAction *)) );
286 mActionCollection->addAction( "message_list", mMailingListActionMenu );
287
288 + mAnnotationMenu = new Nepomuk::AnnotationMenu();
289 + Nepomuk::AnnotationMenu::ConfigurationFlags flags = Nepomuk::AnnotationMenu::ShowAll|Nepomuk::AnnotationMenu::UseSubMenus;
290 + mAnnotationMenu->setConfigurationFlags( flags );
291 + mAnnotationActionMenu = new KActionMenu(KIcon("nepomuk"), i18nc("@title:menu Annotate message using Nepomuk", "Annotate"), this);
292 + mAnnotationActionMenu->setMenu( mAnnotationMenu );
293 + mActionCollection->addAction( "message_annotate", mAnnotationActionMenu );
294 +
295 updateActions();
296 }
297
298 +MessageActions::~MessageActions()
299 +{
300 + delete mAnnotationMenu;
301 +}
302 +
303 void MessageActions::setCurrentMessage(KMMessage * msg)
304 {
305 mCurrentMessage = msg;
306 @@ -284,6 +299,7 @@
307 } else {
308 mMailingListActionMenu->setEnabled( false );
309 }
310 + mAnnotationMenu->setResource( mCurrentMessage->nepomukResource() );
311 }
312
313 mEditAction->setEnabled( singleMsg );
314 Index: kmail/kmcommands.cpp
315 ===================================================================
316 --- kmail/kmcommands.cpp (revision 1129091)
317 +++ kmail/kmcommands.cpp (working copy)
318 @@ -141,7 +141,10 @@
319 #include <QList>
320 #include <QTextCodec>
321 #include <QProgressBar>
322 +#include <QDBusInterface>
323
324 +#include <Nepomuk/Resource>
325 +
326 #include <memory>
327
328 #include "messagelistview/pane.h"
329 @@ -258,8 +261,8 @@
330 if ( mMsgList.size() > 0 )
331 mb = *(mMsgList.begin());
332
333 - if ( ( mb ) && ( mMsgList.count() == 1 ) && ( mb->isMessage() ) &&
334 - ( mb->parent() == 0 ) )
335 + if ( ( mb ) && ( mMsgList.count() == 1 )
336 + && ( mb->isMessage() ) && ( mb->parent() == 0 ) )
337 {
338 // Special case of operating on message that isn't in a folder
339 mRetrievedMsgs.append((KMMessage*)mMsgList.takeFirst());
340 @@ -1018,6 +1021,16 @@
341 setDeletesItself( true );
342 }
343
344 +KMOpenMsgCommand2::KMOpenMsgCommand2( QWidget *parent, KMMsgBase* message,
345 + const QString & encoding )
346 + : KMCommand( parent, message ),
347 + mMsgBase( message ),
348 + mEncoding( encoding )
349 +{
350 + Q_ASSERT(message != NULL );
351 + setDeletesItself( false );
352 +}
353 +
354 KMCommand::Result KMOpenMsgCommand::execute()
355 {
356 if ( mUrl.isEmpty() ) {
357 @@ -1038,6 +1051,20 @@
358 return OK;
359 }
360
361 +KMCommand::Result KMOpenMsgCommand2::execute()
362 +{
363 + KMReaderMainWin *win = new KMReaderMainWin();
364 + KMMessage* msg = new KMMessage (*retrievedMessage() );
365 + msg->setReadyToShow( true );
366 + Q_ASSERT( msg != NULL );
367 + win->showMsg( mEncoding, msg);
368 +
369 + win->show();
370 +
371 + setResult( OK );
372 + return OK;
373 +}
374 +
375 void KMOpenMsgCommand::slotDataArrived( KIO::Job *, const QByteArray & data )
376 {
377 if ( data.isEmpty() )
378 @@ -2192,6 +2219,9 @@
379 }
380 bool undo = msg->enableUndo();
381
382 + // remember nepomuk resource for update later on
383 + QUrl oldNepomukUri = msg->nepomukResource().resourceUri();
384 +
385 if ( msg->transferInProgress() &&
386 srcFolder->folderType() == KMFolderTypeImap )
387 {
388 @@ -2227,6 +2257,11 @@
389 undoId = kmkernel->undoStack()->newUndoAction( srcFolder, mDestFolder );
390 kmkernel->undoStack()->addMsgToAction( undoId, mb->getMsgSerNum() );
391 }
392 +
393 + // update Nepomuk data (we simply use the service to avoid code duplication)
394 + QUrl newNepomukUri = mDestFolder->getMsg( mDestFolder->count() - 1 )->nepomukResource().resourceUri();
395 + QDBusInterface("org.kde.nepomuk.services.nepomukfilewatch", "/nepomukfilewatch", "org.kde.nepomuk.FileWatch")
396 + .call("moveFileMetadata", QString::fromAscii(oldNepomukUri.toEncoded()), QString::fromAscii(newNepomukUri.toEncoded()));
397 } else if (rc != 0) {
398 // Something went wrong. Stop processing here, it is likely that the
399 // other moves would fail as well.
400 Index: kmail/kmkernel.cpp
401 ===================================================================
402 --- kmail/kmkernel.cpp (revision 1129091)
403 +++ kmail/kmkernel.cpp (working copy)
404 @@ -2,6 +2,8 @@
405
406 #include "kmkernel.h"
407
408 +#include "proxyobject.h"
409 +
410 #include <config-kmail.h>
411
412 #include "globalsettings.h"
413 @@ -96,6 +98,8 @@
414 #include <kmailadaptor.h>
415 #include "kmailinterface.h"
416
417 +#include <Nepomuk/ResourceManager>
418 +
419 #include "folderadaptor.h"
420 #include "groupware_types.h"
421 static bool s_askingToGoOnline = false;
422 @@ -182,6 +186,8 @@
423 connect( MailTransport::TransportManager::self(),
424 SIGNAL(transportRenamed(int,QString,QString)),
425 SLOT(transportRenamed(int,QString,QString)) );
426 +
427 + Nepomuk::ResourceManager::instance()->init();
428 }
429
430 KMKernel::~KMKernel ()
431 @@ -234,10 +240,12 @@
432 QString to, cc, bcc, subj, body;
433 QStringList customHeaders;
434 KUrl messageFile;
435 + unsigned long msgSerNum = 0;
436 KUrl::List attachURLs;
437 bool mailto = false;
438 bool checkMail = false;
439 bool viewOnly = false;
440 + bool viewOnlyId = false;
441 bool calledWithSession = false; // for ignoring '-session foo'
442
443 // process args:
444 @@ -321,6 +329,15 @@
445 }
446 }
447
448 + if (args->isSet( "viewid" ) ) {
449 + viewOnlyId = true;
450 + const QString MsgSerNum = args->getOption( "viewid" );
451 + bool conv_ok;
452 + msgSerNum = MsgSerNum.toInt(&conv_ok);
453 + Q_ASSERT(conv_ok != false);
454 + //kDebug() << "MESSAGE SERIAL NUM:" << MsgSerNum;
455 + }
456 +
457 if ( !calledWithSession ) {
458 // only read additional command line arguments if kmail/kontact is
459 // not called with "-session foo"
460 @@ -361,7 +378,9 @@
461 if ( !noArgsOpensReader && !mailto && !checkMail && !viewOnly )
462 return false;
463
464 - if ( viewOnly )
465 + if ( viewOnlyId )
466 + viewMessage( msgSerNum );
467 + else if ( viewOnly )
468 viewMessage( messageFile );
469 else
470 action( mailto, checkMail, to, cc, bcc, subj, body, messageFile,
471 @@ -736,6 +755,14 @@
472 return 1;
473 }
474
475 +int KMKernel::viewMessage( unsigned long msgSerNum )
476 +{
477 + proxyObject* prox = new proxyObject(msgSerNum, this);
478 + QTimer::singleShot(2000, prox, SLOT( Proxy() ));
479 +
480 + return 1;
481 +}
482 +
483 int KMKernel::sendCertificate( const QString& to, const QByteArray& certData )
484 {
485 KMMessage *msg = new KMMessage;
486 Index: kmail/kmail_options.h
487 ===================================================================
488 --- kmail/kmail_options.h (revision 1129091)
489 +++ kmail/kmail_options.h (working copy)
490 @@ -22,6 +22,7 @@
491 options.add("check", ki18n("Only check for new mail"));
492 options.add("composer", ki18n("Only open composer window"));
493 options.add("view <url>", ki18n("View the given message file" ));
494 + options.add("viewid <msg id>", ki18n("View the given message corresponding to the kmail id" ));
495 options.add("+[address|URL]", ki18n("Send message to 'address' resp. "
496 "attach the file the 'URL' points "
497 "to"));
498 Index: kmail/kmmainwidget.cpp
499 ===================================================================
500 --- kmail/kmmainwidget.cpp (revision 1129091)
501 +++ kmail/kmmainwidget.cpp (working copy)
502 @@ -3434,6 +3434,9 @@
503
504 menu->addSeparator();
505 menu->addAction( mMsgActions->createTodoAction() );
506 +
507 + menu->addSeparator();
508 + menu->addAction( mMsgActions->annotationActionMenu() );
509 }
510 KAcceleratorManager::manage(menu);
511 menu->exec( aPoint, 0 );
512 Index: kmail/annotationwidget.h
513 ===================================================================
514 --- kmail/annotationwidget.h (revision 0)
515 +++ kmail/annotationwidget.h (revision 0)
516 @@ -0,0 +1,61 @@
517 +/*
518 + This file is part of KMail, the KDE mail client.
519 + Copyright (c) 2009 Sebastian Trueg <trueg@kde.org>
520 +
521 + This program is free software; you can redistribute it and/or modify
522 + it under the terms of the GNU General Public License as published by
523 + the Free Software Foundation; either version 2 of the License, or
524 + (at your option) any later version.
525 +
526 + This program is distributed in the hope that it will be useful,
527 + but WITHOUT ANY WARRANTY; without even the implied warranty of
528 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
529 + GNU General Public License for more details.
530 +
531 + You should have received a copy of the GNU General Public License along
532 + with this program; if not, write to the Free Software Foundation, Inc.,
533 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
534 +*/
535 +
536 +#ifndef _KMAIL_ANNOTATION_WIDGET_H_
537 +#define _KMAIL_ANNOTATION_WIDGET_H_
538 +
539 +#include <QtGui/QWidget>
540 +
541 +#include <Nepomuk/Resource>
542 +
543 +namespace Nepomuk {
544 + class ResourceAnnotationModel;
545 + class AnnotationRelevanceFilterModel;
546 + class Annotation;
547 +}
548 +class QListView;
549 +class QModelIndex;
550 +
551 +class AnnotationWidget : public QWidget
552 +{
553 + Q_OBJECT
554 +
555 +public:
556 + AnnotationWidget( QWidget* parent = 0 );
557 + ~AnnotationWidget();
558 +
559 + void setResource( const Nepomuk::Resource& res, const QString& content );
560 +
561 +protected:
562 + //virtual QSize sizeHint() const { return QSize(200, 300); }
563 +
564 +Q_SIGNALS:
565 + void newAnnotation( Nepomuk::Annotation* );
566 + void annotationCreated();
567 +
568 +private Q_SLOTS:
569 + void slotAnnotationExecuted( const QModelIndex& );
570 +
571 +private:
572 + Nepomuk::ResourceAnnotationModel* m_model;
573 + Nepomuk::AnnotationRelevanceFilterModel* m_filterModel;
574 + QListView* m_listView;
575 +};
576 +
577 +#endif
578 Index: kmail/kmail.kcfg.cmake
579 ===================================================================
580 --- kmail/kmail.kcfg.cmake (revision 1129091)
581 +++ kmail/kmail.kcfg.cmake (working copy)
582 @@ -303,6 +303,10 @@
583 <label>Hide local inbox if unused</label>
584 <default>true</default>
585 </entry>
586 + <entry name="ShowAnnotationControls" type="Bool">
587 + <label>Show Nepomuk annotations</label>
588 + <default>true</default>
589 + </entry>
590 </group>
591
592 <group name="Composer">
593 Index: kmail/kmcommands.h
594 ===================================================================
595 --- kmail/kmcommands.h (revision 1129091)
596 +++ kmail/kmcommands.h (working copy)
597 @@ -374,6 +374,23 @@
598 const QString mEncoding;
599 };
600
601 +class KMAIL_EXPORT KMOpenMsgCommand2 : public KMCommand
602 +{
603 + Q_OBJECT
604 +public:
605 + explicit KMOpenMsgCommand2( QWidget *parent, KMMsgBase* msgbase,
606 + const QString & encoding = QString() );
607 +private:
608 + virtual KMCommand::Result execute();
609 +
610 + // private slots:
611 + // void slotResult();
612 +
613 + private:
614 + KMMsgBase* mMsgBase;
615 + const QString mEncoding;
616 +};
617 +
618 class KMAIL_EXPORT KMSaveAttachmentsCommand : public KMCommand
619 {
620 Q_OBJECT
621 Index: kmail/kmreaderwin.h
622 ===================================================================
623 --- kmail/kmreaderwin.h (revision 1129091)
624 +++ kmail/kmreaderwin.h (working copy)
625 @@ -37,6 +37,9 @@
626
627 #include <map>
628
629 +class NepomukWidget;
630 +class AnnotationWidget;
631 +
632 class QSplitter;
633 class KHBox;
634 class QTreeWidgetItem;
635 @@ -97,6 +100,7 @@
636
637 friend class KMail::ObjectTreeParser;
638 friend class KMail::KHtmlPartHtmlWriter;
639 + //friend class NepomukWidget; //MINE
640
641 public:
642 KMReaderWin( QWidget *parent, QWidget *mainWindow,
643 @@ -557,6 +561,7 @@
644 private slots:
645 void slotSetEncoding();
646 void injectAttachments();
647 + void slotNepomukDataChanged();
648
649 /** Show hide all fields specified inside this function */
650 void toggleFullAddressList();
651 @@ -653,6 +658,8 @@
652 bool mExternalWindow;
653 bool mShowFullToAddressList;
654 bool mShowFullCcAddressList;
655 + NepomukWidget* m_nepomukWidget;
656 + AnnotationWidget* m_annotationWidget;
657 };
658
659
660 Index: kmail/configuredialog.cpp
661 ===================================================================
662 --- kmail/configuredialog.cpp (revision 1129091)
663 +++ kmail/configuredialog.cpp (working copy)
664 @@ -1922,6 +1922,12 @@
665 hlay2->addWidget( label );
666 hlay2->addWidget( mOverrideCharsetCombo );
667
668 + populateCheckBox( mShowAnnotations = new QCheckBox( this ),
669 + GlobalSettings::self()->showAnnotationControlsItem() );
670 + vlay->addWidget( mShowAnnotations );
671 + connect( mShowAnnotations, SIGNAL ( stateChanged( int ) ),
672 + this, SLOT( slotEmitChanged() ) );
673 +
674 vlay->addStretch( 100 ); // spacer
675 }
676
677 @@ -1988,6 +1994,7 @@
678 mShrinkQuotesCheck->setChecked( GlobalSettings::self()->shrinkQuotes() );
679 mShowExpandQuotesMark->setChecked( GlobalSettings::self()->showExpandQuotesMark() );
680 mCollapseQuoteLevelSpin->setValue( GlobalSettings::self()->collapseQuoteLevelSpin() );
681 + mShowAnnotations->setChecked( GlobalSettings::self()->showAnnotationControls() );
682 readCurrentFallbackCodec();
683 readCurrentOverrideCodec();
684 }
685 @@ -2014,6 +2021,7 @@
686 mOverrideCharsetCombo->currentIndex() == 0 ?
687 QString() :
688 KMMsgBase::encodingForName( mOverrideCharsetCombo->currentText() ) );
689 + GlobalSettings::self()->setShowAnnotationControls( mShowAnnotations->isChecked() );
690 }
691
692 QString AppearancePage::SystemTrayTab::helpAnchor() const
693 Index: kmail/proxyobject.cpp
694 ===================================================================
695 --- kmail/proxyobject.cpp (revision 0)
696 +++ kmail/proxyobject.cpp (revision 0)
697 @@ -0,0 +1,25 @@
698 +#include "proxyobject.h"
699 +#include "kmmsgbase.h"
700 +#include "kmmsgdict.h"
701 +#include "kmcommands.h"
702 +#include "kmfolder.h"
703 +
704 +void proxyObject::Proxy()
705 +{
706 + KMFolder* folder;
707 + KMMsgBase* msgbase;
708 + int index;
709 +
710 + KMMsgDict::instance()->getLocation( msgSerNum, &folder, &index );
711 + if ( folder != NULL && index != -1 ) {
712 + kFatal("msg serial number not found ; the serial number provided may incorrect");
713 + }
714 + folder->open("viewid");
715 + msgbase = folder->getMsgBase( index );
716 + Q_ASSERT( msgbase != NULL );
717 +
718 + KMOpenMsgCommand2 *openCommand = new KMOpenMsgCommand2( 0, msgbase );
719 + openCommand->start();
720 +}
721 +
722 +#include "proxyobject.moc"
723 Index: kmail/kmkernel.h
724 ===================================================================
725 --- kmail/kmkernel.h (revision 1129091)
726 +++ kmail/kmkernel.h (working copy)
727 @@ -14,6 +14,7 @@
728 #include <kconfig.h>
729 #include <kurl.h>
730
731 +#include "kmmsgbase.h"
732 #include "kmail_export.h"
733 #include "kmmsgbase.h"
734 #include "kmmessagetag.h"
735 @@ -233,6 +234,7 @@
736 Q_SCRIPTABLE QString debugSernum( quint32 serialNumber );
737
738 Q_SCRIPTABLE int viewMessage( const KUrl & messageFile );
739 + Q_SCRIPTABLE int viewMessage( unsigned long msgSerNum );
740
741 Q_SIGNALS:
742
743 Index: kmail/nepomukwidget.cpp
744 ===================================================================
745 --- kmail/nepomukwidget.cpp (revision 0)
746 +++ kmail/nepomukwidget.cpp (revision 0)
747 @@ -0,0 +1,102 @@
748 +/*
749 + This file is part of KMail, the KDE mail client.
750 + Copyright (c) 2009 Sebastian Trueg <trueg@kde.org>
751 +
752 + This program is free software; you can redistribute it and/or modify
753 + it under the terms of the GNU General Public License as published by
754 + the Free Software Foundation; either version 2 of the License, or
755 + (at your option) any later version.
756 +
757 + This program is distributed in the hope that it will be useful,
758 + but WITHOUT ANY WARRANTY; without even the implied warranty of
759 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
760 + GNU General Public License for more details.
761 +
762 + You should have received a copy of the GNU General Public License along
763 + with this program; if not, write to the Free Software Foundation, Inc.,
764 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
765 +*/
766 +
767 +#include "nepomukwidget.h"
768 +
769 +#include "kmreaderwin.h"
770 +#include "kmmessage.h"
771 +
772 +#include <nepomuk/annotationwidget.h>
773 +#include <nepomuk/kmetadatatagwidget.h>
774 +#include <nepomuk/kratingwidget.h>
775 +#include <nepomuk/annotationmenu.h>
776 +
777 +#include <QHBoxLayout>
778 +#include <QLabel>
779 +#include <KIcon>
780 +#include <KMessageBox>
781 +#include <QPushButton>
782 +#include <KLocale>
783 +
784 +#include <Nepomuk/Resource>
785 +#include <Nepomuk/Variant>
786 +#include <Nepomuk/Thing>
787 +
788 +#include <KDebug>
789 +
790 +NepomukWidget::NepomukWidget( QWidget* parent )
791 + : QWidget( parent )
792 +{
793 + QHBoxLayout* lay = new QHBoxLayout(this);
794 + m_tagWidget = new Nepomuk::TagWidget(this);
795 + m_ratingWidget = new KRatingWidget(this);
796 + m_annotationWidget = new Nepomuk::AnnotationWidget(this);
797 + m_tasksButton = new QPushButton( i18n("More..."), this );
798 +
799 + lay->addWidget(m_tagWidget);
800 + lay->addWidget(m_ratingWidget);
801 + lay->addWidget(m_tasksButton);
802 + lay->addWidget(m_annotationWidget);
803 +
804 + m_tagWidget->setModeFlags( Nepomuk::TagWidget::MiniMode|Nepomuk::TagWidget::DisableTagClicking );
805 +
806 + connect( m_ratingWidget, SIGNAL( ratingChanged( int ) ),
807 + this, SLOT( slotRatingChanged( int ) ) );
808 + connect( m_annotationWidget, SIGNAL(annotationAdded(Nepomuk::Resource)),
809 + this, SIGNAL(changed()));
810 +
811 + connect( m_tasksButton, SIGNAL( clicked( bool )),
812 + this, SLOT( associateToATask() ));
813 +}
814 +
815 +NepomukWidget::~NepomukWidget()
816 +{
817 +}
818 +
819 +void NepomukWidget::setKMReaderWin( KMReaderWin* kmreaderwin)
820 +{
821 + m_kmreaderwin = kmreaderwin;
822 +}
823 +
824 +void NepomukWidget::associateToATask()
825 +{
826 + Nepomuk::AnnotationMenu menu;
827 + Nepomuk::AnnotationMenu::ConfigurationFlags flags = Nepomuk::AnnotationMenu::ShowAll|Nepomuk::AnnotationMenu::UseSubMenus;
828 + flags &= ~Nepomuk::AnnotationMenu::ShowRatingAction;
829 + flags &= ~Nepomuk::AnnotationMenu::ShowTagActions;
830 + menu.setConfigurationFlags( flags );
831 + menu.setResource( m_resource );
832 + menu.exec( QCursor::pos() );
833 +}
834 +
835 +void NepomukWidget::setResource( const Nepomuk::Resource& res )
836 +{
837 + m_resource = res;
838 + m_tagWidget->setTaggedResource( res );
839 + m_annotationWidget->setResource( res );
840 + m_ratingWidget->setRating( res.rating() );
841 +}
842 +
843 +void NepomukWidget::slotRatingChanged(int rating)
844 +{
845 + m_resource.setRating(rating);
846 + emit changed();
847 +}
848 +
849 +#include "nepomukwidget.moc"
850 Index: kmail/nepomukwidget.h
851 ===================================================================
852 --- kmail/nepomukwidget.h (revision 0)
853 +++ kmail/nepomukwidget.h (revision 0)
854 @@ -0,0 +1,66 @@
855 +/*
856 + This file is part of KMail, the KDE mail client.
857 + Copyright (c) 2009 Sebastian Trueg <trueg@kde.org>
858 +
859 + This program is free software; you can redistribute it and/or modify
860 + it under the terms of the GNU General Public License as published by
861 + the Free Software Foundation; either version 2 of the License, or
862 + (at your option) any later version.
863 +
864 + This program is distributed in the hope that it will be useful,
865 + but WITHOUT ANY WARRANTY; without even the implied warranty of
866 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
867 + GNU General Public License for more details.
868 +
869 + You should have received a copy of the GNU General Public License along
870 + with this program; if not, write to the Free Software Foundation, Inc.,
871 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
872 +*/
873 +
874 +#ifndef _KMAIL_NEPOMUK_WIDGET_H_
875 +#define _KMAIL_NEPOMUK_WIDGET_H_
876 +
877 +#include <QtGui/QWidget>
878 +
879 +#include <Nepomuk/Resource>
880 +
881 +namespace Nepomuk {
882 + class AnnotationWidget;
883 + class TagWidget;
884 +}
885 +class KRatingWidget;
886 +class KMReaderWin;
887 +class QPushButton;
888 +
889 +class NepomukWidget : public QWidget
890 +{
891 + Q_OBJECT
892 +
893 +public:
894 + NepomukWidget( QWidget* parent = 0 );
895 + ~NepomukWidget();
896 +
897 + void setResource( const Nepomuk::Resource& res );
898 + void setKMReaderWin( KMReaderWin* );
899 +
900 +Q_SIGNALS:
901 + /**
902 + * Emitted if an annotation has been added or a rating changed
903 + * or whateever.
904 + */
905 + void changed();
906 +
907 +private Q_SLOTS:
908 + void slotRatingChanged(int);
909 + void associateToATask();
910 +
911 +private:
912 + Nepomuk::AnnotationWidget* m_annotationWidget;
913 + Nepomuk::TagWidget* m_tagWidget;
914 + KRatingWidget* m_ratingWidget;
915 + Nepomuk::Resource m_resource;
916 + KMReaderWin* m_kmreaderwin;
917 + QPushButton* m_tasksButton;
918 +};
919 +
920 +#endif
921 Index: kmail/CMakeLists.txt
922 ===================================================================
923 --- kmail/CMakeLists.txt (revision 1129091)
924 +++ kmail/CMakeLists.txt (working copy)
925 @@ -252,6 +252,9 @@
926 procmailparser.cpp
927 stringutil.cpp
928 iconnamecache.cpp
929 + nepomukwidget.cpp
930 + proxyobject.cpp
931 + annotationwidget.cpp
932 mdnadvicedialog.cpp
933 htmlquotecolorer.cpp
934 attachmentdialog.cpp
935 @@ -370,6 +373,7 @@
936 ${KDE4_KIMAP_LIBRARY}
937 ${KDE4_KPARTS_LIBRARY}
938 ${KDE4_KRESOURCES_LIBRARY}
939 + ${KDE4_KFILE_LIBS}
940 kleo
941 ${QGPGME_LIBRARIES}
942 mimelib
943 @@ -381,6 +385,11 @@
944 ${KDEPIMLIBS_KPIMUTILS_LIBS}
945 ${KDEPIMLIBS_KPIMTEXTEDIT_LIBS}
946 ${QT_QT3SUPPORT_LIBRARY}
947 + ${NEPOMUK_LIBRARIES}
948 + nepomukannotation
949 + nepomuk
950 + nepomukutils
951 + nepomuktasks
952 )
953
954 if(INDICATEQT_FOUND)
955 Index: kmail/annotationwidget.cpp
956 ===================================================================
957 --- kmail/annotationwidget.cpp (revision 0)
958 +++ kmail/annotationwidget.cpp (revision 0)
959 @@ -0,0 +1,79 @@
960 +/*
961 + This file is part of KMail, the KDE mail client.
962 + Copyright (c) 2009 Sebastian Trueg <trueg@kde.org>
963 +
964 + This program is free software; you can redistribute it and/or modify
965 + it under the terms of the GNU General Public License as published by
966 + the Free Software Foundation; either version 2 of the License, or
967 + (at your option) any later version.
968 +
969 + This program is distributed in the hope that it will be useful,
970 + but WITHOUT ANY WARRANTY; without even the implied warranty of
971 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
972 + GNU General Public License for more details.
973 +
974 + You should have received a copy of the GNU General Public License along
975 + with this program; if not, write to the Free Software Foundation, Inc.,
976 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
977 +*/
978 +
979 +#include "annotationwidget.h"
980 +
981 +#include <nepomuk/resourceannotationmodel.h>
982 +#include <nepomuk/annotationrelevancefiltermodel.h>
983 +#include <nepomuk/annotation.h>
984 +#include <nepomuk/resourcemanager.h>
985 +
986 +#include <QHBoxLayout>
987 +#include <QLabel>
988 +#include <QListView>
989 +#include <KDebug>
990 +
991 +#include <KLocale>
992 +
993 +Q_DECLARE_METATYPE(Nepomuk::Annotation*)
994 +
995 +AnnotationWidget::AnnotationWidget( QWidget* parent )
996 + : QWidget( parent )
997 +{
998 + QVBoxLayout* lay = new QVBoxLayout(this);
999 + m_listView = new QListView(this);
1000 + lay->addWidget(new QLabel(i18n("Suggestions:"), this));
1001 + lay->addWidget(m_listView);
1002 +
1003 + m_model = new Nepomuk::ResourceAnnotationModel(m_listView);
1004 + m_model->setAutoUpdate(false);
1005 + m_filterModel = new Nepomuk::AnnotationRelevanceFilterModel(m_model);
1006 + m_filterModel->setSourceModel(m_model);
1007 + m_filterModel->setSortRole(Nepomuk::AnnotationModel::RelevanceRole);
1008 + m_filterModel->setDynamicSortFilter(true);
1009 + m_listView->setModel(m_filterModel);
1010 +
1011 + connect(m_listView, SIGNAL(activated(QModelIndex)),
1012 + this, SLOT(slotAnnotationExecuted(QModelIndex)));
1013 +}
1014 +
1015 +
1016 +AnnotationWidget::~AnnotationWidget()
1017 +{
1018 +}
1019 +
1020 +
1021 +void AnnotationWidget::setResource( const Nepomuk::Resource& res, const QString& content )
1022 +{
1023 + m_model->setResource(res);
1024 + m_model->setContent(content);
1025 + m_filterModel->setFilterResource(res);
1026 + m_model->updateAnnotations();
1027 +}
1028 +
1029 +
1030 +void AnnotationWidget::slotAnnotationExecuted( const QModelIndex& index )
1031 +{
1032 + Nepomuk::Annotation* anno = index.data( Nepomuk::AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>();
1033 + connect(anno, SIGNAL(finished(Nepomuk::Annotation*)), this, SIGNAL(annotationCreated()));
1034 + connect(anno, SIGNAL(finished(Nepomuk::Annotation*)), anno, SLOT(deleteLater()));
1035 + anno->create(m_model->resource());
1036 +}
1037 +
1038 +#include "annotationwidget.moc"

  ViewVC Help
Powered by ViewVC 1.1.30