Adds Single-Click editions on the TableView

This is a linus request, adds a Single-click edition
on the tableview to make it more consistent with the
rest of the interface where edition is permitted.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-07-17 12:13:04 -03:00
parent bad91ef11c
commit 29b92e2fc5
2 changed files with 16 additions and 1 deletions

View file

@ -78,7 +78,9 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
addWeight->setEnabled(false);
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), ui->cylinders->model(), SLOT(remove(QModelIndex)));
connect(ui->cylinders, SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
connect(ui->weights, SIGNAL(clicked(QModelIndex)), ui->weights->model(), SLOT(remove(QModelIndex)));
connect(ui->weights, SIGNAL(clicked(QModelIndex)), this, SLOT(editWeigthWidget(QModelIndex)));
QFontMetrics metrics(defaultModelFont());
QFontMetrics metrics2(font());
@ -532,5 +534,16 @@ void MainTab::initialUiSetup()
ui->weights->resizeColumnToContents(i);
}
s.endGroup();
}
void MainTab::editCylinderWidget(const QModelIndex& index)
{
if (index.column() != CylindersModel::REMOVE)
ui->cylinders->edit(index);
}
void MainTab::editWeigthWidget(const QModelIndex& index)
{
if (index.column() != WeightModel::REMOVE)
ui->weights->edit(index);
}

View file

@ -60,6 +60,8 @@ public slots:
void on_rating_valueChanged(int value);
void on_visibility_valueChanged(int value);
void tabChanged(int idx);
void editCylinderWidget(const QModelIndex& index);
void editWeigthWidget(const QModelIndex& index);
private:
Ui::MainTab *ui;