ViewManager: ask to create Shifts before creating Jobs
JobsHelper: check if there are no shifts
This commit is contained in:
parent
2a3496f0bc
commit
b8483827ae
3 changed files with 25 additions and 0 deletions
|
@ -293,6 +293,12 @@ bool JobsHelper::copyStops(sqlite3pp::database &db, db_id fromJobId, db_id toJob
|
|||
return true;
|
||||
}
|
||||
|
||||
bool JobsHelper::checkShiftsExist(sqlite3pp::database &db)
|
||||
{
|
||||
query q(db, "SELECT id FROM jobshifts LIMIT 1");
|
||||
return q.step() == SQLITE_ROW;
|
||||
}
|
||||
|
||||
JobStopDirectionHelper::JobStopDirectionHelper(sqlite3pp::database &db) :
|
||||
mDb(db),
|
||||
m_query(new sqlite3pp::query(mDb))
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
|
||||
static bool copyStops(sqlite3pp::database &db, db_id fromJobId, db_id toJobId,
|
||||
int secsOffset, bool copyRsOps, bool reversePath);
|
||||
|
||||
static bool checkShiftsExist(sqlite3pp::database &db);
|
||||
};
|
||||
|
||||
class JobStopDirectionHelper
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "sessionstartendrsviewer.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include "utils/owningqpointer.h"
|
||||
|
||||
ViewManager::ViewManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
|
@ -618,6 +619,22 @@ bool ViewManager::requestJobCreation()
|
|||
{
|
||||
/* Creates a new job and opens JobPathEditor */
|
||||
|
||||
if(!JobsHelper::checkShiftsExist(Session->m_Db))
|
||||
{
|
||||
//It's better to create Shifts before creating Jobs,
|
||||
//remind the user on every new Job
|
||||
int ret = QMessageBox::question(m_mainWidget, tr("Create Shift too?"),
|
||||
tr("No Shift are present in this session.\n"
|
||||
"Do you want to create some before creating Jobs?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
if(ret == QMessageBox::Yes)
|
||||
{
|
||||
//Create shift
|
||||
showShiftManager();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!jobEditor || !jobEditor->createNewJob())
|
||||
return false; //JobPathEditor is busy, abort
|
||||
|
||||
|
|
Loading…
Reference in a new issue