summaryrefslogtreecommitdiffstats
path: root/qt-ui/tableview.cpp
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-10-03 11:54:25 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-03 12:13:48 -0700
commit8e81d3f10087fa7ac600dcb18cfebf27716c4209 (patch)
tree3f6fc136134fe7d4f14937617c29e380e7c6e124 /qt-ui/tableview.cpp
parentf0f76056ac3982783ab3dfe94d77ba5d25e19957 (diff)
downloadsubsurface-8e81d3f10087fa7ac600dcb18cfebf27716c4209.tar.gz
Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of overhead. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/tableview.cpp')
-rw-r--r--qt-ui/tableview.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/qt-ui/tableview.cpp b/qt-ui/tableview.cpp
index b3d2c360d..d9731b477 100644
--- a/qt-ui/tableview.cpp
+++ b/qt-ui/tableview.cpp
@@ -7,20 +7,21 @@
#include <QTextStream>
#include <QSettings>
-TableView::TableView(QWidget *parent) : QWidget(parent), ui(new Ui::TableView){
- ui->setupUi(this);
+TableView::TableView(QWidget *parent) : QWidget(parent)
+{
+ ui.setupUi(this);
QFile cssFile(":table-css");
cssFile.open(QIODevice::ReadOnly);
QTextStream reader(&cssFile);
QString css = reader.readAll();
- ui->tableView->setStyleSheet(css);
+ ui.tableView->setStyleSheet(css);
/* There`s mostly a need for a Mac fix here too. */
if (qApp->style()->objectName() == "gtk+")
- ui->groupBox->layout()->setContentsMargins(0, 9, 0, 0);
+ ui.groupBox->layout()->setContentsMargins(0, 9, 0, 0);
else
- ui->groupBox->layout()->setContentsMargins(0, 0, 0, 0);
+ ui.groupBox->layout()->setContentsMargins(0, 0, 0, 0);
QIcon plusIcon(":plus");
- plusBtn = new QPushButton(plusIcon, QString(), ui->groupBox);
+ plusBtn = new QPushButton(plusIcon, QString(), ui.groupBox);
plusBtn->setFlat(true);
plusBtn->setToolTip(tr("Add Cylinder"));
plusBtn->setIconSize(QSize(16,16));
@@ -31,8 +32,8 @@ TableView::~TableView()
{
QSettings s;
s.beginGroup(objectName());
- for (int i = 0; i < ui->tableView->model()->columnCount(); i++) {
- s.setValue(QString("colwidth%1").arg(i), ui->tableView->columnWidth(i));
+ for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
+ s.setValue(QString("colwidth%1").arg(i), ui.tableView->columnWidth(i));
}
s.endGroup();
s.sync();
@@ -45,31 +46,31 @@ void TableView::setBtnToolTip(const QString& tooltip)
void TableView::setTitle(const QString& title)
{
- ui->groupBox->setTitle(title);
+ ui.groupBox->setTitle(title);
}
void TableView::setModel(QAbstractItemModel *model){
- ui->tableView->setModel(model);
- connect(ui->tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
+ ui.tableView->setModel(model);
+ connect(ui.tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
QSettings s;
s.beginGroup(objectName());
- for (int i = 0; i < ui->tableView->model()->columnCount(); i++) {
+ for (int i = 0; i < ui.tableView->model()->columnCount(); i++) {
QVariant width = s.value(QString("colwidth%1").arg(i));
if (width.isValid())
- ui->tableView->setColumnWidth(i, width.toInt());
+ ui.tableView->setColumnWidth(i, width.toInt());
else
- ui->tableView->resizeColumnToContents(i);
+ ui.tableView->resizeColumnToContents(i);
}
s.endGroup();
QFontMetrics metrics(defaultModelFont());
- ui->tableView->horizontalHeader()->setMinimumHeight(metrics.height() + 10);
+ ui.tableView->horizontalHeader()->setMinimumHeight(metrics.height() + 10);
}
void TableView::fixPlusPosition()
{
- plusBtn->setGeometry(ui->groupBox->contentsRect().width() - 30, 2, 24,24);
+ plusBtn->setGeometry(ui.groupBox->contentsRect().width() - 30, 2, 24,24);
}
// We need to manually position the 'plus' on cylinder and weight.
@@ -86,9 +87,9 @@ void TableView::showEvent(QShowEvent* event)
}
void TableView::edit(const QModelIndex& index){
- ui->tableView->edit(index);
+ ui.tableView->edit(index);
}
QTableView *TableView::view(){
- return ui->tableView;
+ return ui.tableView;
}