本文整理汇总了C++中DBManager::saveActivity方法的典型用法代码示例。如果您正苦于以下问题:C++ DBManager::saveActivity方法的具体用法?C++ DBManager::saveActivity怎么用?C++ DBManager::saveActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager::saveActivity方法的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();
}