From: Marcus Eggenberger Date: Tue, 17 Feb 2009 01:02:45 +0000 (+0100) Subject: fixing auto expand issues with new networks X-Git-Tag: 0.4.0~16 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ed955f89251b8bae600080fb79fd033843979cfa fixing auto expand issues with new networks --- 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) { diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index f72b7a6c..0b826e04 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -80,6 +80,7 @@ private slots: void setExpandedState(const QModelIndex &networkIdx); void on_configChanged(); + void on_layoutChanged(); void setCustomFont(const QVariant &font);