X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fbufferview.cpp;h=e06ef720df0dbae563e6c59a1111761278d5bef4;hb=fbc4df88ae0bb5e4d9394922395ce2ba29d9108e;hp=17f637b57602d29f10a5c1d5cb38f4b911a258cc;hpb=9fd4619e9aca7d53d7c5df156a0b25956a1bf682;p=quassel.git diff --git a/src/qtui/bufferview.cpp b/src/qtui/bufferview.cpp index 17f637b5..e06ef720 100644 --- a/src/qtui/bufferview.cpp +++ b/src/qtui/bufferview.cpp @@ -18,7 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "client.h" #include "bufferview.h" +#include "buffertreemodel.h" /***************************************** * The TreeView showing the Buffers @@ -42,45 +44,29 @@ void BufferView::init() { setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); - - connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), - model(), SLOT(changeCurrent(const QModelIndex &, const QModelIndex &))); - - connect(this, SIGNAL(doubleClicked(const QModelIndex &)), - model(), SLOT(doubleClickReceived(const QModelIndex &))); - - connect(model(), SIGNAL(selectionChanged(const QModelIndex &)), - this, SLOT(select(const QModelIndex &))); - - connect(this, SIGNAL(selectionChanged(const QModelIndex &, QItemSelectionModel::SelectionFlags)), - selectionModel(), SLOT(select(const QModelIndex &, QItemSelectionModel::SelectionFlags))); - + connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); } -void BufferView::setFilteredModel(QAbstractItemModel *model, BufferViewFilter::Modes mode, QStringList nets) { +void BufferView::setFilteredModel(QAbstractItemModel *model, BufferViewFilter::Modes mode, QList nets) { BufferViewFilter *filter = new BufferViewFilter(model, mode, nets); setModel(filter); - connect(this, SIGNAL(eventDropped(QDropEvent *)), filter, SLOT(dropEvent(QDropEvent *))); connect(this, SIGNAL(removeBuffer(const QModelIndex &)), filter, SLOT(removeBuffer(const QModelIndex &))); } void BufferView::setModel(QAbstractItemModel *model) { + delete selectionModel(); QTreeView::setModel(model); init(); + } -void BufferView::select(const QModelIndex ¤t) { - emit selectionChanged(current, QItemSelectionModel::ClearAndSelect); -} +void BufferView::joinChannel(const QModelIndex &index) { + Buffer::Type bufferType = (Buffer::Type)index.data(BufferTreeModel::BufferTypeRole).toInt(); -void BufferView::dropEvent(QDropEvent *event) { - if(event->source() != this) { - // another view(?) or widget is the source. maybe it's a drag 'n drop - // view customization -> we tell our friend the filter: - emit eventDropped(event); - } - // in the case that the filter did not accept the event or if it's a merge - QTreeView::dropEvent(event); + if(bufferType != Buffer::ChannelType) + return; + + Client::fakeInput(index.data(BufferTreeModel::BufferUidRole).toUInt(), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString())); } void BufferView::keyPressEvent(QKeyEvent *event) { @@ -96,7 +82,10 @@ void BufferView::keyPressEvent(QKeyEvent *event) { // ensure that newly inserted network nodes are expanded per default void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) { - if(parent == QModelIndex()) - setExpanded(model()->index(start, 0, parent), true); QTreeView::rowsInserted(parent, start, end); + if(model()->rowCount(parent) == 1 && parent != QModelIndex()) { + // without updating the parent the expand will have no effect... Qt Bug? + update(parent); + expand(parent); + } }