当前位置: 首页>>代码示例>>C++>>正文


C++ DBManager::hasOverlaps方法代码示例

本文整理汇总了C++中DBManager::hasOverlaps方法的典型用法代码示例。如果您正苦于以下问题:C++ DBManager::hasOverlaps方法的具体用法?C++ DBManager::hasOverlaps怎么用?C++ DBManager::hasOverlaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager的用法示例。


在下文中一共展示了DBManager::hasOverlaps方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: accept

void ActivityWizard::accept() {
    mActivity->setName(field("name").toString());
    auto activityType = stringToActivityType(field("type").toString());
    mActivity->setType(activityType);
    if (activityType == ActivityType::INDIVIDUAL_WORK) {
        mActivity->setCanOverlap(field("canOverlap").toBool());
    } else {
        mActivity->setCanOverlap(false);
    }
    if (!field("moreThanOnce").toBool()) {
        auto selectedDateTime = field("selectedDateTime").toDateTime();
        mActivity->setStartDate(selectedDateTime.date());
        mActivity->setFinishDate(selectedDateTime.date());
        mActivity->setStartTime(selectedDateTime.time());
        mActivity->setDuration(field("fixedDuration").toTime());
        mActivity->setScheduleType(ActivityScheduleType::ONCE);
    } else {
        auto scheduleType = field("onWeekDays").toBool()
                                ? ActivityScheduleType::WEEK_DAYS
                                : ActivityScheduleType::MONTH_DAYS;
        mActivity->setScheduleType(scheduleType);
        mActivity->setStartDate(field("startDate").toDate());
        mActivity->setFinishDate(field("finishDate").toDate());
        mActivity->setStartTime(field("startTime").toTime());
        mActivity->setDuration(field("repetitiveDuration").toTime());
        mActivity->setScheduledDays(field("selectedDays").toList());
    }
    mActivity->setRoomIds(field("activityRooms").toList());
    if (mActivity->type() == ActivityType::SPECIAL_EVENT) {
        mActivity->setListIds({});
    } else {
        mActivity->setListIds(field("activityLists").toList());
    }
    QSqlError error;
    DBManager manager;

    auto overlaps = manager.hasOverlaps(*mActivity, error);
    if (error.type() != QSqlError::NoError) {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(tr("There was an error while checking whether activity "
                          "overlaps with some other one."));
        msgBox.setDetailedText(error.text());
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();
        reject();
        return;
    }

    if (overlaps) {
        QMessageBox msgBox(QMessageBox::NoIcon, tr("Activity has overlaps"),
                           tr("The activity is overlaping with other "
                              "activities. Do you want to see them?"),
                           QMessageBox::Yes | QMessageBox::No, this);
        msgBox.setWindowModality(Qt::ApplicationModal);
        msgBox.setDefaultButton(QMessageBox::Yes);
        msgBox.setButtonText(QMessageBox::Yes, tr("Yes"));
        msgBox.setButtonText(QMessageBox::No, tr("No"));
        if (msgBox.exec() == QMessageBox::Yes) {
            if (showOverlapsDialog() != QDialog::Accepted) {
                return;
            }
        }
    }

    if (!manager.saveActivity(*mActivity, error)) {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(tr("There was an error while saving activity to the "
                          "database."));
        msgBox.setDetailedText(error.text());
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();
        reject();
        return;
    }
    QWizard::accept();
}
开发者ID:toptan,项目名称:paso,代码行数:80,代码来源:activitywizard.cpp


注:本文中的DBManager::hasOverlaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。