46 //back button |
49 //back button |
47 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
50 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
48 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
51 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
49 } |
52 } |
50 |
53 |
|
54 /*! |
|
55 Destructor |
|
56 */ |
51 CntMyCardView::~CntMyCardView() |
57 CntMyCardView::~CntMyCardView() |
52 { |
58 { |
53 mView->deleteLater(); |
59 mView->deleteLater(); |
54 |
60 |
55 delete mContact; |
61 delete mContact; |
56 mContact = NULL; |
|
57 } |
|
58 |
|
59 /*! |
|
60 Activates a previous view |
|
61 */ |
|
62 void CntMyCardView::showPreviousView() |
|
63 { |
|
64 CntViewParameters args; |
|
65 mViewManager->back(args); |
|
66 } |
62 } |
67 |
63 |
68 /* |
64 /* |
69 Activates a default view |
65 Activates the view |
70 */ |
66 */ |
71 void CntMyCardView::activate(const CntViewParameters aArgs) |
67 void CntMyCardView::activate(const CntViewParameters aArgs) |
72 { |
68 { |
73 mViewManager = &mEngine->viewManager(); |
69 mViewManager = &mEngine->viewManager(); |
74 |
70 |
75 if (mView->navigationAction() != mSoftkey) { |
71 if (mView->navigationAction() != mSoftkey) |
|
72 { |
76 mView->setNavigationAction(mSoftkey); |
73 mView->setNavigationAction(mSoftkey); |
77 } |
74 } |
78 |
75 |
79 HbMainWindow* window = mView->mainWindow(); |
76 HbMainWindow* window = mView->mainWindow(); |
80 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
77 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
81 setOrientation(window->orientation()); |
78 setOrientation(window->orientation()); |
82 |
79 |
83 mContact = new QContact(aArgs.value(ESelectedContact).value<QContact>()); |
80 mContact = new QContact(aArgs.value(ESelectedContact).value<QContact>()); |
84 HbPushButton *newButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_new"))); |
81 |
85 connect(newButton, SIGNAL(clicked()), this, SLOT(openNameEditor())); |
82 mNewButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_new"))); |
86 connect(newButton, SIGNAL(longPress(QPointF)), this, SLOT(openNameEditor())); |
83 connect(mNewButton, SIGNAL(released()), this, SLOT(openEditor())); |
87 |
84 |
88 HbPushButton *chooseButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_choose"))); |
85 mChooseButton = static_cast<HbPushButton*>(mDocumentLoader.findWidget(QString("cnt_button_choose"))); |
89 connect(chooseButton, SIGNAL(clicked()), this, SLOT(openMyCardSelectionView())); |
86 connect(mChooseButton, SIGNAL(released()), this, SLOT(openMyCardSelectionDialog())); |
90 connect(chooseButton, SIGNAL(longPress(QPointF)), this, SLOT(openMyCardSelectionView())); |
87 |
91 |
|
92 QContactDetailFilter filter; |
88 QContactDetailFilter filter; |
93 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
89 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
94 filter.setValue(QLatin1String(QContactType::TypeContact)); |
90 filter.setValue(QLatin1String(QContactType::TypeContact)); |
95 |
91 |
96 if (mEngine->contactManager( SYMBIAN_BACKEND ).contactIds(filter).isEmpty()) |
92 if (mEngine->contactManager( SYMBIAN_BACKEND ).contactIds(filter).isEmpty()) |
97 { |
93 { |
98 chooseButton->setEnabled(false); |
94 mChooseButton->setEnabled(false); |
99 } |
95 } |
100 } |
96 } |
101 |
97 |
102 void CntMyCardView::deactivate() |
98 void CntMyCardView::deactivate() |
103 { |
99 { |
104 } |
100 } |
105 |
101 |
106 void CntMyCardView::setOrientation(Qt::Orientation orientation) |
102 /*! |
107 { |
103 Activates a previous view |
108 if (orientation == Qt::Vertical) |
104 */ |
109 { |
105 void CntMyCardView::showPreviousView() |
110 // reading "portrait" section |
106 { |
111 mDocumentLoader.load(CNT_MYCARD_UI_XML, "portrait"); |
107 CntViewParameters args; |
112 } |
108 mViewManager->back(args); |
113 else |
109 } |
114 { |
110 |
115 // reading "landscape" section |
111 /*! |
116 mDocumentLoader.load(CNT_MYCARD_UI_XML, "landscape"); |
112 Opens the editor view |
117 } |
113 */ |
118 } |
114 void CntMyCardView::openEditor() |
119 |
115 { |
120 /*! |
116 if (mNewButton->isUnderMouse()) |
121 Opens the name detail editor view |
117 { |
122 */ |
118 CntViewParameters viewParameters; |
123 void CntMyCardView::openNameEditor() |
119 viewParameters.insert(EViewId, editView); |
124 { |
120 viewParameters.insert(EMyCard, "myCard" ); |
125 CntViewParameters viewParameters; |
121 |
126 viewParameters.insert(EViewId, editView); |
122 QVariant var; |
127 viewParameters.insert(EMyCard, "myCard" ); |
123 var.setValue(*mContact); |
128 |
124 viewParameters.insert(ESelectedContact, var); |
129 QVariant var; |
125 viewParameters.insert(EExtraAction, CNT_ROOT_ACTION); |
130 var.setValue(*mContact); |
126 mViewManager->changeView(viewParameters); |
131 viewParameters.insert(ESelectedContact, var); |
127 } |
132 viewParameters.insert(EExtraAction, CNT_ROOT_ACTION); |
128 |
133 mViewManager->changeView(viewParameters); |
129 } |
134 } |
130 |
135 |
131 /*! |
136 /*! |
132 Opens the my card selection dialog |
137 Opens the my card selection view |
133 */ |
138 */ |
134 void CntMyCardView::openMyCardSelectionDialog() |
139 void CntMyCardView::openMyCardSelectionView() |
135 { |
140 { |
136 if (mChooseButton->isUnderMouse()) |
141 CntFetchContactPopup* popup = CntFetchContactPopup::createSingleSelectionPopup( |
137 { |
142 hbTrId("txt_phob_title_select_contact"), |
138 CntFetchContactPopup* popup = CntFetchContactPopup::createSingleSelectionPopup( |
143 mEngine->contactManager(SYMBIAN_BACKEND)); |
139 hbTrId("txt_phob_title_select_contact"), |
144 connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), this, SLOT(handleMultiCardSelection(QSet<QContactLocalId>))); |
140 mEngine->contactManager(SYMBIAN_BACKEND)); |
145 QSet<QContactLocalId> ids; |
141 connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), this, SLOT(handleMyCardSelection(QSet<QContactLocalId>))); |
146 popup->setSelectedContacts(ids); |
142 QSet<QContactLocalId> ids; |
147 popup->showPopup(); |
143 popup->setSelectedContacts(ids); |
148 } |
144 popup->showPopup(); |
149 |
145 } |
150 void CntMyCardView::handleMultiCardSelection( QSet<QContactLocalId> aIds ) |
146 } |
|
147 |
|
148 /*! |
|
149 Handle the contact selection |
|
150 */ |
|
151 void CntMyCardView::handleMyCardSelection( QSet<QContactLocalId> aIds ) |
151 { |
152 { |
152 QContactManager& manager = mEngine->contactManager( SYMBIAN_BACKEND ); |
153 QContactManager& manager = mEngine->contactManager( SYMBIAN_BACKEND ); |
153 |
154 |
154 if ( !aIds.isEmpty() ) { |
155 if ( !aIds.isEmpty() ) { |
155 QList<QContactLocalId> selectedContactsList = aIds.values(); |
156 QList<QContactLocalId> selectedContactsList = aIds.values(); |
170 relationshipFilter.setRelatedContactId(aContact->id()); |
191 relationshipFilter.setRelatedContactId(aContact->id()); |
171 relationshipFilter.setRelatedContactRole(QContactRelationship::Second); |
192 relationshipFilter.setRelatedContactRole(QContactRelationship::Second); |
172 QList<QContactLocalId> groupIds = mgr.contactIds(relationshipFilter); |
193 QList<QContactLocalId> groupIds = mgr.contactIds(relationshipFilter); |
173 |
194 |
174 QList<QContactRelationship> relationships; |
195 QList<QContactRelationship> relationships; |
175 for(int i = 0;i < groupIds.count();i++) { |
196 for(int i = 0;i < groupIds.count();i++) |
|
197 { |
176 QContact groupContact = mgr.contact(groupIds.at(i)); |
198 QContact groupContact = mgr.contact(groupIds.at(i)); |
177 QContactRelationship relationship; |
199 QContactRelationship relationship; |
178 relationship.setRelationshipType(QContactRelationship::HasMember); |
200 relationship.setRelationshipType(QContactRelationship::HasMember); |
179 relationship.setFirst(groupContact.id()); |
201 relationship.setFirst(groupContact.id()); |
180 relationship.setSecond(aContact->id()); |
202 relationship.setSecond(aContact->id()); |
181 relationships.append(relationship); |
203 relationships.append(relationship); |
182 } |
204 } |
|
205 |
183 QMap<int, QContactManager::Error> errorMap; |
206 QMap<int, QContactManager::Error> errorMap; |
184 mgr.removeRelationships(relationships,&errorMap); |
207 mgr.removeRelationships(relationships,&errorMap); |
185 } |
208 } |
186 |
209 |
187 // EOF |
210 // EOF |