diff --git a/core/autotablemodel.h b/core/autotablemodel.h index 2e5c309..0866a87 100644 --- a/core/autotablemodel.h +++ b/core/autotablemodel.h @@ -89,6 +89,7 @@ public: for (int i = 0; i < entity->metaObject()->propertyCount(); i++) { if (i == section) { QString colName(entity->metaObject()->property(i + 1).name()); + delete entity; return tr(colName.toStdString().c_str()); } } diff --git a/core/gridform.h b/core/gridform.h index cb65446..2e18917 100644 --- a/core/gridform.h +++ b/core/gridform.h @@ -98,6 +98,12 @@ public slots: hide.append(var.toInt()); } + QMap widths = Context::instance().settings()->value("grids/" + pluginId() + "/widths").toMap(); + foreach (QString key, widths.keys()) { + tableView()->setColumnWidth(key.toInt(), widths[key].toInt()); + } + + connect(tableView()->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(widthChanged(int,int,int))); hideColumns(hide); } diff --git a/core/igridform.cpp b/core/igridform.cpp index ef1d899..f58f52d 100644 --- a/core/igridform.cpp +++ b/core/igridform.cpp @@ -2,6 +2,8 @@ #include "ui_gridform.h" #include +#include +#include #include "context.h" #include "filterui.h" @@ -108,6 +110,15 @@ void IGridForm::columnsAccepted() Context::instance().settings()->setValue("grids/" + pluginId() + "/hide", QVariant::fromValue(varList)); } +void IGridForm::widthChanged(int logicalIndex, int oldSize, int newSize) +{ + Q_UNUSED(oldSize); + + QMap widths = Context::instance().settings()->value("grids/" + pluginId() + "/widths").toMap(); + widths[QString::number(logicalIndex)] = newSize; + Context::instance().settings()->setValue("grids/" + pluginId() + "/widths", QVariant::fromValue(widths)); +} + void IGridForm::on_btnFilter_toggled(bool checked) { diff --git a/core/igridform.h b/core/igridform.h index bf22dc6..fb70ab6 100644 --- a/core/igridform.h +++ b/core/igridform.h @@ -48,6 +48,7 @@ private slots: void on_tableView_customContextMenuRequested(const QPoint &pos); void on_actionSelectColumns_triggered(); void columnsAccepted(); + void widthChanged(int logicalIndex, int oldSize, int newSize); void on_btnFilter_toggled(bool checked);