Skip to content

Commit

Permalink
QE: Time to close extended #337 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
fvacek committed May 17, 2019
1 parent 029fe55 commit 166f526
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
20 changes: 14 additions & 6 deletions libquickevent/libquickeventcore/src/og/timems.cpp
Expand Up @@ -25,21 +25,29 @@ QString TimeMs::toString(QChar sec_sep, QChar msec_sep) const
if(!isValid())
return QString();

int msec = m_msec % 1000;
int sec = (m_msec / 1000) % 60;
int min = m_msec / (1000 * 60);
int msec = m_msec;
bool is_neg = false;
if(msec < 0) {
msec = -msec;
is_neg = true;
}
int ms = msec % 1000;
int sec = (msec / 1000) % 60;
int min = msec / (1000 * 60);
QString ret = QString::number(min) + sec_sep;
if(sec < 10)
ret += '0';
ret += QString::number(sec);
if(!msec_sep.isNull()) {
ret += msec_sep;
if(msec < 100)
if(ms < 100)
ret += '0';
if(msec < 10)
if(ms < 10)
ret += '0';
ret += QString::number(msec);
ret += QString::number(ms);
}
if(is_neg)
ret = '-' + ret;
return ret;
}

Expand Down
21 changes: 14 additions & 7 deletions quickevent/app/plugins/qml/Runs/src/eventstatisticswidget.cpp
Expand Up @@ -165,12 +165,19 @@ QVariant EventStatisticsModel::value(int row_ix, int column_ix) const
if(column_ix == col_timeToCloseMs) {
int stage_start_msec = eventPlugin()->stageStartMsec(eventPlugin()->currentStageId());
int curr_time_msec = QTime::currentTime().msecsSinceStartOfDay();
int start_last_msec = value(row_ix, col_startLastMs).toInt();
int time3_msec = value(row_ix, col_time3Ms).toInt();
int time_to_close_msec = stage_start_msec + start_last_msec + time3_msec - curr_time_msec;
if(time_to_close_msec < 0)
time_to_close_msec = 0;
return time_to_close_msec;
//int runners_count = value(row_ix, col_runnersCount).toInt();
int runners_finished = value(row_ix, col_runnersFinished).toInt();
if(runners_finished == 0) {
return QVariant();
}
else {
int start_last_msec = value(row_ix, col_startLastMs).toInt();
int time3_msec = value(row_ix, col_time3Ms).toInt();
int time_to_close_msec = stage_start_msec + start_last_msec + time3_msec - curr_time_msec;
if(time_to_close_msec < 0)
time_to_close_msec = 0;
return time_to_close_msec;
}
}
else if(column_ix == col_runnersNotFinished) {
int cnt = value(row_ix, col_runnersCount).toInt() - value(row_ix, col_runnersFinished).toInt();
Expand Down Expand Up @@ -352,7 +359,7 @@ FooterView::FooterView(QTableView *table_view, QWidget *parent)
}
QScrollBar *sb = table_view->horizontalScrollBar();
if(sb) {
connect(sb, &QScrollBar::valueChanged, this, [this](int val) {
connect(sb, &QScrollBar::valueChanged, this, [this]() {
this->setOffset(m_tableView->horizontalHeader()->offset());
});
}
Expand Down
2 changes: 0 additions & 2 deletions quickevent/app/plugins/qml/Runs/src/runstableitemdelegate.h
Expand Up @@ -17,8 +17,6 @@ class RunsTableItemDelegate : public quickevent::gui::og::ItemDelegate

void setHighlightedClassId(int class_id, int stage_id);
void reloadHighlightedClassId();

//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &ix) const Q_DECL_OVERRIDE;
protected:
void paintBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
private:
Expand Down
2 changes: 1 addition & 1 deletion quickevent/app/plugins/qml/Runs/src/runstablewidget.cpp
Expand Up @@ -241,7 +241,7 @@ void RunsTableWidget::onCustomContextMenuRequest(const QPoint &pos)
QAction a_print_card(tr("Print card"), nullptr);
QAction a_sep1(nullptr); a_sep1.setSeparator(true);
QAction a_shift_start_times(tr("Shift start times in selected rows"), nullptr);
QAction a_clear_start_times(tr("Clear times in selected rows"), nullptr);
QAction a_clear_start_times(tr("Clear start times in selected rows"), nullptr);
QList<QAction*> lst;
lst << &a_show_receipt << &a_load_card << &a_print_card
<< &a_sep1
Expand Down

0 comments on commit 166f526

Please sign in to comment.