X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferview.cpp;h=086af0aa211dfc8a2aa90667cfe0c6e2ba3ed51f;hp=d6c11069fdd3df05c4d95bd68b366ff28fc396cd;hb=ed955f89251b8bae600080fb79fd033843979cfa;hpb=39f426dc55955e5c22114a703d52cd08a02f84a6 diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index d6c11069..086af0aa 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -86,9 +86,11 @@ void BufferView::init() { // activated() fails on X11 and Qtopia at least #if defined Q_WS_QWS || defined Q_WS_X11 + disconnect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(joinChannel(QModelIndex))); #else // afaik this is better on Mac and Windows + disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); connect(this, SIGNAL(activated(QModelIndex)), SLOT(joinChannel(QModelIndex))); #endif } @@ -120,6 +122,7 @@ void BufferView::setModel(QAbstractItemModel *model) { header()->addAction(showSection); } + connect(model, SIGNAL(layoutChanged()), this, SLOT(on_layoutChanged())); } void BufferView::setFilteredModel(QAbstractItemModel *model_, BufferViewConfig *config) { @@ -281,17 +284,21 @@ void BufferView::removeSelectedBuffers(bool permanently) { } } -void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) { +void BufferView::rowsInserted(const QModelIndex &parent, int start, int end) { QTreeView::rowsInserted(parent, start, end); // ensure that newly inserted network nodes are expanded per default if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType) return; - if(model()->rowCount(parent) == 1 && parent.data(NetworkModel::ItemActiveRole) == true) { - // without updating the parent the expand will have no effect... Qt Bug? - update(parent); - expand(parent); + setExpandedState(parent); +} + +void BufferView::on_layoutChanged() { + int numNets = model()->rowCount(QModelIndex()); + for(int row = 0; row < numNets; row++) { + QModelIndex networkIdx = model()->index(row, 0, QModelIndex()); + setExpandedState(networkIdx); } } @@ -310,7 +317,6 @@ void BufferView::on_configChanged() { if(!networkId.isValid()) continue; - update(networkIdx); setExpandedState(networkIdx); } @@ -318,8 +324,6 @@ void BufferView::on_configChanged() { // update selection to current one Client::bufferModel()->synchronizeView(this); } - - return; } void BufferView::storeExpandedState(const QModelIndex &networkIdx) { @@ -351,9 +355,11 @@ void BufferView::setExpandedState(const QModelIndex &networkIdx) { expandNetwork = (bool)(oldState & WasExpanded); } - storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state - if(expandNetwork != isExpanded(networkIdx)) + if(expandNetwork != isExpanded(networkIdx)) { + update(networkIdx); setExpanded(networkIdx, expandNetwork); + } + storeExpandedState(networkIdx); // this call is needed to keep track of the isActive state } void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {