Set equal size for all row headers
This commit is contained in:
parent
13a6468757
commit
baf0cb8dbe
@ -67,8 +67,7 @@ Qt::ItemFlags CheckableTestModel::flags(const QModelIndex &index) const
|
||||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
bool CheckableTestModel::setData(
|
||||
const QModelIndex &index, const QVariant &value, int role)
|
||||
bool CheckableTestModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!isValidIndex(index))
|
||||
{
|
||||
@ -93,16 +92,31 @@ bool CheckableTestModel::setData(
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant CheckableTestModel::headerData(
|
||||
int section, Qt::Orientation orientation, int role) const
|
||||
QVariant CheckableTestModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Vertical)
|
||||
switch (orientation)
|
||||
{
|
||||
case Qt::Vertical:
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
if (section < m_tests.size())
|
||||
{
|
||||
return m_tests.at(section).name();
|
||||
}
|
||||
}
|
||||
case Qt::SizeHintRole:
|
||||
{
|
||||
return QSize(200, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
@ -151,8 +165,7 @@ CheckableItems &CheckableTestModel::getItems(const QModelIndex &index)
|
||||
throw std::runtime_error("invalid index");
|
||||
}
|
||||
|
||||
const CheckableItems &CheckableTestModel::getItems(
|
||||
const QModelIndex &index) const
|
||||
const CheckableItems &CheckableTestModel::getItems(const QModelIndex &index) const
|
||||
{
|
||||
if (index.row() < m_tests.size())
|
||||
{
|
||||
|
@ -5,21 +5,11 @@
|
||||
PluralModel::PluralModel(QObject *parent)
|
||||
: CheckableTestModel(parent)
|
||||
{
|
||||
m_tests = {{"",
|
||||
m_tests = {{"Plural",
|
||||
{"Fisch /-e/", "Banane /-n/", "Bonbon /-s/", "Ei /-er/", "Eimer /-ø/",
|
||||
"Korn UML+/-er/", "Nuss UML+/-e/", "Bär /-en/", "Apfel UML"}}};
|
||||
}
|
||||
|
||||
QVariant PluralModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
return QSize(180, 0);
|
||||
}
|
||||
|
||||
return CheckableTestModel::data(index, role);
|
||||
}
|
||||
|
||||
void PluralModel::read(const ESGRAF48::PluralModel &model)
|
||||
{
|
||||
auto &testItems = m_tests.at(0).items();
|
||||
|
@ -10,9 +10,6 @@ class PluralModel : public CheckableTestModel
|
||||
public:
|
||||
PluralModel(QObject *parent);
|
||||
|
||||
QVariant data(
|
||||
const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void read(const ESGRAF48::PluralModel &model);
|
||||
void write(ESGRAF48::PluralModel &model) const;
|
||||
};
|
||||
|
@ -8,6 +8,8 @@ PluralWidget::PluralWidget(QWidget *parent)
|
||||
, ui(new Ui::PluralWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->pluralTableView->horizontalHeader()->hide();
|
||||
}
|
||||
|
||||
PluralWidget::~PluralWidget()
|
||||
@ -18,5 +20,4 @@ PluralWidget::~PluralWidget()
|
||||
void PluralWidget::setModel(PluralModel *model)
|
||||
{
|
||||
ui->pluralTableView->setModel(model);
|
||||
ui->pluralTableView->resizeColumnsToContents();
|
||||
}
|
||||
|
@ -15,17 +15,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="pluralTableView">
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>120</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QTableView" name="pluralTableView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
Reference in New Issue
Block a user