void LocalXmlBackend::saveTasks() { QList<ITask*> tasks; do { tasks = m_database->getTasks( IDatabase::QueryDirty, 100 ); for ( ITask *task : tasks ) { QString fileName = task->metaAttributes().value( TaskMetaFileName ).toString(); if ( fileName.isEmpty() ) { ITodo* todo = m_database->getTodo( task->todo() ); if ( todo ) { QString todoFileName = m_localStorageDirectory + "/" + todo->metaAttributes().value( TodoMetaFileName ).toString(); QFileInfo todoFI( todoFileName ); if ( todoFI.isFile() ) { QDir dir( todoFI.absolutePath() ); if ( dir.cd( todo->uuid().toString() ) || ( dir.mkdir( todo->uuid().toString() ) && dir.cd( todo->uuid().toString() ) ) ) { QVariantMap attrs = task->metaAttributes(); attrs.insert( TaskMetaFileName, QDir( m_localStorageDirectory ).relativeFilePath( dir.absoluteFilePath( task->uuid().toString() + ".xml" ) ) ); task->setMetaAttributes( attrs ); } } delete todo; } } saveTask( task ); m_database->onTaskSaved( task ); delete task; } } while ( !tasks.isEmpty() ); }
void TaskWidgetItem::TaskWidgetItem::editTask() { qDebug() << (int)parentWidget()->geometry().width(); m_editor = new TaskEditor(); m_editor->setAllDay(m_todo->allDay()); if (m_todo->hasStartDate()) { m_editor->setStartDate(m_todo->dtStart()); } else { m_editor->disableStartDate(); if (m_todo->hasDueDate()) { if (m_todo->dtDue().date() < QDate::currentDate()) { m_editor->setStartDate(m_todo->dtDue()); } } } if (m_todo->hasDueDate()) { m_editor->setDueDate(m_todo->dtDue()); } else { m_editor->disableDueDate(); } m_editor->setName(m_todo->summary()); m_editor->setDescription(m_todo->description()); KDialog * dialog = new KDialog(); dialog->setCaption(m_todo->summary()); dialog->setButtons(KDialog::Ok | KDialog::Cancel); dialog->setMainWidget(m_editor); connect(dialog, SIGNAL(okClicked()), SLOT(saveTask())); connect(dialog, SIGNAL(okClicked()), dialog, SLOT(delayedDestruct())); connect(dialog, SIGNAL(cancelClicked()), dialog, SLOT(delayedDestruct())); dialog->show(); }
void TaskWidget::assistantBtnClicked() { if (!mpTask) return; saveTask(); //this is necessary since the output may use information from the problem DefaultPlotDialog * pDlg = new DefaultPlotDialog(this); pDlg->setTask(mpTask); if (pDlg->exec() == QDialog::Accepted) { protectedNotify(ListViews::ObjectType::PLOT, ListViews::ADD, std::string()); } if (pDlg)delete pDlg; }
bool TaskWidget::commonBeforeRunTask() { // save the state of the widget if (!saveTask()) { CQMessageBox::critical(this, "Simulation Error", CCopasiMessage::getAllMessageText().c_str(), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); return false; } if (!mpTask) return false; if (mProgressBar != NULL) { //CQMessageBox::critical(this, "Task in Progress", // "A task is currently running, another cannot be started before the current task ended.", // QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); return false; } // if overwrite is enabled and the file exists, then ask if (!mpTask->getReport().getTarget().empty() && mpTask->getReport().confirmOverwrite() && QFile(mpTask->getReport().getTarget().c_str()).exists()) { if (QMessageBox::question(this, QString("Confirm Overwrite"), QString("The report file already exists. Would you like to overwrite it? \n\n(You can disable this dialog by clicking the 'Report' button.)"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) return false; } //set mouse cursor setCursor(Qt::WaitCursor); //handle autosave feature CopasiUI3Window::getMainWindow()->autoSave(); CopasiUI3Window::getMainWindow()->suspendAutoSave(true); //create progress bar mProgressBar = CProgressBar::create(); mpTask->setCallBack(mProgressBar); CCopasiMessage::clearDeque(); return true; }
bool TaskWidget::leaveProtected() { return saveTask(); }
bool TaskWidget::commonBeforeRunTask() { // save the state of the widget if (!saveTask()) { CQMessageBox::critical(this, "Simulation Error", CCopasiMessage::getAllMessageText().c_str(), QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); return false; } if (!mpTask) return false; if (mProgressBar != NULL) { //CQMessageBox::critical(this, "Task in Progress", // "A task is currently running, another cannot be started before the current task ended.", // QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton); return false; } // if overwrite is enabled and the file exists, then ask if (!mpTask->getReport().getTarget().empty() && mpTask->getReport().confirmOverwrite()) { // The target might be a relative path std::string Target = mpTask->getReport().getTarget(); if (CDirEntry::isRelativePath(Target) && !CDirEntry::makePathAbsolute(Target, mpDataModel->getReferenceDirectory())) Target = CDirEntry::fileName(Target); if (CDirEntry::exist(Target) && QMessageBox::question(this, QString("Confirm Overwrite"), QString("The report file already exists. Would you like to overwrite it? \n\n(You can disable this dialog by clicking the 'Report' button.)"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) return false; } //set mouse cursor setCursor(Qt::WaitCursor); //handle autosave feature CopasiUI3Window::getMainWindow()->autoSave(); CopasiUI3Window::getMainWindow()->suspendAutoSave(true); //create progress bar mProgressBar = CProgressBar::create(); mpTask->setCallBack(mProgressBar); CCopasiMessage::clearDeque(); // create population display if needed if (CRootContainer::getConfiguration()->displayPopulations()) { if (dynamic_cast<COptTask*>(mpTask) != NULL || dynamic_cast<CFitTask*>(mpTask) != NULL) { CopasiUI3Window* pWindow = CopasiUI3Window::getMainWindow(); CQOptPopulation* pPopWidget = pWindow->getPopulationDisplay(); COptPopulationMethod* pMethod = dynamic_cast<COptPopulationMethod*>(mpTask->getMethod()); pPopWidget->setMethod(pMethod); if (pMethod != NULL) { pPopWidget->addToMainWindow(pWindow); pPopWidget->show(); mpDataModel->addInterface(pPopWidget); } } } return true; }
bool TaskWidget::leave() { return saveTask(); }