1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
<title>Qt Mobility 1.1: editcalendarspage.cpp Example File (calendardemo/src/editcalendarspage.cpp)</title>
7
<link rel="stylesheet" type="text/css" href="style/style.css"
9
<meta name="MSSmartTagsPreventParsing" content="true">
10
<meta http-equiv="imagetoolbar" content="no">
13
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
16
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
19
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
21
<script src="scripts/jquery.js" type="text/javascript"></script>
22
<script src="scripts/functions.js" type="text/javascript"></script>
23
<script src="./scripts/superfish.js" type="text/javascript"></script>
24
<script src="./scripts/narrow.js" type="text/javascript"></script>
25
<link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /></head>
26
<body class="" onload="CheckEmptyAndLoadList();">
27
<div class="header" id="qtdocheader">
30
<a href="index.html">Home</a></div>
31
<a href="index.html" class="qtref"><span>Qt Mobility Reference Documentation</span></a>
32
<div id="narrowsearch"><form onsubmit="return false;" action="" id="qtdocsearchTop">
34
<input type="text" value="" id="pageType2" name="searchstring"/>
37
<div id="nav-topright">
39
<li class="nav-topright-home"><a href="http://qt.nokia.com/">Qt HOME</a></li>
40
<li class="nav-topright-dev"><a href="http://developer.qt.nokia.com/">DEV</a></li>
41
<li class="nav-topright-labs"><a href="http://labs.qt.nokia.com/blogs/">LABS</a></li>
42
<li class="nav-topright-doc nav-topright-doc-active"><a href="http://doc.qt.nokia.com/">
44
<li class="nav-topright-blog"><a href="http://blog.qt.nokia.com/">BLOG</a></li>
49
<li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1</a></span></li>
50
<li class="shortCut-topleft-active"><a href="http://doc.qt.nokia.com">ALL VERSIONS </a></li>
53
<ul class="sf-menu sf-js-enabled sf-shadow" id="narrowmenu">
54
<li><a href="#">API Lookup</a>
56
<li><a href="classes.html">Class index</a></li>
57
<li><a href="functions.html">Function index</a></li>
58
<li><a href="modules.html">Modules</a></li>
61
<li><a href="#">Examples</a>
62
<ul id="topmenuexample">
63
<li><a href="all-examples.html">Examples</a></li>
73
<div class="bd group">
75
<div class="searchlabel">
78
<form id="qtdocsearch" action="" onsubmit="return false;">
80
<input type="text" name="searchstring" id="pageType" value="" />
84
<div class="box first bottombar" id="lookup">
85
<h2 title="API Lookup"><span></span>
87
<div id="list001" class="list">
89
<li class="defaultLink"><a href="classes.html">Class index</a></li>
90
<li class="defaultLink"><a href="functions.html">Function index</a></li>
91
<li class="defaultLink"><a href="modules.html">Modules</a></li>
92
<li class="defaultLink"><a href="index.html#platform-compatibility">Platform Compatibility</a></li>
93
<li class="defaultLink"><a href="qml-plugins.html">QML Plugins</a></li>
97
<div class="box bottombar" id="topics">
98
<h2 title="Qt Topics"><span></span>
100
<div id="list002" class="list">
102
<li class="defaultLink"><a href="http://doc.qt.nokia.com/4.7-snapshot/">Qt 4.7</a></li>
103
<li class="defaultLink"><a href="http://doc.qt.nokia.com/4.7-snapshot/qt-basic-concepts.html">Basic Qt architecture</a></li>
104
<li class="defaultLink"><a href="http://doc.qt.nokia.com/4.7-snapshot/declarativeui.html">Device UI's & Qt Quick</a></li>
105
<li class="defaultLink"><a href="http://doc.qt.nokia.com/4.7-snapshot/qt-gui-concepts.html">Desktop UI components</a></li>
106
<li class="defaultLink"><a href="http://doc.qt.nokia.com/4.7-snapshot/platform-specific.html">Platform-specific info</a></li>
110
<div class="box" id="examples">
111
<h2 title="Examples"><span></span>
113
<div id="list003" class="list">
115
<li class="defaultLink"><a href="all-examples.html">Examples</a></li>
121
<div class="toolbar">
122
<div class="breadcrumb toolblock">
124
<li class="first"><a href="index.html">Home</a></li>
125
<!-- Bread crumbs goes here -->
128
<div class="toolbuttons toolblock">
130
<li id="smallA" class="t_button">A</li>
131
<li id="medA" class="t_button active">A</li>
132
<li id="bigA" class="t_button">A</li>
133
<li id="print" class="t_button"><a href="javascript:this.print();">
134
<span>Print</span></a></li>
138
<div class="content">
139
<h1 class="title">editcalendarspage.cpp Example File</h1>
140
<span class="small-subtitle">calendardemo/src/editcalendarspage.cpp</span>
142
<pre class="highlightedCode brush: cpp"><span class="comment"> /****************************************************************************
144
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
145
** All rights reserved.
146
** Contact: Nokia Corporation (qt-info@nokia.com)
148
** This file is part of the Qt Mobility Components.
150
** $QT_BEGIN_LICENSE:BSD$
151
** You may use this file under the terms of the BSD license as follows:
153
** "Redistribution and use in source and binary forms, with or without
154
** modification, are permitted provided that the following conditions are
156
** * Redistributions of source code must retain the above copyright
157
** notice, this list of conditions and the following disclaimer.
158
** * Redistributions in binary form must reproduce the above copyright
159
** notice, this list of conditions and the following disclaimer in
160
** the documentation and/or other materials provided with the
162
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
163
** the names of its contributors may be used to endorse or promote
164
** products derived from this software without specific prior written
167
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
168
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
169
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
170
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
171
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
172
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
173
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
174
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
175
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
176
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
177
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
180
****************************************************************************/</span>
181
#include "editcalendarspage.h"
183
#include "calendardemo.h"
184
#include <QtGui>
185
#include <qtorganizer.h>
189
Q_DECLARE_METATYPE(QOrganizerCollection)
191
EditCalendarsPage::EditCalendarsPage(QWidget *parent)
195
m_calendarList = new QListWidget(this);
196
connect(m_calendarList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemDoubleClicked(QListWidgetItem *)));
199
<span class="comment">// Add push buttons for non-Symbian platforms as they do not support soft keys</span>
200
QHBoxLayout* hbLayout = new QHBoxLayout();
201
QPushButton *addButton = new QPushButton("Add new", this);
202
connect(addButton,SIGNAL(clicked()), this, SIGNAL(addClicked()));
203
hbLayout->addWidget(addButton);
204
QPushButton *editButton = new QPushButton("Edit", this);
205
connect(editButton,SIGNAL(clicked()),this,SLOT(editClicked()));
206
hbLayout->addWidget(editButton);
207
QPushButton *deleteButton = new QPushButton("Delete", this);
208
connect(deleteButton,SIGNAL(clicked()),this,SLOT(deleteClicked()));
209
hbLayout->addWidget(deleteButton);
210
QPushButton *backButton = new QPushButton("Back", this);
211
connect(backButton,SIGNAL(clicked()),this,SLOT(backClicked()));
212
hbLayout->addWidget(backButton);
215
QVBoxLayout *scrollAreaLayout = new QVBoxLayout();
216
scrollAreaLayout->addWidget(m_calendarList);
219
scrollAreaLayout->addLayout(hbLayout);
222
QScrollArea *scrollArea = new QScrollArea(this);
223
scrollArea->setWidgetResizable(true);
224
QWidget *formContainer = new QWidget(scrollArea);
225
formContainer->setLayout(scrollAreaLayout);
226
scrollArea->setWidget(formContainer);
228
QVBoxLayout *mainLayout = new QVBoxLayout();
229
mainLayout->addWidget(scrollArea);
230
setLayout(mainLayout);
232
<span class="comment">// Add softkeys</span>
233
QAction* cancelSoftKey = new QAction("Cancel", this);
234
cancelSoftKey->setSoftKeyRole(QAction::NegativeSoftKey);
235
addAction(cancelSoftKey);
236
connect(cancelSoftKey, SIGNAL(triggered(bool)), this, SLOT(cancelClicked()));
238
QAction* saveSoftKey = new QAction("Save",this);
239
saveSoftKey->setSoftKeyRole(QAction::PositiveSoftKey);
240
addAction(saveSoftKey);
241
connect(saveSoftKey, SIGNAL(triggered(bool)), this, SLOT(saveClicked()));
244
EditCalendarsPage::~EditCalendarsPage()
249
void EditCalendarsPage::editClicked()
251
if (m_calendarList->currentItem())
252
itemDoubleClicked(m_calendarList->currentItem());
255
void EditCalendarsPage::deleteClicked()
257
if (!m_calendarList->currentItem())
261
msgBox.setText("Are you sure you want to delete this calendar?");
262
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
263
msgBox.setDefaultButton(QMessageBox::No);
264
int ret = msgBox.exec();
266
if (ret == QMessageBox::Yes) {
267
m_collection = m_calendarList->currentItem()->data(ORGANIZER_CALENDAR_ROLE).value<QOrganizerCollection>();
268
if(!m_manager->removeCollection(m_collection.id()))
269
QMessageBox::information(this, "Failed!", QString("Failed to remove calendar!\n(error code %1)").arg(m_manager->error()));
274
void EditCalendarsPage::backClicked()
276
emit showPreviousPage();
279
void EditCalendarsPage::itemDoubleClicked(QListWidgetItem *listItem)
284
m_collection = listItem->data(ORGANIZER_CALENDAR_ROLE).value<QOrganizerCollection>();
285
emit showAddCalendarPage(m_manager, &m_collection);
288
void EditCalendarsPage::showPage(QOrganizerManager *manager)
291
m_calendarList->clear();
292
QList<QOrganizerCollection> collections = manager->collections();
294
foreach(QOrganizerCollection collection, collections) {
296
if (collection.metaData("Name").canConvert(QVariant::String))
297
visibleName = collection.metaData("Name").toString();
299
<span class="comment">// We currently have no way of stringifying ids</span>
300
<span class="comment">// visibleName = "Calendar id " + QString::number(collection.id().localId());</span>
301
visibleName = "Calendar " + QString::number(index++);
303
QListWidgetItem* listItem = new QListWidgetItem();
304
listItem->setText(visibleName);
305
QVariant data = QVariant::fromValue<QOrganizerCollection>(collection);
306
listItem->setData(ORGANIZER_CALENDAR_ROLE, data);
307
m_calendarList->addItem(listItem);
311
void EditCalendarsPage::showEvent(QShowEvent *event)
313
window()->setWindowTitle("Edit calendars");
314
QWidget::showEvent(event);
318
<div class="feedback t_button">
319
[+] Documentation Feedback</div>
329
<acronym title="Copyright">©</acronym> 2008-2010 Nokia Corporation and/or its
330
subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation
331
in Finland and/or other countries worldwide.</p>
333
All other trademarks are property of their respective owners. <a title="Privacy Policy"
334
href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
336
<div id="feedbackBox">
337
<div id="feedcloseX" class="feedclose t_button">X</div>
338
<form id="feedform" action="http://doc.qt.nokia.com/docFeedbck/feedback.php" method="get">
339
<p id="noteHead">Thank you for giving your feedback.</p> <div class="note"><p>Make sure it is related to this specific page. For more general bugs and
340
requests, please use the <a href="http://bugreports.qt.nokia.com/secure/Dashboard.jspa">Qt Bug Tracker</a>.</p></div>
341
<p><textarea id="feedbox" name="feedText" rows="5" cols="40"></textarea></p>
342
<p><input id="feedsubmit" class="feedclose" type="submit" name="feedback" /></p>
348
<script src="scripts/functions.js" type="text/javascript"></script>