X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=bee4c7463f303b61319fd1a0c51b39d54a1a31aa;hp=8c28ac0f700bb2c758c198a119f21b3661024b8a;hb=efee441a243efb88929e1e275d71ee27991bf074;hpb=6ee26fd6d0a163314002616d277e5444f11b7720 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 8c28ac0f..bee4c746 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -69,7 +69,7 @@ void BufferView::init() hideColumn(2); setIndentation(10); - expandAll(); + // New entries will be expanded automatically when added; no need to call expandAll() header()->hide(); // nobody seems to use this anyway @@ -130,6 +130,11 @@ void BufferView::setModel(QAbstractItemModel *model) } connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged())); + + // Make sure collapsation is correct after setting a model + // This might not be needed here, only in BufferView::setFilteredModel(). If issues arise, just + // move down to setFilteredModel (which calls this function). + setExpandedState(); } @@ -330,7 +335,19 @@ void BufferView::on_configChanged() { Q_ASSERT(model()); - // expand all active networks... collapse inactive ones... unless manually changed + // Expand/collapse as needed + setExpandedState(); + + if (config()) { + // update selection to current one + Client::bufferModel()->synchronizeView(this); + } +} + + +void BufferView::setExpandedState() +{ + // Expand all active networks, collapse inactive ones... unless manually changed QModelIndex networkIdx; NetworkId networkId; for (int row = 0; row < model()->rowCount(); row++) { @@ -344,11 +361,6 @@ void BufferView::on_configChanged() setExpandedState(networkIdx); } - - if (config()) { - // update selection to current one - Client::bufferModel()->synchronizeView(this); - } } @@ -657,7 +669,11 @@ bool BufferViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, c if (!value.isValid()) return QStyledItemDelegate::editorEvent(event, model, option, index); +#if QT_VERSION < 0x050000 QStyleOptionViewItemV4 viewOpt(option); +#else + QStyleOptionViewItem viewOpt(option); +#endif initStyleOption(&viewOpt, index); QRect checkRect = viewOpt.widget->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, viewOpt.widget);