1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-23 16:25:12 +03:00

TableWidget only used if -D TABLE_LAYOUT=yes compile option is defined

This commit is contained in:
Damjan Adamic 2015-12-06 19:41:11 +01:00
parent 1dcc660f31
commit 191e37f29c
6 changed files with 79 additions and 6 deletions

View file

@ -1004,6 +1004,7 @@ QStringList extractLatLon(const QString & position)
TableLayout::TableLayout(QWidget * parent, int rowCount, const QStringList & headerLabels)
{
#if defined(TABLE_LAYOUT)
tableWidget = new QTableWidget(parent);
QVBoxLayout * layout = new QVBoxLayout();
layout->addWidget(tableWidget);
@ -1020,19 +1021,73 @@ TableLayout::TableLayout(QWidget * parent, int rowCount, const QStringList & hea
tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
tableWidget->setStyleSheet("QTableWidget {background-color: transparent;}");
tableWidget->setHorizontalHeaderLabels(headerLabels);
#else
gridWidget = new QGridLayout(parent);
int col = 0;
foreach(QString text, headerLabels) {
QLabel *label = new QLabel();
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter);
label->setMargin(5);
label->setText(text);
// if (!minimize)
// label->setMinimumWidth(100);
gridWidget->addWidget(label, 0, col++);
}
#endif
}
void TableLayout::addWidget(int row, int column, QWidget * widget)
{
#if defined(TABLE_LAYOUT)
QHBoxLayout * layout = new QHBoxLayout(tableWidget);
layout->addWidget(widget);
addLayout(row, column, layout);
#else
gridWidget->addWidget(widget, row + 1, column);
#endif
}
void TableLayout::addLayout(int row, int column, QLayout * layout)
{
#if defined(TABLE_LAYOUT)
layout->setContentsMargins(1, 3, 1, 3);
QWidget * containerWidget = new QWidget(tableWidget);
containerWidget->setLayout(layout);
tableWidget->setCellWidget(row, column, containerWidget);
#else
gridWidget->addLayout(layout, row + 1, column);
#endif
}
void TableLayout::resizeColumnsToContents()
{
#if defined(TABLE_LAYOUT)
tableWidget->resizeColumnsToContents();
#else
#endif
}
void TableLayout::setColumnWidth(int col, int width)
{
#if defined(TABLE_LAYOUT)
tableWidget->setColumnWidth(col, width);
#else
#endif
}
void TableLayout::pushRowsUp(int row)
{
#if defined(TABLE_LAYOUT)
#else
// Push the rows up
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
gridWidget->addItem(spacer, row, 0);
#endif
// Push rows upward
// addDoubleSpring(gridLayout, 5, num_fsw+1);
}