diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a6ea03698..56ff39aca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,4 +39,4 @@ jobs: - name: Run clazy uses: ./.github/actions/run-linter with: - lint_program_with_args: clazy-standalone --checks=level1,no-fully-qualified-moc-types,no-non-pod-global-static,no-qstring-arg,no-qproperty-without-notify,no-range-loop-detach,no-lambda-unique-connection + lint_program_with_args: clazy-standalone --checks=level1,no-fully-qualified-moc-types,no-non-pod-global-static,no-qstring-arg,no-qproperty-without-notify,no-range-loop-detach,no-lambda-unique-connection,no-qstring-ref diff --git a/libqf/libqfcore/CMakeLists.txt b/libqf/libqfcore/CMakeLists.txt index 6bdab83fb..7501d285f 100644 --- a/libqf/libqfcore/CMakeLists.txt +++ b/libqf/libqfcore/CMakeLists.txt @@ -5,11 +5,6 @@ add_library(libqfcore SHARED src/core/stacktrace.cpp src/core/string.cpp src/core/utils.cpp - src/model/datadocument.cpp - src/model/logtablemodel.cpp - src/model/sqldatadocument.cpp - src/model/sqltablemodel.cpp - src/model/tablemodel.cpp src/network/networkaccessmanager.cpp src/network/networkreply.cpp src/sql/catalog.cpp diff --git a/libqf/libqfcore/src/core/utils.cpp b/libqf/libqfcore/src/core/utils.cpp index 5e62a301e..5b591a1f6 100644 --- a/libqf/libqfcore/src/core/utils.cpp +++ b/libqf/libqfcore/src/core/utils.cpp @@ -9,12 +9,6 @@ namespace qf::core { -const QString& Utils::nullValueString() -{ - static QString n = QStringLiteral("null"); - return n; -} - void qf::core::Utils::parseFieldName(const QString &full_field_name, QString *pfield_name, QString *ptable_name, QString *pdb_name) { QString s = full_field_name; @@ -269,6 +263,9 @@ QStringList Utils::parseProgramAndArgumentsList(const QString &command_line) QVariant Utils::jsonToQVariant(const QString &json) { + if (json.isEmpty()) { + return {}; + } QJsonParseError error; auto doc = QJsonDocument::fromJson(json.toUtf8(), &error); if (error.error != QJsonParseError::NoError) { diff --git a/libqf/libqfcore/src/core/utils.h b/libqf/libqfcore/src/core/utils.h index 8f1633edb..68adb2599 100644 --- a/libqf/libqfcore/src/core/utils.h +++ b/libqf/libqfcore/src/core/utils.h @@ -156,7 +156,6 @@ namespace core { class QFCORE_DECL_EXPORT Utils { public: - static const QString &nullValueString(); static void parseFieldName(const QString& full_field_name, QString *pfield_name = nullptr, QString *ptable_name = nullptr, QString *pdb_name = nullptr); static QString composeFieldName(const QString &field_name, const QString &table_name = QString(), const QString &db_name = QString()); /// @returns: True if @a field_name1 ends with @a field_name2. Comparision is case insensitive diff --git a/libqf/libqfcore/src/sql/connection.cpp b/libqf/libqfcore/src/sql/connection.cpp index 9f827224a..11a9b232b 100644 --- a/libqf/libqfcore/src/sql/connection.cpp +++ b/libqf/libqfcore/src/sql/connection.cpp @@ -87,9 +87,11 @@ void Connection::close() Connection Connection::forName(const QString &connection_name) { QString cn = connection_name; - if(cn.isEmpty()) + if(cn.isEmpty()) { cn = QSqlDatabase::defaultConnection; - Connection ret(QSqlDatabase::database(cn, false)); + } + auto db = QSqlDatabase::database(cn, false); + Connection ret(db); return ret; } diff --git a/libqf/libqfqmlwidgets/CMakeLists.txt b/libqf/libqfqmlwidgets/CMakeLists.txt index 726da81f1..28ddb9c22 100644 --- a/libqf/libqfqmlwidgets/CMakeLists.txt +++ b/libqf/libqfqmlwidgets/CMakeLists.txt @@ -7,6 +7,13 @@ add_library(libqfqmlwidgets SHARED src/dateedit.cpp src/datetimeedit.cpp src/dialogbuttonbox.cpp + + src/model/datadocument.cpp + src/model/logtablemodel.cpp + src/model/sqldatadocument.cpp + src/model/sqltablemodel.cpp + src/model/tablemodel.cpp + src/dialogs/dialog.cpp src/dialogs/filedialog.cpp src/dialogs/getiteminputdialog.cpp @@ -98,8 +105,10 @@ add_library(libqfqmlwidgets SHARED src/timeedit.cpp src/toolbar.cpp style/qf_qmlwidgets_style.qrc + images/qf_qmlwidgets_images.qrc images/flat/qf_qmlwidgets_images_flat.qrc + images/dark/qf_qmlwidgets_images_dark.qrc src/reports/widgets/printtableviewwidget/reports/qf_qmlwidgets_printtablewidget_reports.qrc ) diff --git a/libqf/libqfqmlwidgets/images/dark/clone-row.svg b/libqf/libqfqmlwidgets/images/dark/clone-row.svg new file mode 100644 index 000000000..dcc039720 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/clone-row.svg @@ -0,0 +1,68 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/copy.svg b/libqf/libqfqmlwidgets/images/dark/copy.svg new file mode 100644 index 000000000..dbfda77b5 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/copy.svg @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/cut.svg b/libqf/libqfqmlwidgets/images/dark/cut.svg new file mode 100644 index 000000000..1d9551ada --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/cut.svg @@ -0,0 +1,60 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/delete-column.svg b/libqf/libqfqmlwidgets/images/dark/delete-column.svg new file mode 100644 index 000000000..06dabb9bf --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/delete-column.svg @@ -0,0 +1,66 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/delete-row.svg b/libqf/libqfqmlwidgets/images/dark/delete-row.svg new file mode 100644 index 000000000..a5780ec4c --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/delete-row.svg @@ -0,0 +1,65 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/delete.svg b/libqf/libqfqmlwidgets/images/dark/delete.svg new file mode 100644 index 000000000..aacf76fd4 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/delete.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/down.svg b/libqf/libqfqmlwidgets/images/dark/down.svg new file mode 100644 index 000000000..b41df834f --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/down.svg @@ -0,0 +1,56 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/find.svg b/libqf/libqfqmlwidgets/images/dark/find.svg new file mode 100644 index 000000000..a8253e7ab --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/find.svg @@ -0,0 +1,57 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/home.svg b/libqf/libqfqmlwidgets/images/dark/home.svg new file mode 100644 index 000000000..3d7aac369 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/home.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/insert-column.svg b/libqf/libqfqmlwidgets/images/dark/insert-column.svg new file mode 100644 index 000000000..6558fe049 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/insert-column.svg @@ -0,0 +1,63 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/insert-row.svg b/libqf/libqfqmlwidgets/images/dark/insert-row.svg new file mode 100644 index 000000000..ceb1857d0 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/insert-row.svg @@ -0,0 +1,63 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/left.svg b/libqf/libqfqmlwidgets/images/dark/left.svg new file mode 100644 index 000000000..9d9e0f7c5 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/left.svg @@ -0,0 +1,56 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/media-pause.svg b/libqf/libqfqmlwidgets/images/dark/media-pause.svg new file mode 100644 index 000000000..0fc5cd17d --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-pause.svg @@ -0,0 +1,39 @@ + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-play.svg b/libqf/libqfqmlwidgets/images/dark/media-play.svg new file mode 100644 index 000000000..f4e9c6c6d --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-play.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-record.svg b/libqf/libqfqmlwidgets/images/dark/media-record.svg new file mode 100644 index 000000000..a9db4e83a --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-record.svg @@ -0,0 +1,39 @@ + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-skip-backward.svg b/libqf/libqfqmlwidgets/images/dark/media-skip-backward.svg new file mode 100644 index 000000000..9a90de2e5 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-skip-backward.svg @@ -0,0 +1,38 @@ + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-skip-forward.svg b/libqf/libqfqmlwidgets/images/dark/media-skip-forward.svg new file mode 100644 index 000000000..5b1bb0e74 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-skip-forward.svg @@ -0,0 +1,38 @@ + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-step-backward.svg b/libqf/libqfqmlwidgets/images/dark/media-step-backward.svg new file mode 100644 index 000000000..b03ef89e0 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-step-backward.svg @@ -0,0 +1,47 @@ + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-step-forward.svg b/libqf/libqfqmlwidgets/images/dark/media-step-forward.svg new file mode 100644 index 000000000..82bf89945 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-step-forward.svg @@ -0,0 +1,47 @@ + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/media-stop.svg b/libqf/libqfqmlwidgets/images/dark/media-stop.svg new file mode 100644 index 000000000..5ecfe9d64 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/media-stop.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/menu.svg b/libqf/libqfqmlwidgets/images/dark/menu.svg new file mode 100644 index 000000000..6572dfc9c --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/menu.svg @@ -0,0 +1,72 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/new.svg b/libqf/libqfqmlwidgets/images/dark/new.svg new file mode 100644 index 000000000..4552f293f --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/new.svg @@ -0,0 +1,54 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/open.svg b/libqf/libqfqmlwidgets/images/dark/open.svg new file mode 100644 index 000000000..c38436459 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/open.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/paste.svg b/libqf/libqfqmlwidgets/images/dark/paste.svg new file mode 100644 index 000000000..49c5e7153 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/paste.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/printer.svg b/libqf/libqfqmlwidgets/images/dark/printer.svg new file mode 100644 index 000000000..979e7b0fc --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/printer.svg @@ -0,0 +1,59 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/qf_qmlwidgets_images_dark.qrc b/libqf/libqfqmlwidgets/images/dark/qf_qmlwidgets_images_dark.qrc new file mode 100644 index 000000000..4d8871627 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/qf_qmlwidgets_images_dark.qrc @@ -0,0 +1,40 @@ + + + home.svg + new.svg + open.svg + save.svg + reload.svg + revert.svg + delete.svg + find.svg + sort-asc.svg + sort-desc.svg + insert-row.svg + insert-column.svg + clone-row.svg + delete-row.svg + delete-column.svg + copy.svg + cut.svg + paste.svg + printer.svg + settings.svg + left.svg + right.svg + up.svg + down.svg + menu.svg + zoom_fitall.svg + zoom_fitwidth.svg + zoom_fitheight.svg + media-pause.svg + media-play.svg + media-record.svg + media-skip-backward.svg + media-skip-forward.svg + media-step-backward.svg + media-step-forward.svg + media-stop.svg + + diff --git a/libqf/libqfqmlwidgets/images/dark/reload.svg b/libqf/libqfqmlwidgets/images/dark/reload.svg new file mode 100644 index 000000000..3332d7d0c --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/reload.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/revert.svg b/libqf/libqfqmlwidgets/images/dark/revert.svg new file mode 100644 index 000000000..daa54b040 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/revert.svg @@ -0,0 +1,62 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/right.svg b/libqf/libqfqmlwidgets/images/dark/right.svg new file mode 100644 index 000000000..d45e9fa91 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/right.svg @@ -0,0 +1,86 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/save.svg b/libqf/libqfqmlwidgets/images/dark/save.svg new file mode 100644 index 000000000..6ed35b326 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/save.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/settings.svg b/libqf/libqfqmlwidgets/images/dark/settings.svg new file mode 100644 index 000000000..ec2aa8575 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/settings.svg @@ -0,0 +1,66 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/sort-asc.svg b/libqf/libqfqmlwidgets/images/dark/sort-asc.svg new file mode 100644 index 000000000..06716ba50 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/sort-asc.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/sort-desc.svg b/libqf/libqfqmlwidgets/images/dark/sort-desc.svg new file mode 100644 index 000000000..c272e952b --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/sort-desc.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/libqf/libqfqmlwidgets/images/dark/up.svg b/libqf/libqfqmlwidgets/images/dark/up.svg new file mode 100644 index 000000000..0aa13f6d1 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/up.svg @@ -0,0 +1,56 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/zoom_fitall.svg b/libqf/libqfqmlwidgets/images/dark/zoom_fitall.svg new file mode 100644 index 000000000..4e132b3ff --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/zoom_fitall.svg @@ -0,0 +1,87 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/zoom_fitheight.svg b/libqf/libqfqmlwidgets/images/dark/zoom_fitheight.svg new file mode 100644 index 000000000..9c0c9b2e0 --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/zoom_fitheight.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml diff --git a/libqf/libqfqmlwidgets/images/dark/zoom_fitwidth.svg b/libqf/libqfqmlwidgets/images/dark/zoom_fitwidth.svg new file mode 100644 index 000000000..a80a7394d --- /dev/null +++ b/libqf/libqfqmlwidgets/images/dark/zoom_fitwidth.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml diff --git a/libqf/libqfcore/include/qf/core/model/datadocument.h b/libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/datadocument.h similarity index 100% rename from libqf/libqfcore/include/qf/core/model/datadocument.h rename to libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/datadocument.h diff --git a/libqf/libqfcore/include/qf/core/model/logtablemodel.h b/libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/logtablemodel.h similarity index 100% rename from libqf/libqfcore/include/qf/core/model/logtablemodel.h rename to libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/logtablemodel.h diff --git a/libqf/libqfcore/include/qf/core/model/sqldatadocument.h b/libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/sqldatadocument.h similarity index 100% rename from libqf/libqfcore/include/qf/core/model/sqldatadocument.h rename to libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/sqldatadocument.h diff --git a/libqf/libqfcore/include/qf/core/model/sqltablemodel.h b/libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/sqltablemodel.h similarity index 100% rename from libqf/libqfcore/include/qf/core/model/sqltablemodel.h rename to libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/sqltablemodel.h diff --git a/libqf/libqfcore/include/qf/core/model/tablemodel.h b/libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/tablemodel.h similarity index 100% rename from libqf/libqfcore/include/qf/core/model/tablemodel.h rename to libqf/libqfqmlwidgets/include/qf/qmlwidgets/model/tablemodel.h diff --git a/libqf/libqfqmlwidgets/src/combobox.cpp b/libqf/libqfqmlwidgets/src/combobox.cpp index b6a8dfee4..2f09ca494 100644 --- a/libqf/libqfqmlwidgets/src/combobox.cpp +++ b/libqf/libqfqmlwidgets/src/combobox.cpp @@ -259,7 +259,7 @@ void DbEnumComboBox::loadItems(bool force) QColor c = dbe.color(); if(c.isValid()) { setItemData(count() - 1, c, Qt::BackgroundRole); - setItemData(count() - 1, qf::core::model::TableModel::contrastTextColor(c), Qt::ForegroundRole); + setItemData(count() - 1, qf::qmlwidgets::model::TableModel::contrastTextColor(c), Qt::ForegroundRole); } } } diff --git a/libqf/libqfqmlwidgets/src/datacontroller.cpp b/libqf/libqfqmlwidgets/src/datacontroller.cpp index 2dc73625b..4feba93db 100644 --- a/libqf/libqfqmlwidgets/src/datacontroller.cpp +++ b/libqf/libqfqmlwidgets/src/datacontroller.cpp @@ -15,20 +15,20 @@ DataController::DataController(QObject *parent) DataController::~DataController() = default; -qf::core::model::DataDocument *DataController::document(bool throw_exc) const +qf::qmlwidgets::model::DataDocument *DataController::document(bool throw_exc) const { if(!m_document && throw_exc) QF_EXCEPTION("DataDocument is NULL!"); return m_document; } -void DataController::setDocument(qf::core::model::DataDocument *doc) +void DataController::setDocument(qf::qmlwidgets::model::DataDocument *doc) { if(m_document != doc) { m_document = doc; - connect(doc, &qf::core::model::DataDocument::loaded, this, &DataController::documentLoaded); - connect(doc, &qf::core::model::DataDocument::valueChanged, this, &DataController::documentValueChanged); - connect(doc, &qf::core::model::DataDocument::aboutToSave, this, &DataController::documentAboutToSave); + connect(doc, &qf::qmlwidgets::model::DataDocument::loaded, this, &DataController::documentLoaded); + connect(doc, &qf::qmlwidgets::model::DataDocument::valueChanged, this, &DataController::documentValueChanged); + connect(doc, &qf::qmlwidgets::model::DataDocument::aboutToSave, this, &DataController::documentAboutToSave); emit documentChanged(doc); } } diff --git a/libqf/libqfqmlwidgets/src/datacontroller.h b/libqf/libqfqmlwidgets/src/datacontroller.h index b8edc21e9..c82669189 100644 --- a/libqf/libqfqmlwidgets/src/datacontroller.h +++ b/libqf/libqfqmlwidgets/src/datacontroller.h @@ -2,9 +2,9 @@ #define QF_QMLWIDGETS_DATACONTROLLER_H #include "qmlwidgetsglobal.h" +#include "model/datadocument.h" #include -#include #include #include @@ -17,7 +17,7 @@ class IDataWidget; class QFQMLWIDGETS_DECL_EXPORT DataController : public QObject { Q_OBJECT - Q_PROPERTY(qf::core::model::DataDocument* document READ document WRITE setDocument NOTIFY documentChanged) + Q_PROPERTY(qf::qmlwidgets::model::DataDocument* document READ document WRITE setDocument NOTIFY documentChanged) Q_PROPERTY(QWidget* widget READ widget WRITE setWidget NOTIFY widgetChanged) //Q_PROPERTY(QString dbConnectionName READ dbConnectionName WRITE setDbConnectionName) public: @@ -26,9 +26,9 @@ class QFQMLWIDGETS_DECL_EXPORT DataController : public QObject //QF_PROPERTY_IMPL2(QString, d, D, bConnectionName, QSqlDatabase::defaultConnection) - qf::core::model::DataDocument* document(bool throw_exc = qf::core::Exception::Throw) const; - void setDocument(qf::core::model::DataDocument *doc); - Q_SIGNAL void documentChanged(qf::core::model::DataDocument *doc); + qf::qmlwidgets::model::DataDocument* document(bool throw_exc = qf::core::Exception::Throw) const; + void setDocument(qf::qmlwidgets::model::DataDocument *doc); + Q_SIGNAL void documentChanged(qf::qmlwidgets::model::DataDocument *doc); QWidget* widget() const { return m_dataWidgetsParent;} void setWidget(QWidget *w) @@ -49,7 +49,7 @@ class QFQMLWIDGETS_DECL_EXPORT DataController : public QObject Q_SLOT void documentValueChanged(const QString &data_id, const QVariant &old_val, const QVariant &new_val); Q_SLOT void documentAboutToSave(); protected: - qf::core::model::DataDocument *m_document = nullptr; + qf::qmlwidgets::model::DataDocument *m_document = nullptr; QWidget *m_dataWidgetsParent = nullptr; QList m_dataWidgets; }; diff --git a/libqf/libqfqmlwidgets/src/dialogs/dialog.cpp b/libqf/libqfqmlwidgets/src/dialogs/dialog.cpp index fc943f3c4..7321f815b 100644 --- a/libqf/libqfqmlwidgets/src/dialogs/dialog.cpp +++ b/libqf/libqfqmlwidgets/src/dialogs/dialog.cpp @@ -133,7 +133,7 @@ void Dialog::setRecordEditMode(int mode) if(m_dialogButtonBox) { auto bt_save = m_dialogButtonBox->button(QDialogButtonBox::Save); if(bt_save) { - if(mode == qf::core::model::DataDocument::ModeDelete) { + if(mode == qf::qmlwidgets::model::DataDocument::ModeDelete) { bt_save->setText(tr("Delete")); } else { diff --git a/libqf/libqfqmlwidgets/src/dialogs/internal/captionframe.cpp b/libqf/libqfqmlwidgets/src/dialogs/internal/captionframe.cpp index 78cace2d1..c562530e7 100644 --- a/libqf/libqfqmlwidgets/src/dialogs/internal/captionframe.cpp +++ b/libqf/libqfqmlwidgets/src/dialogs/internal/captionframe.cpp @@ -4,7 +4,7 @@ #include "../../style.h" #include -#include +#include #include #include @@ -95,7 +95,7 @@ QIcon CaptionFrame::createIcon() void CaptionFrame::setRecordEditMode(int mode) { - qfLogFuncFrame() << "mode:" << qf::core::model::DataDocument::recordEditModeToString(qf::core::model::DataDocument::RecordEditMode(mode)); + qfLogFuncFrame() << "mode:" << qf::qmlwidgets::model::DataDocument::recordEditModeToString(qf::qmlwidgets::model::DataDocument::RecordEditMode(mode)); m_recordEditMode = mode; update(); } @@ -105,12 +105,12 @@ void CaptionFrame::update() qfLogFuncFrame() << "text:" << text(); QString label_text = text(); if(m_recordEditMode >= 0) { - auto mode = qf::core::model::DataDocument::RecordEditMode(m_recordEditMode); - if(mode == qf::core::model::DataDocument::ModeDelete) { + auto mode = qf::qmlwidgets::model::DataDocument::RecordEditMode(m_recordEditMode); + if(mode == qf::qmlwidgets::model::DataDocument::ModeDelete) { label_text = tr("Delete ") + label_text; setAlert(true); } - else if(mode == qf::core::model::DataDocument::ModeEdit) { + else if(mode == qf::qmlwidgets::model::DataDocument::ModeEdit) { label_text = tr("Edit ") + label_text; } } diff --git a/libqf/libqfqmlwidgets/src/exportcsvtableviewwidget.cpp b/libqf/libqfqmlwidgets/src/exportcsvtableviewwidget.cpp index 202b5b294..57454f8cd 100644 --- a/libqf/libqfqmlwidgets/src/exportcsvtableviewwidget.cpp +++ b/libqf/libqfqmlwidgets/src/exportcsvtableviewwidget.cpp @@ -1,8 +1,7 @@ #include "exportcsvtableviewwidget.h" #include "ui_exporttableviewwidget.h" -#include - +#include namespace qf::qmlwidgets { diff --git a/libqf/libqfqmlwidgets/src/framework/datadialogwidget.cpp b/libqf/libqfqmlwidgets/src/framework/datadialogwidget.cpp index a7206c05d..151c063f6 100644 --- a/libqf/libqfqmlwidgets/src/framework/datadialogwidget.cpp +++ b/libqf/libqfqmlwidgets/src/framework/datadialogwidget.cpp @@ -1,10 +1,10 @@ #include "datadialogwidget.h" #include "../dialogs/dialog.h" -#include +#include #include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using namespace qf::qmlwidgets::framework; DataDialogWidget::DataDialogWidget(QWidget *parent) @@ -28,7 +28,7 @@ void DataDialogWidget::setDataController(qf::qmlwidgets::DataController *dc) m_dataController = dc; } -qf::core::model::DataDocument *DataDialogWidget::dataDocument(bool throw_exc) +qf::qmlwidgets::model::DataDocument *DataDialogWidget::dataDocument(bool throw_exc) { qf::qmlwidgets::DataController *dc = dataController(); return dc->document(throw_exc); @@ -36,13 +36,10 @@ qf::core::model::DataDocument *DataDialogWidget::dataDocument(bool throw_exc) bool DataDialogWidget::load(const QVariant &id, int mode) { - core::model::DataDocument *doc = dataDocument(!qf::core::Exception::Throw); + auto *doc = dataDocument(!qf::core::Exception::Throw); if(doc) { - //connect(doc, &qfm::DataDocument::saved, this, &DataDialogWidget::dataSaved, Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); - //qfInfo() << "============" << (bool)c; connect(doc, &qfm::DataDocument::saved, this, &DataDialogWidget::dataSaved, Qt::UniqueConnection); - bool ok = doc->load(id, qf::core::model::DataDocument::RecordEditMode(mode)); - //qfInfo() << "emit ..."; + bool ok = doc->load(id, qf::qmlwidgets::model::DataDocument::RecordEditMode(mode)); if(ok) emit recordEditModeChanged(mode); return ok; @@ -56,12 +53,12 @@ bool DataDialogWidget::acceptDialogDone(int result) bool ret = true; if(result == qf::qmlwidgets::dialogs::Dialog::ResultAccept) { auto mode = recordEditMode(); - if(mode == qf::core::model::DataDocument::ModeDelete) { + if(mode == qf::qmlwidgets::model::DataDocument::ModeDelete) { ret = dropData(); } - else if(mode == qf::core::model::DataDocument::ModeEdit - || mode == qf::core::model::DataDocument::ModeInsert - || mode == qf::core::model::DataDocument::ModeCopy) { + else if(mode == qf::qmlwidgets::model::DataDocument::ModeEdit + || mode == qf::qmlwidgets::model::DataDocument::ModeInsert + || mode == qf::qmlwidgets::model::DataDocument::ModeCopy) { ret = saveData(); } } diff --git a/libqf/libqfqmlwidgets/src/framework/datadialogwidget.h b/libqf/libqfqmlwidgets/src/framework/datadialogwidget.h index 1dea10058..e0b69b49f 100644 --- a/libqf/libqfqmlwidgets/src/framework/datadialogwidget.h +++ b/libqf/libqfqmlwidgets/src/framework/datadialogwidget.h @@ -5,7 +5,7 @@ #include "../datacontroller.h" #include "dialogwidget.h" -#include +#include "../model/datadocument.h" namespace qf { namespace qmlwidgets { @@ -24,9 +24,9 @@ class QFQMLWIDGETS_DECL_EXPORT DataDialogWidget : public DialogWidget qf::qmlwidgets::DataController *dataController(); void setDataController(qf::qmlwidgets::DataController *dc); - core::model::DataDocument* dataDocument(bool throw_exc = qf::core::Exception::Throw); + qf::qmlwidgets::model::DataDocument* dataDocument(bool throw_exc = qf::core::Exception::Throw); - Q_SLOT virtual bool load(const QVariant &id = QVariant(), int mode = qf::core::model::DataDocument::ModeEdit); + Q_SLOT virtual bool load(const QVariant &id = QVariant(), int mode = qf::qmlwidgets::model::DataDocument::ModeEdit); bool acceptDialogDone(int result) Q_DECL_OVERRIDE; diff --git a/libqf/libqfqmlwidgets/src/framework/logwidget.cpp b/libqf/libqfqmlwidgets/src/framework/logwidget.cpp index 6d07036c4..54ad1e894 100644 --- a/libqf/libqfqmlwidgets/src/framework/logwidget.cpp +++ b/libqf/libqfqmlwidgets/src/framework/logwidget.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -18,9 +18,7 @@ #include #include -namespace qfm = qf::core::model; - - +namespace qfm = qf::qmlwidgets::model; namespace qf::qmlwidgets::framework { @@ -100,7 +98,7 @@ LogWidget::LogWidget(QWidget *parent) { auto *a = new QAction(tr("Maximal log length"), this); connect(a, &QAction::triggered, this, [this]() { - qf::core::model::LogTableModel *m = this->logTableModel(); + qf::qmlwidgets::model::LogTableModel *m = this->logTableModel(); int max_rows = m->maximumRowCount(); bool ok; max_rows = QInputDialog::getInt(this, tr("Get number"), tr("Maximal log row count:"), max_rows, 0, std::numeric_limits::max(), 100, &ok); @@ -147,13 +145,13 @@ void LogWidget::clear() m_logTableModel->clear(); } -void LogWidget::setLogTableModel(core::model::LogTableModel *m) +void LogWidget::setLogTableModel(qmlwidgets::model::LogTableModel *m) { if(m_logTableModel != m) { m_logTableModel = m; m_filterModel->setSourceModel(m_logTableModel); if(m_logTableModel) { - connect(m_logTableModel, &core::model::LogTableModel::logEntryInserted, this, &LogWidget::checkScrollToLastEntry, Qt::UniqueConnection); + connect(m_logTableModel, &qmlwidgets::model::LogTableModel::logEntryInserted, this, &LogWidget::checkScrollToLastEntry, Qt::UniqueConnection); QScrollBar *sb = ui->tableView->verticalScrollBar(); if(sb) connect(sb, &QScrollBar::valueChanged, this, &LogWidget::onVerticalScrollBarValueChanged, Qt::UniqueConnection); @@ -172,7 +170,7 @@ void LogWidget::addLogEntry(const qf::core::LogEntryMap &le) addLog(le.level(), le.category(), le.file(), le.line(), le.message(), le.timeStamp(), le.function()); } -qf::core::model::LogTableModel *LogWidget::logTableModel() +qf::qmlwidgets::model::LogTableModel *LogWidget::logTableModel() { if(!m_logTableModel) { auto *m = new qfm::LogTableModel(this); @@ -223,7 +221,7 @@ bool LogWidget::isAutoScroll() { QScrollBar *sb = ui->tableView->verticalScrollBar(); if(sb) { - if(logTableModel()->direction() == qf::core::model::LogTableModel::Direction::AppendToBottom) { + if(logTableModel()->direction() == qf::qmlwidgets::model::LogTableModel::Direction::AppendToBottom) { //fprintf(stderr, "BOTTOM scrollbar min: %d max: %d value: %d\n", sb->minimum(), sb->maximum(), sb->value()); return (sb->value() == sb->maximum()); } @@ -355,7 +353,7 @@ void LogWidget::checkScrollToLastEntry() ui->tableView->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); } if(isAutoScroll()) { - if(logTableModel()->direction() == qf::core::model::LogTableModel::Direction::AppendToBottom) { + if(logTableModel()->direction() == qf::qmlwidgets::model::LogTableModel::Direction::AppendToBottom) { ui->tableView->scrollToBottom(); } else { diff --git a/libqf/libqfqmlwidgets/src/framework/logwidget.h b/libqf/libqfqmlwidgets/src/framework/logwidget.h index e8978ff3b..497535c7b 100644 --- a/libqf/libqfqmlwidgets/src/framework/logwidget.h +++ b/libqf/libqfqmlwidgets/src/framework/logwidget.h @@ -9,16 +9,10 @@ class QAbstractButton; -namespace qf { -namespace core { -class LogEntryMap; -namespace model { class LogTableModel; } -} -} +namespace qf::core { class LogEntryMap; } +namespace qf::qmlwidgets::model { class LogTableModel; } -namespace qf { -namespace qmlwidgets { -namespace framework { +namespace qf::qmlwidgets::framework { class LogFilterProxyModel; @@ -54,8 +48,8 @@ class QFQMLWIDGETS_DECL_EXPORT LogWidget : public qf::qmlwidgets::framework::Doc Q_SLOT void checkScrollToLastEntry(); void clear(); - virtual void setLogTableModel(qf::core::model::LogTableModel *m); - qf::core::model::LogTableModel* logTableModel(); + virtual void setLogTableModel(qf::qmlwidgets::model::LogTableModel *m); + qf::qmlwidgets::model::LogTableModel* logTableModel(); Q_SIGNAL void severityTresholdChanged(NecroLog::Level lvl); void setSeverityTreshold(NecroLog::Level lvl); @@ -80,7 +74,7 @@ class QFQMLWIDGETS_DECL_EXPORT LogWidget : public qf::qmlwidgets::framework::Doc bool isAutoScroll(); protected: - qf::core::model::LogTableModel* m_logTableModel = nullptr; + qf::qmlwidgets::model::LogTableModel* m_logTableModel = nullptr; LogFilterProxyModel* m_filterModel = nullptr; private: Ui::LogWidget *ui; @@ -91,8 +85,6 @@ class QFQMLWIDGETS_DECL_EXPORT LogWidget : public qf::qmlwidgets::framework::Doc bool m_columnsResized = false; }; +} -} // namespace framework -} // namespace qmlwiggets -} // namespace qf #endif // QF_QMLWIDGETS_FRAMEWORK_LOGWIDGET_H diff --git a/libqf/libqfqmlwidgets/src/idatawidget.cpp b/libqf/libqfqmlwidgets/src/idatawidget.cpp index 67d37cab0..236f71a7d 100644 --- a/libqf/libqfqmlwidgets/src/idatawidget.cpp +++ b/libqf/libqfqmlwidgets/src/idatawidget.cpp @@ -2,11 +2,12 @@ #include "datacontroller.h" -#include +#include #include -namespace qfm = qf::core::model; -using namespace qf::qmlwidgets; +namespace qfm = qf::qmlwidgets::model; + +namespace qf::qmlwidgets { IDataWidget::IDataWidget(QWidget *data_widget) : m_dataWidget(data_widget) @@ -69,3 +70,4 @@ bool IDataWidget::checkSetDataValueFirstTime() return false; } +} diff --git a/libqf/libqfqmlwidgets/src/idatawidget.h b/libqf/libqfqmlwidgets/src/idatawidget.h index 438817028..6d4344ea9 100644 --- a/libqf/libqfqmlwidgets/src/idatawidget.h +++ b/libqf/libqfqmlwidgets/src/idatawidget.h @@ -3,6 +3,8 @@ #include "qmlwidgetsglobal.h" +#include "model/datadocument.h" + #include #include @@ -41,7 +43,7 @@ class QFQMLWIDGETS_DECL_EXPORT IDataWidget QWidget* dataWidget() {return m_dataWidget;} protected: - qf::core::model::DataDocument* dataDocument(bool throw_exc = qf::core::Exception::Throw); + qf::qmlwidgets::model::DataDocument* dataDocument(bool throw_exc = qf::core::Exception::Throw); bool checkSetDataValueFirstTime(); protected: QPointer m_dataController; diff --git a/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.cpp b/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.cpp index a363a39f1..5a5458816 100644 --- a/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.cpp +++ b/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.cpp @@ -1,7 +1,7 @@ #include "tableviewchoosecolumnswidget.h" #include "ui_tableviewchoosecolumnswidget.h" -#include +#include #include #include @@ -42,7 +42,7 @@ TableViewChooseColumnsWidget::~TableViewChooseColumnsWidget() delete ui; } -void TableViewChooseColumnsWidget::loadColumns(qf::core::model::TableModel *model) +void TableViewChooseColumnsWidget::loadColumns(qf::qmlwidgets::model::TableModel *model) { if(model) { { diff --git a/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.h b/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.h index d28a4c5b0..4676e886d 100644 --- a/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.h +++ b/libqf/libqfqmlwidgets/src/internal/tableviewchoosecolumnswidget.h @@ -2,20 +2,13 @@ #define QF_QMLWIDGETS_INTERNAL_TABLEVIEWCHOOSECOLUMNSWIDGET_H #include -//#include class QStandardItemModel; -namespace qf { -namespace core { -namespace model { -class TableModel; -} -} +namespace qf::qmlwidgets::model { class TableModel; } -namespace qmlwidgets { -namespace internal { +namespace qf::qmlwidgets::internal { namespace Ui { class TableViewChooseColumnsWidget; @@ -30,7 +23,7 @@ class TableViewChooseColumnsWidget : public QWidget protected: QStandardItemModel *f_exportedColumnsModel; public: - void loadColumns(qf::core::model::TableModel *model); + void loadColumns(qf::qmlwidgets::model::TableModel *model); protected slots: void onColumnsAllClicked(); void onColumnsNoneClicked(); @@ -47,7 +40,7 @@ protected slots: Ui::TableViewChooseColumnsWidget *ui; }; -}}} +} #endif // QF_QMLWIDGETS_INTERNAL_TABLEVIEWCHOOSECOLUMNSWIDGET_H diff --git a/libqf/libqfqmlwidgets/src/internal/tableviewcopytodialogwidget.cpp b/libqf/libqfqmlwidgets/src/internal/tableviewcopytodialogwidget.cpp index ee038879f..dafeb7c91 100644 --- a/libqf/libqfqmlwidgets/src/internal/tableviewcopytodialogwidget.cpp +++ b/libqf/libqfqmlwidgets/src/internal/tableviewcopytodialogwidget.cpp @@ -3,9 +3,9 @@ #include "../tableview.h" #include -#include +#include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using namespace qf::qmlwidgets::internal; TableViewCopyToDialogWidget::TableViewCopyToDialogWidget(QWidget *parent) diff --git a/libqf/libqfcore/src/model/datadocument.cpp b/libqf/libqfqmlwidgets/src/model/datadocument.cpp similarity index 98% rename from libqf/libqfcore/src/model/datadocument.cpp rename to libqf/libqfqmlwidgets/src/model/datadocument.cpp index 188bb5030..81952d399 100644 --- a/libqf/libqfcore/src/model/datadocument.cpp +++ b/libqf/libqfqmlwidgets/src/model/datadocument.cpp @@ -1,10 +1,11 @@ #include "datadocument.h" -#include "../core/log.h" -#include "../core/assert.h" -#include "../utils/table.h" +#include -using namespace qf::core::model; +#include +#include + +namespace qf::qmlwidgets::model { DataDocument::DataDocument(QObject *parent) : QObject(parent) @@ -311,3 +312,4 @@ bool DataDocument::copyData() return model()->prepareForCopyRow(ix); } +} diff --git a/libqf/libqfcore/src/model/datadocument.h b/libqf/libqfqmlwidgets/src/model/datadocument.h similarity index 88% rename from libqf/libqfcore/src/model/datadocument.h rename to libqf/libqfqmlwidgets/src/model/datadocument.h index 59ddcd767..fb43c0dd0 100644 --- a/libqf/libqfcore/src/model/datadocument.h +++ b/libqf/libqfqmlwidgets/src/model/datadocument.h @@ -1,21 +1,19 @@ -#ifndef QF_CORE_MODEL_DATADOCUMENT_H -#define QF_CORE_MODEL_DATADOCUMENT_H +#pragma once -#include "../core/coreglobal.h" #include "tablemodel.h" #include #include namespace qf { -namespace core { +namespace qmlwidgets { namespace model { -class QFCORE_DECL_EXPORT DataDocument : public QObject +class QFQMLWIDGETS_DECL_EXPORT DataDocument : public QObject { Q_OBJECT - Q_PROPERTY(qf::core::model::DataDocument::RecordEditMode mode READ mode WRITE setMode NOTIFY modeChanged) - Q_PROPERTY(qf::core::model::TableModel* model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(qf::qmlwidgets::model::DataDocument::RecordEditMode mode READ mode WRITE setMode NOTIFY modeChanged) + Q_PROPERTY(qf::qmlwidgets::model::TableModel* model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QVariant dataId READ dataId WRITE setDataId NOTIFY dataIdChanged) Q_PROPERTY(QString idFieldName READ idFieldName WRITE setIdFieldName NOTIFY idFieldNameChanged) public: @@ -94,4 +92,3 @@ class QFCORE_DECL_EXPORT DataDocument : public QObject }}} -#endif // QF_CORE_MODEL_DATADOCUMENT_H diff --git a/libqf/libqfcore/src/model/logtablemodel.cpp b/libqf/libqfqmlwidgets/src/model/logtablemodel.cpp similarity index 96% rename from libqf/libqfcore/src/model/logtablemodel.cpp rename to libqf/libqfqmlwidgets/src/model/logtablemodel.cpp index 36583b401..08516d9c7 100644 --- a/libqf/libqfcore/src/model/logtablemodel.cpp +++ b/libqf/libqfqmlwidgets/src/model/logtablemodel.cpp @@ -1,14 +1,14 @@ #include "logtablemodel.h" -#include "../core/logentrymap.h" -#include "../core/log.h" +#include +#include #include #include Q_DECLARE_METATYPE(NecroLog::Level) -namespace qf::core::model { +namespace qf::qmlwidgets::model { LogTableModel::Row::Row(NecroLog::Level severity, const QString &domain, const QString &file, int line, const QString &msg, const QDateTime &time_stamp, const QString &function, const QVariant &user_data) { @@ -135,7 +135,7 @@ LogTableModel::Row LogTableModel::rowAt(int row) const return m_rows.value(row); } -void LogTableModel::addLogEntry(const LogEntryMap &le) +void LogTableModel::addLogEntry(const qf::core::LogEntryMap &le) { addLog(le.level(), le.category(), le.file(), le.line(), le.message(), le.timeStamp(), le.function()); } diff --git a/libqf/libqfcore/src/model/logtablemodel.h b/libqf/libqfqmlwidgets/src/model/logtablemodel.h similarity index 81% rename from libqf/libqfcore/src/model/logtablemodel.h rename to libqf/libqfqmlwidgets/src/model/logtablemodel.h index c98de5492..89107c195 100644 --- a/libqf/libqfcore/src/model/logtablemodel.h +++ b/libqf/libqfqmlwidgets/src/model/logtablemodel.h @@ -1,26 +1,28 @@ -#ifndef QF_CORE_MODEL_LOGTABLEMODEL_H -#define QF_CORE_MODEL_LOGTABLEMODEL_H +#pragma once -#include "../core/coreglobal.h" -#include "../core/utils.h" +#include "../qmlwidgetsglobal.h" + +#include +#include #include #include +namespace qf::core { class LogEntryMap; } + namespace qf { -namespace core { -class LogEntryMap; +namespace qmlwidgets { namespace model { -class QFCORE_DECL_EXPORT LogTableModel : public QAbstractTableModel +class QFQMLWIDGETS_DECL_EXPORT LogTableModel : public QAbstractTableModel { Q_OBJECT private: using Super = QAbstractTableModel; public: enum Cols {TimeStamp, Severity, Category, Message, File, Line, Function, UserData, Count}; - class QFCORE_DECL_EXPORT Row { + class QFQMLWIDGETS_DECL_EXPORT Row { public: explicit Row() {} explicit Row(NecroLogLevel severity, const QString& domain, const QString& file, int line, const QString& msg, const QDateTime& time_stamp, const QString& function = QString(), const QVariant &user_data = QVariant()); @@ -45,7 +47,7 @@ class QFCORE_DECL_EXPORT LogTableModel : public QAbstractTableModel virtual void clear(); Row rowAt(int row) const; - Q_SLOT void addLogEntry(const qf::core::LogEntryMap &le); + Q_SLOT void addLogEntry(const core::LogEntryMap &le); void addLog(NecroLogLevel severity, const QString& category, const QString &file, int line, const QString& msg, const QDateTime& time_stamp, const QString &function = QString(), const QVariant &user_data = QVariant()); void addRow(const Row &row); Q_SIGNAL void logEntryInserted(int row_no); @@ -57,4 +59,3 @@ class QFCORE_DECL_EXPORT LogTableModel : public QAbstractTableModel }}} -#endif // QF_CORE_MODEL_LOGTABLEMODEL_H diff --git a/libqf/libqfcore/src/model/sqldatadocument.cpp b/libqf/libqfqmlwidgets/src/model/sqldatadocument.cpp similarity index 95% rename from libqf/libqfcore/src/model/sqldatadocument.cpp rename to libqf/libqfqmlwidgets/src/model/sqldatadocument.cpp index 9d476fec6..f9f6dc742 100644 --- a/libqf/libqfcore/src/model/sqldatadocument.cpp +++ b/libqf/libqfqmlwidgets/src/model/sqldatadocument.cpp @@ -1,7 +1,8 @@ #include "sqldatadocument.h" -#include "../core/assert.h" -using namespace qf::core::model; +#include + +namespace qf::qmlwidgets::model { SqlDataDocument::SqlDataDocument(QObject *parent) : Super(parent) @@ -68,3 +69,4 @@ bool SqlDataDocument::loadData() return ret; } +} diff --git a/libqf/libqfcore/src/model/sqldatadocument.h b/libqf/libqfqmlwidgets/src/model/sqldatadocument.h similarity index 79% rename from libqf/libqfcore/src/model/sqldatadocument.h rename to libqf/libqfqmlwidgets/src/model/sqldatadocument.h index 6c056ac96..e725d9c90 100644 --- a/libqf/libqfcore/src/model/sqldatadocument.h +++ b/libqf/libqfqmlwidgets/src/model/sqldatadocument.h @@ -1,14 +1,13 @@ -#ifndef QF_CORE_MODEL_SQLDATADOCUMENT_H -#define QF_CORE_MODEL_SQLDATADOCUMENT_H +#pragma once #include "datadocument.h" #include "sqltablemodel.h" namespace qf { -namespace core { +namespace qmlwidgets { namespace model { -class QFCORE_DECL_EXPORT SqlDataDocument : public DataDocument +class QFQMLWIDGETS_DECL_EXPORT SqlDataDocument : public DataDocument { Q_OBJECT public: @@ -38,4 +37,3 @@ class QFCORE_DECL_EXPORT SqlDataDocument : public DataDocument }}} -#endif // QF_CORE_MODEL_SQLDATADOCUMENT_H diff --git a/libqf/libqfcore/src/model/sqltablemodel.cpp b/libqf/libqfqmlwidgets/src/model/sqltablemodel.cpp similarity index 97% rename from libqf/libqfcore/src/model/sqltablemodel.cpp rename to libqf/libqfqmlwidgets/src/model/sqltablemodel.cpp index 4d574ae84..7dcd9bbf3 100644 --- a/libqf/libqfcore/src/model/sqltablemodel.cpp +++ b/libqf/libqfqmlwidgets/src/model/sqltablemodel.cpp @@ -1,11 +1,12 @@ #include "sqltablemodel.h" -#include "../core/assert.h" -#include "../core/utils.h" -#include "../core/exception.h" -#include "../sql/connection.h" -#include "../sql/dbenum.h" -#include "../sql/dbenumcache.h" -#include "../sql/query.h" + +#include +#include +#include +#include +#include +#include +#include #include #include @@ -18,7 +19,7 @@ namespace qfs = qf::core::sql; namespace qfu = qf::core::utils; -using namespace qf::core::model; +namespace qf::qmlwidgets::model { SqlTableModel::SqlTableModel(QObject *parent) : Super(parent) @@ -38,9 +39,9 @@ QVariant SqlTableModel::data(const QModelIndex &index, int role) const QString group_name = props.groupName(); if(!group_name.isEmpty()) { QVariant v = data(index, Qt::EditRole); - sql::DbEnumCache& db_enum_cache = qf::core::sql::DbEnumCache::instanceForConnection(connectionName()); + qf::core::sql::DbEnumCache& db_enum_cache = qf::core::sql::DbEnumCache::instanceForConnection(connectionName()); QString group_id = v.toString(); - sql::DbEnum dbe = db_enum_cache.dbEnum(group_name, group_id); + qf::core::sql::DbEnum dbe = db_enum_cache.dbEnum(group_name, group_id); QString caption_format = props.captionFormat(); QString caption = dbe.fillInPlaceholders(caption_format); return caption; @@ -57,8 +58,8 @@ QVariant SqlTableModel::data(const QModelIndex &index, int role) const QVariant v = data(index, Qt::EditRole); QString group_id = v.toString(); if(!group_id.isEmpty()) { - sql::DbEnumCache& db_enum_cache = qf::core::sql::DbEnumCache::instanceForConnection(connectionName()); - sql::DbEnum dbe = db_enum_cache.dbEnum(group_name, group_id); + qf::core::sql::DbEnumCache& db_enum_cache = qf::core::sql::DbEnumCache::instanceForConnection(connectionName()); + qf::core::sql::DbEnum dbe = db_enum_cache.dbEnum(group_name, group_id); QColor color = dbe.color(); if(color.isValid()) return color; @@ -699,7 +700,7 @@ QString compose_table_id(const QString &table_name, const QString &schema_name) } } -QStringList SqlTableModel::tableIds(const qf::core::utils::Table::FieldList &table_fields) +QStringList SqlTableModel::tableIds(const core::utils::Table::FieldList &table_fields) { QStringList ret; int fld_cnt = table_fields.count(); @@ -863,3 +864,4 @@ QStringList SqlTableModel::tableIdsSortedAccordingToForeignKeys() return ret; } +} diff --git a/libqf/libqfcore/src/model/sqltablemodel.h b/libqf/libqfqmlwidgets/src/model/sqltablemodel.h similarity index 90% rename from libqf/libqfcore/src/model/sqltablemodel.h rename to libqf/libqfqmlwidgets/src/model/sqltablemodel.h index e9c52828e..a7727b7c7 100644 --- a/libqf/libqfcore/src/model/sqltablemodel.h +++ b/libqf/libqfqmlwidgets/src/model/sqltablemodel.h @@ -1,21 +1,23 @@ -#ifndef QF_CORE_MODEL_SQLTABLEMODEL_H -#define QF_CORE_MODEL_SQLTABLEMODEL_H +#pragma once #include "tablemodel.h" -#include "../core/utils.h" -#include "../sql/querybuilder.h" + +#include +#include +#include +#include #include #include namespace qf { -namespace core { +namespace qmlwidgets { namespace sql { class Connection; } namespace model { -class QFCORE_DECL_EXPORT SqlTableModel : public TableModel +class QFQMLWIDGETS_DECL_EXPORT SqlTableModel : public TableModel { Q_OBJECT Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) @@ -79,7 +81,7 @@ class QFCORE_DECL_EXPORT SqlTableModel : public TableModel bool reloadQuery(const QString &query_str); virtual bool reloadTable(const QString &query_str); - QStringList tableIds(const utils::Table::FieldList &table_fields); + QStringList tableIds(const qf::core::utils::Table::FieldList &table_fields); void setSqlFlags(qf::core::utils::Table::FieldList &table_fields, const QString &query_str) const; QSet referencedForeignTables(); @@ -99,4 +101,3 @@ class QFCORE_DECL_EXPORT SqlTableModel : public TableModel }}} -#endif // QF_CORE_MODEL_SQLTABLEMODEL_H diff --git a/libqf/libqfcore/src/model/tablemodel.cpp b/libqf/libqfqmlwidgets/src/model/tablemodel.cpp similarity index 98% rename from libqf/libqfcore/src/model/tablemodel.cpp rename to libqf/libqfqmlwidgets/src/model/tablemodel.cpp index 05b12cf81..5e88d811e 100644 --- a/libqf/libqfcore/src/model/tablemodel.cpp +++ b/libqf/libqfqmlwidgets/src/model/tablemodel.cpp @@ -1,8 +1,10 @@ #include "tablemodel.h" -#include "../core/log.h" -#include "../core/assert.h" -#include "../core/utils.h" -#include "../utils/treetable.h" +#include "../style.h" + +#include +#include +#include +#include #include #include @@ -13,7 +15,7 @@ namespace qfc = qf::core; namespace qfu = qf::core::utils; -using namespace qf::core::model; +namespace qf::qmlwidgets::model { //========================================= // TableModel::ColumnDefinition @@ -210,11 +212,14 @@ QVariant TableModel::data(const QModelIndex &index, int role) const } } else if(role == Qt::ForegroundRole) { + static const auto blue_color = isDarkTheme()? QColor(0x99ccff): QColor(Qt::blue); + int type = columnType(index.column()); - if(type == QMetaType::QByteArray) - return QColor(Qt::blue); + if(type == QMetaType::QByteArray) { + return blue_color; + } if(data(index, ValueIsNullRole).toBool()) { - return QColor(Qt::blue); + return blue_color; } ret = QVariant(); } @@ -730,7 +735,7 @@ void TableModel::clearColumns(int new_column_count) m_columnsAutoGenerated = false; } -qf::core::model::TableModel::ColumnDefinition& TableModel::addColumn(const QString &field_name, const QString &caption) +qf::qmlwidgets::model::TableModel::ColumnDefinition& TableModel::addColumn(const QString &field_name, const QString &caption) { return insertColumn(m_columns.count(), field_name, caption); } @@ -937,3 +942,5 @@ TableModel::ColumnDefinition TableModel::columnDefinition(int ix) const { return m_columns.value(ix); } + +} diff --git a/libqf/libqfcore/src/model/tablemodel.h b/libqf/libqfqmlwidgets/src/model/tablemodel.h similarity index 95% rename from libqf/libqfcore/src/model/tablemodel.h rename to libqf/libqfqmlwidgets/src/model/tablemodel.h index 8999e801f..c9d425505 100644 --- a/libqf/libqfcore/src/model/tablemodel.h +++ b/libqf/libqfqmlwidgets/src/model/tablemodel.h @@ -1,14 +1,14 @@ -#ifndef QF_CORE_MODEL_TABLEMODEL_H -#define QF_CORE_MODEL_TABLEMODEL_H +#pragma once -#include "../core/coreglobal.h" -#include "../utils/table.h" -#include "../core/utils.h" +#include "../qmlwidgetsglobal.h" + +#include +#include #include namespace qf { -namespace core { +namespace qmlwidgets { namespace utils { class TreeTable; @@ -16,7 +16,7 @@ class TreeTable; namespace model { -class QFCORE_DECL_EXPORT TableModel : public QAbstractTableModel +class QFQMLWIDGETS_DECL_EXPORT TableModel : public QAbstractTableModel { Q_OBJECT Q_PROPERTY(bool nullReportedAsString READ isNullReportedAsString WRITE setNullReportedAsString NOTIFY nullReportedAsStringChanged) @@ -32,7 +32,7 @@ class QFCORE_DECL_EXPORT TableModel : public QAbstractTableModel FirstUnusedRole }; //enum RecordEditMode {ModeView, ModeEdit, ModeInsert, ModeCopy, ModeDelete}; public: - class QFCORE_DECL_EXPORT ColumnDefinition + class QFQMLWIDGETS_DECL_EXPORT ColumnDefinition { private: class SharedDummyHelper {}; @@ -186,7 +186,7 @@ class QFCORE_DECL_EXPORT TableModel : public QAbstractTableModel qf::core::utils::TableRow& tableRowRef(int row_no); qf::core::utils::TableRow tableRow(int row_no) const; - class QFCORE_DECL_EXPORT TreeTableExportOptions : public QVariantMap + class QFQMLWIDGETS_DECL_EXPORT TreeTableExportOptions : public QVariantMap { QF_VARIANTMAP_FIELD2(bool, is, set, ExportRawValues, true) public: @@ -223,6 +223,5 @@ class QFCORE_DECL_EXPORT TableModel : public QAbstractTableModel }}} -Q_DECLARE_METATYPE(qf::core::model::TableModel::ColumnDefinition) +Q_DECLARE_METATYPE(qf::qmlwidgets::model::TableModel::ColumnDefinition) -#endif // QF_CORE_MODEL_TABLEMODEL_H diff --git a/libqf/libqfqmlwidgets/src/reports/widgets/printtableviewwidget/printtableviewwidget.cpp b/libqf/libqfqmlwidgets/src/reports/widgets/printtableviewwidget/printtableviewwidget.cpp index c3923b919..242f5d9fb 100644 --- a/libqf/libqfqmlwidgets/src/reports/widgets/printtableviewwidget/printtableviewwidget.cpp +++ b/libqf/libqfqmlwidgets/src/reports/widgets/printtableviewwidget/printtableviewwidget.cpp @@ -7,7 +7,6 @@ #include -namespace qfc = qf::core; namespace qfu = qf::core::utils; using namespace qf::qmlwidgets::reports; @@ -27,7 +26,7 @@ PrintTableViewWidget::PrintTableViewWidget(TableView *table_view, QWidget *paren connect(cbx, &QComboBox::activated, this, &PrintTableViewWidget::onLstQrcReportsActivated); } - qfc::model::TableModel *model = table_view->tableModel(); + auto *model = table_view->tableModel(); ui->columnsChooser->setVisible(model); ui->columnsChooser->loadColumns(model); diff --git a/libqf/libqfqmlwidgets/src/sqltableitemdelegate.cpp b/libqf/libqfqmlwidgets/src/sqltableitemdelegate.cpp index 367e915e4..c23b1747f 100644 --- a/libqf/libqfqmlwidgets/src/sqltableitemdelegate.cpp +++ b/libqf/libqfqmlwidgets/src/sqltableitemdelegate.cpp @@ -1,7 +1,7 @@ #include "sqltableitemdelegate.h" #include "tableview.h" -#include +#include #include #include #include @@ -27,13 +27,13 @@ QString SqlTableItemDelegate::displayText(const QVariant &value, const QLocale & */ QWidget *SqlTableItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QVariant v = index.data(qf::core::model::TableModel::ColumnDefinitionRole); - auto cd = v.value(); + QVariant v = index.data(qf::qmlwidgets::model::TableModel::ColumnDefinitionRole); + auto cd = v.value(); if(cd.castType() == qMetaTypeId()) { auto *editor = new QComboBox(parent); - auto m = qobject_cast(view()->tableModel()); + auto m = qobject_cast(view()->tableModel()); if(m) { - qf::core::model::SqlTableModel::DbEnumCastProperties props(cd.castProperties()); + qf::qmlwidgets::model::SqlTableModel::DbEnumCastProperties props(cd.castProperties()); qf::core::sql::DbEnumCache& db_enum_cache = qf::core::sql::DbEnumCache::instanceForConnection(m->connectionName()); Q_FOREACH(auto dbe, db_enum_cache.dbEnumsForGroup(props.groupName())) { QString cap = dbe.fillInPlaceholders(props.captionFormat()); @@ -41,7 +41,7 @@ QWidget *SqlTableItemDelegate::createEditor(QWidget *parent, const QStyleOptionV QColor c = dbe.color(); if(c.isValid()) { editor->setItemData(editor->count() - 1, c, Qt::BackgroundRole); - editor->setItemData(editor->count() - 1, qf::core::model::TableModel::contrastTextColor(c), Qt::ForegroundRole); + editor->setItemData(editor->count() - 1, qf::qmlwidgets::model::TableModel::contrastTextColor(c), Qt::ForegroundRole); } } } @@ -54,8 +54,8 @@ QWidget *SqlTableItemDelegate::createEditor(QWidget *parent, const QStyleOptionV void SqlTableItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - QVariant v = index.data(qf::core::model::TableModel::ColumnDefinitionRole); - auto cd = v.value(); + QVariant v = index.data(qf::qmlwidgets::model::TableModel::ColumnDefinitionRole); + auto cd = v.value(); if(cd.castType() == qMetaTypeId()) { auto cbx = qobject_cast(editor); if(cbx) { @@ -72,8 +72,8 @@ void SqlTableItemDelegate::setEditorData(QWidget *editor, const QModelIndex &ind void SqlTableItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - QVariant v = index.data(qf::core::model::TableModel::ColumnDefinitionRole); - auto cd = v.value(); + QVariant v = index.data(qf::qmlwidgets::model::TableModel::ColumnDefinitionRole); + auto cd = v.value(); if(cd.castType() == qMetaTypeId()) { auto cbx = qobject_cast(editor); if(cbx) { diff --git a/libqf/libqfqmlwidgets/src/style.cpp b/libqf/libqfqmlwidgets/src/style.cpp index 5e3a71cfa..51ce03efb 100644 --- a/libqf/libqfqmlwidgets/src/style.cpp +++ b/libqf/libqfqmlwidgets/src/style.cpp @@ -8,8 +8,21 @@ #include #include #include +#include +#include -using namespace qf::qmlwidgets; +namespace qf::qmlwidgets { + +bool isDarkTheme() +{ + // MUST be called after QApplication instance is created + QColor window_color = QApplication::palette().color(QPalette::Window); + QColor text_color = QApplication::palette().color(QPalette::WindowText); + // qDebug() << "window:" << window_color << window_color.value() << colorDarknes(window_color); + // qDebug() << "text:" << text_color << text_color.value() << colorDarknes(text_color); + // Simple heuristic: if background is darker than text, assume dark theme + return window_color.value() < text_color.value(); +} static const char *PROPERTY_STYLE_INSTANCE = "qf::qmlwidget::Style::instance"; @@ -125,18 +138,22 @@ QFileInfo Style::findFile(const QString &path, const QString &default_extension) } QFileInfo fi(fn); if(fi.isAbsolute()) { - if(fi.isReadable()) + if(fi.isReadable()) { return fi; + } } else { for(const auto &prefix : m_iconSearchPaths) { auto fn2 = prefix + '/' + fn; QFileInfo fi2(fn2); - //qfInfo() << "checking:" << fn2; - if(fi2.isReadable()) + // qfInfo() << "checking:" << fn2; + if(fi2.isReadable()) { + // qfInfo() << "\t\tHHIITT" << fn2; return fi2; + } } } return {}; } +} diff --git a/libqf/libqfqmlwidgets/src/style.h b/libqf/libqfqmlwidgets/src/style.h index edc0200ca..6e3698e0d 100644 --- a/libqf/libqfqmlwidgets/src/style.h +++ b/libqf/libqfqmlwidgets/src/style.h @@ -13,6 +13,8 @@ class QFileInfo; namespace qf { namespace qmlwidgets { +QFQMLWIDGETS_DECL_EXPORT bool isDarkTheme(); + class QFQMLWIDGETS_DECL_EXPORT Style : public QObject { Q_OBJECT diff --git a/libqf/libqfqmlwidgets/src/tableitemdelegate.cpp b/libqf/libqfqmlwidgets/src/tableitemdelegate.cpp index 2d2c63703..dad4d9e74 100644 --- a/libqf/libqfqmlwidgets/src/tableitemdelegate.cpp +++ b/libqf/libqfqmlwidgets/src/tableitemdelegate.cpp @@ -1,5 +1,6 @@ #include "tableitemdelegate.h" +#include "style.h" #include "tableview.h" #include @@ -22,18 +23,6 @@ TableView * TableItemDelegate::view() const void TableItemDelegate::paintBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - /** - Protoze z nepochopitelnyho duvodu neni funkce drawBackground() virtualni, musim patchovat QItemDelegate::drawBackground() v QT, kdyz chci podsvitit aktivni radek - qtitemdelegate.cpp:823 - - #if 1/// QF_PATCH patch pro podsviceni radku se selekci - QVariant value = index.data(Qt::BackgroundRole); - if(!value.isValid()) value = property("qfSelectedRowHighlightColor"); - #else - QVariant value = index.data(Qt::BackgroundRole); - #endif - - */ TableView *v = view(); if(v) { QModelIndex ix = v->currentIndex(); @@ -41,8 +30,8 @@ void TableItemDelegate::paintBackground(QPainter *painter, const QStyleOptionVie /// fill current row background /// da se to udelat i takhle bez patchovani QT /// pozor, aby to fungovalo musi se jeste v TableView::currentChanged() volat updateRow() na radky u kterych se meni selekce - static const QColor sel_row_background1(245, 245, 184); - static const QColor sel_row_background2(210, 240, 184); + static const auto sel_row_background1 = isDarkTheme()? QColor(0x707010): QColor(245, 245, 184); // khaki + static const auto sel_row_background2 = isDarkTheme()? QColor(0x284125): QColor(245, 245, 184); // lime painter->fillRect(option.rect, (v->inlineEditSaveStrategy() == TableView::OnEditedValueCommit)? sel_row_background2: sel_row_background1); } else { @@ -50,7 +39,7 @@ void TableItemDelegate::paintBackground(QPainter *painter, const QStyleOptionVie Qt::ItemFlags flags = index.flags(); //qfInfo() << "col:" << index.column() << "editable:" << f.contains(Qt::ItemIsEditable); if(!(flags & Qt::ItemIsEditable)) { - static const QColor ro_cell_background(0xeeeeff); + static const auto ro_cell_background = isDarkTheme()? QColor(0x00264d): QColor(0xeeeeff); painter->fillRect(option.rect, ro_cell_background); } } diff --git a/libqf/libqfqmlwidgets/src/tableview.cpp b/libqf/libqfqmlwidgets/src/tableview.cpp index 098f78f48..731bdfde8 100644 --- a/libqf/libqfqmlwidgets/src/tableview.cpp +++ b/libqf/libqfqmlwidgets/src/tableview.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -49,7 +49,7 @@ namespace qfc = qf::core; namespace qfu = qf::core::utils; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using namespace qf::qmlwidgets; TableView::TableView(QWidget *parent) : @@ -155,19 +155,19 @@ void TableView::setModel(QAbstractItemModel *model) Super::setModel(model); } -qf::core::model::TableModel *TableView::tableModel() const +qf::qmlwidgets::model::TableModel *TableView::tableModel() const { - auto *ret = qobject_cast(lastProxyModel()->sourceModel()); + auto *ret = qobject_cast(lastProxyModel()->sourceModel()); return ret; } -void TableView::setTableModel(core::model::TableModel *m) +void TableView::setTableModel(qmlwidgets::model::TableModel *m) { - qf::core::model::TableModel *old_m = tableModel(); + qf::qmlwidgets::model::TableModel *old_m = tableModel(); if (old_m != m) { QAbstractProxyModel *pxm = lastProxyModel(); pxm->setSourceModel(m); - m_proxyModel->setSortRole(qf::core::model::TableModel::SortRole); + m_proxyModel->setSortRole(qf::qmlwidgets::model::TableModel::SortRole); if(pxm->columnCount() > 0) { qfDebug() << persistentSettingsPath() << "Load persistent settings."; // it does not make sense to load column widths unless we have table columns @@ -182,7 +182,7 @@ void TableView::refreshActions() { qfLogFuncFrame() << "model:" << model(); enableAllActions(false); - qfc::model::TableModel *m = tableModel(); + auto *m = tableModel(); if(!m) return; action("filter")->setEnabled(true); @@ -284,7 +284,7 @@ void TableView::reload(bool preserve_sorting) sort_order = horizontalHeader()->sortIndicatorOrder(); horizontalHeader()->setSortIndicator(-1, Qt::AscendingOrder); } - qf::core::model::TableModel *table_model = tableModel(); + qf::qmlwidgets::model::TableModel *table_model = tableModel(); if(table_model) { QModelIndex ix = currentIndex(); int r = ix.row(); @@ -395,7 +395,7 @@ void TableView::cloneRowInline() if(ix.row() < 0) return; int tri1 = toTableModelRowNo(ix.row()); - core::model::TableModel *tm = tableModel(); + qmlwidgets::model::TableModel *tm = tableModel(); tm->cloneRow(tri1); m_proxyModel->sort(); setCurrentIndex(m_proxyModel->index(ix.row() + 1, ix.column())); @@ -451,7 +451,7 @@ bool TableView::postRowImpl(int row_no) if(row_no < 0) return false; bool ret = false; - qfc::model::TableModel *m = tableModel(); + auto *m = tableModel(); if(m) { ret = m->postRow(toTableModelRowNo(row_no), true); if(ret) @@ -480,7 +480,7 @@ void TableView::revertRow(int row_no) row_no = currentIndex().row(); if(row_no < 0) return; - qfc::model::TableModel *m = tableModel(); + auto *m = tableModel(); if(m) { m->revertRow(toTableModelRowNo(row_no)); } @@ -494,7 +494,7 @@ int TableView::reloadRow(int row_no) row_no = currentIndex().row(); if(row_no < 0) return 0; - qfc::model::TableModel *m = tableModel(); + auto *m = tableModel(); if(m) { return m->reloadRow(toTableModelRowNo(row_no)); } @@ -646,7 +646,7 @@ void TableView::setValueInSelection_helper(const QVariant &new_val) } else if(selected_row_indexes.count() > 1) { qfc::sql::Connection conn; - auto *sql_m = qobject_cast(tableModel()); + auto *sql_m = qobject_cast(tableModel()); if(sql_m) { try { conn = sql_m->sqlConnection(); @@ -740,7 +740,7 @@ void TableView::editCellContentInEditor() void TableView::exportCSV() { - core::model::TableModel *m = tableModel(); + qmlwidgets::model::TableModel *m = tableModel(); if(!m) return; @@ -820,14 +820,14 @@ void TableView::selectCurrentRow() selectRow(ix.row()); } -qf::core::utils::TreeTable TableView::toTreeTable(const QString &table_name, const QVariantList &_exported_columns, const qf::core::model::TableModel::TreeTableExportOptions &opts) const +qf::core::utils::TreeTable TableView::toTreeTable(const QString &table_name, const QVariantList &_exported_columns, const qf::qmlwidgets::model::TableModel::TreeTableExportOptions &opts) const { qfu::TreeTable ret(table_name); QVariantList exported_columns = _exported_columns; QAbstractItemModel *proxy_model = model(); if(!proxy_model) return ret; - core::model::TableModel *table_model = tableModel(); + qmlwidgets::model::TableModel *table_model = tableModel(); if(!table_model) return ret; const core::utils::Table &table = table_model->table(); @@ -859,12 +859,12 @@ qf::core::utils::TreeTable TableView::toTreeTable(const QString &table_name, con //qfWarning() << fld.toString(); } else { - t = proxy_model->headerData(ix, Qt::Horizontal, core::model::TableModel::FieldTypeRole).toInt(); + t = proxy_model->headerData(ix, Qt::Horizontal, qmlwidgets::model::TableModel::FieldTypeRole).toInt(); } - cd.setName(proxy_model->headerData(ix, Qt::Horizontal, core::model::TableModel::FieldNameRole).toString()); + cd.setName(proxy_model->headerData(ix, Qt::Horizontal, qmlwidgets::model::TableModel::FieldNameRole).toString()); cd.setType(t); cd.setHeader(cap); - //ret.appendColumn(proxy_model->headerData(ix, Qt::Horizontal, core::model::TableModel::FieldNameRole).toString(), t, cap); + //ret.appendColumn(proxy_model->headerData(ix, Qt::Horizontal, qmlwidgets::model::TableModel::FieldNameRole).toString(), t, cap); } cd.setWidth(col.value("width")); ret.appendColumn(cd); @@ -886,7 +886,7 @@ qf::core::utils::TreeTable TableView::toTreeTable(const QString &table_name, con else { QModelIndex mix = proxy_model->index(i, ix); if(raw_values) { - val = proxy_model->data(mix, core::model::TableModel::RawValueRole); + val = proxy_model->data(mix, qmlwidgets::model::TableModel::RawValueRole); //qfWarning() << col << val.typeName() << "val:" << val.toString(); } else { @@ -912,7 +912,7 @@ void TableView::exportReport_helper(const QVariant& _options) qfu::TreeTable ttable; { - qfc::model::TableModel::TreeTableExportOptions opts; + qf::qmlwidgets::model::TableModel::TreeTableExportOptions opts; //opts.setExportRawValues(true); ttable = toTreeTable("data", exported_columns, opts); } @@ -1085,7 +1085,7 @@ int TableView::logicalColumnIndex(const QString &field_name) const { auto *m = model(); if(m) for (int i = 0; i < m->columnCount(); ++i) { - QString fldn = m->headerData(i, Qt::Horizontal, qf::core::model::TableModel::FieldNameRole).toString(); + QString fldn = m->headerData(i, Qt::Horizontal, qf::qmlwidgets::model::TableModel::FieldNameRole).toString(); if(qf::core::Utils::fieldNameEndsWith(fldn, field_name)) return i; } @@ -1317,7 +1317,7 @@ void TableView::loadPersistentSettings() qfDebug() << path << "Cannot load persistent settings, horizontal header does not exist or it is empty."; return; } - qf::core::model::TableModel *mod = tableModel(); + qf::qmlwidgets::model::TableModel *mod = tableModel(); if(!mod || mod->columnCount() == 0) { qfDebug() << path << "Cannot load persistent settings, table model does not exist or it is empty."; return; @@ -1973,7 +1973,7 @@ void TableView::copySpecial_helper(const QTableView *table_view, const QString & for (auto col : cols) { QModelIndex ix = m->index(row, col); QString s; - if(!ix.data(qf::core::model::TableModel::ValueIsNullRole).toBool()) { + if(!ix.data(qf::qmlwidgets::model::TableModel::ValueIsNullRole).toBool()) { s = ix.data(Qt::DisplayRole).toString(); if(s.isEmpty()) { QVariant v = ix.data(Qt::CheckStateRole); @@ -2211,7 +2211,7 @@ bool TableView::edit(const QModelIndex& index, EditTrigger trigger, QEvent* even bool read_only = isReadOnly(); /* if(!read_only) { - qfc::model::TableModel *m = tableModel(); + auto *m = tableModel(); read_only = (!m || m->isReadOnly()); } */ diff --git a/libqf/libqfqmlwidgets/src/tableview.h b/libqf/libqfqmlwidgets/src/tableview.h index da868f2fd..4ee530c56 100644 --- a/libqf/libqfqmlwidgets/src/tableview.h +++ b/libqf/libqfqmlwidgets/src/tableview.h @@ -3,10 +3,10 @@ #include "qmlwidgetsglobal.h" #include "framework/ipersistentsettings.h" +#include "model/datadocument.h" #include #include -#include #include @@ -25,7 +25,7 @@ class QFQMLWIDGETS_DECL_EXPORT TableView : public QTableView, public framework:: Q_OBJECT Q_PROPERTY(QString persistentSettingsId READ persistentSettingsId WRITE setPersistentSettingsId) - Q_PROPERTY(qf::core::model::TableModel* model READ tableModel WRITE setTableModel) + Q_PROPERTY(qf::qmlwidgets::model::TableModel* model READ tableModel WRITE setTableModel) Q_PROPERTY(RowEditorMode rowEditorMode READ rowEditorMode WRITE setRowEditorMode NOTIFY rowEditorModeChanged) Q_PROPERTY(InlineEditSaveStrategy inlineEditSaveStrategy READ inlineEditSaveStrategy WRITE setInlineEditSaveStrategy NOTIFY inlineEditSaveStrategyChanged) Q_PROPERTY(QString idColumnName READ idColumnName WRITE setIdColumnName) @@ -52,11 +52,11 @@ class QFQMLWIDGETS_DECL_EXPORT TableView : public QTableView, public framework:: EditRowsMixed }; enum RecordEditMode { - ModeView = qf::core::model::DataDocument::ModeView, - ModeEdit = qf::core::model::DataDocument::ModeEdit, - ModeInsert = qf::core::model::DataDocument::ModeInsert, - ModeCopy = qf::core::model::DataDocument::ModeCopy, - ModeDelete = qf::core::model::DataDocument::ModeDelete + ModeView = qf::qmlwidgets::model::DataDocument::ModeView, + ModeEdit = qf::qmlwidgets::model::DataDocument::ModeEdit, + ModeInsert = qf::qmlwidgets::model::DataDocument::ModeInsert, + ModeCopy = qf::qmlwidgets::model::DataDocument::ModeCopy, + ModeDelete = qf::qmlwidgets::model::DataDocument::ModeDelete }; QF_PROPERTY_IMPL2(InlineEditSaveStrategy, i, I, nlineEditSaveStrategy, OnEditedValueCommit) @@ -67,8 +67,8 @@ class QFQMLWIDGETS_DECL_EXPORT TableView : public QTableView, public framework:: public: QSortFilterProxyModel* sortFilterProxyModel() const; - qf::core::model::TableModel* tableModel() const; - void setTableModel(qf::core::model::TableModel* m); + qf::qmlwidgets::model::TableModel* tableModel() const; + void setTableModel(qf::qmlwidgets::model::TableModel* m); //Q_SIGNAL void tableModelChanged(); Q_SIGNAL void currentRowChanged(int current_row); @@ -169,7 +169,7 @@ class QFQMLWIDGETS_DECL_EXPORT TableView : public QTableView, public framework:: void seek(const QString &prefix_str); void cancelSeek(); - qf::core::utils::TreeTable toTreeTable(const QString& table_name = QString(), const QVariantList& exported_columns = QVariantList(), const qf::core::model::TableModel::TreeTableExportOptions &opts = qf::core::model::TableModel::TreeTableExportOptions()) const; + qf::core::utils::TreeTable toTreeTable(const QString& table_name = QString(), const QVariantList& exported_columns = QVariantList(), const qf::qmlwidgets::model::TableModel::TreeTableExportOptions &opts = qf::qmlwidgets::model::TableModel::TreeTableExportOptions()) const; void exportReport_helper(const QVariant& _options); void exportCSV_helper(const QVariant& export_options); protected: diff --git a/libqf/libqfqmlwidgets/src/tableviewproxymodel.cpp b/libqf/libqfqmlwidgets/src/tableviewproxymodel.cpp index 520a694dd..8892ef049 100644 --- a/libqf/libqfqmlwidgets/src/tableviewproxymodel.cpp +++ b/libqf/libqfqmlwidgets/src/tableviewproxymodel.cpp @@ -2,18 +2,18 @@ #include #include -#include +#include #include #include -//namespace qfm = qf::core::model; +//namespace qfm = qf::qmlwidgets::model; using namespace qf::qmlwidgets; TableViewProxyModel::TableViewProxyModel(QObject *parent) : Super(parent) { - setSortRole(qf::core::model::TableModel::SortRole); + setSortRole(qf::qmlwidgets::model::TableModel::SortRole); } TableViewProxyModel::~TableViewProxyModel() diff --git a/libqf/plugins/qf/core/CMakeLists.txt b/libqf/plugins/qf/core/CMakeLists.txt index fde7900fe..de6d0546c 100644 --- a/libqf/plugins/qf/core/CMakeLists.txt +++ b/libqf/plugins/qf/core/CMakeLists.txt @@ -37,7 +37,7 @@ target_link_libraries(qfcoreplugin PUBLIC Qt::Core # Qt::Gui Qt::Qml - libqfcore + libqfqmlwidgets ) set(PLUGIN_DEST_DIR ${CMAKE_INSTALL_BINDIR}/qml/qf/core) diff --git a/libqf/plugins/qf/core/src/model/sqldatadocument.cpp b/libqf/plugins/qf/core/src/model/sqldatadocument.cpp index 27e8ab418..46957a627 100644 --- a/libqf/plugins/qf/core/src/model/sqldatadocument.cpp +++ b/libqf/plugins/qf/core/src/model/sqldatadocument.cpp @@ -2,11 +2,11 @@ #include "../sql/sqlquerybuilder.h" -#include +#include #include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using namespace qf::core::qml; SqlDataDocument::SqlDataDocument(QObject *parent) diff --git a/libqf/plugins/qf/core/src/model/sqldatadocument.h b/libqf/plugins/qf/core/src/model/sqldatadocument.h index a122722cd..1b5f713b0 100644 --- a/libqf/plugins/qf/core/src/model/sqldatadocument.h +++ b/libqf/plugins/qf/core/src/model/sqldatadocument.h @@ -3,7 +3,7 @@ #include "../sql/sqlquerybuilder.h" -#include +#include namespace qf { namespace core { @@ -11,12 +11,12 @@ namespace qml { //class SqlQueryBuilder; -class SqlDataDocument : public qf::core::model::SqlDataDocument +class SqlDataDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT Q_PROPERTY(qf::core::qml::SqlQueryBuilder* queryBuilder READ qmlSqlQueryBuilder) private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: SqlDataDocument(QObject *parent = nullptr); ~SqlDataDocument() Q_DECL_OVERRIDE; diff --git a/libqf/plugins/qf/core/src/model/sqltablemodel.h b/libqf/plugins/qf/core/src/model/sqltablemodel.h index d48130972..e2bbe3363 100644 --- a/libqf/plugins/qf/core/src/model/sqltablemodel.h +++ b/libqf/plugins/qf/core/src/model/sqltablemodel.h @@ -3,7 +3,7 @@ #include "tablemodelcolumn.h" -#include +#include #include @@ -14,14 +14,14 @@ namespace qml { class SqlQueryBuilder; class TableModelColumn; -class SqlTableModel : public qf::core::model::SqlTableModel +class SqlTableModel : public qf::qmlwidgets::model::SqlTableModel { Q_OBJECT Q_PROPERTY(qf::core::qml::SqlQueryBuilder* queryBuilder READ sqlQueryBuilder /*NOTIFY queryBuilderChanged*/) Q_PROPERTY(QQmlListProperty columns READ columns /*NOTIFY columnsChanged*/) Q_CLASSINFO("DefaultProperty", "columns") private: - typedef qf::core::model::SqlTableModel Super; + typedef qf::qmlwidgets::model::SqlTableModel Super; public: explicit SqlTableModel(QObject *parent = nullptr); ~SqlTableModel() Q_DECL_OVERRIDE; diff --git a/libqf/plugins/qf/core/src/model/tablemodelcolumn.cpp b/libqf/plugins/qf/core/src/model/tablemodelcolumn.cpp index 468072925..d2539ea47 100644 --- a/libqf/plugins/qf/core/src/model/tablemodelcolumn.cpp +++ b/libqf/plugins/qf/core/src/model/tablemodelcolumn.cpp @@ -38,7 +38,7 @@ void TableModelColumn::setReadOnly(bool arg) void TableModelColumn::setCastType(int arg) { - //qf::core::model::TableModel *m = qobject_cast(parent()); + //qf::qmlwidgets::model::TableModel *m = qobject_cast(parent()); //qfWarning() << arg << m; m_columnDefinition.setCastType(arg); if(m_columnIndex >= 0) diff --git a/libqf/plugins/qf/core/src/model/tablemodelcolumn.h b/libqf/plugins/qf/core/src/model/tablemodelcolumn.h index af154f0a1..512275802 100644 --- a/libqf/plugins/qf/core/src/model/tablemodelcolumn.h +++ b/libqf/plugins/qf/core/src/model/tablemodelcolumn.h @@ -1,7 +1,7 @@ #ifndef TABLEMODELCOLUMN_H #define TABLEMODELCOLUMN_H -#include +#include #include @@ -20,7 +20,7 @@ class TableModelColumn : public QObject explicit TableModelColumn(QObject *parent = nullptr); ~TableModelColumn() Q_DECL_OVERRIDE; - const qf::core::model::TableModel::ColumnDefinition& columnDefinition() {return m_columnDefinition; } + const qf::qmlwidgets::model::TableModel::ColumnDefinition& columnDefinition() {return m_columnDefinition; } QString fieldName() const { return m_columnDefinition.fieldName(); } void setFieldName(QString arg); @@ -38,7 +38,7 @@ class TableModelColumn : public QObject signals: void updated(int column_index); private: - qf::core::model::TableModel::ColumnDefinition m_columnDefinition; + qf::qmlwidgets::model::TableModel::ColumnDefinition m_columnDefinition; int m_columnIndex = -1; }; diff --git a/libqf/plugins/qf/core/src/qfcore_plugin.cpp b/libqf/plugins/qf/core/src/qfcore_plugin.cpp index fb2ac803e..cafd7cbee 100644 --- a/libqf/plugins/qf/core/src/qfcore_plugin.cpp +++ b/libqf/plugins/qf/core/src/qfcore_plugin.cpp @@ -18,8 +18,8 @@ //#include //#include -//#include -//#include +//#include +//#include //#include @@ -44,10 +44,10 @@ void QFCorePlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "SqlRecord"); qmlRegisterType(uri, 1, 0, "SqlQueryBuilder"); qmlRegisterType(uri, 1, 0, "SqlTableModel"); - qmlRegisterType(uri, 1, 0, "TableModel"); + qmlRegisterType(uri, 1, 0, "TableModel"); qmlRegisterType(uri, 1, 0, "ModelColumn"); - qmlRegisterType(uri, 1, 0, "DataDocument"); + qmlRegisterType(uri, 1, 0, "DataDocument"); qmlRegisterType(uri, 1, 0, "SqlDataDocument"); qmlRegisterType(uri, 1, 0, "Settings"); diff --git a/libqf/plugins/qf/core/src/settings.h b/libqf/plugins/qf/core/src/settings.h index 16b382e1f..1367c9418 100644 --- a/libqf/plugins/qf/core/src/settings.h +++ b/libqf/plugins/qf/core/src/settings.h @@ -15,16 +15,15 @@ class Settings : public qf::core::utils::Settings public: explicit Settings(QObject *parent = nullptr); ~Settings() Q_DECL_OVERRIDE; -public slots: - void beginGroup(const QString & prefix) {Super::beginGroup(prefix);} - int beginReadArray(const QString & prefix) {return Super::beginReadArray(prefix);} - void beginWriteArray(const QString & prefix, int size = -1) {Super::beginWriteArray(prefix, size);} - void endArray() {Super::endArray();} - void endGroup() {Super::endGroup();} - void setArrayIndex(int i) {Super::setArrayIndex(i);} - QString group() const {return Super::group();} - - void sync() {Super::sync();} +public: + Q_INVOKABLE void beginGroup(const QString & prefix) {Super::beginGroup(prefix);} + Q_INVOKABLE int beginReadArray(const QString & prefix) {return Super::beginReadArray(prefix);} + Q_INVOKABLE void beginWriteArray(const QString & prefix, int size = -1) {Super::beginWriteArray(prefix, size);} + Q_INVOKABLE void endArray() {Super::endArray();} + Q_INVOKABLE void endGroup() {Super::endGroup();} + Q_INVOKABLE void setArrayIndex(int i) {Super::setArrayIndex(i);} + Q_INVOKABLE QString group() const {return Super::group();} + Q_INVOKABLE void sync() {Super::sync();} }; }}} diff --git a/libquickevent/libquickeventcore/CMakeLists.txt b/libquickevent/libquickeventcore/CMakeLists.txt index 190413e90..56ad7bb06 100644 --- a/libquickevent/libquickeventcore/CMakeLists.txt +++ b/libquickevent/libquickeventcore/CMakeLists.txt @@ -6,7 +6,6 @@ add_library(libquickeventcore SHARED src/exporters/stageresultscsvexporter.cpp src/exporters/stageresultshtmlexporter.cpp src/exporters/stagestartlisthtmlexporter.cpp - src/og/sqltablemodel.cpp src/og/timems.cpp src/runstatus.cpp src/si/checkedcard.cpp diff --git a/libquickevent/libquickeventcore/include/quickevent/core/og/sqltablemodel.h b/libquickevent/libquickeventcore/include/quickevent/core/og/sqltablemodel.h deleted file mode 100644 index 97631f790..000000000 --- a/libquickevent/libquickeventcore/include/quickevent/core/og/sqltablemodel.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../../../src/og/sqltablemodel.h" diff --git a/libquickevent/libquickeventcore/src/og/sqltablemodel.cpp b/libquickevent/libquickeventcore/src/og/sqltablemodel.cpp deleted file mode 100644 index ce2c1ff9d..000000000 --- a/libquickevent/libquickeventcore/src/og/sqltablemodel.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "sqltablemodel.h" -#include "timems.h" -#include "../si/siid.h" - -#include - -#include - - - -namespace quickevent::core::og { - -SqlTableModel::SqlTableModel(QObject *parent) - : Super(parent) -{ -} - -SqlTableModel::~SqlTableModel() -= default; - -QVariant SqlTableModel::data(const QModelIndex &index, int role) const -{ - if(role == Qt::DisplayRole) { - QVariant v = Super::data(index, Qt::EditRole); - int type = v.userType(); - if(type == qMetaTypeId()) { - auto t = v.value(); - return t.toString(); - } - if(type == qMetaTypeId()) { - int id = (int)v.value(); - if(id == 0) - return QString();// QStringLiteral("null"); - return id; - } - } - else if(role == SortRole) { - QVariant v = Super::data(index, Qt::EditRole); - int type = v.userType(); - if(type == qMetaTypeId()) { - auto t = v.value(); - return t.msec(); - } - return Super::data(index, role); - } - else if(role == Qt::TextAlignmentRole) { - QVariant v = Super::data(index, Qt::EditRole); - if(v.userType() == qMetaTypeId()) { - return Qt::AlignRight; - } - } - return Super::data(index, role); -} - -QVariant SqlTableModel::rawValueToEdit(int column_index, const QVariant &val) const -{ - QVariant ret = val; - int type = columnType(column_index); - if(type == qMetaTypeId()) { - TimeMs t; - if(!ret.isNull()) { - t = TimeMs(ret.toInt()); - } - ret = QVariant::fromValue(t); - } - else if(type == qMetaTypeId()) { - si::SiId id(val.toInt()); - ret = QVariant::fromValue(id); - } - return ret; -} - -QVariant SqlTableModel::editValueToRaw(int column_index, const QVariant &val) const -{ - QVariant ret = val; - int type = columnType(column_index); - if(type == qMetaTypeId()) { - auto t = val.value(); -#if QT_VERSION_MAJOR >= 6 - ret = t.isValid()? t.msec(): QVariant(QMetaType(QMetaType::Int)); -#else - ret = t.isValid()? t.msec(): QVariant(QVariant::Int); -#endif - } - else if(type == qMetaTypeId()) { - auto id = (int)val.value(); - if(id == 0) -#if QT_VERSION_MAJOR >= 6 - ret = QVariant(QMetaType(QMetaType::Int)); -#else - ret = QVariant(QVariant::Int); -#endif - else - ret = id; - } - //qfInfo() << val << ret; - return ret; -} - -} diff --git a/libquickevent/libquickeventcore/src/og/sqltablemodel.h b/libquickevent/libquickeventcore/src/og/sqltablemodel.h deleted file mode 100644 index 92c2b597c..000000000 --- a/libquickevent/libquickeventcore/src/og/sqltablemodel.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QUICKEVENTCORE_OG_SQLTABLEMODEL_H -#define QUICKEVENTCORE_OG_SQLTABLEMODEL_H - -#include "../quickeventcoreglobal.h" - -#include - -namespace quickevent { -namespace core { -namespace og { - -class QUICKEVENTCORE_DECL_EXPORT SqlTableModel : public qf::core::model::SqlTableModel -{ - Q_OBJECT -private: - typedef qf::core::model::SqlTableModel Super; -public: - SqlTableModel(QObject *parent = nullptr); - ~SqlTableModel(); -public: - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; -protected: - QVariant rawValueToEdit(int column_index, const QVariant &val) const Q_DECL_OVERRIDE; - QVariant editValueToRaw(int column_index, const QVariant &val) const Q_DECL_OVERRIDE; -}; - -}}} - -#endif // QUICKEVENTCORE_OG_SQLTABLEMODEL_H diff --git a/libquickevent/libquickeventgui/include/quickevent/gui/og/sqltablemodel.h b/libquickevent/libquickeventgui/include/quickevent/gui/og/sqltablemodel.h index 937cedff9..97631f790 100644 --- a/libquickevent/libquickeventgui/include/quickevent/gui/og/sqltablemodel.h +++ b/libquickevent/libquickeventgui/include/quickevent/gui/og/sqltablemodel.h @@ -1 +1 @@ -#include "../../../src/og/sqltablemodel.h" +#include "../../../../src/og/sqltablemodel.h" diff --git a/libquickevent/libquickeventgui/src/og/sqltablemodel.h b/libquickevent/libquickeventgui/src/og/sqltablemodel.h index 0bbd9f076..4f65db683 100644 --- a/libquickevent/libquickeventgui/src/og/sqltablemodel.h +++ b/libquickevent/libquickeventgui/src/og/sqltablemodel.h @@ -3,17 +3,17 @@ #include "../quickeventguiglobal.h" -#include +#include namespace quickevent { namespace gui { namespace og { -class QUICKEVENTGUI_DECL_EXPORT SqlTableModel : public qf::core::model::SqlTableModel +class QUICKEVENTGUI_DECL_EXPORT SqlTableModel : public qf::qmlwidgets::model::SqlTableModel { Q_OBJECT private: - typedef qf::core::model::SqlTableModel Super; + typedef qf::qmlwidgets::model::SqlTableModel Super; public: SqlTableModel(QObject *parent = nullptr); ~SqlTableModel(); diff --git a/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.cpp b/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.cpp index c0e670802..bc9207b9a 100644 --- a/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.cpp +++ b/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -73,11 +73,11 @@ using Receipts::ReceiptsPlugin; using Runs::RunsPlugin; namespace { -class Model : public quickevent::core::og::SqlTableModel +class Model : public quickevent::gui::og::SqlTableModel { Q_OBJECT private: - typedef quickevent::core::og::SqlTableModel Super; + typedef quickevent::gui::og::SqlTableModel Super; public: enum Columns { col_cards_id = 0, diff --git a/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.h b/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.h index 5b3746bb4..353bc55c9 100644 --- a/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.h +++ b/quickevent/app/quickevent/plugins/CardReader/src/cardreaderwidget.h @@ -16,7 +16,7 @@ namespace Ui { class CardReaderWidget; } -namespace quickevent::core::og { class SqlTableModel; } +namespace quickevent::gui::og { class SqlTableModel; } namespace qf { namespace qmlwidgets { @@ -109,7 +109,7 @@ private slots: private: Ui::CardReaderWidget *ui; qf::qmlwidgets::Action *m_actAssignCard = nullptr; - quickevent::core::og::SqlTableModel *m_cardsModel = nullptr; + quickevent::gui::og::SqlTableModel *m_cardsModel = nullptr; quickevent::gui::audio::Player *m_audioPlayer = nullptr; siut::DeviceDriver *f_siDriver = nullptr; siut::CommPort *m_commPort = nullptr; diff --git a/quickevent/app/quickevent/plugins/CardReader/src/services/mqttpunches.cpp b/quickevent/app/quickevent/plugins/CardReader/src/services/mqttpunches.cpp index 8bcb0ba79..d1fb43788 100644 --- a/quickevent/app/quickevent/plugins/CardReader/src/services/mqttpunches.cpp +++ b/quickevent/app/quickevent/plugins/CardReader/src/services/mqttpunches.cpp @@ -28,7 +28,7 @@ #include #endif -//namespace qfm = qf::core::model; +//namespace qfm = qf::qmlwidgets::model; using qf::qmlwidgets::framework::getPlugin; using CardReader::CardReaderPlugin; diff --git a/quickevent/app/quickevent/plugins/CardReader/src/services/racomclient.cpp b/quickevent/app/quickevent/plugins/CardReader/src/services/racomclient.cpp index 1be203989..4ea375b0e 100644 --- a/quickevent/app/quickevent/plugins/CardReader/src/services/racomclient.cpp +++ b/quickevent/app/quickevent/plugins/CardReader/src/services/racomclient.cpp @@ -31,7 +31,7 @@ #include #endif -//namespace qfm = qf::core::model; +//namespace qfm = qf::qmlwidgets::model; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; using CardReader::CardReaderPlugin; diff --git a/quickevent/app/quickevent/plugins/Classes/src/classdefdocument.h b/quickevent/app/quickevent/plugins/Classes/src/classdefdocument.h index 93b5e6801..47bd20287 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/classdefdocument.h +++ b/quickevent/app/quickevent/plugins/Classes/src/classdefdocument.h @@ -1,13 +1,13 @@ #ifndef CLASSDEFDOCUMENT_H #define CLASSDEFDOCUMENT_H -#include +#include -class ClassDefDocument : public qf::core::model::SqlDataDocument +class ClassDefDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: ClassDefDocument(QObject *parent = nullptr); }; diff --git a/quickevent/app/quickevent/plugins/Classes/src/classdefwidget.h b/quickevent/app/quickevent/plugins/Classes/src/classdefwidget.h index 5f4a28b30..062b3a350 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/classdefwidget.h +++ b/quickevent/app/quickevent/plugins/Classes/src/classdefwidget.h @@ -16,7 +16,7 @@ class ClassDefWidget : public qf::qmlwidgets::framework::DataDialogWidget ClassDefWidget(QWidget *parent = nullptr); ~ClassDefWidget() Q_DECL_OVERRIDE; - bool load(const QVariant &id = QVariant(), int mode = qf::core::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; + bool load(const QVariant &id = QVariant(), int mode = qf::qmlwidgets::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; private: Ui::ClassDefWidget *ui; }; diff --git a/quickevent/app/quickevent/plugins/Classes/src/classdocument.h b/quickevent/app/quickevent/plugins/Classes/src/classdocument.h index da396daeb..32fd92933 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/classdocument.h +++ b/quickevent/app/quickevent/plugins/Classes/src/classdocument.h @@ -1,15 +1,15 @@ #ifndef CLASSES_CLASSDOCUMENT_H #define CLASSES_CLASSDOCUMENT_H -#include +#include namespace Classes { -class ClassDocument : public qf::core::model::SqlDataDocument +class ClassDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: ClassDocument(QObject *parent = nullptr); protected: diff --git a/quickevent/app/quickevent/plugins/Classes/src/classeswidget.cpp b/quickevent/app/quickevent/plugins/Classes/src/classeswidget.cpp index dbe559878..08bc96d11 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/classeswidget.cpp +++ b/quickevent/app/quickevent/plugins/Classes/src/classeswidget.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ static const auto SkipEmptyParts = Qt::SkipEmptyParts; namespace qfc = qf::core; namespace qfw = qf::qmlwidgets; namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -193,11 +193,9 @@ ClassesWidget::ClassesWidget(QWidget *parent) : m->addColumn("courses.length", tr("Length")); m->addColumn("courses.climb", tr("Climb")); - if (auto is_relays = getPlugin()->eventConfig()->isRelays(); is_relays) { - m->addColumn("relaysCount", tr("Rel. count")).setToolTip(tr("Relays count")); - m->addColumn("classdefs.relayStartNumber", tr("Rel. num")).setToolTip(tr("Relay start number")); - m->addColumn("classdefs.relayLegCount", tr("Legs")).setToolTip(tr("Relay leg count")); - } + m->addColumn("relaysCount", tr("Rel. count")).setToolTip(tr("Relays count")); + m->addColumn("classdefs.relayStartNumber", tr("Rel. num")).setToolTip(tr("Relay start number")); + m->addColumn("classdefs.relayLegCount", tr("Legs")).setToolTip(tr("Relay leg count")); ui->tblClasses->setTableModel(m); diff --git a/quickevent/app/quickevent/plugins/Classes/src/classeswidget.h b/quickevent/app/quickevent/plugins/Classes/src/classeswidget.h index 40a866be4..6a6cc8c7d 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/classeswidget.h +++ b/quickevent/app/quickevent/plugins/Classes/src/classeswidget.h @@ -11,10 +11,8 @@ namespace Ui { class ClassesWidget; } -namespace qf { -namespace core { namespace model { class SqlTableModel; } } -namespace qmlwidgets { class ForeignKeyComboBox; } -} +namespace qf::qmlwidgets { class ForeignKeyComboBox; } +namespace qf::qmlwidgets::model { class SqlTableModel; } namespace quickevent { namespace core { class CodeDef; }} @@ -50,8 +48,8 @@ class ClassesWidget : public QFrame void importCourses(const QList &course_defs, const QList &code_defs); private: Ui::ClassesWidget *ui; - qf::core::model::SqlTableModel *m_classesModel; - qf::core::model::SqlTableModel *m_courseCodesModel; + qf::qmlwidgets::model::SqlTableModel *m_classesModel; + qf::qmlwidgets::model::SqlTableModel *m_courseCodesModel; QComboBox *m_cbxStage = nullptr; CourseItemDelegate *m_courseItemDelegate = nullptr; }; diff --git a/quickevent/app/quickevent/plugins/Classes/src/drawing/classitem.cpp b/quickevent/app/quickevent/plugins/Classes/src/drawing/classitem.cpp index eb14b9b6f..93cd2838a 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/drawing/classitem.cpp +++ b/quickevent/app/quickevent/plugins/Classes/src/drawing/classitem.cpp @@ -23,7 +23,7 @@ namespace qfd = qf::qmlwidgets::dialogs; namespace qfc = qf::core; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace drawing { @@ -462,7 +462,7 @@ void ClassItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) bool ok = dlg.exec(); if(ok) { //qfInfo() << "OK"; - qf::core::model::DataDocument *doc = w->dataDocument(); + qf::qmlwidgets::model::DataDocument *doc = w->dataDocument(); ClassData dt = data(); dt.setStartTimeMin(doc->value("startTimeMin").toInt()); dt.setStartIntervalMin(doc->value("startIntervalMin").toInt()); diff --git a/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.cpp b/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.cpp index 70f6f02c4..ccf8e4360 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.cpp +++ b/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.cpp @@ -1,9 +1,9 @@ #include "editcodeswidget.h" #include "ui_editcodeswidget.h" -#include +#include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; EditCodesWidget::EditCodesWidget(QWidget *parent) diff --git a/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.h b/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.h index 2ce421a6d..820319bf4 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.h +++ b/quickevent/app/quickevent/plugins/Classes/src/editcodeswidget.h @@ -7,9 +7,7 @@ namespace Ui { class EditCodesWidget; } -namespace qf { -namespace core { namespace model { class SqlTableModel; } } -} +namespace qf::qmlwidgets::model { class SqlTableModel; } class EditCodesWidget : public qf::qmlwidgets::framework::DialogWidget { @@ -21,7 +19,7 @@ class EditCodesWidget : public qf::qmlwidgets::framework::DialogWidget ~EditCodesWidget() Q_DECL_OVERRIDE; private: Ui::EditCodesWidget *ui; - qf::core::model::SqlTableModel *m_tableModel; + qf::qmlwidgets::model::SqlTableModel *m_tableModel; }; #endif // EDITCODESWIDGET_H diff --git a/quickevent/app/quickevent/plugins/Classes/src/editcoursecodeswidget.cpp b/quickevent/app/quickevent/plugins/Classes/src/editcoursecodeswidget.cpp index fac74ae69..7190baeee 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/editcoursecodeswidget.cpp +++ b/quickevent/app/quickevent/plugins/Classes/src/editcoursecodeswidget.cpp @@ -1,7 +1,7 @@ #include "editcoursecodeswidget.h" #include "ui_editcoursecodeswidget.h" -#include +#include #include #include diff --git a/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.cpp b/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.cpp index 516e1aa5b..49fb61c22 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.cpp +++ b/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.cpp @@ -3,16 +3,15 @@ #include "ui_editcourseswidget.h" #include -#include +#include #include #include #include #include -namespace qfc = qf::core; namespace qfw = qf::qmlwidgets; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; class CoursesTableModel : public qfm::SqlTableModel @@ -37,15 +36,15 @@ class CoursesTableModel : public qfm::SqlTableModel CoursesTableModel(QObject *parent) : Super(parent) { clearColumns(Col_COUNT); - setColumn(Col_id, qf::core::model::TableModel::ColumnDefinition("id", tr("Id")).setReadOnly(true)); - setColumn(Col_name, qf::core::model::TableModel::ColumnDefinition("courses.name", tr("Name"))); - setColumn(Col_length, qf::core::model::TableModel::ColumnDefinition("courses.length", tr("Length"))); - setColumn(Col_climb, qf::core::model::TableModel::ColumnDefinition("courses.climb", tr("Climb"))); - setColumn(Col_mapCount, qf::core::model::TableModel::ColumnDefinition("courses.mapCount", tr("Maps"))); - setColumn(Col_runCount, qf::core::model::TableModel::ColumnDefinition("run_count", tr("Runners"))); - setColumn(Col_note, qf::core::model::TableModel::ColumnDefinition("courses.note", tr("Note"))); - setColumn(Col_codeCount, qf::core::model::TableModel::ColumnDefinition("code_count", tr("Code count")).setReadOnly(true)); - setColumn(Col_codeList, qf::core::model::TableModel::ColumnDefinition("code_list", tr("Codes")).setReadOnly(true)); + setColumn(Col_id, qf::qmlwidgets::model::TableModel::ColumnDefinition("id", tr("Id")).setReadOnly(true)); + setColumn(Col_name, qf::qmlwidgets::model::TableModel::ColumnDefinition("courses.name", tr("Name"))); + setColumn(Col_length, qf::qmlwidgets::model::TableModel::ColumnDefinition("courses.length", tr("Length"))); + setColumn(Col_climb, qf::qmlwidgets::model::TableModel::ColumnDefinition("courses.climb", tr("Climb"))); + setColumn(Col_mapCount, qf::qmlwidgets::model::TableModel::ColumnDefinition("courses.mapCount", tr("Maps"))); + setColumn(Col_runCount, qf::qmlwidgets::model::TableModel::ColumnDefinition("run_count", tr("Runners"))); + setColumn(Col_note, qf::qmlwidgets::model::TableModel::ColumnDefinition("courses.note", tr("Note"))); + setColumn(Col_codeCount, qf::qmlwidgets::model::TableModel::ColumnDefinition("code_count", tr("Code count")).setReadOnly(true)); + setColumn(Col_codeList, qf::qmlwidgets::model::TableModel::ColumnDefinition("code_list", tr("Codes")).setReadOnly(true)); } public: QVariant data(const QModelIndex &index, int role) const override @@ -139,7 +138,7 @@ EditCoursesWidget::~EditCoursesWidget() void EditCoursesWidget::editCourseCodes(const QModelIndex &ix) { - qfc::model::TableModel *m = ui->tblCourses->tableModel(); + auto *m = ui->tblCourses->tableModel(); if(!m) return; int row_no = ui->tblCourses->toTableModelRowNo(ix.row()); diff --git a/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.h b/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.h index 08d7fe1b0..ae4bf2996 100644 --- a/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.h +++ b/quickevent/app/quickevent/plugins/Classes/src/editcourseswidget.h @@ -7,9 +7,7 @@ namespace Ui { class EditCoursesWidget; } -namespace qf { -namespace core { namespace model { class SqlTableModel; } } -} +namespace qf::qmlwidgets::model { class SqlTableModel; } class EditCoursesWidget : public qf::qmlwidgets::framework::DialogWidget { @@ -23,7 +21,7 @@ class EditCoursesWidget : public qf::qmlwidgets::framework::DialogWidget void editCourseCodes(const QModelIndex &ix); private: Ui::EditCoursesWidget *ui; - qf::core::model::SqlTableModel *m_coursesModel; + qf::qmlwidgets::model::SqlTableModel *m_coursesModel; }; #endif // EDITCOURSESWIDGET_H diff --git a/quickevent/app/quickevent/plugins/Competitors/src/competitordocument.h b/quickevent/app/quickevent/plugins/Competitors/src/competitordocument.h index 3ecea5bab..04a764da7 100644 --- a/quickevent/app/quickevent/plugins/Competitors/src/competitordocument.h +++ b/quickevent/app/quickevent/plugins/Competitors/src/competitordocument.h @@ -1,17 +1,17 @@ #ifndef COMPETITORS_COMPETITORDOCUMENT_H #define COMPETITORS_COMPETITORDOCUMENT_H -#include +#include #include namespace Competitors { -class CompetitorDocument : public qf::core::model::SqlDataDocument +class CompetitorDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: CompetitorDocument(QObject *parent = nullptr); diff --git a/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.cpp b/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.cpp index f6ab41c6c..c9f6b95ae 100644 --- a/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.cpp +++ b/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -40,11 +40,11 @@ using Event::EventPlugin; namespace { -class CompetitorRunsModel : public quickevent::core::og::SqlTableModel +class CompetitorRunsModel : public quickevent::gui::og::SqlTableModel { Q_DECLARE_TR_FUNCTIONS(CompetitorRunsModel) private: - using Super = quickevent::core::og::SqlTableModel; + using Super = quickevent::gui::og::SqlTableModel; public: CompetitorRunsModel(QObject *parent = nullptr); @@ -256,7 +256,7 @@ CompetitorWidget::~CompetitorWidget() bool CompetitorWidget::loadRunsTable() { //bool is_relays = getPlugin()->eventConfig()->isRelays(); - qf::core::model::DataDocument *doc = dataController()->document(); + qf::qmlwidgets::model::DataDocument *doc = dataController()->document(); qf::core::sql::QueryBuilder qb; qb.select2("runs", "*") .select2("classes", "name") @@ -311,11 +311,11 @@ void CompetitorWidget::onRunsTableCustomContextMenuRequest(const QPoint &pos) */ bool CompetitorWidget::load(const QVariant &id, int mode) { - ui->chkFind->setChecked(mode == qf::core::model::DataDocument::ModeInsert); - if(mode == qf::core::model::DataDocument::ModeInsert) { + ui->chkFind->setChecked(mode == qf::qmlwidgets::model::DataDocument::ModeInsert); + if(mode == qf::qmlwidgets::model::DataDocument::ModeInsert) { ui->edFind->setFocus(); } - else if(mode == qf::core::model::DataDocument::ModeView || mode == qf::core::model::DataDocument::ModeDelete) { + else if(mode == qf::qmlwidgets::model::DataDocument::ModeView || mode == qf::qmlwidgets::model::DataDocument::ModeDelete) { ui->frmFind->hide(); } if(Super::load(id, mode)) @@ -469,7 +469,7 @@ QList CompetitorWidget::possibleStartTimesMs(int run_id) // if(!saveData()) // return; -// qf::core::model::DataDocument*doc = dataController()->document(); +// qf::qmlwidgets::model::DataDocument*doc = dataController()->document(); // int competitor_id = doc->value("competitors.id").toInt(); // int class_id = ui->cbxClass->currentData().toInt(); // QString sort_col = QStringLiteral("runs.startTimeMs"); diff --git a/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.h b/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.h index 9d06b6482..9a5668d9d 100644 --- a/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.h +++ b/quickevent/app/quickevent/plugins/Competitors/src/competitorwidget.h @@ -19,7 +19,7 @@ class CompetitorWidget : public qf::qmlwidgets::framework::DataDialogWidget explicit CompetitorWidget(QWidget *parent = nullptr); ~CompetitorWidget() override; - bool load(const QVariant &id = QVariant(), int mode = qf::core::model::DataDocument::ModeEdit) override; + bool load(const QVariant &id = QVariant(), int mode = qf::qmlwidgets::model::DataDocument::ModeEdit) override; void loadFromRegistrations(int siid); void save(); private slots: @@ -36,6 +36,6 @@ private slots: static QList possibleStartTimesMs(int run_id); private: Ui::CompetitorWidget *ui; - quickevent::core::og::SqlTableModel *m_runsModel; + quickevent::gui::og::SqlTableModel *m_runsModel; }; diff --git a/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.cpp b/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.cpp index 8882f5216..68892e634 100644 --- a/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.cpp @@ -23,6 +23,7 @@ ConnectDbDialogWidget::ConnectDbDialogWidget(QWidget *parent) : if(checked) ui->dataStorageStackedWidget->setCurrentWidget(ui->pgSingleFile); }); + connect(ui->btSingleWorkingDirectory, &QAbstractButton::clicked, this, &ConnectDbDialogWidget::onSingleWorkingDirectoryClicked); } ConnectDbDialogWidget::~ConnectDbDialogWidget() @@ -103,7 +104,7 @@ void ConnectDbDialogWidget::saveSettings() settings.setSingleWorkingDir(ui->edSingleWorkingDir->text()); } -void ConnectDbDialogWidget::on_btSingleWorkingDirectory_clicked() +void ConnectDbDialogWidget::onSingleWorkingDirectoryClicked() { //qf::qmlwidgets::framework::MainWindow *fwk = qf::qmlwidgets::framework::MainWindow::frameWork(); QString wd = qf::qmlwidgets::dialogs::FileDialog::getExistingDirectory(this, tr("Event files directory"), ui->edSingleWorkingDir->text()); diff --git a/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.h b/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.h index 62eb8cb81..52c953371 100644 --- a/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.h +++ b/quickevent/app/quickevent/plugins/Event/src/connectdbdialogwidget.h @@ -13,7 +13,7 @@ class ConnectDbDialogWidget : public qf::qmlwidgets::framework::DialogWidget { Q_OBJECT private: - typedef qf::qmlwidgets::framework::DialogWidget Super; + using Super = qf::qmlwidgets::framework::DialogWidget; public: explicit ConnectDbDialogWidget(QWidget *parent = nullptr); ~ConnectDbDialogWidget(); @@ -29,7 +29,7 @@ class ConnectDbDialogWidget : public qf::qmlwidgets::framework::DialogWidget void loadSettings(); void saveSettings(); private: - Q_SLOT void on_btSingleWorkingDirectory_clicked(); + void onSingleWorkingDirectoryClicked(); private: Ui::ConnectDbDialogWidget *ui; }; diff --git a/quickevent/app/quickevent/plugins/Event/src/eventconfig.cpp b/quickevent/app/quickevent/plugins/Event/src/eventconfig.cpp index abe4d8c07..8988b6792 100644 --- a/quickevent/app/quickevent/plugins/Event/src/eventconfig.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/eventconfig.cpp @@ -64,17 +64,19 @@ void EventConfig::load() Query q(conn); QueryBuilder qb; qb.select("ckey, cvalue, ctype").from("config").orderBy("ckey"); - if(q.exec(qb.toString())) while(q.next()) { - QString key = q.value(0).toString(); - /* - if(!knownKeys().contains(key)) { - qfWarning() << "Config key" << key << "is not known to the QuickEvent config system"; + if(q.exec(qb.toString(), qf::core::Exception::Throw)) { + while(q.next()) { + QString key = q.value(0).toString(); + /* + if(!knownKeys().contains(key)) { + qfWarning() << "Config key" << key << "is not known to the QuickEvent config system"; + } + */ + QVariant val = q.value(1); + QString type = q.value(2).toString(); + QVariant v = qf::core::Utils::retypeStringValue(val.toString(), type); + setValue(key, v); } - */ - QVariant val = q.value(1); - QString type = q.value(2).toString(); - QVariant v = qf::core::Utils::retypeStringValue(val.toString(), type); - setValue(key, v); } // checkApiKey(); } diff --git a/quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp b/quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp index d482d0243..830f9d0ad 100644 --- a/quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/eventplugin.cpp @@ -1367,10 +1367,10 @@ void EventPlugin::reloadRegistrationsModel() m_registrationsTable = qf::core::utils::Table(); } -qf::core::model::SqlTableModel* EventPlugin::registrationsModel() +qf::qmlwidgets::model::SqlTableModel* EventPlugin::registrationsModel() { if(!m_registrationsModel) { - m_registrationsModel = new qf::core::model::SqlTableModel(this); + m_registrationsModel = new qf::qmlwidgets::model::SqlTableModel(this); m_registrationsModel->addColumn("competitorName", tr("Name")); m_registrationsModel->addColumn("registration", tr("Reg")); m_registrationsModel->addColumn("licence", tr("Lic")); @@ -1389,7 +1389,7 @@ qf::core::model::SqlTableModel* EventPlugin::registrationsModel() const qf::core::utils::Table &EventPlugin::registrationsTable() { - qf::core::model::SqlTableModel *m = registrationsModel(); + qf::qmlwidgets::model::SqlTableModel *m = registrationsModel(); if(m_registrationsTable.isNull() && !m->table().isNull()) { m_registrationsTable = m->table(); auto c_nsk = QStringLiteral("competitorNameAscii7"); diff --git a/quickevent/app/quickevent/plugins/Event/src/eventplugin.h b/quickevent/app/quickevent/plugins/Event/src/eventplugin.h index d82b57799..31a7401ba 100644 --- a/quickevent/app/quickevent/plugins/Event/src/eventplugin.h +++ b/quickevent/app/quickevent/plugins/Event/src/eventplugin.h @@ -15,7 +15,7 @@ namespace qf::core::sql { class Query; class Connection; } namespace qf::qmlwidgets { class Action; } namespace qf::qmlwidgets::framework { class DockWidget; } -namespace qf::core::model { class SqlTableModel; } +namespace qf::qmlwidgets::model { class SqlTableModel; } class QComboBox; class DbSchema; @@ -111,7 +111,7 @@ class EventPlugin : public qf::qmlwidgets::framework::Plugin Q_SLOT void onInstalled(); - qf::core::model::SqlTableModel* registrationsModel(); + qf::qmlwidgets::model::SqlTableModel* registrationsModel(); const qf::core::utils::Table& registrationsTable(); public: @@ -162,7 +162,7 @@ class EventPlugin : public qf::qmlwidgets::framework::Plugin qf::qmlwidgets::framework::DockWidget *m_servicesDockWidget = nullptr; qf::qmlwidgets::framework::DockWidget *m_registrationsDockWidget = nullptr; - qf::core::model::SqlTableModel *m_registrationsModel = nullptr; + qf::qmlwidgets::model::SqlTableModel *m_registrationsModel = nullptr; qf::core::utils::Table m_registrationsTable; }; diff --git a/quickevent/app/quickevent/plugins/Event/src/findregistrationedit.cpp b/quickevent/app/quickevent/plugins/Event/src/findregistrationedit.cpp index bda32a23e..bc5bb9715 100644 --- a/quickevent/app/quickevent/plugins/Event/src/findregistrationedit.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/findregistrationedit.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.cpp b/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.cpp index 737d33e81..5e5394574 100644 --- a/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.cpp @@ -1,9 +1,9 @@ #include "lentcardssettingspage.h" #include "ui_lentcardssettingspage.h" -#include +#include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; LentCardsSettingsPage::LentCardsSettingsPage(QWidget *parent) diff --git a/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.h b/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.h index 683988bcf..2275d63a9 100644 --- a/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.h +++ b/quickevent/app/quickevent/plugins/Event/src/lentcardssettingspage.h @@ -8,9 +8,7 @@ namespace Ui { class LentCardsSettingsPage; } -namespace qf { -namespace core { namespace model { class SqlTableModel; } } -} +namespace qf::qmlwidgets::model { class SqlTableModel; } class LentCardsSettingsPage : public Core::SettingsPage { @@ -27,6 +25,6 @@ class LentCardsSettingsPage : public Core::SettingsPage private: Ui::LentCardsSettingsPage *ui; - qf::core::model::SqlTableModel *m_tableModel; + qf::qmlwidgets::model::SqlTableModel *m_tableModel; }; diff --git a/quickevent/app/quickevent/plugins/Event/src/registrationswidget.cpp b/quickevent/app/quickevent/plugins/Event/src/registrationswidget.cpp index b9b5b8264..3b2469b89 100644 --- a/quickevent/app/quickevent/plugins/Event/src/registrationswidget.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/registrationswidget.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include #include @@ -37,9 +37,9 @@ void RegistrationsWidget::checkModel() return; if(!ui->tblRegistrations->tableModel()) { - qf::core::model::SqlTableModel *reg_model = getPlugin()->registrationsModel(); + qf::qmlwidgets::model::SqlTableModel *reg_model = getPlugin()->registrationsModel(); ui->tblRegistrations->setTableModel(reg_model); - connect(reg_model, &qf::core::model::SqlTableModel::reloaded, this, [this]() { + connect(reg_model, &qf::qmlwidgets::model::SqlTableModel::reloaded, this, [this]() { ui->tblRegistrations->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); }); } diff --git a/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.cpp b/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.cpp index 1f79f9dc7..285209fca 100644 --- a/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.cpp @@ -8,14 +8,14 @@ #include #include -#include +#include #include #include #include #include -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; namespace qfw = qf::qmlwidgets; using qf::qmlwidgets::framework::getPlugin; diff --git a/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.h b/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.h index e6b15317a..3439049be 100644 --- a/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.h +++ b/quickevent/app/quickevent/plugins/Event/src/services/qx/qxlateregistrationswidget.h @@ -2,7 +2,7 @@ #include -namespace qf::core::model { class SqlTableModel; } +namespace qf::qmlwidgets::model { class SqlTableModel; } namespace Event::services::qx { @@ -36,7 +36,7 @@ class QxLateRegistrationsWidget : public QWidget private: Ui::QxLateRegistrationsWidget *ui; - qf::core::model::SqlTableModel *m_model; + qf::qmlwidgets::model::SqlTableModel *m_model; }; } diff --git a/quickevent/app/quickevent/plugins/Event/src/services/qx/runchangedialog.cpp b/quickevent/app/quickevent/plugins/Event/src/services/qx/runchangedialog.cpp index 9b0988b3a..6b01dc76b 100644 --- a/quickevent/app/quickevent/plugins/Event/src/services/qx/runchangedialog.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/services/qx/runchangedialog.cpp @@ -15,8 +15,6 @@ #include #include -using namespace qf::core::model; - namespace Event::services::qx { RunChangeDialog::RunChangeDialog(int change_id, int run_id, int lock_number, const RunChange &run_change, QWidget *parent) @@ -112,7 +110,7 @@ void RunChangeDialog::loadOrigValues() } Competitors::CompetitorDocument doc; - doc.load(m_competitorId, DataDocument::ModeView); + doc.load(m_competitorId, qf::qmlwidgets::model::DataDocument::ModeView); m_origValues.first_name = doc.value("firstName").toString(); m_origValues.last_name = doc.value("lastName").toString(); @@ -239,6 +237,8 @@ void RunChangeDialog::resolveChanges(bool is_accepted) void RunChangeDialog::applyLocalChanges(bool is_accepted) { + using namespace qf::qmlwidgets::model; + bool is_insert = m_runId == 0; Competitors::CompetitorDocument doc; doc.load(m_competitorId, is_insert? DataDocument::ModeInsert: DataDocument::ModeEdit); diff --git a/quickevent/app/quickevent/plugins/Event/src/stagedocument.h b/quickevent/app/quickevent/plugins/Event/src/stagedocument.h index 364fb0b8f..4ec5d1de8 100644 --- a/quickevent/app/quickevent/plugins/Event/src/stagedocument.h +++ b/quickevent/app/quickevent/plugins/Event/src/stagedocument.h @@ -1,15 +1,15 @@ #ifndef EVENT_STAGEDOCUMENT_H #define EVENT_STAGEDOCUMENT_H -#include +#include namespace Event { -class StageDocument : public qf::core::model::SqlDataDocument +class StageDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: StageDocument(QObject *parent = nullptr); }; diff --git a/quickevent/app/quickevent/plugins/Event/src/stagewidget.cpp b/quickevent/app/quickevent/plugins/Event/src/stagewidget.cpp index 84022b3c8..c06093495 100644 --- a/quickevent/app/quickevent/plugins/Event/src/stagewidget.cpp +++ b/quickevent/app/quickevent/plugins/Event/src/stagewidget.cpp @@ -29,7 +29,7 @@ bool StageWidget::load(const QVariant &id, int mode) bool ok = Super::load(id, mode); if(ok) { QDateTime dt; - qf::core::model::DataDocument *doc = dataDocument(); + qf::qmlwidgets::model::DataDocument *doc = dataDocument(); const auto START_DATE_TIME = QStringLiteral("startDateTime"); dt = doc->value(START_DATE_TIME).toDateTime().toLocalTime(); /* @@ -51,7 +51,7 @@ bool StageWidget::saveData() QDate d = ui->dateEdit->date(); QTime t = ui->timeEdit->time(); QDateTime dt(d, t, QTimeZone::systemTimeZone()); - qf::core::model::DataDocument *doc = dataDocument(); + qf::qmlwidgets::model::DataDocument *doc = dataDocument(); const auto START_DATE_TIME = QStringLiteral("startDateTime"); doc->setValue(START_DATE_TIME, dt); /* diff --git a/quickevent/app/quickevent/plugins/Event/src/stagewidget.h b/quickevent/app/quickevent/plugins/Event/src/stagewidget.h index 5558ac5de..4cc348cc2 100644 --- a/quickevent/app/quickevent/plugins/Event/src/stagewidget.h +++ b/quickevent/app/quickevent/plugins/Event/src/stagewidget.h @@ -20,7 +20,7 @@ class StageWidget : public qf::qmlwidgets::framework::DataDialogWidget explicit StageWidget(QWidget *parent = 0); ~StageWidget(); - bool load(const QVariant &id = QVariant(), int mode = qf::core::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; + bool load(const QVariant &id = QVariant(), int mode = qf::qmlwidgets::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; protected: bool saveData() Q_DECL_OVERRIDE; private: diff --git a/quickevent/app/quickevent/plugins/Oris/src/txtimporter.cpp b/quickevent/app/quickevent/plugins/Oris/src/txtimporter.cpp index 71609b48d..17cee8277 100644 --- a/quickevent/app/quickevent/plugins/Oris/src/txtimporter.cpp +++ b/quickevent/app/quickevent/plugins/Oris/src/txtimporter.cpp @@ -14,11 +14,7 @@ #include -// namespace qfc = qf::core; -// namespace qfw = qf::qmlwidgets; namespace qfd = qf::qmlwidgets::dialogs; -// namespace qfm = qf::core::model; -namespace qfs = qf::core::sql; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; diff --git a/quickevent/app/quickevent/plugins/Receipts/src/receiptsplugin.cpp b/quickevent/app/quickevent/plugins/Receipts/src/receiptsplugin.cpp index 4f74ce4f1..59386f735 100644 --- a/quickevent/app/quickevent/plugins/Receipts/src/receiptsplugin.cpp +++ b/quickevent/app/quickevent/plugins/Receipts/src/receiptsplugin.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -88,7 +88,7 @@ QVariantMap ReceiptsPlugin::readCardTablesData(int card_id) start_time_ms = read_card.checkTime(); start_time_ms *= 1000; int prev_stp_time_ms = 0; - for(auto v : read_card.punches()) { + for(const auto &v : read_card.punches()) { quickevent::core::si::ReadPunch punch(v.toMap()); int punch_time_ms = punch.time() * 1000 + punch.msec(); int stp_time_ms = quickevent::core::og::TimeMs::msecIntervalAM(start_time_ms, punch_time_ms); @@ -158,7 +158,7 @@ QVariantMap ReceiptsPlugin::receiptTablesData(int card_id) QMap lap_stand; // position->standing in lap QMap lap_stand_cummulative; // position->cummulative standing after lap { - qf::core::model::SqlTableModel model; + qf::qmlwidgets::model::SqlTableModel model; qf::core::sql::QueryBuilder qb; qb.select2("competitors", "*") .select2("runs", "*") @@ -365,7 +365,7 @@ QVariantMap ReceiptsPlugin::receiptTablesData(int card_id) } tt.setValue("isOk", checked_card.isOk()); int position = 0; - for(auto v : checked_card.punches()) { + for(const auto &v : checked_card.punches()) { quickevent::core::si::CheckedPunch punch(v.toMap()); int ix = tt.appendRow(); qf::core::utils::TreeTableRow tt_row = tt.row(ix); @@ -425,8 +425,9 @@ void ReceiptsPlugin::previewCard(int card_id) w->setWindowTitle(tr("Card")); w->setReport(findReportFile("sicard.qml")); QVariantMap dt = readCardTablesData(card_id); - for(auto key : dt.keys()) - w->setTableData(key, dt.value(key)); + for(const auto &[k, v] : dt.asKeyValueRange()) { + w->setTableData(k, v); + } qff::MainWindow *fwk = qff::MainWindow::frameWork(); qf::qmlwidgets::dialogs::Dialog dlg(fwk); dlg.setCentralWidget(w); @@ -476,8 +477,9 @@ void ReceiptsPlugin::previewReceipt(int card_id) w->setWindowTitle(tr("Receipt")); w->setReport(findReportFile(settings.receiptPath())); QVariantMap dt = receiptTablesData(card_id); - for(auto key : dt.keys()) - w->setTableData(key, dt.value(key)); + for(const auto &[k, v] : dt.asKeyValueRange()) { + w->setTableData(k, v); + } auto fwk = qff::MainWindow::frameWork(); qf::qmlwidgets::dialogs::Dialog dlg(fwk); dlg.setCentralWidget(w); diff --git a/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.cpp b/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.cpp index 9e08740b5..e11685ed4 100644 --- a/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.cpp +++ b/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -36,9 +36,7 @@ #include #include -namespace qfm = qf::core::model; namespace qfs = qf::core::sql; -namespace qff = qf::qmlwidgets::framework; namespace qfw = qf::qmlwidgets; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -61,7 +59,7 @@ ReceiptsWidget::ReceiptsWidget(QWidget *parent) : //ui->tblPrintJobs->setRowEditorMode(qfw::TableView::EditRowsMixed); ui->tblCards->setInlineEditSaveStrategy(qfw::TableView::OnEditedValueCommit); ui->tblCards->setItemDelegate(new quickevent::gui::og::ItemDelegate(ui->tblCards)); - auto m = new quickevent::core::og::SqlTableModel(this); + auto m = new quickevent::gui::og::SqlTableModel(this); m->addColumn("cards.id", "id").setReadOnly(true); m->addColumn("cards.siId", tr("SI")).setReadOnly(true).setCastType(qMetaTypeId()); @@ -84,6 +82,7 @@ ReceiptsWidget::ReceiptsWidget(QWidget *parent) : ui->tblCards->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tblCards, &qfw::TableView::customContextMenuRequested, this, &ReceiptsWidget::onCustomContextMenuRequest); + connect(ui->btPrintNew, &QAbstractButton::clicked, this, &ReceiptsWidget::onPrintNewClicked); QTimer::singleShot(0, this, &ReceiptsWidget::lazyInit); } @@ -97,7 +96,7 @@ void ReceiptsWidget::lazyInit() { } -void ReceiptsWidget::settleDownInPartWidget(::PartWidget *part_widget) +void ReceiptsWidget::settleDownInPartWidget(::PartWidget *part_widget) const { connect(part_widget, &::PartWidget::resetPartRequest, this, &ReceiptsWidget::reset); connect(part_widget, &::PartWidget::reloadPartRequest, this, &ReceiptsWidget::reload); @@ -196,7 +195,7 @@ void ReceiptsWidget::loadNewCards() m_cardsModel->reloadInserts(QStringLiteral("cards.id")); } -void ReceiptsWidget::on_btPrintNew_clicked() +void ReceiptsWidget::onPrintNewClicked() { printNewCards(); loadNewCards(); diff --git a/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.h b/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.h index cc80e5af3..c41b6477a 100644 --- a/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.h +++ b/quickevent/app/quickevent/plugins/Receipts/src/receiptswidget.h @@ -9,12 +9,9 @@ namespace Ui { class ReceiptsWidget; } +namespace qf::qmlwidgets::model { class SqlTableModel; } + namespace qf { -namespace core { -namespace model { -class SqlTableModel; -} -} namespace qmlwidgets { class Action; namespace framework { @@ -40,14 +37,14 @@ class ReceiptsWidget : public QFrame explicit ReceiptsWidget(QWidget *parent = 0); ~ReceiptsWidget() Q_DECL_OVERRIDE; - void settleDownInPartWidget(::PartWidget *part_widget); + void settleDownInPartWidget(::PartWidget *part_widget) const; Q_SLOT void reset(); Q_SLOT void reload(); bool isAutoPrintEnabled(); private: - Q_SLOT void on_btPrintNew_clicked(); + void onPrintNewClicked(); void onCustomContextMenuRequest(const QPoint &pos); void printSelectedCards(); @@ -67,7 +64,7 @@ class ReceiptsWidget : public QFrame bool thisReaderOnly(); private: Ui::ReceiptsWidget *ui; - qf::core::model::SqlTableModel *m_cardsModel = nullptr; + qf::qmlwidgets::model::SqlTableModel *m_cardsModel = nullptr; }; #endif // RECEIPTSWIDGET_H diff --git a/quickevent/app/quickevent/plugins/Relays/src/addlegdialogwidget.cpp b/quickevent/app/quickevent/plugins/Relays/src/addlegdialogwidget.cpp index 5ccf0a8b7..34421ffb3 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/addlegdialogwidget.cpp +++ b/quickevent/app/quickevent/plugins/Relays/src/addlegdialogwidget.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include // #include #include @@ -31,7 +31,7 @@ AddLegDialogWidget::AddLegDialogWidget(QWidget *parent) m_defaultStatusText = ui->lblStatus->text(); - auto *competitors_model = new qf::core::model::SqlTableModel(this); + auto *competitors_model = new qf::qmlwidgets::model::SqlTableModel(this); //competitors_model->addColumn("relays.club", tr("Club")); competitors_model->addColumn("relayName", tr("Name")); competitors_model->addColumn("runs.leg", tr("Leg")); @@ -60,7 +60,7 @@ AddLegDialogWidget::AddLegDialogWidget(QWidget *parent) auto *reg_model = getPlugin()->registrationsModel(); ui->tblRegistrations->setTableModel(reg_model); ui->tblRegistrations->setReadOnly(true); - connect(reg_model, &qf::core::model::SqlTableModel::reloaded, this, [this]() { + connect(reg_model, &qf::qmlwidgets::model::SqlTableModel::reloaded, this, [this]() { ui->tblRegistrations->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); }); @@ -157,7 +157,7 @@ void AddLegDialogWidget::updateLegAddedStatus(const QString &msg) m_updateStatusTimer = new QTimer(this); m_updateStatusTimer->setSingleShot(true); m_updateStatusTimer->setInterval(3000); - connect(m_updateStatusTimer, &QTimer::timeout, [this]() { + connect(m_updateStatusTimer, &QTimer::timeout, this, [this]() { ui->lblStatus->setText(m_defaultStatusText); ui->lblStatus->setStyleSheet(QString()); }); diff --git a/quickevent/app/quickevent/plugins/Relays/src/relaydocument.h b/quickevent/app/quickevent/plugins/Relays/src/relaydocument.h index 79c704842..3c6575ee9 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relaydocument.h +++ b/quickevent/app/quickevent/plugins/Relays/src/relaydocument.h @@ -1,15 +1,15 @@ #ifndef RELAYS_RELAYDOCUMENT_H #define RELAYS_RELAYDOCUMENT_H -#include +#include namespace Relays { -class RelayDocument : public qf::core::model::SqlDataDocument +class RelayDocument : public qf::qmlwidgets::model::SqlDataDocument { Q_OBJECT private: - typedef qf::core::model::SqlDataDocument Super; + typedef qf::qmlwidgets::model::SqlDataDocument Super; public: RelayDocument(QObject *parent = nullptr); protected: diff --git a/quickevent/app/quickevent/plugins/Relays/src/relaysplugin.cpp b/quickevent/app/quickevent/plugins/Relays/src/relaysplugin.cpp index 573abbe76..d6ff97ca5 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relaysplugin.cpp +++ b/quickevent/app/quickevent/plugins/Relays/src/relaysplugin.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,7 +30,7 @@ namespace qff = qf::qmlwidgets::framework; namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; namespace qfs = qf::core::sql; namespace qog = quickevent::core::og; using ::PartWidget; @@ -470,8 +470,8 @@ qf::core::utils::TreeTable RelaysPlugin::nLegsClassResultsTable(int class_id, in QVariant RelaysPlugin::startListByClassesTableData(const QString &class_filter, bool with_vacants) { qfLogFuncFrame() << class_filter; - qf::core::model::SqlTableModel model; - qf::core::model::SqlTableModel model2; + qf::qmlwidgets::model::SqlTableModel model; + qf::qmlwidgets::model::SqlTableModel model2; { qf::core::sql::QueryBuilder qb; qb.select2("classes", "id, name") diff --git a/quickevent/app/quickevent/plugins/Relays/src/relayswidget.cpp b/quickevent/app/quickevent/plugins/Relays/src/relayswidget.cpp index 6daeae8e7..2488299e9 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relayswidget.cpp +++ b/quickevent/app/quickevent/plugins/Relays/src/relayswidget.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ namespace qfs = qf::core::sql; namespace qfw = qf::qmlwidgets; namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; using Relays::RelaysPlugin; @@ -251,7 +251,7 @@ void RelaysWidget::editRelay(const QVariant &id, int mode) dlg.setDefaultButton(QDialogButtonBox::Save); QPushButton *bt_save_and_next = dlg.buttonBox()->addButton(tr("Save and &next"), QDialogButtonBox::AcceptRole); bool save_and_next = false; - connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, [&save_and_next, bt_save_and_next](QAbstractButton *button) { + connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, this, [&save_and_next, bt_save_and_next](QAbstractButton *button) { save_and_next = (button == bt_save_and_next); }); dlg.setCentralWidget(w); @@ -269,8 +269,8 @@ void RelaysWidget::editRelay(const QVariant &id, int mode) //else // transaction.rollback(); if(ok && save_and_next) { - QTimer::singleShot(0, [this]() { - this->editRelay(QVariant(), qf::core::model::DataDocument::ModeInsert); + QTimer::singleShot(0, this, [this]() { + this->editRelay(QVariant(), qf::qmlwidgets::model::DataDocument::ModeInsert); }); } } @@ -354,8 +354,8 @@ void RelaysWidget::relays_assignNumbers() QVariant RelaysWidget::startListByClubsTableData(bool with_vacants) { qfLogFuncFrame(); - qf::core::model::SqlTableModel model; - qf::core::model::SqlTableModel model2; + qf::qmlwidgets::model::SqlTableModel model; + qf::qmlwidgets::model::SqlTableModel model2; { qf::core::sql::QueryBuilder qb1; qb1.select("relays.club") diff --git a/quickevent/app/quickevent/plugins/Relays/src/relayswidget.h b/quickevent/app/quickevent/plugins/Relays/src/relayswidget.h index f4c5a6291..4dc77edb4 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relayswidget.h +++ b/quickevent/app/quickevent/plugins/Relays/src/relayswidget.h @@ -9,16 +9,9 @@ class QCheckBox; namespace Ui { class RelaysWidget; } -namespace qf { -namespace core { -namespace model { -class SqlTableModel; -} -} -namespace qmlwidgets { -class ForeignKeyComboBox; -} -} + +namespace qf::qmlwidgets::model { class SqlTableModel; } +namespace qf::qmlwidgets { class ForeignKeyComboBox; } class RelaysWidget : public QFrame { @@ -59,7 +52,7 @@ class RelaysWidget : public QFrame //void printResults(const QString &settings_id, const QVariantMap &default_options); private: Ui::RelaysWidget *ui; - qf::core::model::SqlTableModel *m_tblModel; + qf::qmlwidgets::model::SqlTableModel *m_tblModel; qf::qmlwidgets::ForeignKeyComboBox *m_cbxClasses = nullptr; void save_xml_file(QString str, QString fn); }; diff --git a/quickevent/app/quickevent/plugins/Relays/src/relaywidget.cpp b/quickevent/app/quickevent/plugins/Relays/src/relaywidget.cpp index 6913fe53e..6b73b202a 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relaywidget.cpp +++ b/quickevent/app/quickevent/plugins/Relays/src/relaywidget.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -33,11 +33,11 @@ namespace qfd = qf::qmlwidgets::dialogs; namespace { -class LegsModel : public quickevent::core::og::SqlTableModel +class LegsModel : public quickevent::gui::og::SqlTableModel { Q_DECLARE_TR_FUNCTIONS(LegsModel) private: - using Super = quickevent::core::og::SqlTableModel; + using Super = quickevent::gui::og::SqlTableModel; public: LegsModel(QObject *parent = nullptr); diff --git a/quickevent/app/quickevent/plugins/Relays/src/relaywidget.h b/quickevent/app/quickevent/plugins/Relays/src/relaywidget.h index dc2f61de1..aaf79acfb 100644 --- a/quickevent/app/quickevent/plugins/Relays/src/relaywidget.h +++ b/quickevent/app/quickevent/plugins/Relays/src/relaywidget.h @@ -3,7 +3,7 @@ #include -namespace quickevent { namespace core { namespace og { class SqlTableModel; }}} +namespace quickevent::gui::og { class SqlTableModel; } namespace Ui { class RelayWidget; } @@ -16,7 +16,7 @@ class RelayWidget : public qf::qmlwidgets::framework::DataDialogWidget explicit RelayWidget(QWidget *parent = nullptr); ~RelayWidget() Q_DECL_OVERRIDE; - bool load(const QVariant &id = QVariant(), int mode = qf::core::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; + bool load(const QVariant &id = QVariant(), int mode = qf::qmlwidgets::model::DataDocument::ModeEdit) Q_DECL_OVERRIDE; private: Q_SLOT bool loadLegsTable(); //Q_SLOT bool saveLegsTable(); @@ -30,7 +30,7 @@ class RelayWidget : public qf::qmlwidgets::framework::DataDialogWidget void moveLegDown(); private: Ui:: RelayWidget *ui; - quickevent::core::og::SqlTableModel *m_legsModel; + quickevent::gui::og::SqlTableModel *m_legsModel; }; #endif // RELAYWIDGET_H diff --git a/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.cpp b/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.cpp index 90fdba459..30c35a21a 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.cpp @@ -21,11 +21,11 @@ CardFlagsDialog::~CardFlagsDialog() delete ui; } -void CardFlagsDialog::load(quickevent::core::og::SqlTableModel *model, int row) +void CardFlagsDialog::load(quickevent::gui::og::SqlTableModel *model, int row) { m_model = model; m_row = row; - qf::core::utils::TableRow table_row = m_model->tableRow(m_row); + auto table_row = m_model->tableRow(m_row); ui->cbxCardLent->setChecked(table_row.value(QStringLiteral("runs.cardLent")).toBool()); ui->cbxCardInLentTable->setChecked(table_row.value(QStringLiteral("cardInLentTable")).toBool()); ui->cbxCardReturned->setChecked(table_row.value(QStringLiteral("runs.cardReturned")).toBool()); @@ -34,7 +34,7 @@ void CardFlagsDialog::load(quickevent::core::og::SqlTableModel *model, int row) void CardFlagsDialog::save() { - qf::core::utils::TableRow &table_row = m_model->tableRowRef(m_row); + auto &table_row = m_model->tableRowRef(m_row); table_row.setValue(QStringLiteral("runs.cardLent"), ui->cbxCardLent->isChecked()); //table_row.setValue(QStringLiteral("cardInLentTable"), ui->cbxCardInLentTable->isChecked()); table_row.setValue(QStringLiteral("runs.cardReturned"), ui->cbxCardReturned->isChecked()); diff --git a/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.h b/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.h index 80c9d667b..8425ae618 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.h +++ b/quickevent/app/quickevent/plugins/Runs/src/cardflagsdialog.h @@ -2,7 +2,7 @@ #include -namespace quickevent::core::og { class SqlTableModel; } +namespace quickevent::gui::og { class SqlTableModel; } namespace Runs { @@ -18,13 +18,13 @@ class CardFlagsDialog : public QDialog explicit CardFlagsDialog(QWidget *parent = nullptr); ~CardFlagsDialog() override; - void load(quickevent::core::og::SqlTableModel *model, int row); + void load(quickevent::gui::og::SqlTableModel *model, int row); void save(); private: void updateStatus(); private: Ui::CardFlagsDialog *ui; - quickevent::core::og::SqlTableModel *m_model; + quickevent::gui::og::SqlTableModel *m_model; int m_row; }; diff --git a/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.cpp b/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.cpp index 65db600d7..db9c3d31a 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include @@ -32,11 +32,11 @@ using Runs::RunsPlugin; //============================================================ // EventStatisticsModel //============================================================ -class EventStatisticsModel : public quickevent::core::og::SqlTableModel +class EventStatisticsModel : public quickevent::gui::og::SqlTableModel { Q_DECLARE_TR_FUNCTIONS(EventStatisticsModel) private: - typedef quickevent::core::og::SqlTableModel Super; + typedef quickevent::gui::og::SqlTableModel Super; public: enum Cols { col_className, @@ -207,7 +207,7 @@ QVariant EventStatisticsModel::data(const QModelIndex &index, int role) const } //============================================================ -// FooterModel +// FooterModel //============================================================ class FooterModel : public QAbstractTableModel { @@ -220,12 +220,12 @@ class FooterModel : public QAbstractTableModel QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; - qf::core::model::TableModel* masterModel() const; - void setMasterModel(qf::core::model::TableModel *masterModel); + qf::qmlwidgets::model::TableModel* masterModel() const; + void setMasterModel(qf::qmlwidgets::model::TableModel *masterModel); void reload(); private: - qf::core::model::TableModel *m_masterModel = nullptr; + qf::qmlwidgets::model::TableModel *m_masterModel = nullptr; QVector m_columnSums; }; @@ -261,23 +261,20 @@ QVariant FooterModel::headerData(int section, Qt::Orientation orientation, int r if(role == Qt::TextAlignmentRole) { return Qt::AlignRight; } - if(role == Qt::BackgroundRole) { - return QColor("khaki"); - } } return Super::headerData(section, orientation, role); } -qf::core::model::TableModel *FooterModel::masterModel() const +qf::qmlwidgets::model::TableModel *FooterModel::masterModel() const { QF_ASSERT_EX(m_masterModel != nullptr, "Master model is NULL"); return m_masterModel; } -void FooterModel::setMasterModel(qf::core::model::TableModel *masterModel) +void FooterModel::setMasterModel(qf::qmlwidgets::model::TableModel *masterModel) { m_masterModel = masterModel; - connect(m_masterModel, &qf::core::model::SqlTableModel::reloaded, this, &FooterModel::reload); + connect(m_masterModel, &qf::qmlwidgets::model::SqlTableModel::reloaded, this, &FooterModel::reload); } void FooterModel::reload() @@ -339,11 +336,11 @@ FooterView::FooterView(QTableView *table_view, QWidget *parent) if(hh) { //qfWarning() << "header view:" << hh->metaObject()->className(); //setMaximumHeight(hh->defaultSectionSize()); - connect(hh, &QHeaderView::sectionResized, [this](int logical_index, int old_size, int new_size) { + connect(hh, &QHeaderView::sectionResized, this, [this](int logical_index, int old_size, int new_size) { Q_UNUSED(old_size) this->resizeSection(logical_index, new_size); }); - connect(hh, &QHeaderView::sectionMoved, [this](int logical_index, int old_visual_index, int new_visual_index) { + connect(hh, &QHeaderView::sectionMoved, this, [this](int logical_index, int old_visual_index, int new_visual_index) { Q_UNUSED(logical_index) this->moveSection(old_visual_index, new_visual_index); }); diff --git a/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.ui b/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.ui index 1d723fffc..4d4735f2d 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.ui +++ b/quickevent/app/quickevent/plugins/Runs/src/eventstatisticswidget.ui @@ -32,10 +32,10 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame - QFrame::Raised + QFrame::Shadow::Raised @@ -73,7 +73,7 @@ Print results in selected rows - + :/qf/qmlwidgets/images/flat/printer.svg:/qf/qmlwidgets/images/flat/printer.svg @@ -87,7 +87,7 @@ Clear new results in selected rows - + :/qf/qmlwidgets/images/flat/delete.svg:/qf/qmlwidgets/images/flat/delete.svg @@ -101,7 +101,7 @@ Reload table - + :/qf/qmlwidgets/images/flat/reload.svg:/qf/qmlwidgets/images/flat/reload.svg @@ -115,7 +115,7 @@ Options - + :/qf/qmlwidgets/images/flat/settings.svg:/qf/qmlwidgets/images/flat/settings.svg @@ -126,7 +126,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -159,7 +159,7 @@ - + diff --git a/quickevent/app/quickevent/plugins/Runs/src/findrunneredit.cpp b/quickevent/app/quickevent/plugins/Runs/src/findrunneredit.cpp index 8fd1f3400..de68b9a6f 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/findrunneredit.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/findrunneredit.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/quickevent/app/quickevent/plugins/Runs/src/findrunnerwidget.cpp b/quickevent/app/quickevent/plugins/Runs/src/findrunnerwidget.cpp index 60c09e939..5d33c440f 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/findrunnerwidget.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/findrunnerwidget.cpp @@ -4,13 +4,11 @@ #include -#include +#include #include #include #include -namespace qfm = qf::core::model; -namespace qfs = qf::core::sql; using qf::qmlwidgets::framework::getPlugin; using Runs::RunsPlugin; using Event::EventPlugin; diff --git a/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.cpp b/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.cpp index dac968afa..c096ff544 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.cpp @@ -24,7 +24,7 @@ RunFlagsDialog::~RunFlagsDialog() delete ui; } -void RunFlagsDialog::load(quickevent::core::og::SqlTableModel *model, int row) +void RunFlagsDialog::load(quickevent::gui::og::SqlTableModel *model, int row) { m_model = model; m_row = row; diff --git a/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.h b/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.h index 6d0781a81..0b47aef3b 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.h +++ b/quickevent/app/quickevent/plugins/Runs/src/runflagsdialog.h @@ -2,7 +2,7 @@ #include -namespace quickevent::core::og { class SqlTableModel; } +namespace quickevent::gui::og { class SqlTableModel; } namespace Runs { @@ -17,14 +17,14 @@ class RunFlagsDialog : public QDialog explicit RunFlagsDialog(QWidget *parent = nullptr); ~RunFlagsDialog() override; - void load(quickevent::core::og::SqlTableModel *model, int row); + void load(quickevent::gui::og::SqlTableModel *model, int row); void save(); private: void updateStatus(); bool isDisqualified() const; private: Ui::RunFlagsDialog *ui; - quickevent::core::og::SqlTableModel *m_model; + quickevent::gui::og::SqlTableModel *m_model; int m_row; bool m_isDisqualified; }; diff --git a/quickevent/app/quickevent/plugins/Runs/src/runsplugin.cpp b/quickevent/app/quickevent/plugins/Runs/src/runsplugin.cpp index 0124b0635..9a15308c4 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runsplugin.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/runsplugin.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -80,7 +80,7 @@ const qf::core::utils::Table &RunsPlugin::runnersTable(int stage_id) .join("competitors.classId", "classes.id") .joinRestricted("competitors.id", "runs.competitorId", "runs.stageId=" QF_IARG(stage_id), "JOIN") .orderBy("classes.name, lastName, firstName"); - qf::core::model::SqlTableModel m; + qf::qmlwidgets::model::SqlTableModel m; m.setQueryBuilder(qb, false); m.reload(); m_runnersTableCache = m.table(); @@ -560,7 +560,7 @@ qf::core::utils::Table RunsPlugin::nstagesClassResultsTable(int stages_count, in qb.select(QF_IARG(UNREAL_TIME_MSEC) " AS timeMs"); qb.select(QF_IARG(UNREAL_TIME_MSEC) " AS timeLossMs"); qb.select("'' AS pos"); - qf::core::model::SqlTableModel mod; + qf::qmlwidgets::model::SqlTableModel mod; mod.setQueryBuilder(qb, false); mod.reload(); QMap competitor_id_to_row; @@ -649,7 +649,7 @@ qf::core::utils::TreeTable RunsPlugin::nstagesResultsTable(const QString &class_ qfLogFuncFrame(); //qf::core::utils::Table::FieldList cols; //cols << qf::core::utils::Table::Field("") - qf::core::model::SqlTableModel mod; + qf::qmlwidgets::model::SqlTableModel mod; { qfs::QueryBuilder qb; qb.select2("classes", "id, name") @@ -695,7 +695,7 @@ qf::core::utils::TreeTable RunsPlugin::currentStageResultsTable(const QString &c qf::core::utils::TreeTable RunsPlugin::stageResultsTable(int stage_id, const QString &class_filter, int max_competitors_in_class, bool exclude_disq, bool add_laps) { qfLogFuncFrame(); - qf::core::model::SqlTableModel model; + qf::qmlwidgets::model::SqlTableModel model; { qf::core::sql::QueryBuilder qb; qb.select2("classes", "id, name") @@ -1394,7 +1394,7 @@ qf::core::utils::TreeTable RunsPlugin::startListClassesTable(const QString &wher qb.where(where_expr); QVariantMap qpm; qpm["stage_id"] = stage_id; - qf::core::model::SqlTableModel m; + qf::qmlwidgets::model::SqlTableModel m; m.setQueryBuilder(qb); m.setQueryParameters(qpm); m.reload(); @@ -1453,7 +1453,7 @@ qf::core::utils::TreeTable RunsPlugin::startListClassesTable(const QString &wher int class_id = tt_row.value(QStringLiteral("classes.id")).toInt(); //console.debug("class id:", class_id); qpm["class_id"] = class_id; - qf::core::model::SqlTableModel m2; + qf::qmlwidgets::model::SqlTableModel m2; m2.setQueryBuilder(qb2); m2.setQueryParameters(qpm); m2.reload(); @@ -1513,7 +1513,7 @@ qf::core::utils::TreeTable RunsPlugin::startListClubsTable(const quickevent::gui QString qs = "SELECT t2.clubAbbr, clubs.name FROM ( " + qs1 + " ) AS t2" + " LEFT JOIN clubs ON t2.clubAbbr=clubs.abbr" + " ORDER BY t2.clubAbbr"; - qf::core::model::SqlTableModel m; + qf::qmlwidgets::model::SqlTableModel m; m.setQuery(qs); m.reload(); auto tt = m.toTreeTable(); @@ -1560,7 +1560,7 @@ qf::core::utils::TreeTable RunsPlugin::startListClubsTable(const quickevent::gui .orderBy(order_sql_part); QVariantMap qpm; qpm["stage_id"] = stage_id; - qf::core::model::SqlTableModel m2; + qf::qmlwidgets::model::SqlTableModel m2; m2.setQueryBuilder(qb); m2.setQueryParameters(qpm); for(int i=0; i #include -#include +#include #include #include #include @@ -15,7 +15,6 @@ #include -namespace qfs = qf::core::sql; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -57,7 +56,7 @@ void RunsTableItemDelegate::paintBackground(QPainter *painter, const QStyleOptio // check that start time in classes is the same if(index.column() == RunsTableModel::Columns::col_runs_startTimeMs) { QVariant stime_v = m->data(index.sibling(index.row(), RunsTableModel::Columns::col_runs_startTimeMs), Qt::EditRole); - quickevent::core::og::TimeMs stime = stime_v.value(); + auto stime = stime_v.value(); int start_ms = stime.msec(); if(!stime.isValid()) return; @@ -73,7 +72,7 @@ void RunsTableItemDelegate::paintBackground(QPainter *painter, const QStyleOptio else if(isStartTimeHighlightVisible() && m_classDef.classInterval > 0) { //qfInfo() << "col:" << index.column() << m_highlightedClassId << "interval:" << m_classInterval << isStartTimeHighlightVisible(); QVariant stime_v = m->data(index.sibling(index.row(), RunsTableModel::Columns::col_runs_startTimeMs), Qt::EditRole); - quickevent::core::og::TimeMs stime = stime_v.value(); + auto stime = stime_v.value(); int start_ms = stime.msec(); if(!stime.isValid()) return; @@ -113,7 +112,7 @@ void RunsTableItemDelegate::paintBackground(QPainter *painter, const QStyleOptio */ else if(bad_club) { //qfInfo() << (start_ms - prev_start_ms) << m_classInterval; - QColor c = QColor(Qt::magenta); + auto c = QColor(Qt::magenta); painter->fillRect(option.rect, c); } } diff --git a/quickevent/app/quickevent/plugins/Runs/src/runstablemodel.h b/quickevent/app/quickevent/plugins/Runs/src/runstablemodel.h index a60fab59a..e58e1618b 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runstablemodel.h +++ b/quickevent/app/quickevent/plugins/Runs/src/runstablemodel.h @@ -1,13 +1,13 @@ #ifndef RUNSTABLEMODEL_H #define RUNSTABLEMODEL_H -#include +#include -class RunsTableModel : public quickevent::core::og::SqlTableModel +class RunsTableModel : public quickevent::gui::og::SqlTableModel { Q_OBJECT private: - typedef quickevent::core::og::SqlTableModel Super; + using Super = quickevent::gui::og::SqlTableModel; public: enum Columns { col_runs_isRunning = 0, diff --git a/quickevent/app/quickevent/plugins/Runs/src/runstablewidget.cpp b/quickevent/app/quickevent/plugins/Runs/src/runstablewidget.cpp index 7f6f3b6d7..b875f50a4 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runstablewidget.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/runstablewidget.cpp @@ -91,7 +91,7 @@ RunsTableWidget::RunsTableWidget(QWidget *parent) : if(col == RunsTableModel::col_runFlags || col == RunsTableModel::col_cardFlags) { return; } - if (mode == qf::core::model::DataDocument::ModeInsert) { + if (mode == qf::qmlwidgets::model::DataDocument::ModeInsert) { emit editCompetitorRequest(0, mode); } else { @@ -194,8 +194,7 @@ void RunsTableWidget::reload(int stage_id, int class_id, bool show_offrace, cons QModelIndex ix = m_runsModel->index(i, sort_col_ix); ix = ui->tblRuns->sortFilterProxyModel()->mapFromSource(ix); ui->tblRuns->setCurrentIndex(ix); - //ui->tblRuns->selectionModel()->select(ix, QItemSelectionModel::ClearAndSelect); - QTimer::singleShot(0, [this, ix]() { + QTimer::singleShot(0, this, [this, ix]() { this->ui->tblRuns->scrollTo(ix); }); } diff --git a/quickevent/app/quickevent/plugins/Runs/src/runswidget.cpp b/quickevent/app/quickevent/plugins/Runs/src/runswidget.cpp index c5cad8a28..f89856e33 100644 --- a/quickevent/app/quickevent/plugins/Runs/src/runswidget.cpp +++ b/quickevent/app/quickevent/plugins/Runs/src/runswidget.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ namespace qfs = qf::core::sql; namespace qfw = qf::qmlwidgets; namespace qff = qf::qmlwidgets::framework; namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; +namespace qfm = qf::qmlwidgets::model; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -68,7 +68,7 @@ RunsWidget::RunsWidget(QWidget *parent) : ui->frmDrawing->setVisible(false); - connect(getPlugin(), &Event::EventPlugin::eventOpenChanged, [this]() { + connect(getPlugin(), &Event::EventPlugin::eventOpenChanged, this, [this]() { ui->cbxDrawMethod->clear(); if(!getPlugin()->isEventOpen()) return; @@ -233,7 +233,7 @@ void RunsWidget::settleDownInPartWidget(::PartWidget *part_widget) } { auto *a = new qfw::Action(tr("&Competitors with rented cards")); - connect(a, &qfw::Action::triggered, [this]() { + connect(a, &qfw::Action::triggered, this, [this]() { qff::MainWindow *fwk = qff::MainWindow::frameWork(); quickevent::gui::ReportOptionsDialog dlg(fwk); dlg.setPersistentSettingsId("competitorsWithRentedCards"); @@ -441,9 +441,9 @@ QList< QList > RunsWidget::runnersByClubSortedByCount(int stage_id, int cla runner_id_to_club[id] = club; } { - for(auto club : ids_by_clubs.keys()) { + for(const auto &[club, val] : ids_by_clubs.asKeyValueRange()) { QStringList sl; - for(auto id : ids_by_clubs.value(club)) { + for(auto id : val) { sl << QString::number(id); } qfDebug() << "\t" << club << ":" << sl.join(", "); @@ -456,7 +456,7 @@ QList< QList > RunsWidget::runnersByClubSortedByCount(int stage_id, int cla shuffle(ret[i]); } { - for(auto lst : ret) { + for(const auto &lst : ret) { QStringList sl; for(auto id : lst) { sl << QString::number(id); @@ -792,8 +792,9 @@ void RunsWidget::onDrawClicked() QList< QList > runners_by_club = runnersByClubSortedByCount(stage_id, class_id, runner_id_to_club); if(runners_by_club.count()) { int runners_cnt = 0; - for(auto lst : runners_by_club) + for(const auto &lst : runners_by_club) { runners_cnt += lst.count(); + } runners_draw_ids.reserve(runners_cnt); runners_draw_ids << runners_by_club.first(); int club_ix = 1; @@ -961,7 +962,7 @@ void RunsWidget::onDrawRemoveClicked() for (int i = 0; i < runs_model->rowCount(); ++i) { runs_model->setValue(i, "startTimeMs", QVariant()); // bypass mid-air collision check - runs_model->quickevent::core::og::SqlTableModel::postRow(i, qf::core::Exception::Throw); + runs_model->quickevent::gui::og::SqlTableModel::postRow(i, qf::core::Exception::Throw); } int stage_id = selectedStageId(); saveLockedForDrawing(class_id, stage_id, false, 0); @@ -1092,7 +1093,7 @@ void RunsWidget::report_competitorsStatistics() qfs::QueryBuilder qb; qb.select2("classes", "id, name").from("classes").orderBy("classes.name"); - qf::core::model::SqlTableModel m; + qf::qmlwidgets::model::SqlTableModel m; m.setQueryBuilder(qb); m.reload(); qfu::TreeTable tt = m.toTreeTable(); @@ -1154,15 +1155,15 @@ void RunsWidget::editCompetitor_helper(const QVariant &id, int mode, int siid) w->setWindowTitle(tr("Edit Competitor")); qfd::Dialog dlg(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); dlg.setDefaultButton(QDialogButtonBox::Ok); - if(mode == qf::core::model::DataDocument::ModeInsert || mode == qf::core::model::DataDocument::ModeEdit) { + if(mode == qf::qmlwidgets::model::DataDocument::ModeInsert || mode == qf::qmlwidgets::model::DataDocument::ModeEdit) { QPushButton *bt_save = dlg.buttonBox()->addButton(tr("Save"), QDialogButtonBox::ApplyRole); - connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, [w, bt_save](QAbstractButton *button) { + connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, &dlg, [w, bt_save](QAbstractButton *button) { if (button == bt_save) { w->save(); } }); QPushButton *bt_save_and_next = dlg.buttonBox()->addButton(tr("Ok and &next"), QDialogButtonBox::AcceptRole); - connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, [&save_and_next, bt_save_and_next](QAbstractButton *button) { + connect(dlg.buttonBox(), &qf::qmlwidgets::DialogButtonBox::clicked, &dlg, [&save_and_next, bt_save_and_next](QAbstractButton *button) { save_and_next = (button == bt_save_and_next); }); } @@ -1190,8 +1191,8 @@ void RunsWidget::editCompetitor_helper(const QVariant &id, int mode, int siid) } if(ok && save_and_next) { - QTimer::singleShot(0, [this]() { - this->editCompetitor(QVariant(), qf::core::model::DataDocument::ModeInsert); + QTimer::singleShot(0, this, [this]() { + this->editCompetitor(QVariant(), qf::qmlwidgets::model::DataDocument::ModeInsert); }); } } diff --git a/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.cpp b/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.cpp index 433b3c467..4c7f1d212 100644 --- a/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.cpp +++ b/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -20,11 +20,6 @@ #include #include -namespace qfs = qf::core::sql; -namespace qfw = qf::qmlwidgets; -namespace qff = qf::qmlwidgets::framework; -namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -38,7 +33,7 @@ CodeClassResultsWidget::CodeClassResultsWidget(QWidget *parent) //ui->tblView->setPersistentSettingsId("tblView"); //ui->tblPunches->setRowEditorMode(qfw::TableView::EditRowsMixed); //ui->tblPunches->setInlineEditSaveStrategy(qfw::TableView::OnEditedValueCommit); - quickevent::core::og::SqlTableModel *m = new quickevent::core::og::SqlTableModel(this); + auto *m = new quickevent::gui::og::SqlTableModel(this); m->addColumn("competitorName", tr("Competitor")); m->addColumn("competitors.registration", tr("Reg"));//.setReadOnly(true); m->addColumn("timeMs", tr("Time")).setCastType(qMetaTypeId()); @@ -132,10 +127,10 @@ void CodeClassResultsWidget::reset(int class_id, int code, int pin_to_code) if(pin_to_code == ALL_CODES) { ui->lblCode->show(); ui->lstCode->show(); - connect(ui->lstClass, static_cast(&QComboBox::currentIndexChanged), [this](int ) { + connect(ui->lstClass, static_cast(&QComboBox::currentIndexChanged), this, [this](int ) { int stage_id = getPlugin()->currentStageId(); int class_id = this->ui->lstClass->currentData().toInt(); - ui->lstCode->blockSignals(true); + QSignalBlocker b1(ui->lstCode); ui->lstCode->clear(); ui->lstCode->addItem(tr("Results"), RESULTS_PUNCH_CODE); ui->lstCode->addItem(tr("Finish"), quickevent::core::CodeDef::FINISH_PUNCH_CODE); @@ -156,11 +151,11 @@ void CodeClassResultsWidget::reset(int class_id, int code, int pin_to_code) QVariant code = q.value(0); bool radio = q.value(1).toBool(); QString caption = code.toString(); - if(radio) + if(radio) { caption += " " + tr("R", "Radio station"); + } ui->lstCode->addItem(caption, code); } - ui->lstCode->blockSignals(false); }); ui->lstClass->setCurrentIndex(ui->lstClass->findData(class_id)); diff --git a/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.h b/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.h index 3553cf92f..c7682f21b 100644 --- a/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.h +++ b/quickevent/app/quickevent/plugins/Speaker/src/codeclassresultswidget.h @@ -5,10 +5,8 @@ class QJsonObject; -namespace quickevent { namespace core { -namespace og { class SqlTableModel; } -namespace si { class PunchRecord; } -}} +namespace quickevent::gui::og { class SqlTableModel; } +namespace quickevent::core::si { class PunchRecord; } namespace Ui { class CodeClassResultsWidget; @@ -37,7 +35,7 @@ class CodeClassResultsWidget : public QWidget //void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; private: Ui::CodeClassResultsWidget *ui; - quickevent::core::og::SqlTableModel *m_tableModel = nullptr; + quickevent::gui::og::SqlTableModel *m_tableModel = nullptr; QTimer *m_reloadDeferredTimer = nullptr; int m_pinnedToCode = ALL_CODES; }; diff --git a/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.cpp b/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.cpp index 785b0e774..22e23d7d0 100644 --- a/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.cpp +++ b/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -30,10 +30,6 @@ #include namespace qfs = qf::core::sql; -namespace qfw = qf::qmlwidgets; -namespace qff = qf::qmlwidgets::framework; -namespace qfd = qf::qmlwidgets::dialogs; -namespace qfm = qf::core::model; using qf::qmlwidgets::framework::getPlugin; using Event::EventPlugin; @@ -62,17 +58,8 @@ SpeakerWidget::SpeakerWidget(QWidget *parent) : ui->tblPunches->setPersistentSettingsId("tblPunches"); connect(ui->tblPunches, &PunchesTableView::codeClassActivated, this, &SpeakerWidget::onCodeClassActivated); - /* - ui->tblPunches->setDragEnabled(true); - //ui->tblView->setDragDropMode(QAbstractItemView::DragOnly); - ui->tblPunches->setDragDropMode(QAbstractItemView::InternalMove); - ui->tblPunches->setSelectionMode(QAbstractItemView::SingleSelection); - ui->tblPunches->viewport()->setAcceptDrops(true); - ui->tblPunches->setDropIndicatorShown(true); - */ - //ui->tblPunches->setRowEditorMode(qfw::TableView::EditRowsMixed); - //ui->tblPunches->setInlineEditSaveStrategy(qfw::TableView::OnEditedValueCommit); - quickevent::core::og::SqlTableModel *m = new quickevent::core::og::SqlTableModel(this); + + auto *m = new quickevent::gui::og::SqlTableModel(this); m->addColumn("punches.id");//.setReadOnly(true); m->addColumn("punches.code", tr("Code")); m->addColumn("punches.siId", tr("SI")).setReadOnly(true).setCastType(qMetaTypeId()); @@ -143,7 +130,6 @@ void SpeakerWidget::onDbEventNotify(const QString &domain, int connection_id, co void SpeakerWidget::reset() { - qfInfo() << Q_FUNC_INFO; if(!getPlugin()->isEventOpen()) { m_punchesModel->clearRows(); return; @@ -212,19 +198,19 @@ bool SpeakerWidget::isPartActive() void SpeakerWidget::onCodeClassActivated(int class_id, int code) { - CodeClassResultsWidget *w = new CodeClassResultsWidget(this); + auto *w = new CodeClassResultsWidget(this); w->reset(class_id, code); //if(getPlugin()->isEventOpen()) // w->loadSetup(QJsonObject()); connect(this, &SpeakerWidget::punchReceived, w, &CodeClassResultsWidget::onPunchReceived); - QDockWidget *dw = new QDockWidget(); + auto *dw = new QDockWidget(); static int dock_widget_no = 0; dw->setObjectName("CodeClassResultsWidgetDockWidget_" + QString::number(++dock_widget_no)); dw->setAllowedAreas(Qt::AllDockWidgetAreas); dw->setWidget(w); //dw->show(); - qf::qmlwidgets::framework::MainWindow *fwk = qf::qmlwidgets::framework::MainWindow::frameWork(); + auto *fwk = qf::qmlwidgets::framework::MainWindow::frameWork(); fwk->addDockWidget(Qt::LeftDockWidgetArea, dw); dw->setFloating(true); } diff --git a/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.h b/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.h index 29b373de3..8be7db2cc 100644 --- a/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.h +++ b/quickevent/app/quickevent/plugins/Speaker/src/speakerwidget.h @@ -8,15 +8,10 @@ namespace Ui { class SpeakerWidget; } -namespace qf { -//namespace core { namespace model { class SqlTableModel; } } -namespace qmlwidgets { -class ForeignKeyComboBox; -} -} -namespace quickevent { namespace core { namespace og { class SqlTableModel; }}} -namespace quickevent { namespace core { namespace si { class PunchRecord; }}} +namespace qf::qmlwidgets { class ForeignKeyComboBox; } +namespace quickevent::gui::og { class SqlTableModel; } +namespace quickevent::core::si { class PunchRecord; } class ThisPartWidget; @@ -48,7 +43,7 @@ class SpeakerWidget : public QFrame void onCodeClassActivated(int class_id, int code); private: Ui::SpeakerWidget *ui; - quickevent::core::og::SqlTableModel *m_punchesModel = nullptr; + quickevent::gui::og::SqlTableModel *m_punchesModel = nullptr; qf::qmlwidgets::framework::PartWidget *m_partWidget = nullptr; bool m_resetRequest = false; bool m_settingsLoaded = false; diff --git a/quickevent/app/quickevent/src/application.cpp b/quickevent/app/quickevent/src/application.cpp index 5cfb5b7b1..182de4f80 100644 --- a/quickevent/app/quickevent/src/application.cpp +++ b/quickevent/app/quickevent/src/application.cpp @@ -24,7 +24,11 @@ Application::Application(int &argc, char **argv, AppCliOptions *cli_opts) } auto *style = qf::qmlwidgets::Style::instance(); - style->addIconSearchPath(":/qf/qmlwidgets/images/flat"); + if (qf::qmlwidgets::isDarkTheme()) { + style->addIconSearchPath(":/qf/qmlwidgets/images/dark"); + } else { + style->addIconSearchPath(":/qf/qmlwidgets/images/flat"); + } style->addIconSearchPath(":/qf/qmlwidgets/images"); loadStyleSheet(); diff --git a/quickevent/app/quickevent/src/loggerwidget.cpp b/quickevent/app/quickevent/src/loggerwidget.cpp index 91422c5e6..52ace84c0 100644 --- a/quickevent/app/quickevent/src/loggerwidget.cpp +++ b/quickevent/app/quickevent/src/loggerwidget.cpp @@ -3,22 +3,19 @@ #include -#include +#include LoggerWidget::LoggerWidget(QWidget *parent) : Super(parent) { addCategoryActions(tr(""), QString(), NecroLog::Level::Info); - m_logModel = new qf::core::model::LogTableModel(this); - connect(Application::instance(), &Application::newLogEntry, m_logModel, &qf::core::model::LogTableModel::addLogEntry, Qt::QueuedConnection); + m_logModel = new qf::qmlwidgets::model::LogTableModel(this); + connect(Application::instance(), &Application::newLogEntry, m_logModel, &qf::qmlwidgets::model::LogTableModel::addLogEntry, Qt::QueuedConnection); setLogTableModel(m_logModel); } -LoggerWidget::~LoggerWidget() -{ - //QF_SAFE_DELETE(m_logDevice); -} +LoggerWidget::~LoggerWidget() = default; void LoggerWidget::onDockWidgetVisibleChanged(bool visible) { @@ -28,12 +25,3 @@ void LoggerWidget::onDockWidgetVisibleChanged(bool visible) } } -void LoggerWidget::registerLogCategories() -{ - Super::registerLogCategories(); - //qfError() << "LoggerWidget::registerLogCategories" << "IMPL missing"; - //auto *ld = qobject_cast(qf::core::LogDevice::findDevice(TABLE_MODEL_LOG_DEVICE)); - //ld->setCategories(selectedLogCategories()); -} - - diff --git a/quickevent/app/quickevent/src/loggerwidget.h b/quickevent/app/quickevent/src/loggerwidget.h index ca47c91e4..80155aa5a 100644 --- a/quickevent/app/quickevent/src/loggerwidget.h +++ b/quickevent/app/quickevent/src/loggerwidget.h @@ -18,9 +18,7 @@ class LoggerWidget : public qf::qmlwidgets::framework::LogWidget void onDockWidgetVisibleChanged(bool visible) Q_DECL_OVERRIDE; private: - void registerLogCategories() Q_DECL_OVERRIDE; -private: - qf::core::model::LogTableModel *m_logModel = nullptr; + qf::qmlwidgets::model::LogTableModel *m_logModel = nullptr; }; #endif // LOGGERWIDGET_H diff --git a/quickevent/app/quickevent/src/main.cpp b/quickevent/app/quickevent/src/main.cpp index e87b93e6b..31a873e72 100644 --- a/quickevent/app/quickevent/src/main.cpp +++ b/quickevent/app/quickevent/src/main.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -49,8 +49,9 @@ int main(int argc, char *argv[]) std::vector shv_args = NecroLog::setCLIOptions(argc, argv); QStringList args; - for(const auto &s : shv_args) + for(const auto &s : shv_args) { args << QString::fromStdString(s); + } QSettings::setDefaultFormat(QSettings::IniFormat); @@ -124,7 +125,7 @@ int main(int argc, char *argv[]) QStringLiteral("libsiut"), QStringLiteral("quickevent"), }) { - QTranslator *translator = new QTranslator(&app); + auto *translator = new QTranslator(&app); bool ok = translator->load(QLocale(lc_name), file_name, QString("-"), lc_dir); if (ok) { ok = QCoreApplication::installTranslator(translator); @@ -133,7 +134,7 @@ int main(int argc, char *argv[]) } { - QTranslator *translator = new QTranslator(&app); + auto *translator = new QTranslator(&app); const auto file_name = QStringLiteral("qt"); bool ok = translator->load(QLocale(lc_name), file_name, QString("_"), QString("translations")); if (ok) { @@ -149,7 +150,7 @@ int main(int argc, char *argv[]) main_window.show(); emit main_window.applicationLaunched(); - int ret = app.exec(); + int ret = Application::exec(); return ret; } diff --git a/tools/qsqlmon/src/columnselectorwidget.cpp b/tools/qsqlmon/src/columnselectorwidget.cpp index c51add108..1e2a3dead 100644 --- a/tools/qsqlmon/src/columnselectorwidget.cpp +++ b/tools/qsqlmon/src/columnselectorwidget.cpp @@ -18,14 +18,18 @@ #include //================================================= -// ColumnSelectorWidget +// ColumnSelectorWidget //================================================= ColumnSelectorWidget::ColumnSelectorWidget(QString table_name, const QSqlDatabase &conn, QWidget *parent) : Super(parent), m_tableName(table_name) { ui = new Ui::ColumnSelectorWidget; ui->setupUi(this); - //Qf::connectSlotsByName(centralWidget(), this); + + connect(ui->btAll, &QAbstractButton::clicked, this, &ColumnSelectorWidget::onAll_clicked); + connect(ui->btInvert, &QAbstractButton::clicked, this, &ColumnSelectorWidget::onInvert_clicked); + connect(ui->btPasteSelectedColumns, &QAbstractButton::clicked, this, &ColumnSelectorWidget::onPasteSelectedColumns_clicked); + { qf::core::sql::Connection dbi(conn); QStringList fields = dbi.fields(m_tableName); @@ -51,13 +55,13 @@ void ColumnSelectorWidget::lazyInit() //QFXmlConfigPersistenter::loadPersistentDataRecursively(this); } -void ColumnSelectorWidget::on_btAll_clicked() +void ColumnSelectorWidget::onAll_clicked() { QListWidget *w = ui->lstFields; w->selectAll(); } -void ColumnSelectorWidget::on_btInvert_clicked() +void ColumnSelectorWidget::onInvert_clicked() { QListWidget *w = ui->lstFields; QAbstractItemModel *m = w->model(); @@ -69,7 +73,7 @@ void ColumnSelectorWidget::on_btInvert_clicked() } } -void ColumnSelectorWidget::on_btPasteSelectedColumns_clicked() +void ColumnSelectorWidget::onPasteSelectedColumns_clicked() { QStringList col_names; QListWidget *w = ui->lstFields; diff --git a/tools/qsqlmon/src/columnselectorwidget.h b/tools/qsqlmon/src/columnselectorwidget.h index 32784c5ea..5fb5870ec 100644 --- a/tools/qsqlmon/src/columnselectorwidget.h +++ b/tools/qsqlmon/src/columnselectorwidget.h @@ -26,9 +26,9 @@ class ColumnSelectorWidget : public qf::qmlwidgets::framework::DialogWidget QString m_tableName; protected slots: void lazyInit(); - void on_btAll_clicked(); - void on_btInvert_clicked(); - void on_btPasteSelectedColumns_clicked(); + void onAll_clicked(); + void onInvert_clicked(); + void onPasteSelectedColumns_clicked(); signals: void columnNamesCopiedToClipboard(const QString &column_names); public: diff --git a/tools/qsqlmon/src/dlgaltertable.cpp b/tools/qsqlmon/src/dlgaltertable.cpp index c7e742276..f9b11b0b5 100644 --- a/tools/qsqlmon/src/dlgaltertable.cpp +++ b/tools/qsqlmon/src/dlgaltertable.cpp @@ -1,5 +1,4 @@ #include "mainwindow.h" -#include "theapp.h" #include "dlgaltertable.h" #include "dlgcolumndef.h" #include "dlgindexdef.h" @@ -20,6 +19,16 @@ DlgAlterTable::DlgAlterTable(QWidget * parent, const QString& db, const QString& : QDialog(parent), m_tableName(table), m_schemaName(db) { setupUi(this); + + connect(Ui::DlgAlterTable::btFieldAppend, &QAbstractButton::clicked, this, &DlgAlterTable::onFieldAppend_clicked); + connect(Ui::DlgAlterTable::btFieldInsert, &QAbstractButton::clicked, this, &DlgAlterTable::onFieldInsert_clicked); + connect(Ui::DlgAlterTable::btFieldEdit, &QAbstractButton::clicked, this, &DlgAlterTable::onFieldEdit_clicked); + connect(Ui::DlgAlterTable::btFieldDelete, &QAbstractButton::clicked, this, &DlgAlterTable::onFieldDelete_clicked); + + connect(Ui::DlgAlterTable::btIndexAdd, &QAbstractButton::clicked, this, &DlgAlterTable::onIndexAdd_clicked); + connect(Ui::DlgAlterTable::btIndexDelete, &QAbstractButton::clicked, this, &DlgAlterTable::onIndexDelete_clicked); + connect(Ui::DlgAlterTable::btIndexEdit, &QAbstractButton::clicked, this, &DlgAlterTable::onIndexEdit_clicked); + txtComment->setEnabled(false); if(connection().driverName().endsWith("SQLITE")) { btFieldInsert->setEnabled(false); @@ -32,9 +41,7 @@ DlgAlterTable::DlgAlterTable(QWidget * parent, const QString& db, const QString& refresh(); } -DlgAlterTable::~DlgAlterTable() -{ -} +DlgAlterTable::~DlgAlterTable() = default; void DlgAlterTable::refresh() { @@ -58,7 +65,7 @@ void DlgAlterTable::refresh() } } -void DlgAlterTable::on_btFieldInsert_clicked(bool append) +void DlgAlterTable::onFieldInsert_clicked(bool append) { if(lstFields->currentRow() < 0) append = true; @@ -71,7 +78,7 @@ void DlgAlterTable::on_btFieldInsert_clicked(bool append) qf::qmlwidgets::dialogs::MessageBox::showInfo(this, "Not supported in SQLite version <= 3.2.2"); } QString fld_name = dlg.edName->text(); - QString s, qs = "ALTER TABLE %1 ADD COLUMN %2 "; + QString qs = "ALTER TABLE %1 ADD COLUMN %2 "; qs = qs.arg(m_tableName).arg(fld_name); qs += dlg.toString(); sql_commands << qs; @@ -84,7 +91,7 @@ void DlgAlterTable::on_btFieldInsert_clicked(bool append) qf::qmlwidgets::dialogs::MessageBox::showInfo(this, "Columns insertion is not supported in PSQL"); } QString fld_name = dlg.edName->text(); - QString s, qs = "ALTER TABLE %1.%2 ADD COLUMN %3 "; + QString qs = "ALTER TABLE %1.%2 ADD COLUMN %3 "; qs = qs.arg(m_schemaName).arg(m_tableName).arg(fld_name); qs += dlg.toString(); sql_commands << qs; @@ -102,7 +109,7 @@ void DlgAlterTable::on_btFieldInsert_clicked(bool append) } } QString fld_name = dlg.edName->text(); - QString s, qs = "ALTER TABLE %1 ADD COLUMN %2 "; + QString qs = "ALTER TABLE %1 ADD COLUMN %2 "; qs = qs.arg(m_tableName).arg(fld_name); qs += dlg.toString(); qs += insert_where; @@ -136,12 +143,12 @@ void DlgAlterTable::on_btFieldInsert_clicked(bool append) } } -void DlgAlterTable::on_btFieldAppend_clicked() +void DlgAlterTable::onFieldAppend_clicked() { - on_btFieldInsert_clicked(true); + onFieldInsert_clicked(true); } -void DlgAlterTable::on_btFieldEdit_clicked() +void DlgAlterTable::onFieldEdit_clicked() { qfLogFuncFrame(); if(lstFields->currentRow() < 0) @@ -168,7 +175,7 @@ void DlgAlterTable::on_btFieldEdit_clicked() } else if(connection().driverName().endsWith("PSQL")) { if(fi.shortName() != dlg.edName->text()) { - QString s = "ALTER TABLE %1 RENAME COLUMN \"%2\" TO \"%3\""; + QString s = R"(ALTER TABLE %1 RENAME COLUMN "%2" TO "%3")"; s = s.arg(m_tableName).arg(fi.shortName()).arg(dlg.edName->text()); sql_commands << s; } @@ -223,7 +230,7 @@ void DlgAlterTable::on_btFieldEdit_clicked() } -void DlgAlterTable::on_btFieldDelete_clicked() +void DlgAlterTable::onFieldDelete_clicked() { if(lstFields->currentRow() < 0) return; @@ -238,7 +245,7 @@ void DlgAlterTable::on_btFieldDelete_clicked() MainWindow* DlgAlterTable::mainWindow() { - MainWindow *w = qf::core::Utils::findParent(this); + auto *w = qf::core::Utils::findParent(this); return w; } @@ -262,7 +269,7 @@ QString DlgAlterTable::dropIndexCommand(const QString &index_name) return ret; } -void DlgAlterTable::on_btIndexAdd_clicked() +void DlgAlterTable::onIndexAdd_clicked() { DlgIndexDef dlg(this, m_schemaName + "." + m_tableName); if(dlg.exec()) { @@ -271,7 +278,7 @@ void DlgAlterTable::on_btIndexAdd_clicked() } } -void DlgAlterTable::on_btIndexEdit_clicked() +void DlgAlterTable::onIndexEdit_clicked() { if(lstIndexes->currentRow() < 0) return; DlgIndexDef dlg(this, m_schemaName + "." + m_tableName, lstIndexes->currentItem()->text()); @@ -284,7 +291,7 @@ void DlgAlterTable::on_btIndexEdit_clicked() //qf::qmlwidgets::dialogs::MessageBox::showInfo(this, tr("If you want to edit index, drop it and create again.")); } -void DlgAlterTable::on_btIndexDelete_clicked() +void DlgAlterTable::onIndexDelete_clicked() { if(lstIndexes->currentRow() < 0) return; QString indexname = lstIndexes->currentItem()->text(); diff --git a/tools/qsqlmon/src/dlgaltertable.h b/tools/qsqlmon/src/dlgaltertable.h index c3d2002c0..3d379f8f0 100644 --- a/tools/qsqlmon/src/dlgaltertable.h +++ b/tools/qsqlmon/src/dlgaltertable.h @@ -36,15 +36,14 @@ class DlgAlterTable : public QDialog, Ui::DlgAlterTable void accept() Q_DECL_OVERRIDE; protected: void refresh(); -private slots: - void on_btFieldEdit_clicked(); - void on_btFieldInsert_clicked(bool append = false); - void on_btFieldAppend_clicked(); - void on_btFieldDelete_clicked(); - - void on_btIndexAdd_clicked(); - void on_btIndexEdit_clicked(); - void on_btIndexDelete_clicked(); +private: + void onFieldEdit_clicked(); + void onFieldInsert_clicked(bool append = false); + void onFieldAppend_clicked(); + void onFieldDelete_clicked(); + void onIndexAdd_clicked(); + void onIndexEdit_clicked(); + void onIndexDelete_clicked(); protected: MainWindow* mainWindow(); diff --git a/tools/qsqlmon/src/dlgcolumndef.cpp b/tools/qsqlmon/src/dlgcolumndef.cpp index 669e738fe..7372df3bf 100644 --- a/tools/qsqlmon/src/dlgcolumndef.cpp +++ b/tools/qsqlmon/src/dlgcolumndef.cpp @@ -19,10 +19,14 @@ namespace qfc = qf::core; QMap< QString, QMap > DlgColumnDef::f_collationsCache; DlgColumnDef::DlgColumnDef(QWidget * parent, const QString& table) - :QDialog(parent) + : QDialog(parent) { - qfc::Utils::parseFieldName(table, &tableName, &dbName); setupUi(this); + + connect(Ui::DlgColumnDef::lstRefTable, &QComboBox::currentTextChanged, this, &DlgColumnDef::onRefTable_currentIndexChanged); + connect(Ui::DlgColumnDef::lstCharacterSet, &QComboBox::currentTextChanged, this, &DlgColumnDef::onCharacterSet_activated); + + qfc::Utils::parseFieldName(table, &tableName, &dbName); QStringList types; if(connection().driverName().endsWith("SQLITE")) { types << "INTEGER" << "REAL" << "TEXT" << "BLOB"; @@ -229,7 +233,7 @@ void DlgColumnDef::loadColumnDefinition(const qf::core::sql::FieldInfo &fi) //edOk->setEnabled(false); } -void DlgColumnDef::on_lstRefTable_currentIndexChanged(const QString & text) +void DlgColumnDef::onRefTable_currentIndexChanged(const QString & text) { lstRefColumn->clear(); if(!text.isEmpty()) { @@ -340,7 +344,7 @@ void DlgColumnDef::loadCollationsForCurrentCharset() } } -void DlgColumnDef::on_lstCharacterSet_activated(const QString & text) +void DlgColumnDef::onCharacterSet_activated(const QString & text) { Q_UNUSED(text); loadCollationsForCurrentCharset(); diff --git a/tools/qsqlmon/src/dlgcolumndef.h b/tools/qsqlmon/src/dlgcolumndef.h index 95a1c29fe..ff8754629 100644 --- a/tools/qsqlmon/src/dlgcolumndef.h +++ b/tools/qsqlmon/src/dlgcolumndef.h @@ -46,9 +46,9 @@ class DlgColumnDef : public QDialog, public Ui::DlgColumnDef bool isShowCommand(); QString toString(); -private slots: - void on_lstRefTable_currentIndexChanged(const QString & text); - void on_lstCharacterSet_activated(const QString & text); +private: + void onRefTable_currentIndexChanged(const QString & text); + void onCharacterSet_activated(const QString & text); public: DlgColumnDef(QWidget * parent, const QString& table); virtual ~DlgColumnDef(); diff --git a/tools/qsqlmon/src/dlgeditconnection.cpp b/tools/qsqlmon/src/dlgeditconnection.cpp index 2b8129fca..5739ed0a6 100644 --- a/tools/qsqlmon/src/dlgeditconnection.cpp +++ b/tools/qsqlmon/src/dlgeditconnection.cpp @@ -14,6 +14,12 @@ DlgEditConnection::DlgEditConnection(QWidget *parent) : { qfLogFuncFrame(); setupUi(this); + + connect(Ui_DlgEditConnection::btOk, &QAbstractButton::clicked, this, &DlgEditConnection::onOkClicked); + connect(Ui_DlgEditConnection::btCancel, &QAbstractButton::clicked, this, &DlgEditConnection::onCancelClicked); + connect(Ui_DlgEditConnection::cbxDriver, &QComboBox::currentTextChanged, this, &DlgEditConnection::onDriverCurrentIndexChanged); + connect(Ui_DlgEditConnection::btFindDatabaseFile, &QAbstractButton::clicked, this, &DlgEditConnection::onFindDatabaseFileClicked); + btFindDatabaseFile->setVisible(false); drivers = QSqlDatabase::drivers(); //drivers << "QMYSQL" << "QFMYSQL" << "QPSQL" << "QFPSQL" << "QSQLITE" << "QFSQLITE" << "QIBASE" << "QFIBASE"; @@ -71,7 +77,7 @@ const Connection::Params &DlgEditConnection::params() return m_connectionParams; } -void DlgEditConnection::on_btOk_clicked() +void DlgEditConnection::onOkClicked() { /* if(!currConnection) { @@ -93,7 +99,7 @@ void DlgEditConnection::on_btOk_clicked() accept(); } -void DlgEditConnection::on_cbxDriver_currentIndexChanged(const QString &s) +void DlgEditConnection::onDriverCurrentIndexChanged(const QString &s) { qfLogFuncFrame() << s << (s.endsWith("SQLITE") || s.endsWith("IBASE")); //qfTrash() << QF_FUNC_NAME << s << QFSqlConnectionBase::defaultPort(s); @@ -111,7 +117,7 @@ void DlgEditConnection::on_cbxDriver_currentIndexChanged(const QString &s) } } -void DlgEditConnection::on_btFindDatabaseFile_clicked() +void DlgEditConnection::onFindDatabaseFileClicked() { QString s = edDatabase->text(); s = qf::qmlwidgets::dialogs::FileDialog::getOpenFileName(this, tr("Open database file"), s); diff --git a/tools/qsqlmon/src/dlgeditconnection.h b/tools/qsqlmon/src/dlgeditconnection.h index 6f6e8d5b4..023305d2f 100644 --- a/tools/qsqlmon/src/dlgeditconnection.h +++ b/tools/qsqlmon/src/dlgeditconnection.h @@ -13,10 +13,10 @@ class DlgEditConnection : public QDialog, private Ui::DlgEditConnection public: DlgEditConnection(QWidget *parent = nullptr); private slots: - void on_btOk_clicked(); - void on_btCancel_clicked() {reject();} - void on_cbxDriver_currentIndexChanged(const QString &s); - void on_btFindDatabaseFile_clicked(); + void onOkClicked(); + void onCancelClicked() {reject();} + void onDriverCurrentIndexChanged(const QString &s); + void onFindDatabaseFileClicked(); protected: QStringList drivers; QStringList codecs; diff --git a/tools/qsqlmon/src/dlgindexdef.cpp b/tools/qsqlmon/src/dlgindexdef.cpp index 7413c07d1..ec15861e9 100644 --- a/tools/qsqlmon/src/dlgindexdef.cpp +++ b/tools/qsqlmon/src/dlgindexdef.cpp @@ -1,5 +1,4 @@ #include "mainwindow.h" -#include "theapp.h" #include "ui_dlgindexdef.h" #include "dlgindexdef.h" @@ -16,6 +15,10 @@ DlgIndexDef::DlgIndexDef(QWidget * parent, const QString &table_name, const QStr { ui = new Ui::DlgIndexDef; ui->setupUi(this); + + connect(ui->actionAddFieldToIndex, &QAction::triggered, this, &DlgIndexDef::onAddFieldToIndex_triggered); + connect(ui->actionRemoveFieldFromIndex, &QAction::triggered, this, &DlgIndexDef::onRemoveFieldFromIndex_triggered); + ui->btAdd->setDefaultAction(ui->actionAddFieldToIndex); ui->btRemove->setDefaultAction(ui->actionRemoveFieldFromIndex); @@ -42,7 +45,7 @@ QSqlDatabase DlgIndexDef::connection() return w->activeConnection(); } -void DlgIndexDef::on_actionAddFieldToIndex_triggered() +void DlgIndexDef::onAddFieldToIndex_triggered() { //qfTrash() << QF_FUNC_NAME; QListWidgetItem *it; @@ -59,7 +62,7 @@ void DlgIndexDef::on_actionAddFieldToIndex_triggered() } } -void DlgIndexDef::on_actionRemoveFieldFromIndex_triggered() +void DlgIndexDef::onRemoveFieldFromIndex_triggered() { //qfTrash() << QF_FUNC_NAME; QListWidgetItem *it = ui->lstIndex->currentItem(); diff --git a/tools/qsqlmon/src/dlgindexdef.h b/tools/qsqlmon/src/dlgindexdef.h index 0341dcfd9..658f95f52 100644 --- a/tools/qsqlmon/src/dlgindexdef.h +++ b/tools/qsqlmon/src/dlgindexdef.h @@ -32,8 +32,8 @@ class DlgIndexDef : public QDialog public: QString createIndexCommand(); public slots: - void on_actionAddFieldToIndex_triggered(); - void on_actionRemoveFieldFromIndex_triggered(); + void onAddFieldToIndex_triggered(); + void onRemoveFieldFromIndex_triggered(); public: DlgIndexDef(QWidget * parent, const QString &table_name, const QString &index_name = QString()); virtual ~DlgIndexDef(); diff --git a/tools/qsqlmon/src/mainwindow.cpp b/tools/qsqlmon/src/mainwindow.cpp index 841755c4d..4619d260c 100644 --- a/tools/qsqlmon/src/mainwindow.cpp +++ b/tools/qsqlmon/src/mainwindow.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -125,16 +125,16 @@ void MainWindow::lazyInit() serverDock->ui.treeServers->resizeColumnToContents(0); } -qf::core::model::SqlTableModel* MainWindow::queryViewModel() +qf::qmlwidgets::model::SqlTableModel* MainWindow::queryViewModel() { auto *m1 = ui.queryView->tableView()->tableModel(); - auto *m = qobject_cast(m1); + auto *m = qobject_cast(m1); qfDebug() << "model:" << m1 << m; - //QF_CHECK(m!=nullptr, "Model is NULL or not a kind of qf::core::model::SqlTableModel."); + //QF_CHECK(m!=nullptr, "Model is NULL or not a kind of qf::qmlwidgets::model::SqlTableModel."); return m; } -void MainWindow::setQueryViewModel(qf::core::model::SqlTableModel *m) +void MainWindow::setQueryViewModel(qf::qmlwidgets::model::SqlTableModel *m) { qfDebug() << "set model:" << m; ui.queryView->tableView()->setTableModel(m); @@ -209,7 +209,7 @@ qf::core::sql::Connection MainWindow::setActiveConnection1(const qf::core::sql:: QObject *old_model = queryViewModel(); qfDebug() << "\t deletenig old model:" << old_model; QF_SAFE_DELETE(old_model); - auto *m = new qf::core::model::SqlTableModel(this); + auto *m = new qf::qmlwidgets::model::SqlTableModel(this); m->setConnectionName(c.connectionName()); qfDebug() << "\t new table model created:" << m; setQueryViewModel(m); @@ -564,7 +564,7 @@ bool MainWindow::execQuery(const QString& query_str) bool is_select = qs.startsWith(QLatin1String("SELECT"), Qt::CaseInsensitive); do { if(is_select) { - qf::core::model::SqlTableModel *m = queryViewModel(); + qf::qmlwidgets::model::SqlTableModel *m = queryViewModel(); m->clearColumns(); m->setQuery(qs); ok = m->reload(); @@ -706,7 +706,6 @@ void MainWindow::executeSelectedLines() { qfLogFuncFrame(); SqlTextEdit *ed = sqlDock->ui.txtSql; - QString s = ed->toPlainText(); QTextCursor c = ed->textCursor(); int sel_end = c.selectionEnd(); c.setPosition(c.selectionStart()); @@ -1335,7 +1334,7 @@ void MainWindow::checkDrivers() QString msg; QTextStream ts(&msg); { - for(QString plugin_dir : QCoreApplication::libraryPaths()) { + for(const auto &plugin_dir : QCoreApplication::libraryPaths()) { qfInfo() << "plugin dir:" << plugin_dir; QString path = qf::core::utils::FileUtils::joinPath(plugin_dir, "sqldrivers"); ts << tr("Plugins found (looked in %1):").arg(QDir::toNativeSeparators(path)) << '\n'; @@ -1379,7 +1378,7 @@ void MainWindow::tearOffTable() //ui.queryView->setContextMenuPolicy(); connect(ui.queryView, &TableViewWidget::statusBarAction, this, &MainWindow::onTableStatusBarAction); ly->addWidget(ui.queryView); - auto *m = new qf::core::model::SqlTableModel(ui.queryView); + auto *m = new qf::qmlwidgets::model::SqlTableModel(ui.queryView); m->setConnectionName(activeConnection().connectionName()); setQueryViewModel(m); } diff --git a/tools/qsqlmon/src/mainwindow.h b/tools/qsqlmon/src/mainwindow.h index b45928e92..90dbbd0ab 100644 --- a/tools/qsqlmon/src/mainwindow.h +++ b/tools/qsqlmon/src/mainwindow.h @@ -15,7 +15,6 @@ class QAction; class QLabel; class QMenu; class QTextEdit; -//class QUdpSocket; class QModelIndex; class ServerTreeDock; class SqlDock; @@ -24,13 +23,7 @@ class Connection; class Database; class QSpinBox; -namespace qf { -namespace core { -namespace model { -class SqlTableModel; -} -} -} +namespace qf::qmlwidgets::model { class SqlTableModel; } class MainWindow : public QMainWindow, public qf::qmlwidgets::framework::IPersistentSettings { @@ -40,11 +33,8 @@ class MainWindow : public QMainWindow, public qf::qmlwidgets::framework::IPersis MainWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~MainWindow(); protected: - //bool event(QEvent *event); virtual void closeEvent(QCloseEvent *e); - //virtual void showEvent(QShowEvent * e); virtual void changeEvent(QEvent * e); - //virtual void focusInEvent(QFocusEvent *e); void executeSqlLines(const QString &lines); @@ -108,8 +98,8 @@ private slots: QList > tearOffDialogs; - qf::core::model::SqlTableModel* queryViewModel(); - void setQueryViewModel(qf::core::model::SqlTableModel *m); + qf::qmlwidgets::model::SqlTableModel* queryViewModel(); + void setQueryViewModel(qf::qmlwidgets::model::SqlTableModel *m); //QList statusBarWidgets; private: QAction* action(const QString& action_name) { diff --git a/tools/qsqlmon/src/tableviewwidget.cpp b/tools/qsqlmon/src/tableviewwidget.cpp index d8345c361..6cfa059e0 100644 --- a/tools/qsqlmon/src/tableviewwidget.cpp +++ b/tools/qsqlmon/src/tableviewwidget.cpp @@ -3,13 +3,6 @@ #include -//#include -//#include -//#include -//#include - -namespace qfq = qf::qmlwidgets; - //====================================================== // TableView //====================================================== @@ -32,7 +25,7 @@ TableViewWidget::TableViewWidget(QWidget *parent) : ui->setupUi(this); ui->btMenu->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); - connect(ui->btMenu, &QToolButton::clicked, [this](bool) { + connect(ui->btMenu, &QToolButton::clicked, this, [this](bool) { emit statusBarAction(this->ui->edInfo->text()); }); @@ -54,7 +47,7 @@ qf::qmlwidgets::TableView *TableViewWidget::tableView() void TableViewWidget::updateStatus() { - qf::core::model::TableModel *m = tableView()->tableModel(); + qf::qmlwidgets::model::TableModel *m = tableView()->tableModel(); if(m) { ui->lblRowCnt->setText(QString("%1 rows").arg(m->rowCount())); }