|
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: Plugin interface for Music Player collection view. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <xqplugin.h> |
|
19 |
|
20 #include "mpcollectionviewplugin.h" |
|
21 #include "mpcollectionview.h" |
|
22 #include "mptrace.h" |
|
23 |
|
24 /*! |
|
25 \class MpCollectionViewPlugin |
|
26 \brief Plugin interface for Music Player collection view. |
|
27 |
|
28 Collection view plugin provides interface to the collection view |
|
29 beyond a plugin interface for application and view separation. |
|
30 */ |
|
31 |
|
32 /*! |
|
33 \fn void command( int command ) |
|
34 |
|
35 This signal is emitted when the view issues a \a command to the |
|
36 application such as request to switch to a different view. |
|
37 */ |
|
38 |
|
39 /*! |
|
40 Constructs the collection view plugin. |
|
41 */ |
|
42 MpCollectionViewPlugin::MpCollectionViewPlugin() |
|
43 : mView(0), |
|
44 mState(NullView) |
|
45 { |
|
46 TX_LOG |
|
47 } |
|
48 |
|
49 /*! |
|
50 Destructs the collection view plugin. |
|
51 */ |
|
52 MpCollectionViewPlugin::~MpCollectionViewPlugin() |
|
53 { |
|
54 TX_LOG |
|
55 } |
|
56 |
|
57 /*! |
|
58 Creates the collection view. |
|
59 */ |
|
60 void MpCollectionViewPlugin::createView() |
|
61 { |
|
62 TX_ENTRY |
|
63 if ( mState == NullView ) { |
|
64 mView = new MpCollectionView(); |
|
65 connect( mView, SIGNAL(command(int)), this, SIGNAL(command(int)) ); |
|
66 mState = Created; |
|
67 } |
|
68 TX_EXIT |
|
69 } |
|
70 |
|
71 /*! |
|
72 Destroys the collection view. |
|
73 */ |
|
74 void MpCollectionViewPlugin::destroyView() |
|
75 { |
|
76 TX_LOG |
|
77 if ( mState != NullView ) { |
|
78 delete mView; |
|
79 mView = 0; |
|
80 mState = NullView; |
|
81 } |
|
82 } |
|
83 |
|
84 /*! |
|
85 Activates the collection view. View initialization is done very first time. |
|
86 */ |
|
87 void MpCollectionViewPlugin::activateView() |
|
88 { |
|
89 TX_ENTRY_ARGS("mState=" << mState); |
|
90 switch ( mState ) { |
|
91 case Created: |
|
92 mView->initializeView(); |
|
93 mView->activateView(); |
|
94 mState = Activated; |
|
95 break; |
|
96 case Initialized: |
|
97 mView->activateView(); |
|
98 mState = Activated; |
|
99 break; |
|
100 default: |
|
101 // Ignore |
|
102 break; |
|
103 } |
|
104 TX_EXIT |
|
105 } |
|
106 |
|
107 /*! |
|
108 Deactivates the collection view. |
|
109 */ |
|
110 void MpCollectionViewPlugin::deactivateView() |
|
111 { |
|
112 TX_ENTRY |
|
113 if ( mState == Activated ) { |
|
114 mView->deactivateView(); |
|
115 mState = Initialized; |
|
116 } |
|
117 TX_EXIT |
|
118 } |
|
119 |
|
120 /*! |
|
121 Returns pointer to QGraphicsWidget, which is the collection view. |
|
122 The returned pointer is 0, if it is not created first. |
|
123 |
|
124 \sa createView() |
|
125 */ |
|
126 QGraphicsWidget* MpCollectionViewPlugin::getView() |
|
127 { |
|
128 return mView; |
|
129 } |
|
130 |
|
131 /*! |
|
132 Slot to be called when application orientation changes. |
|
133 |
|
134 \reimp |
|
135 */ |
|
136 void MpCollectionViewPlugin::orientationChange( Qt::Orientation orientation ) |
|
137 { |
|
138 if ( mState == Activated ) { |
|
139 mView->orientationChange(orientation); |
|
140 } |
|
141 } |
|
142 |
|
143 /*! |
|
144 Slot to handle back command from softkey. |
|
145 |
|
146 \reimp |
|
147 */ |
|
148 void MpCollectionViewPlugin::back() |
|
149 { |
|
150 //do nothing, softkey is handled internally by the view. |
|
151 TX_LOG |
|
152 } |
|
153 |
|
154 XQ_EXPORT_PLUGIN2( mpcollectionviewplugin, MpCollectionViewPlugin ); |
|
155 |