} else {
BufferViewFilter *filter = new BufferViewFilter(model_, config);
setModel(filter);
- connect(this, SIGNAL(removeBuffer(const QModelIndex &)), filter, SLOT(removeBuffer(const QModelIndex &)));
+ connect(this, SIGNAL(removeBuffer(const QModelIndex &)),
+ filter, SLOT(removeBuffer(const QModelIndex &)));
}
setConfig(config);
}
+void BufferView::setSelectionModel(QItemSelectionModel *selectionModel) {
+ if(QTreeView::selectionModel())
+ disconnect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ model(), SIGNAL(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
+
+ QTreeView::setSelectionModel(selectionModel);
+ BufferViewFilter *filter = qobject_cast<BufferViewFilter *>(model());
+ if(filter) {
+ connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ filter, SLOT(checkPreviousCurrentForRemoval(QModelIndex, QModelIndex)));
+ }
+}
+
void BufferView::setConfig(BufferViewConfig *config) {
if(_config == config)
return;
void setModel(QAbstractItemModel *model);
void setFilteredModel(QAbstractItemModel *model, BufferViewConfig *config);
+ virtual void setSelectionModel(QItemSelectionModel *selectionModel);
void setConfig(BufferViewConfig *config);
inline BufferViewConfig *config() { return _config; }
#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
*****************************************/
setDynamicSortFilter(true);
loadColors();
+
+ connect(this, SIGNAL(_dataChanged(const QModelIndex &, const QModelIndex &)),
+ this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex)));
}
void BufferViewFilter::loadColors() {
}
}
+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<CheckRemovalEvent *>(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
// ******************************
public slots:
void removeBuffer(const QModelIndex &);
+ void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous);
+ void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); }
+ void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void source_rowsInserted(const QModelIndex &parent, int start, int end);
protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
bool bufferLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
bool networkLessThan(const QModelIndex &source_left, const QModelIndex &source_right) const;
+ virtual void customEvent(QEvent *event);
+signals:
+ void _dataChanged(const QModelIndex &source_topLeft, const QModelIndex &source_bottomRight);
+
private:
QPointer<BufferViewConfig> _config;
-
+
QColor _FgColorInactiveActivity;
QColor _FgColorNoActivity;
QColor _FgColorHighlightActivity;
QColor _FgColorNewMessageActivity;
QColor _FgColorOtherActivity;
void loadColors();
-
+
bool filterAcceptBuffer(const QModelIndex &) const;
bool filterAcceptNetwork(const QModelIndex &) const;
void addBuffer(const BufferId &);
{ using namespace Global;
quasselVersion = "0.2.0-beta1-pre";
- quasselDate = "2008-05-02";
- quasselBuild = 807;
+ quasselDate = "2008-05-03";
+ quasselBuild = 808;
//! Minimum client build number the core needs
clientBuildNeeded = 731;