Column widths saving to user settings.

Fixed memory leak in AutoTableModel.
print
Josef Rokos 9 years ago
parent f49f19783e
commit d108a42b08

@ -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());
}
}

@ -98,6 +98,12 @@ public slots:
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);
}

@ -2,6 +2,8 @@
#include "ui_gridform.h"
#include <QList>
#include <QDebug>
#include <QMap>
#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<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)
{

@ -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);

Loading…
Cancel
Save