Two hours of bughunting ending between keyboard and chair. Or something like that...
[quassel.git] / gui / bufferview.cpp
index e0923cf..d30e4da 100644 (file)
@@ -75,6 +75,8 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc
 /*****************************************
 * The TreeView showing the Buffers
 *****************************************/
+// Please be carefull when reimplementing methods which are used to inform the view about changes to the data
+// to be on the safe side: call QTreeView's method aswell
 BufferView::BufferView(QWidget *parent) : QTreeView(parent) {
 }
 
@@ -90,6 +92,8 @@ void BufferView::init() {
   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(updateSelection(const QModelIndex &, QItemSelectionModel::SelectionFlags)), selectionModel(), SLOT(select(const QModelIndex &, QItemSelectionModel::SelectionFlags)));
+
+  expandAll();
 }
 
 void BufferView::setFilteredModel(QAbstractItemModel *model, BufferViewFilter::Modes mode, QStringList nets) {
@@ -97,3 +101,17 @@ void BufferView::setFilteredModel(QAbstractItemModel *model, BufferViewFilter::M
   setModel(filter);
 }
 
+void BufferView::setModel(QAbstractItemModel *model) {
+  QTreeView::setModel(model);
+  init();
+}
+
+void BufferView::dragEnterEvent(QDragEnterEvent *event) {
+  // not yet needed... this will be usefull to keep track of the active view when customizing them with drag and drop
+  QTreeView::dragEnterEvent(event);
+}
+
+void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) {
+  if(parent.parent() == QModelIndex()) setExpanded(parent, true);
+  QTreeView::rowsInserted(parent, start, end);
+}