~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to examples/coisceim/coisceim-mobile/messageviewitem.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2010 Volker Krause <vkrause@kde.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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
 
17
    02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "messageviewitem.h"
 
21
 
 
22
#include <math.h>
 
23
 
 
24
#include <QtCore/QAbstractItemModel>
 
25
#include <QtGui/QApplication>
 
26
#include <QtGui/QGraphicsProxyWidget>
 
27
#include <QtGui/QGraphicsSceneMouseEvent>
 
28
 
 
29
#include <kdescendantsproxymodel.h>
 
30
 
 
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>
 
37
#include <KAction>
 
38
 
 
39
using namespace MessageViewer;
 
40
 
 
41
MessageViewItem::MessageViewItem( QDeclarativeItem* parent )
 
42
  : DeclarativeAkonadiItem( parent )
 
43
{
 
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 );
 
50
 
 
51
  KDescendantsProxyModel *flatProxy = new KDescendantsProxyModel( this );
 
52
  flatProxy->setSourceModel( m_viewer->messageTreeModel() );
 
53
 
 
54
//   m_attachmentProxy = new AttachmentProxyModel( this );
 
55
//   m_attachmentProxy->setSourceModel( flatProxy );
 
56
 
 
57
  connect( m_viewer, SIGNAL(urlClicked(Akonadi::Item,KUrl)), SIGNAL(urlClicked(Akonadi::Item,KUrl)) );
 
58
  connect( m_viewer, SIGNAL(itemRemoved()), SIGNAL(mailRemoved()) );
 
59
}
 
60
 
 
61
MessageViewItem::~MessageViewItem()
 
62
{
 
63
  delete m_viewer;
 
64
}
 
65
 
 
66
qint64 MessageViewItem::itemId() const
 
67
{
 
68
  return m_viewer->messageItem().id();
 
69
}
 
70
 
 
71
void MessageViewItem::setItemId( qint64 id )
 
72
{
 
73
  m_viewer->setMessageItem( Akonadi::Item( id ) );
 
74
}
 
75
 
 
76
void MessageViewItem::setItem( const Akonadi::Item &item )
 
77
{
 
78
  m_viewer->setMessageItem( item );
 
79
}
 
80
 
 
81
QString MessageViewItem::splashMessage() const
 
82
{
 
83
  return QString(); // TODO
 
84
}
 
85
 
 
86
void MessageViewItem::setSplashMessage(const QString& message)
 
87
{
 
88
  if ( message.isEmpty() )
 
89
    m_viewer->enableMessageDisplay();
 
90
  else
 
91
    m_viewer->displaySplashPage( message );
 
92
}
 
93
 
 
94
QString MessageViewItem::messagePath() const
 
95
{
 
96
  return m_viewer->messagePath();
 
97
}
 
98
 
 
99
void MessageViewItem::setMessagePath( const QString& messagePath )
 
100
{
 
101
  m_viewer->setMessagePath( messagePath );
 
102
}
 
103
 
 
104
QObject* MessageViewItem::attachmentModel() const
 
105
{
 
106
  return 0;
 
107
}
 
108
 
 
109
void MessageViewItem::scrollDown( int dist )
 
110
{
 
111
  m_viewer->slotScrollDown( dist );
 
112
}
 
113
 
 
114
 
 
115
void MessageViewItem::scrollUp( int dist )
 
116
{
 
117
  m_viewer->slotScrollUp( dist );
 
118
}
 
119
 
 
120
Viewer* MessageViewItem::viewer()
 
121
{
 
122
    return m_viewer;
 
123
}
 
124
 
 
125
void MessageViewItem::saveAllAttachments()
 
126
{
 
127
  m_viewer->slotAttachmentSaveAll();
 
128
}
 
129
 
 
130
void MessageViewItem::copyAllToClipboard()
 
131
{
 
132
  m_viewer->selectAll();
 
133
  m_viewer->copySelectionToClipboard();
 
134
  m_viewer->clearSelection();
 
135
}
 
136
 
 
137
 
 
138
#include "messageviewitem.moc"