Skip to content

Commit

Permalink
Fix clang tidy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Apr 22, 2024
1 parent 3397a1c commit 90ed790
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 71 deletions.
62 changes: 31 additions & 31 deletions quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ DbEventPayload DbEventPayload::fromJson(const QByteArray &json)
QVariantMap m = jsd.toVariant().toMap();
return DbEventPayload(m);
}
else {
qfError() << "JSON parse error:" << error.errorString();
}
qfError() << "JSON parse error:" << error.errorString();
return DbEventPayload();
}

Expand All @@ -99,31 +97,37 @@ QByteArray DbEventPayload::toJson() const
return jsd.toJson(QJsonDocument::Compact);
}

static auto QBE_EXT = QStringLiteral(".qbe");
/// strange is that 'quickboxDbEvent' just doesn't work without any error
/// from psql doc: Commonly, the channel name is the same as the name of some table in the database
/// I guess that channel name cannot contain capital letters to work
const char* const EventPlugin::DBEVENT_NOTIFY_NAME = "quickbox_db_event";

const char* const EventPlugin::DBEVENT_COMPETITOR_COUNTS_CHANGED = "competitorCountsChanged";
const char* const EventPlugin::DBEVENT_CARD_READ = "cardRead";
const char* const EventPlugin::DBEVENT_COMPETITOR_EDITED = "competitorEdited";
const char* const EventPlugin::DBEVENT_RUN_CHANGED = "runChanged";
const char* const EventPlugin::DBEVENT_CARD_PROCESSED_AND_ASSIGNED = "cardProcessedAndAssigned";
const char* const EventPlugin::DBEVENT_PUNCH_RECEIVED = "punchReceived";
const char* const EventPlugin::DBEVENT_REGISTRATIONS_IMPORTED = "registrationsImported";
const char* const EventPlugin::DBEVENT_STAGE_START_CHANGED = "stageStartChanged";

const char* EventPlugin::DBEVENT_COMPETITOR_COUNTS_CHANGED = "competitorCountsChanged";
const char* EventPlugin::DBEVENT_CARD_READ = "cardRead";
const char* EventPlugin::DBEVENT_COMPETITOR_EDITED = "competitorEdited";
const char* EventPlugin::DBEVENT_RUN_CHANGED = "runChanged";
const char* EventPlugin::DBEVENT_CARD_PROCESSED_AND_ASSIGNED = "cardProcessedAndAssigned";
const char* EventPlugin::DBEVENT_PUNCH_RECEIVED = "punchReceived";
const char* EventPlugin::DBEVENT_REGISTRATIONS_IMPORTED = "registrationsImported";
const char* EventPlugin::DBEVENT_STAGE_START_CHANGED = "stageStartChanged";
namespace {
const auto QBE_EXT = QStringLiteral(".qbe");

static QString singleFileStorageDir()
QString singleFileStorageDir()
{
ConnectionSettings connection_settings;
QString ret = connection_settings.singleWorkingDir();
return ret;
}

static QString eventNameToFileName(const QString &event_name)
QString eventNameToFileName(const QString &event_name)
{
QString ret = singleFileStorageDir() + '/' + event_name + QBE_EXT;
return ret;
}

static QString fileNameToEventName(const QString &file_name)
QString fileNameToEventName(const QString &file_name)
{
QString fn = file_name;
fn.replace("\\", "/");
Expand All @@ -133,11 +137,7 @@ static QString fileNameToEventName(const QString &file_name)
event_name = event_name.mid(0, event_name.length() - QBE_EXT.length());
return event_name;
}

/// strange is that 'quickboxDbEvent' just doesn't work without any error
/// from psql doc: Commonly, the channel name is the same as the name of some table in the database
/// I guess that channel name cannot contain capital letters to work
const char *EventPlugin::DBEVENT_NOTIFY_NAME = "quickbox_db_event";
}

EventPlugin::EventPlugin(QObject *parent)
: Super("Event", parent)
Expand Down Expand Up @@ -343,14 +343,14 @@ void EventPlugin::onInstalled()
tb->setObjectName("EventToolbar");
tb->setWindowTitle(tr("Event"));
{
QToolButton *bt_stage = new QToolButton();
auto *bt_stage = new QToolButton();
//bt_stage->setFlat(true);
bt_stage->setAutoRaise(true);
bt_stage->setCheckable(true);
tb->addWidget(bt_stage);
m_cbxStage = new QComboBox();
connect(m_cbxStage, &QComboBox::activated, this, &EventPlugin::onCbxStageActivated);
connect(this, &EventPlugin::currentStageIdChanged, [bt_stage](int stage_id) {
connect(this, &EventPlugin::currentStageIdChanged, bt_stage, [bt_stage](int stage_id) {
bt_stage->setText(tr("Current stage E%1").arg(stage_id));
});
QAction *act_stage = tb->addWidget(m_cbxStage);
Expand All @@ -364,7 +364,7 @@ void EventPlugin::onInstalled()
connect(m_actEditStage, &QAction::triggered, this, &EventPlugin::editStage);
tb->addAction(m_actEditStage);

connect(bt_stage, &QPushButton::clicked, [this, act_stage](bool checked) {
connect(bt_stage, &QPushButton::clicked, this, [this, act_stage](bool checked) {
act_stage->setVisible(checked);
m_actEditStage->setVisible(checked);
});
Expand Down Expand Up @@ -430,8 +430,8 @@ void EventPlugin::editStage()
{
//qfLogFuncFrame();// << "id:" << id << "mode:" << mode;
int stage_id = currentStageId();
Event::StageWidget *w = new Event::StageWidget();
auto fwk = qf::qmlwidgets::framework::MainWindow::frameWork();
auto *w = new Event::StageWidget();
auto *fwk = qf::qmlwidgets::framework::MainWindow::frameWork();
qfd::Dialog dlg(QDialogButtonBox::Save | QDialogButtonBox::Cancel, fwk);
dlg.setDefaultButton(QDialogButtonBox::Save);
dlg.setCentralWidget(w);
Expand Down Expand Up @@ -655,7 +655,7 @@ void EventPlugin::connectToSqlServer()
dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
dlg.setDefaultButton(QDialogButtonBox::Ok);
dlg.setSavePersistentPosition(false);
ConnectDbDialogWidget *conn_w = new ConnectDbDialogWidget();
auto *conn_w = new ConnectDbDialogWidget();
dlg.setCentralWidget(conn_w);
while(!connect_ok) {
conn_w->loadSettings();
Expand Down Expand Up @@ -736,8 +736,8 @@ void EventPlugin::connectToSqlServer()
openEvent(conn_w->eventName());
}
}

static bool run_sql_script(qf::core::sql::Query &q, const QStringList &sql_lines)
namespace {
bool run_sql_script(qf::core::sql::Query &q, const QStringList &sql_lines)
{
qfLogFuncFrame();
QVariantMap replacements;
Expand All @@ -758,7 +758,7 @@ static bool run_sql_script(qf::core::sql::Query &q, const QStringList &sql_lines
}
return true;
}

}
bool EventPlugin::createEvent(const QString &event_name, const QVariantMap &event_params)
{
qfLogFuncFrame();
Expand All @@ -775,7 +775,7 @@ bool EventPlugin::createEvent(const QString &event_name, const QVariantMap &even
do {
qfd::Dialog dlg(fwk);
dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
EventDialogWidget *event_w = new EventDialogWidget();
auto *event_w = new EventDialogWidget();
event_w->setWindowTitle(tr("Create event"));
event_w->setEventId(event_id);
event_w->loadParams(new_params);
Expand Down Expand Up @@ -877,7 +877,7 @@ void EventPlugin::editEvent()
qff::MainWindow *fwk = qff::MainWindow::frameWork();
qfd::Dialog dlg(fwk);
dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
EventDialogWidget *event_w = new EventDialogWidget();
auto *event_w = new EventDialogWidget();
event_w->setWindowTitle(tr("Edit event"));
event_w->setEventId(eventName());
event_w->setEventIdEditable(false);
Expand Down
18 changes: 9 additions & 9 deletions quickevent/app/quickevent/plugins/Event/src/eventplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class EventPlugin : public qf::qmlwidgets::framework::Plugin
QF_PROPERTY_BOOL_IMPL(e, E, ventOpen)
QF_PROPERTY_IMPL(QString, e, E, ventName)

static const char *DBEVENT_NOTIFY_NAME;
static const char* DBEVENT_COMPETITOR_COUNTS_CHANGED; //< number of competitors in classes changed
static const char* DBEVENT_CARD_READ;
static const char* DBEVENT_COMPETITOR_EDITED;
static const char* DBEVENT_RUN_CHANGED;
static const char* DBEVENT_CARD_PROCESSED_AND_ASSIGNED;
static const char* DBEVENT_PUNCH_RECEIVED;
static const char* DBEVENT_REGISTRATIONS_IMPORTED;
static const char* DBEVENT_STAGE_START_CHANGED;
static const char* const DBEVENT_NOTIFY_NAME;
static const char* const DBEVENT_COMPETITOR_COUNTS_CHANGED; //< number of competitors in classes changed
static const char* const DBEVENT_CARD_READ;
static const char* const DBEVENT_COMPETITOR_EDITED;
static const char* const DBEVENT_RUN_CHANGED;
static const char* const DBEVENT_CARD_PROCESSED_AND_ASSIGNED;
static const char* const DBEVENT_PUNCH_RECEIVED;
static const char* const DBEVENT_REGISTRATIONS_IMPORTED;
static const char* const DBEVENT_STAGE_START_CHANGED;

Q_INVOKABLE void initEventConfig();
Event::EventConfig* eventConfig(bool reload = false);
Expand Down
46 changes: 21 additions & 25 deletions quickevent/app/quickevent/plugins/Runs/src/runstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ QVariant RunsTableModel::value(int row_ix, int column_ix) const
sl << tr("OT", "OverTime");
if(sl.isEmpty())
return QStringLiteral("");
else
return sl.join(',');
return sl.join(',');
}
else if(column_ix == col_cardFlags) {
if(column_ix == col_cardFlags) {
qf::core::utils::TableRow row = tableRow(row_ix);
bool card_rent_requested = row.value(QStringLiteral("runs.cardLent")).toBool();
bool card_returned = row.value(QStringLiteral("runs.cardReturned")).toBool();
Expand All @@ -113,10 +112,9 @@ QVariant RunsTableModel::value(int row_ix, int column_ix) const
sl << tr("RET", "Card returned");
if(sl.isEmpty())
return QStringLiteral("");
else
return sl.join(',');
return sl.join(',');
}
else if(column_ix == col_runs_isRunning) {
if(column_ix == col_runs_isRunning) {
bool is_running = Super::value(row_ix, column_ix).toBool();
return is_running;
}
Expand Down Expand Up @@ -156,7 +154,7 @@ bool RunsTableModel::setValue(int row_ix, int column_ix, const QVariant &val)
}
return Super::setValue(row_ix, column_ix, val);
}
else if(column_ix == col_runs_penaltyTimeMs) {
if(column_ix == col_runs_penaltyTimeMs) {
int penalty_ms = val.toInt();
int old_penalty_ms = Super::value(row_ix, col_runs_penaltyTimeMs).toInt();
int time_ms = value(row_ix, col_runs_timeMs).toInt();
Expand All @@ -166,30 +164,28 @@ bool RunsTableModel::setValue(int row_ix, int column_ix, const QVariant &val)
}
return Super::setValue(row_ix, column_ix, val);
}
else if(column_ix == col_runs_timeMs) {
if(column_ix == col_runs_timeMs) {
int rt = val.toInt();
if(rt == 0) {
/// run time cannot be 0
Super::setValue(row_ix, col_runs_finishTimeMs, QVariant());
Super::setValue(row_ix, col_runs_penaltyTimeMs, QVariant());
return Super::setValue(row_ix, column_ix, QVariant());
}
else {
QVariant start_ms = value(row_ix, col_runs_startTimeMs);
if(!start_ms.isNull()) {
int penalty_ms = value(row_ix, col_runs_penaltyTimeMs).toInt();
int finish_ms = val.toInt() + start_ms.toInt() - penalty_ms;
if(finish_ms > 0) {
Super::setValue(row_ix, col_runs_finishTimeMs, finish_ms);
}
else {
Super::setValue(row_ix, col_runs_finishTimeMs, QVariant());
}
QVariant start_ms = value(row_ix, col_runs_startTimeMs);
if(!start_ms.isNull()) {
int penalty_ms = value(row_ix, col_runs_penaltyTimeMs).toInt();
int finish_ms = val.toInt() + start_ms.toInt() - penalty_ms;
if(finish_ms > 0) {
Super::setValue(row_ix, col_runs_finishTimeMs, finish_ms);
}
else {
Super::setValue(row_ix, col_runs_finishTimeMs, QVariant());
}
return Super::setValue(row_ix, column_ix, val);
}
return Super::setValue(row_ix, column_ix, val);
}
else if(column_ix == col_runs_startTimeMs) {
if(column_ix == col_runs_startTimeMs) {
if(!val.isNull()) {
int start_ms = val.toInt();
int finish_ms = value(row_ix, col_runs_finishTimeMs).toInt();
Expand All @@ -209,7 +205,7 @@ bool RunsTableModel::setValue(int row_ix, int column_ix, const QVariant &val)
return ret;
}

static auto MIME_TYPE = QStringLiteral("application/quickevent.startTime");
static const auto MIME_TYPE = QStringLiteral("application/quickevent.startTime");

QStringList RunsTableModel::mimeTypes() const
{
Expand All @@ -221,7 +217,7 @@ QStringList RunsTableModel::mimeTypes() const
QMimeData *RunsTableModel::mimeData(const QModelIndexList &indexes) const
{
qfLogFuncFrame();
QMimeData *mimeData = new QMimeData();
auto *mimeData = new QMimeData();
QByteArray encoded_data = QString::number(indexes.value(0).row()).toUtf8();
mimeData->setData(MIME_TYPE, encoded_data);
return mimeData;
Expand Down Expand Up @@ -291,8 +287,8 @@ void RunsTableModel::switchStartTimes(int r1, int r2)
}
else {
//qf::core::sql::Transaction transaction(sqlConnection());
quickevent::core::og::TimeMs t1 = v1.value<quickevent::core::og::TimeMs>();
quickevent::core::og::TimeMs t2 = v2.value<quickevent::core::og::TimeMs>();
auto t1 = v1.value<quickevent::core::og::TimeMs>();
auto t2 = v2.value<quickevent::core::og::TimeMs>();
int msec1 = -1, msec2 = -1;
qf::core::sql::Query q(sqlConnection());
QString qs = "SELECT id, startTimeMs FROM runs WHERE id IN (" QF_IARG(id1) ", " QF_IARG(id2) ")";
Expand Down
6 changes: 1 addition & 5 deletions quickevent/app/quickevent/src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ Application::Application(int &argc, char **argv, AppCliOptions *cli_opts)
//qf::qmlwidgets::reports::ReportProcessor::qmlEngineImportPaths().append(plugin_path);
}

Application::~Application()
{
}

Application *Application::instance(bool must_exist)
{
Application *ret = qobject_cast<Application*>(Super::instance());
auto *ret = qobject_cast<Application*>(Super::instance());
if(!ret && must_exist) {
qfFatal("Application instance MUST exist.");
}
Expand Down
2 changes: 1 addition & 1 deletion quickevent/app/quickevent/src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Application : public qf::qmlwidgets::framework::Application
typedef qf::qmlwidgets::framework::Application Super;
public:
Application(int & argc, char ** argv, AppCliOptions *cli_opts);
~Application() Q_DECL_OVERRIDE;
~Application() override = default;

static Application* instance(bool must_exist = true);

Expand Down

0 comments on commit 90ed790

Please sign in to comment.