~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to doc/html/calendardemo-src-daypage-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    </div>
47
47
    <div id="shortCut">
48
48
      <ul>
49
 
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1 BETA</a></span></li>
 
49
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Mobility 1.1</a></span></li>
50
50
        <li class="shortCut-topleft-active"><a href="http://doc.qt.nokia.com">ALL VERSIONS        </a></li>
51
51
      </ul>
52
52
     </div>
196
196
     m_itemList(0),
197
197
     m_menuBar(0)
198
198
 {
199
 
     QVBoxLayout *mainLayout = new QVBoxLayout(this);
 
199
     QVBoxLayout *mainLayout = new QVBoxLayout();
200
200
 
201
 
     QHBoxLayout *dateLayout = new QHBoxLayout(this);
 
201
     QHBoxLayout *dateLayout = new QHBoxLayout();
202
202
     m_dateLabel = new QLabel(this);
203
203
     m_dateLabel-&gt;setAlignment(Qt::AlignCenter);
204
204
     dateLayout-&gt;addWidget(m_dateLabel);
256
256
     m_dateLabel-&gt;setText(m_day.toString());
257
257
     m_itemList-&gt;clear();
258
258
 
259
 
     <span class="comment">// Items</span>
260
 
     QList&lt;QOrganizerItem&gt; items = m_manager-&gt;items();
261
 
 
262
 
     <span class="comment">// Today's item instances</span>
263
 
     QOrganizerItemDateTimePeriodFilter filter;
264
 
     filter.setStartPeriod(QDateTime(m_day, QTime(0, 0, 0)));
265
 
     filter.setEndPeriod(QDateTime(m_day, QTime(23, 59, 59)));
266
 
     QList&lt;QOrganizerItem&gt; instances = m_manager-&gt;itemInstances(filter);
 
259
     <span class="comment">// Today's item</span>
 
260
     QList&lt;QOrganizerItem&gt; items = m_manager-&gt;items(QDateTime(m_day), QDateTime(m_day, QTime(23, 59, 59)));
267
261
 
268
262
     foreach (const QOrganizerItem &amp;item, items)
269
263
     {
270
 
         QOrganizerEventTimeRange eventTimeRange = item.detail&lt;QOrganizerEventTimeRange&gt;();
271
 
         if (!eventTimeRange.isEmpty()) {
272
 
             QOrganizerItemGuid itemGuid = item.detail&lt;QOrganizerItemGuid&gt;();
273
 
             QOrganizerEventTimeRange itemTimeRange = item.detail&lt;QOrganizerEventTimeRange&gt;();
274
 
             bool instancesContainGuid = false;
275
 
             foreach (QOrganizerItem instance, instances) {
276
 
                 if (instance.detail&lt;QOrganizerItemGuid&gt;() == itemGuid
277
 
                     &amp;&amp; instance.detail&lt;QOrganizerEventTimeRange&gt;().startDateTime() != itemTimeRange.startDateTime()) {
278
 
                     instancesContainGuid = true;
279
 
                     break;
280
 
                 }
281
 
             }
282
 
 
283
 
             if (eventTimeRange.startDateTime().date() == m_day &amp;&amp; !instancesContainGuid) {
284
 
                 QString time = eventTimeRange.startDateTime().time().toString(&quot;hh:mm&quot;);
285
 
                 QListWidgetItem* listItem = new QListWidgetItem();
 
264
         QOrganizerEventTime eventTime = item.detail&lt;QOrganizerEventTime&gt;();
 
265
         if (!eventTime.isEmpty()) {
 
266
             QString time = eventTime.startDateTime().time().toString(&quot;hh:mm&quot;);
 
267
             QListWidgetItem* listItem = new QListWidgetItem();
 
268
             if (item.type() == QOrganizerItemType::TypeEventOccurrence)
 
269
                 listItem-&gt;setText(QString(&quot;Event occurance:%1-%2&quot;).arg(time).arg(item.displayLabel()));
 
270
             else
286
271
                 listItem-&gt;setText(QString(&quot;Event:%1-%2&quot;).arg(time).arg(item.displayLabel()));
287
 
                 QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
288
 
                 listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
289
 
                 m_itemList-&gt;addItem(listItem);
290
 
             }
291
 
         }
292
 
 
293
 
         QOrganizerTodoTimeRange todoTimeRange = item.detail&lt;QOrganizerTodoTimeRange&gt;();
294
 
         if (!todoTimeRange.isEmpty()) {
295
 
             if (todoTimeRange.startDateTime().date() == m_day) {
296
 
                 QString time = todoTimeRange.startDateTime().time().toString(&quot;hh:mm&quot;);
297
 
                 QListWidgetItem* listItem = new QListWidgetItem();
298
 
                 listItem-&gt;setText(QString(&quot;Todo:%1-%2&quot;).arg(time).arg(item.displayLabel()));
299
 
                 QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
300
 
                 listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
301
 
                 m_itemList-&gt;addItem(listItem);
302
 
             }
303
 
         }
304
 
 
305
 
         QOrganizerJournalTimeRange journalTimeRange = item.detail&lt;QOrganizerJournalTimeRange&gt;();
306
 
         if (!journalTimeRange.isEmpty()) {
307
 
             if (journalTimeRange.entryDateTime().date() == m_day) {
308
 
                 QString time = journalTimeRange.entryDateTime().time().toString(&quot;hh:mm&quot;);
309
 
                 QListWidgetItem* listItem = new QListWidgetItem();
310
 
                 listItem-&gt;setText(QString(&quot;Journal:%1-%2&quot;).arg(time).arg(item.displayLabel()));
311
 
                 QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
312
 
                 listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
313
 
                 m_itemList-&gt;addItem(listItem);
314
 
             }
 
272
             QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
 
273
             listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
 
274
             m_itemList-&gt;addItem(listItem);
 
275
         }
 
276
 
 
277
         QOrganizerTodoTime todoTime = item.detail&lt;QOrganizerTodoTime&gt;();
 
278
         if (!todoTime.isEmpty()) {
 
279
             QString time = todoTime.startDateTime().time().toString(&quot;hh:mm&quot;);
 
280
             QListWidgetItem* listItem = new QListWidgetItem();
 
281
             listItem-&gt;setText(QString(&quot;Todo:%1-%2&quot;).arg(time).arg(item.displayLabel()));
 
282
             QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
 
283
             listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
 
284
             m_itemList-&gt;addItem(listItem);
 
285
         }
 
286
 
 
287
         QOrganizerJournalTime journalTime = item.detail&lt;QOrganizerJournalTime&gt;();
 
288
         if (!journalTime.isEmpty()) {
 
289
             QString time = journalTime.entryDateTime().time().toString(&quot;hh:mm&quot;);
 
290
             QListWidgetItem* listItem = new QListWidgetItem();
 
291
             listItem-&gt;setText(QString(&quot;Journal:%1-%2&quot;).arg(time).arg(item.displayLabel()));
 
292
             QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(item);
 
293
             listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
 
294
             m_itemList-&gt;addItem(listItem);
315
295
         }
316
296
 
317
297
         <span class="comment">// TODO: other item types</span>
318
298
     }
319
299
 
320
 
     foreach (const QOrganizerItem &amp;instance, instances)
321
 
     {
322
 
         QString type = instance.type();
323
 
         if (type == QOrganizerItemType::TypeEventOccurrence) {
324
 
             QOrganizerEventOccurrence occurrence = static_cast&lt;QOrganizerEventOccurrence&gt;(instance);
325
 
             QString time = occurrence.startDateTime().time().toString(&quot;hh:mm&quot;);
326
 
             QListWidgetItem* listItem = new QListWidgetItem();
327
 
             listItem-&gt;setText(QString(&quot;Event occurrence:%1-%2&quot;).arg(time).arg(occurrence.displayLabel()));
328
 
             QVariant data = QVariant::fromValue&lt;QOrganizerItem&gt;(instance);
329
 
             listItem-&gt;setData(ORGANIZER_ITEM_ROLE, data);
330
 
             m_itemList-&gt;addItem(listItem);
331
 
         }
332
 
     }
333
 
 
334
300
     if (m_itemList-&gt;count() == 0)
335
301
         m_itemList-&gt;addItem(&quot;(no entries)&quot;);
336
302
 }
337
303
 
338
 
 void DayPage::changeManager(QOrganizerItemManager *manager)
 
304
 void DayPage::changeManager(QOrganizerManager *manager)
339
305
 {
340
306
     m_manager = manager;
341
307
 }
381
347
     if (organizerItem.isEmpty())
382
348
         return;
383
349
 
384
 
     m_manager-&gt;removeItem(organizerItem.localId());
 
350
     if (organizerItem.type() == QOrganizerItemType::TypeEventOccurrence
 
351
         || organizerItem.type() == QOrganizerItemType::TypeTodoOccurrence) {
 
352
         <span class="comment">// Here we could ask if the user wishes to remove only the occurrence (meaning we would</span>
 
353
         <span class="comment">// add an exception date to the parent item), or the parent item. The current</span>
 
354
         <span class="comment">// implementation is to remove the parent (including all the occurrences).</span>
 
355
         m_manager-&gt;removeItem(organizerItem.detail&lt;QOrganizerItemParent&gt;().parentId());
 
356
     } else {
 
357
         m_manager-&gt;removeItem(organizerItem.id());
 
358
     }
 
359
 
385
360
     if (m_manager-&gt;error())
386
361
         QMessageBox::information(this, &quot;Failed!&quot;, QString(&quot;Failed to remove item!\n(error code %1)&quot;).arg(m_manager-&gt;error()));
387
362
     else