int CustomTimeCtrl::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: isAuto((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: isDateTime((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 2: dateTimeChanged((*reinterpret_cast< const QDateTime(*)>(_a[1]))); break;
        case 3: adjustDateTime((*reinterpret_cast< QModelIndex(*)>(_a[1])),(*reinterpret_cast< QVariant(*)>(_a[2]))); break;
        case 4: blockSignals((*reinterpret_cast< const bool(*)>(_a[1]))); break;
        case 5: setHasTime((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: onDateChanged((*reinterpret_cast< const QDate(*)>(_a[1]))); break;
        case 7: onTimeChanged((*reinterpret_cast< const QTime(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QDateTime*>(_v) = dateTime(); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDateTime(*reinterpret_cast< QDateTime*>(_v)); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #2
0
TodoEditDialog::TodoEditDialog(QWidget *parent, CTodo *todo) :
    ComponentEditDialog(parent),
    ui(new Ui::TodoEditDialog),
    saveDue(true)
{
    ui->setupUi(this);

    if (todo && !todo->getId().empty()) {
        todo = CWrapper::details(todo);

        this->setWindowTitle(tr("Edit task"));
        this->setupDeleteButton(ui->buttonBox, SLOT(deleteTodo()));
    } else {
        this->setWindowTitle(tr("New task"));
    }

    QSettings settings;

    // Set up date picker
    DatePickSelector *dps = new DatePickSelector();
    ui->dateButton->setPickSelector(dps);

    // Set up time zone picker
    ZonePickSelector *zps;
    if (settings.value("TimeZones", false).toBool()) {
        zps = new ZonePickSelector();
        ui->zoneButton->setPickSelector(zps);
    } else {
        zps = NULL;
        ui->zoneButton->hide();
    }

    // Set up calendar picker
    CalendarPickSelector *cps = new CalendarPickSelector();
    ui->calendarButton->setPickSelector(cps);

    // Set up alarm picker
    AlarmPickSelector *aps = new AlarmPickSelector(E_AM_EXACTDATETIME);
    ui->alarmButton->setPickSelector(aps);

    // Make sure that AlarmPickSelector's reference date is set
    onDateChanged();

    connect(dps, SIGNAL(selected(QString)), this, SLOT(onDateChanged()));

    if (todo) {
        // Do not change the default settings when editing an existing todo
        saveDefaults = false;

        // Configure time
        QString zone;
        QDateTime due;
        if (zps) {
            // Display time in the selected time zone
            zone = todo->getTzid().c_str();
            due = Date::toRemote(todo->getDue(), zone);
            zps->setCurrentZone(todo->getTzid().c_str());
        } else {
            // Display local time
            due = QDateTime::fromTime_t(todo->getDue());
        }

        ui->summaryEdit->setText(QString::fromUtf8(todo->getSummary().c_str()));
        ui->descriptionEdit->setPlainText(QString::fromUtf8(todo->getDescription().c_str()));
        ui->doneBox->setChecked(todo->getStatus());
        dps->setCurrentDate(due.date());
        cps->setCalendar(todo->getCalendarId());
        aps->setAlarm(todo->getAlarm(), zone);
    } else {
        todo = new CTodo();

        saveDefaults = true;

        // Load last used settings
        settings.beginGroup("TodoEditDialog");
        cps->setCalendar(settings.value("Calendar", 1).toInt());
        aps->setSecondsBefore(settings.value("Alarm", -1).toInt());

        // Prepre to calculate the due date
        const time_t dueOffset = settings.value("DueOffset", 0).toInt() * 24*60*60;
        time_t currentStamp = QDateTime::currentDateTime().toTime_t();
        QDateTime due;

        // Some additional processing for time zones
        if (zps) {
            const QString zone = settings.value("TimeZone", QString()).toString();
            if (!zone.isEmpty()) {
                // Display time in the selected time zone
                currentStamp = Date::toRemote(currentStamp, zone).toTime_t();

                // Load last used setting
                zps->setCurrentZone(zone);
            }
        }

        // Calculate the due date in an under/overflow-proof way
        if (dueOffset > 0) {
            due = QDateTime::fromTime_t(currentStamp > std::numeric_limits<time_t>::max() - dueOffset
                                      ? std::numeric_limits<time_t>::max()
                                      : currentStamp + dueOffset);
        } else {
            due = QDateTime::fromTime_t(currentStamp < -dueOffset
                                      ? 0
                                      : currentStamp + dueOffset);
        }
        dps->setCurrentDate(due.date());

        ui->doneBox->hide();

        ui->summaryEdit->setFocus();
    }

    this->setupSaveButton(ui->buttonBox, SLOT(saveTodo()));

    ui->editArea->widget()->layout()->activate();

    this->setFeatures(ui->dialogLayout, ui->buttonBox);

    this->todo = todo;
}