|
1 /* |
|
2 * Copyright (c) 2010 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 * The source file for messaging's audio fetcher view. |
|
16 * |
|
17 */ |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <hbaction.h> |
|
21 #include <hbtoolbar.h> |
|
22 |
|
23 // USER INCLUDES |
|
24 #include "msgaudiofetcherview.h" |
|
25 #include "msgaudiofetcherwidget.h" |
|
26 #include "convergedmessage.h" |
|
27 |
|
28 MsgAudioFetcherView::MsgAudioFetcherView() |
|
29 { |
|
30 initToolBar(); |
|
31 initMainWidget(); |
|
32 QMetaObject::connectSlotsByName(this); |
|
33 } |
|
34 |
|
35 MsgAudioFetcherView::~MsgAudioFetcherView() |
|
36 { |
|
37 removeToolBarAction(); |
|
38 } |
|
39 |
|
40 void MsgAudioFetcherView::initMainWidget() |
|
41 { |
|
42 mWidget = new MsgAudioFetcherWidget(); |
|
43 Q_ASSERT(mWidget); |
|
44 setWidget(mWidget); |
|
45 connect(mWidget, SIGNAL(triggerToolBar(bool)), this, SLOT(enableToolBar(bool))); |
|
46 } |
|
47 |
|
48 void MsgAudioFetcherView::initToolBar() |
|
49 { |
|
50 mToolBarLeftAction = new HbAction(this); |
|
51 mToolBarLeftAction->setObjectName("leftAction"); |
|
52 //TODO: need localized string |
|
53 mToolBarLeftAction->setText(hbTrId("Play/Pause")); |
|
54 toolBar()->addAction(mToolBarLeftAction); |
|
55 mToolBarLeftAction->setEnabled(false); |
|
56 |
|
57 mToolBarRightAction = new HbAction(this); |
|
58 mToolBarRightAction->setObjectName("rightAction"); |
|
59 //TODO: need localized string |
|
60 mToolBarRightAction->setText(hbTrId("Select")); |
|
61 mToolBarRightAction->setEnabled(false); |
|
62 toolBar()->addAction(mToolBarRightAction); |
|
63 |
|
64 toolBar()->setOrientation(Qt::Horizontal); |
|
65 toolBar()->setEnabled(false); |
|
66 } |
|
67 |
|
68 void MsgAudioFetcherView::removeToolBarAction() |
|
69 { |
|
70 toolBar()->removeAction(mToolBarRightAction); |
|
71 toolBar()->removeAction(mToolBarLeftAction); |
|
72 } |
|
73 |
|
74 void MsgAudioFetcherView::on_leftAction_triggered() |
|
75 { |
|
76 mWidget->playOrPause(); |
|
77 } |
|
78 |
|
79 void MsgAudioFetcherView::on_rightAction_triggered() |
|
80 { |
|
81 // param list for switching to editor view |
|
82 QVariantList params; |
|
83 QByteArray dataArray; |
|
84 QDataStream messageStream |
|
85 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
86 |
|
87 ConvergedMessage message; |
|
88 QString filepath(mWidget->getCurrentItemPath()); |
|
89 ConvergedMessageAttachment* attachment = |
|
90 new ConvergedMessageAttachment(filepath); |
|
91 ConvergedMessageAttachmentList attachmentList; |
|
92 attachmentList.append(attachment); |
|
93 message.addAttachments(attachmentList); |
|
94 |
|
95 message.serialize(messageStream); |
|
96 params << MsgBaseView::UNIEDITOR; |
|
97 params << MsgBaseView::AUDIOFETCHER; |
|
98 params << dataArray; |
|
99 params << MsgBaseView::ADD_AUDIO; |
|
100 emit switchView(params); |
|
101 } |
|
102 |
|
103 void MsgAudioFetcherView::enableToolBar(bool enable) |
|
104 { |
|
105 mToolBarRightAction->setEnabled(enable); |
|
106 mToolBarLeftAction->setEnabled(enable); |
|
107 toolBar()->setEnabled(enable); |
|
108 } |
|
109 |
|
110 //End of File |