2
Copyright (c) 2010 Volker Krause <vkrause@kde.org>
4
This library is free software; you can redistribute it and/or modify it
5
under the terms of the GNU Library General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or (at your
7
option) any later version.
9
This library is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12
License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to the
16
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
#include "messageviewitem.h"
24
#include <QtCore/QAbstractItemModel>
25
#include <QtGui/QApplication>
26
#include <QtGui/QGraphicsProxyWidget>
27
#include <QtGui/QGraphicsSceneMouseEvent>
29
#include <kdescendantsproxymodel.h>
31
#include <messageviewer/headerstyle.h>
32
#include <messageviewer/headerstrategy.h>
33
#include <messageviewer/mailwebview.h>
34
#include <messageviewer/markmessagereadhandler.h>
35
#include <messageviewer/viewer.h>
36
#include <messageviewer/viewer_p.h>
39
using namespace MessageViewer;
41
MessageViewItem::MessageViewItem( QDeclarativeItem* parent )
42
: DeclarativeAkonadiItem( parent )
44
m_viewer = new Viewer( 0 );
45
m_viewer->setHeaderStyleAndStrategy( HeaderStyle::mobile(), HeaderStrategy::all() );
46
m_viewer->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
47
m_viewer->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
48
m_viewer->addMessageLoadedHandler( new MessageViewer::MarkMessageReadHandler( this ) );
49
setWidget( m_viewer );
51
KDescendantsProxyModel *flatProxy = new KDescendantsProxyModel( this );
52
flatProxy->setSourceModel( m_viewer->messageTreeModel() );
54
// m_attachmentProxy = new AttachmentProxyModel( this );
55
// m_attachmentProxy->setSourceModel( flatProxy );
57
connect( m_viewer, SIGNAL(urlClicked(Akonadi::Item,KUrl)), SIGNAL(urlClicked(Akonadi::Item,KUrl)) );
58
connect( m_viewer, SIGNAL(itemRemoved()), SIGNAL(mailRemoved()) );
61
MessageViewItem::~MessageViewItem()
66
qint64 MessageViewItem::itemId() const
68
return m_viewer->messageItem().id();
71
void MessageViewItem::setItemId( qint64 id )
73
m_viewer->setMessageItem( Akonadi::Item( id ) );
76
void MessageViewItem::setItem( const Akonadi::Item &item )
78
m_viewer->setMessageItem( item );
81
QString MessageViewItem::splashMessage() const
83
return QString(); // TODO
86
void MessageViewItem::setSplashMessage(const QString& message)
88
if ( message.isEmpty() )
89
m_viewer->enableMessageDisplay();
91
m_viewer->displaySplashPage( message );
94
QString MessageViewItem::messagePath() const
96
return m_viewer->messagePath();
99
void MessageViewItem::setMessagePath( const QString& messagePath )
101
m_viewer->setMessagePath( messagePath );
104
QObject* MessageViewItem::attachmentModel() const
109
void MessageViewItem::scrollDown( int dist )
111
m_viewer->slotScrollDown( dist );
115
void MessageViewItem::scrollUp( int dist )
117
m_viewer->slotScrollUp( dist );
120
Viewer* MessageViewItem::viewer()
125
void MessageViewItem::saveAllAttachments()
127
m_viewer->slotAttachmentSaveAll();
130
void MessageViewItem::copyAllToClipboard()
132
m_viewer->selectAll();
133
m_viewer->copySelectionToClipboard();
134
m_viewer->clearSelection();
138
#include "messageviewitem.moc"