You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
1.7 KiB
C++
91 lines
1.7 KiB
C++
#include "igridform.h"
|
|
#include "ui_gridform.h"
|
|
|
|
#include <QList>
|
|
|
|
#include "context.h"
|
|
|
|
IGridForm::IGridForm(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::GridForm)
|
|
{
|
|
ui->setupUi(this);
|
|
m_contextMenu = new QMenu(this);
|
|
m_contextMenu->addAction(ui->actionSelectColumns);
|
|
|
|
m_columnDialog = new ColumnDialog(this);
|
|
connect(m_columnDialog, SIGNAL(accepted()), this, SLOT(columnsAccepted()));
|
|
}
|
|
|
|
IGridForm::~IGridForm()
|
|
{
|
|
}
|
|
|
|
void IGridForm::setPluginId(const QString &pluginId)
|
|
{
|
|
m_pluginId = pluginId;
|
|
}
|
|
|
|
QString IGridForm::pluginId()
|
|
{
|
|
return m_pluginId;
|
|
}
|
|
|
|
QTableView *IGridForm::tableView()
|
|
{
|
|
return ui->tableView;
|
|
}
|
|
|
|
void IGridForm::hideColumns(const QList<int> &cols)
|
|
{
|
|
foreach (int col, cols) {
|
|
tableView()->setColumnHidden(col, true);
|
|
}
|
|
}
|
|
|
|
|
|
void IGridForm::on_btnNew_clicked()
|
|
{
|
|
handleNewRecord();
|
|
}
|
|
|
|
void IGridForm::on_btnEdit_clicked()
|
|
{
|
|
handleEditRecord();
|
|
}
|
|
|
|
void IGridForm::on_btnDelete_clicked()
|
|
{
|
|
handleDeleteRecord();
|
|
}
|
|
|
|
void IGridForm::on_tableView_customContextMenuRequested(const QPoint &pos)
|
|
{
|
|
m_contextMenu->popup(tableView()->viewport()->mapToGlobal(pos));
|
|
}
|
|
|
|
void IGridForm::on_actionSelectColumns_triggered()
|
|
{
|
|
m_columnDialog->setTable(tableView());
|
|
m_columnDialog->show();
|
|
}
|
|
|
|
void IGridForm::columnsAccepted()
|
|
{
|
|
for(int i = 0; i < tableView()->model()->columnCount(); i++)
|
|
{
|
|
tableView()->setColumnHidden(i, false);
|
|
}
|
|
|
|
QList<int> hide = m_columnDialog->columnsToHide();
|
|
hideColumns(hide);
|
|
|
|
QList<QVariant> varList;
|
|
|
|
foreach (int i, hide) {
|
|
varList.append(i);
|
|
}
|
|
|
|
Context::instance().settings()->setValue("grids/" + pluginId() + "/hide", QVariant::fromValue(varList));
|
|
}
|