EditStopDialog: allow RS import from other Jobs
- Removed unused included header - Added new button to UI - New importJobRS() slot connected to button Import all uncoupled RS from another Job
This commit is contained in:
parent
a4393aec43
commit
585476240f
|
@ -15,9 +15,11 @@
|
|||
#include "model/trainassetmodel.h"
|
||||
#include "model/jobpassingsmodel.h"
|
||||
#include "jobs/jobsmanager/model/jobshelper.h"
|
||||
#include "jobs/jobsmanager/model/jobmatchmodel.h"
|
||||
|
||||
#include "utils/delegates/sql/modelpageswitcher.h"
|
||||
#include "utils/delegates/sql/customcompletionlineedit.h"
|
||||
#include "utils/delegates/sql/chooseitemdlg.h"
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
|
@ -66,6 +68,7 @@ EditStopDialog::EditStopDialog(StopModel *m, QWidget *parent) :
|
|||
ui->uncoupledView->setModel(uncoupledModel);
|
||||
ui->uncoupledLayout->insertWidget(1, ps);
|
||||
|
||||
connect(ui->importJobRsBut, &QPushButton::clicked, this, &EditStopDialog::importJobRS);
|
||||
connect(ui->editCoupledBut, &QPushButton::clicked, this, &EditStopDialog::editCoupled);
|
||||
connect(ui->editUncoupledBut, &QPushButton::clicked, this, &EditStopDialog::editUncoupled);
|
||||
|
||||
|
@ -267,6 +270,54 @@ void EditStopDialog::saveDataToModel()
|
|||
stopModel->setStopInfo(stopIdx, curStop, prevStop.nextSegment, avoidTimeRecalc);
|
||||
}
|
||||
|
||||
void EditStopDialog::importJobRS()
|
||||
{
|
||||
const StopItem& curStop = helper->getCurItem();
|
||||
if(!curStop.stationId)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Import Error"),
|
||||
tr("In order to import rollingstock from other<br>"
|
||||
"Jobs stopping in the <b>same station</b> as current one, "
|
||||
"you must first set a valid station for this stop."));
|
||||
return;
|
||||
}
|
||||
|
||||
JobMatchModel jobsMatch(Session->m_Db);
|
||||
jobsMatch.setDefaultId(JobMatchModel::StopId);
|
||||
jobsMatch.setFilter(m_jobId, curStop.stationId, curStop.departure);
|
||||
|
||||
QString stName = helper->getStationEdit()->text();
|
||||
|
||||
OwningQPointer<ChooseItemDlg> dlg = new ChooseItemDlg(&jobsMatch, this);
|
||||
dlg->setDescription(tr("Please choose a Job among the ones stopping at <b>%1</b> before <b>%2</b>.<br>"
|
||||
"All rollingstock uncoupled by selected Job at current station<br>"
|
||||
"will be coupled to current Job.")
|
||||
.arg(stName,
|
||||
curStop.departure.toString("HH:mm")));
|
||||
dlg->setPlaceholder(tr("Job number without category"));
|
||||
|
||||
//Select model
|
||||
int ret = dlg->exec();
|
||||
if(ret != QDialog::Accepted || !dlg)
|
||||
return;
|
||||
|
||||
db_id otherJobStopId = dlg->getItemId();
|
||||
if(!otherJobStopId)
|
||||
return;
|
||||
|
||||
//Import rollingstock
|
||||
int count = couplingMgr->importRSFromJob(otherJobStopId);
|
||||
|
||||
//Refresh views
|
||||
coupledModel->refreshData(true);
|
||||
trainAssetModelAfter->refreshData(true);
|
||||
|
||||
//Tell user it's completed
|
||||
QMessageBox::information(this, tr("Importation Finished"),
|
||||
tr("<b>%1</b> rollingstock items were successfully imported")
|
||||
.arg(count));
|
||||
}
|
||||
|
||||
void EditStopDialog::editCoupled()
|
||||
{
|
||||
const StopItem& curStop = helper->getCurItem();
|
||||
|
@ -284,7 +335,6 @@ void EditStopDialog::editCoupled()
|
|||
trainAssetModelAfter->refreshData(true);
|
||||
}
|
||||
|
||||
|
||||
void EditStopDialog::editUncoupled()
|
||||
{
|
||||
const StopItem& curStop = helper->getCurItem();
|
||||
|
|
|
@ -42,6 +42,7 @@ public slots:
|
|||
void done(int val) override;
|
||||
|
||||
private slots:
|
||||
void importJobRS();
|
||||
void editCoupled();
|
||||
void editUncoupled();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="stopTab">
|
||||
<attribute name="title">
|
||||
|
@ -246,40 +246,6 @@
|
|||
<string>Rollingstock</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="rsTabLay">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="coupledBox">
|
||||
<property name="title">
|
||||
<string>Coupled</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="coupledLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListView" name="coupledView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editCoupledBut">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="uncoupledBox">
|
||||
<property name="title">
|
||||
|
@ -314,7 +280,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="rollingstockBox">
|
||||
<property name="title">
|
||||
<string>Job Asset</string>
|
||||
|
@ -325,7 +291,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -360,7 +325,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -371,7 +335,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -383,6 +346,47 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="coupledBox">
|
||||
<property name="title">
|
||||
<string>Coupled</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="coupledLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListView" name="coupledView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editCoupledBut">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="importJobRsBut">
|
||||
<property name="text">
|
||||
<string>Import From Job</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="infoTab">
|
||||
|
@ -425,7 +429,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>837</width>
|
||||
<height>589</height>
|
||||
<height>581</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="infoScrollLay">
|
||||
|
|
Loading…
Reference in New Issue