Playlists model ALWAYS needs to return a columnCount of 6. In TreeView, set a flag 'forceSingleColumn' when model is set, TreeView will hide all bar 1st column.

This is better than resetting the proxy each time - as this messes up the column stretching.

BUG: 397
This commit is contained in:
craig.p.drummond
2014-01-28 20:23:04 +00:00
parent b4209be12c
commit cb65db90c8
5 changed files with 17 additions and 15 deletions

View File

@@ -90,6 +90,7 @@ bool TreeView::getForceSingleClick()
TreeView::TreeView(QWidget *parent, bool menuAlwaysAllowed)
: QTreeView(parent)
, forceSingleColumn(false)
, alwaysAllowMenu(menuAlwaysAllowed)
{
setDragEnabled(true);
@@ -121,6 +122,7 @@ void TreeView::setPageDefaults()
setDragDropMode(QAbstractItemView::DragOnly);
setSortingEnabled(true);
setAnimated(true);
forceSingleColumn=true;
}
void TreeView::setExpandOnClick()
@@ -357,6 +359,16 @@ void TreeView::setModel(QAbstractItemModel *m)
QAbstractItemModel *old=model();
QTreeView::setModel(m);
if (forceSingleColumn && m) {
int columnCount=m->columnCount();
if (columnCount>1) {
QHeaderView *hdr=header();
for (int i=1; i<columnCount; ++i) {
hdr->setSectionHidden(i, true);
}
}
}
if (old) {
disconnect(old, SIGNAL(layoutChanged()), this, SLOT(correctSelection()));
}