StopModel: allow skipping travel time recalculation
- Now EditStopDialog and StopDelegate check for SHIFT pressed on save. - Added tooltips to StopEditor and EditStopDialog Ok button
This commit is contained in:
parent
0c04121867
commit
de54030785
|
@ -107,6 +107,9 @@ EditStopDialog::EditStopDialog(StopModel *m, QWidget *parent) :
|
|||
//So you get a mixed state: Arrival/Departure/Descriptio ecc changes are canceled but Coupling changes are still applied
|
||||
ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setToolTip(tr("Press SHIFT modifier and click to save changes"
|
||||
" without recalculating travel times."));
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
|
@ -261,7 +264,8 @@ void EditStopDialog::saveDataToModel()
|
|||
ui->descriptionEdit->toPlainText());
|
||||
}
|
||||
|
||||
stopModel->setStopInfo(stopIdx, curStop, prevStop.nextSegment);
|
||||
bool avoidTimeRecalc = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
||||
stopModel->setStopInfo(stopIdx, curStop, prevStop.nextSegment, avoidTimeRecalc);
|
||||
}
|
||||
|
||||
void EditStopDialog::editCoupled()
|
||||
|
|
|
@ -837,7 +837,7 @@ void StopModel::setNewShiftId(db_id shiftId)
|
|||
emit jobShiftChanged(newShiftId);
|
||||
}
|
||||
|
||||
void StopModel::setStopInfo(const QModelIndex &idx, StopItem newStop, StopItem::Segment prevSeg)
|
||||
void StopModel::setStopInfo(const QModelIndex &idx, StopItem newStop, StopItem::Segment prevSeg, bool avoidTimeRecalc)
|
||||
{
|
||||
const int row = idx.row();
|
||||
int lastUpdatedRow = row;
|
||||
|
@ -971,7 +971,7 @@ void StopModel::setStopInfo(const QModelIndex &idx, StopItem newStop, StopItem::
|
|||
|
||||
nextStop.arrival = s.departure.addSecs(secs);
|
||||
|
||||
if(oldNextArr != nextStop.arrival)
|
||||
if(timeCalcEnabled && !avoidTimeRecalc)
|
||||
{
|
||||
if(!updateStopTime(nextStop, row + 1, true, oldNextArr, oldNextDep))
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
db_id getNewShiftId() const;
|
||||
|
||||
// Setters
|
||||
void setStopInfo(const QModelIndex& idx, StopItem newStop, StopItem::Segment prevSeg);
|
||||
void setStopInfo(const QModelIndex& idx, StopItem newStop, StopItem::Segment prevSeg, bool avoidTimeRecalc = false);
|
||||
|
||||
bool setStopTypeRange(int firstRow, int lastRow, StopType type);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "app/scopedebug.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -258,7 +258,9 @@ void StopDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
|||
StopEditor *ed = static_cast<StopEditor*>(editor);
|
||||
StopModel *stopModel = static_cast<StopModel *>(model);
|
||||
|
||||
stopModel->setStopInfo(index, ed->getCurItem(), ed->getPrevItem().nextSegment);
|
||||
bool avoidTimeRecalc = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
||||
|
||||
stopModel->setStopInfo(index, ed->getCurItem(), ed->getPrevItem().nextSegment, avoidTimeRecalc);
|
||||
}
|
||||
|
||||
void StopDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const
|
||||
|
|
|
@ -43,6 +43,8 @@ StopEditor::StopEditor(sqlite3pp::database &db, StopModel *m, QWidget *parent) :
|
|||
setTabOrder(mStationEdit, arrEdit);
|
||||
setTabOrder(arrEdit, depEdit);
|
||||
setTabOrder(depEdit, mOutGateEdit);
|
||||
|
||||
setToolTip(tr("To avoid recalculation of travel times when saving changes, hold SHIFT modifier while closing editor"));
|
||||
}
|
||||
|
||||
StopEditor::~StopEditor()
|
||||
|
|
Loading…
Reference in New Issue