+void BufferViewFilter::dropEvent(QDropEvent *event) {
+ const QMimeData *data = event->mimeData();
+ if(!(mode & FullCustom))
+ return; // only custom buffers can be customized... obviously... :)
+
+ if(!(data->hasFormat("application/Quassel/BufferItem/row")
+ && data->hasFormat("application/Quassel/BufferItem/network")
+ && data->hasFormat("application/Quassel/BufferItem/bufferId")))
+ return; // whatever the drop is... it's not a buffer...
+
+ event->accept();
+ uint bufferuid = data->data("application/Quassel/BufferItem/bufferId").toUInt();
+ QString networkname = QString::fromUtf8("application/Quassel/BufferItem/network");
+
+ for(int rowid = 0; rowid < rowCount(); rowid++) {
+ QModelIndex networkindex = index(rowid, 0);
+ if(networkindex.data(Qt::DisplayRole) == networkname) {
+ addBuffer(bufferuid);
+ return;
+ }
+ }
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ addBuffer(bufferuid);
+ endInsertRows();
+}
+
+
+void BufferViewFilter::addBuffer(const uint &bufferuid) {
+ if(!customBuffers.contains(bufferuid)) {
+ customBuffers << bufferuid;
+ invalidateFilter();
+ }
+}
+
+void BufferViewFilter::removeBuffer(const QModelIndex &index) {
+ if(!(mode & FullCustom))
+ return; // only custom buffers can be customized... obviously... :)
+
+ if(index.parent() == QModelIndex())
+ return; // only child elements can be deleted
+
+ uint bufferuid = index.data(BufferTreeModel::BufferIdRole).toUInt();
+ if(customBuffers.contains(bufferuid)) {
+ beginRemoveRows(index.parent(), index.row(), index.row());
+ customBuffers.removeAt(customBuffers.indexOf(bufferuid));
+ endRemoveRows();
+ invalidateFilter();
+ }
+
+}
+