X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.cpp;h=d3ec1998bf654c85b08b9cdfd3cb969b6fd8af51;hp=50387363573ee780c1b57ca9701e363c8eac2a7d;hb=6fe30667a4a4747e8fad048dad499f7d2390b044;hpb=e017aca90eb3444df68fb365a5d50b05881b1c5c diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 50387363..d3ec1998 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -26,6 +26,12 @@ #include "uisettings.h" +class CheckRemovalEvent : public QEvent { +public: + CheckRemovalEvent(const QModelIndex &source_index) : QEvent(QEvent::User), index(source_index) {}; + QPersistentModelIndex index; +}; + /***************************************** * The Filter for the Tree View *****************************************/ @@ -40,6 +46,9 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig * setDynamicSortFilter(true); loadColors(); + + connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); } void BufferViewFilter::loadColors() { @@ -268,6 +277,28 @@ void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, } } +void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous) { + Q_UNUSED(current); + if(previous.isValid()) + qApp->postEvent(this, new CheckRemovalEvent(previous)); +} + +void BufferViewFilter::customEvent(QEvent *event) { + if(event->type() != QEvent::User) + return; + + CheckRemovalEvent *removalEvent = static_cast(event); + checkItemForRemoval(removalEvent->index); + + event->accept(); +} + +void BufferViewFilter::checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + QModelIndex source_topLeft = mapToSource(topLeft); + QModelIndex source_bottomRight = mapToSource(bottomRight); + emit _dataChanged(source_topLeft, source_bottomRight); +} + // ****************************** // Helper // ******************************