mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix Last Column adding a horizontal Scroll on the Dive List.
Fixes the last column adding a horizontal scroll on the dive list, since we have the hability to show / hide columns, I had to create a helper method to discover what is the last column and set the size of it very small so no scroll is created. Also, I'v set the setStrechLastSection to true. :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9f8577a5ea
commit
37e7984e15
2 changed files with 15 additions and 0 deletions
|
@ -37,6 +37,7 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec
|
||||||
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
const QFontMetrics metrics(defaultModelFont());
|
const QFontMetrics metrics(defaultModelFont());
|
||||||
header()->setMinimumHeight(metrics.height() + 10);
|
header()->setMinimumHeight(metrics.height() + 10);
|
||||||
|
header()->setStretchLastSection(true);
|
||||||
QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
|
QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
|
||||||
showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
|
showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
|
||||||
showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
|
showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
|
||||||
|
@ -87,6 +88,18 @@ void DiveListView::setupUi(){
|
||||||
else
|
else
|
||||||
collapseAll();
|
collapseAll();
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
|
setColumnWidth(lastVisibleColumn(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DiveListView::lastVisibleColumn()
|
||||||
|
{
|
||||||
|
int lastColumn = -1;
|
||||||
|
for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) {
|
||||||
|
if(isColumnHidden(i))
|
||||||
|
continue;
|
||||||
|
lastColumn = i;
|
||||||
|
}
|
||||||
|
return lastColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::backupExpandedRows(){
|
void DiveListView::backupExpandedRows(){
|
||||||
|
@ -320,6 +333,7 @@ void DiveListView::toggleColumnVisibilityByIndex()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
s.sync();
|
s.sync();
|
||||||
setColumnHidden(action->property("index").toInt(), !action->isChecked());
|
setColumnHidden(action->property("index").toInt(), !action->isChecked());
|
||||||
|
setColumnWidth(lastVisibleColumn(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
void DiveListView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
|
|
@ -62,6 +62,7 @@ private:
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void backupExpandedRows();
|
void backupExpandedRows();
|
||||||
void restoreExpandedRows();
|
void restoreExpandedRows();
|
||||||
|
int lastVisibleColumn();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVELISTVIEW_H
|
#endif // DIVELISTVIEW_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue