|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Handles saving and opening activites. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "msgactivityhandler.h" |
|
20 |
|
21 #include "msgviewmanager.h" |
|
22 #include "msgbaseview.h" |
|
23 #include "msgmainwindow.h" |
|
24 #include <hbapplication.h> |
|
25 #include <hbactivitymanager.h> |
|
26 #include <QVariantHash> |
|
27 |
|
28 // Activity Names |
|
29 const QString ListViewActivityName("MsgConversationsList"); |
|
30 |
|
31 //----------------------------------------------------------------------------- |
|
32 // MsgActivityHandler::MsgActivityHandler |
|
33 // Constructor |
|
34 //----------------------------------------------------------------------------- |
|
35 MsgActivityHandler::MsgActivityHandler(QObject* parent): |
|
36 QObject(parent) |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 //----------------------------------------------------------------------------- |
|
42 // MsgActivityHandler::MsgActivityHandler |
|
43 // Destructor |
|
44 //----------------------------------------------------------------------------- |
|
45 MsgActivityHandler::~MsgActivityHandler() |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 //----------------------------------------------------------------------------- |
|
51 // MsgActivityHandler::saveActivity |
|
52 // @see header |
|
53 //----------------------------------------------------------------------------- |
|
54 void MsgActivityHandler::saveActivity() |
|
55 { |
|
56 HbActivityManager* activityManager = |
|
57 qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
58 |
|
59 if( mMainWindow->viewManager()->currentView()== MsgBaseView::CLV) |
|
60 { |
|
61 // get a screenshot for saving to the activity manager |
|
62 QVariantHash metadata; |
|
63 metadata.insert("screenshot", |
|
64 QPixmap::grabWidget(mMainWindow, mMainWindow->rect())); |
|
65 |
|
66 // save any data necessary to save the state |
|
67 QByteArray serializedActivity; |
|
68 QDataStream stream(&serializedActivity, |
|
69 QIODevice::WriteOnly | QIODevice::Append); |
|
70 stream << ListViewActivityName; |
|
71 |
|
72 // add the activity to the activity manager |
|
73 bool ok = activityManager->addActivity(ListViewActivityName, |
|
74 serializedActivity, metadata); |
|
75 } |
|
76 } |
|
77 |
|
78 //----------------------------------------------------------------------------- |
|
79 // MsgActivityHandler::handleActivity |
|
80 // @see header |
|
81 //----------------------------------------------------------------------------- |
|
82 void MsgActivityHandler::handleActivity(const QVariant &activityData) |
|
83 { |
|
84 // To be handled later |
|
85 Q_UNUSED(activityData) |
|
86 } |
|
87 |
|
88 //----------------------------------------------------------------------------- |
|
89 // MsgActivityHandler::clearActivities |
|
90 // @see header |
|
91 //----------------------------------------------------------------------------- |
|
92 void MsgActivityHandler::clearActivities() |
|
93 { |
|
94 HbActivityManager* activityManager = |
|
95 qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
96 activityManager->removeActivity(ListViewActivityName); |
|
97 } |
|
98 |
|
99 //----------------------------------------------------------------------------- |
|
100 // MsgActivityHandler::setMainWindow |
|
101 // @see header |
|
102 //----------------------------------------------------------------------------- |
|
103 void MsgActivityHandler::setMainWindow(MsgMainWindow* mainWindow) |
|
104 { |
|
105 mMainWindow = mainWindow; |
|
106 } |