Column widths saving to user settings.
Fixed memory leak in AutoTableModel.
This commit is contained in:
@@ -89,6 +89,7 @@ public:
|
|||||||
for (int i = 0; i < entity->metaObject()->propertyCount(); i++) {
|
for (int i = 0; i < entity->metaObject()->propertyCount(); i++) {
|
||||||
if (i == section) {
|
if (i == section) {
|
||||||
QString colName(entity->metaObject()->property(i + 1).name());
|
QString colName(entity->metaObject()->property(i + 1).name());
|
||||||
|
delete entity;
|
||||||
return tr(colName.toStdString().c_str());
|
return tr(colName.toStdString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ public slots:
|
|||||||
hide.append(var.toInt());
|
hide.append(var.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString, QVariant> 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);
|
hideColumns(hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "ui_gridform.h"
|
#include "ui_gridform.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "filterui.h"
|
#include "filterui.h"
|
||||||
@@ -108,6 +110,15 @@ void IGridForm::columnsAccepted()
|
|||||||
Context::instance().settings()->setValue("grids/" + pluginId() + "/hide", QVariant::fromValue(varList));
|
Context::instance().settings()->setValue("grids/" + pluginId() + "/hide", QVariant::fromValue(varList));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IGridForm::widthChanged(int logicalIndex, int oldSize, int newSize)
|
||||||
|
{
|
||||||
|
Q_UNUSED(oldSize);
|
||||||
|
|
||||||
|
QMap<QString, QVariant> 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)
|
void IGridForm::on_btnFilter_toggled(bool checked)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ private slots:
|
|||||||
void on_tableView_customContextMenuRequested(const QPoint &pos);
|
void on_tableView_customContextMenuRequested(const QPoint &pos);
|
||||||
void on_actionSelectColumns_triggered();
|
void on_actionSelectColumns_triggered();
|
||||||
void columnsAccepted();
|
void columnsAccepted();
|
||||||
|
void widthChanged(int logicalIndex, int oldSize, int newSize);
|
||||||
|
|
||||||
void on_btnFilter_toggled(bool checked);
|
void on_btnFilter_toggled(bool checked);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user