using configdir to store crash logs instead of cwd
[quassel.git] / src / uisupport / bufferviewfilter.cpp
index dfad3c2..7179f26 100644 (file)
@@ -198,7 +198,7 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action
        row = 0;
 
       if(row < rowCount(parent)) {
-       QModelIndex source_child = sourceModel()->index(row, 0, parent);
+       QModelIndex source_child = mapToSource(index(row, 0, parent));
        BufferId beforeBufferId = sourceModel()->data(source_child, NetworkModel::BufferIdRole).value<BufferId>();
        pos = config()->bufferList().indexOf(beforeBufferId);
        if(_sortOrder == Qt::DescendingOrder)
@@ -262,7 +262,8 @@ bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex)
 
   if(!config()->bufferList().contains(bufferId) && !_editMode) {
     // add the buffer if...
-    if(config()->isInitialized() && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either
+    if(config()->isInitialized()
+       && !config()->removedBuffers().contains(bufferId) // it hasn't been manually removed and either
        && ((config()->addNewBuffersAutomatically() && !config()->temporarilyRemovedBuffers().contains(bufferId)) // is totally unknown to us (a new buffer)...
           || (config()->temporarilyRemovedBuffers().contains(bufferId) && activityLevel > BufferInfo::OtherActivity))) { // or was just temporarily hidden and has a new message waiting for us.
       addBuffer(bufferId);
@@ -313,10 +314,15 @@ bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc
     return false;
   }
 
-  if(!source_parent.isValid())
+  NetworkModel::ItemType childType = (NetworkModel::ItemType)sourceModel()->data(child, NetworkModel::ItemTypeRole).toInt();
+  switch(childType) {
+  case NetworkModel::NetworkItemType:
     return filterAcceptNetwork(child);
-  else
+  case NetworkModel::BufferItemType:
     return filterAcceptBuffer(child);
+  default:
+    return false;
+  }
 }
 
 bool BufferViewFilter::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const {
@@ -377,6 +383,9 @@ QVariant BufferViewFilter::icon(const QModelIndex &index) const {
     return QVariant();
 
   QModelIndex source_index = mapToSource(index);
+  if(sourceModel()->data(source_index, NetworkModel::ItemTypeRole).toInt() != NetworkModel::BufferItemType)
+    return QVariant();
+
   if(sourceModel()->data(source_index, NetworkModel::BufferTypeRole).toInt() != BufferInfo::QueryBuffer)
     return QVariant();