Пример #1
0
void E2ServerInterface::updateAppointment()
{
    if(m_model->rowCount() == 0) {
        occurrenceText = "No meetings today";
    } else {
        QAppointment appointment;
        bool found = false;
        int secs = 0;
        for(int ii = 0; !found && ii < m_model->rowCount(); ++ii) {
            appointment = m_model->appointment(ii);
            occurrenceText = appointment.description();
            QOccurrence occurrence =
                appointment.nextOccurrence(QDate::currentDate());
            secs = QDateTime::currentDateTime().secsTo(occurrence.start());
            if(secs >= 0) {
                found = true;
            }
        }

        if(!found) {
            occurrenceText = "No meetings today";
        }
    }

    update();
}
Пример #2
0
bool AlarmView::updateAlarms()
{
    bool playSound = false;
    QIcon aicon(":icon/audible");
    QIcon sicon(":icon/silent");

    mStandardModel->clear();
    mAlarmCount = 0;

    QString localDT;
    QString tzDT;

    // Filter out occurrences that do not have an alarm
    for (int i=0; i < mModel->rowCount(); i++) {
        QOccurrence o = mModel->occurrence(i);
        QAppointment a = o.appointment();
        if (a.hasAlarm() && (o.startInCurrentTZ() == mStartTime) && (o.alarmDelay() == mDelay)) {
            if (!playSound && (a.alarm() == QAppointment::Audible)) {
                playSound = true;
            }
            QStandardItem* item = new QStandardItem();
            if (a.alarm() == QAppointment::Audible)
                item->setData(aicon, Qt::DecorationRole);
            else
                item->setData(sicon, Qt::DecorationRole);

            if (!a.description().isEmpty())
                item->setData(a.description(), Qt::DisplayRole);
            else
                item->setData(tr("No description", "no description for appointment"), Qt::DisplayRole);

            QList< StringPair > subList;
            if (!a.location().isEmpty()) {
                subList.append(qMakePair(QString(), a.location()));
            }

            formatDateTime(o, true, localDT, tzDT);
            if (a.isAllDay()) {
                subList.append(qMakePair(tr("All day: "), localDT));
            } else {
                subList.append(qMakePair(tr("Starts: "), localDT));
                if (!tzDT.isEmpty())
                    subList.append(qMakePair(QString(""), tzDT));
                formatDateTime(o, false, localDT, tzDT);
                subList.append(qMakePair(tr("Ends: "), localDT));
                if (!tzDT.isEmpty())
                    subList.append(qMakePair(QString(""), tzDT));
            }
            item->setData(QVariant::fromValue(subList), TwoLevelDelegate::SubLabelsRole);

            item->setData(i, TwoLevelDelegate::TwoLevelDelegateUserRole);
            mStandardModel->appendRow(item);
        }
    }

    int rowCount = mStandardModel->rowCount();

    // Select the first item
    mAlarmList->setCurrentIndex(mStandardModel->index(0,0));

    // XXX i18n boneheadedness.
    if (rowCount < 2) {
        setWindowTitle(tr("Reminder"));
    } else {
        setWindowTitle(tr("Reminders"));
    }

    mSnoozeButton->setFocus();

    // If we actually got any matching alarms...
    if (rowCount > 0) {
        if (playSound) {
            Qtopia::soundAlarm();
            mAlarmTimer.start(5000,this);
        }

        return true;
    } else {
        emit closeView();
        return false;
    }
}