projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix license headers: Quassel IRC Team -> Quassel Project, 2007 -> 2008
[quassel.git]
/
src
/
uisupport
/
bufferviewfilter.cpp
diff --git
a/src/uisupport/bufferviewfilter.cpp
b/src/uisupport/bufferviewfilter.cpp
index
2969400
..
4204ac0
100644
(file)
--- a/
src/uisupport/bufferviewfilter.cpp
+++ b/
src/uisupport/bufferviewfilter.cpp
@@
-1,5
+1,5
@@
/***************************************************************************
/***************************************************************************
- * Copyright (C) 2005-0
7 by the Quassel IRC Team
*
+ * Copyright (C) 2005-0
8 by the Quassel Project
*
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-20,6
+20,8
@@
#include "bufferviewfilter.h"
#include "bufferviewfilter.h"
+#include "networkmodel.h"
+
/*****************************************
* The Filter for the Tree View
*****************************************/
/*****************************************
* The Filter for the Tree View
*****************************************/
@@
-30,10
+32,14
@@
BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, const Modes &filte
{
setSourceModel(model);
setSortCaseSensitivity(Qt::CaseInsensitive);
{
setSourceModel(model);
setSortCaseSensitivity(Qt::CaseInsensitive);
+
+ // FIXME
+ // ok the following basically sucks. therfore it's commented out. Justice served.
+ // a better solution would use dataChanged()
// I have this feeling that this resulted in a fuckup once... no clue though right now and invalidateFilter isn't a slot -.-
//connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidate()));
// I have this feeling that this resulted in a fuckup once... no clue though right now and invalidateFilter isn't a slot -.-
//connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidate()));
- connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateFilter_()));
+
//
connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateFilter_()));
}
void BufferViewFilter::invalidateFilter_() {
}
void BufferViewFilter::invalidateFilter_() {
@@
-54,16
+60,18
@@
bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action
if(parent != QModelIndex())
return QSortFilterProxyModel::dropMimeData(data, action, row, column, parent);
if(parent != QModelIndex())
return QSortFilterProxyModel::dropMimeData(data, action, row, column, parent);
- if(!
BufferTree
Model::mimeContainsBufferList(data))
+ if(!
Network
Model::mimeContainsBufferList(data))
return false;
return false;
- QList< QPair<uint, uint> > bufferList =
BufferTree
Model::mimeDataToBufferList(data);
+ QList< QPair<uint, uint> > bufferList =
Network
Model::mimeDataToBufferList(data);
uint netId, bufferId;
for(int i = 0; i < bufferList.count(); i++) {
netId = bufferList[i].first;
bufferId = bufferList[i].second;
uint netId, bufferId;
for(int i = 0; i < bufferList.count(); i++) {
netId = bufferList[i].first;
bufferId = bufferList[i].second;
- networks << netId;
+ if(!networks.contains(netId)) {
+ networks << netId;
+ }
addBuffer(bufferId);
}
return true;
addBuffer(bufferId);
}
return true;
@@
-84,12
+92,17
@@
void BufferViewFilter::removeBuffer(const QModelIndex &index) {
return; // only child elements can be deleted
bool lastBuffer = (rowCount(index.parent()) == 1);
return; // only child elements can be deleted
bool lastBuffer = (rowCount(index.parent()) == 1);
- uint netId = index.data(BufferTreeModel::NetworkIdRole).toUInt();
- uint bufferuid = index.data(BufferTreeModel::BufferUidRole).toUInt();
+ uint netId = index.data(NetworkModel::NetworkIdRole).toUInt();
+ uint bufferuid = index.data(NetworkModel::BufferUidRole).toUInt();
+
if(buffers.contains(bufferuid)) {
buffers.remove(bufferuid);
if(buffers.contains(bufferuid)) {
buffers.remove(bufferuid);
- if(lastBuffer)
+
+ if(lastBuffer) {
networks.remove(netId);
networks.remove(netId);
+ Q_ASSERT(!networks.contains(netId));
+ }
+
invalidateFilter();
}
invalidateFilter();
}
@@
-97,7
+110,7
@@
void BufferViewFilter::removeBuffer(const QModelIndex &index) {
bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const {
bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex) const {
- Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(
BufferTree
Model::BufferTypeRole).toInt();
+ Buffer::Type bufferType = (Buffer::Type) source_bufferIndex.data(
Network
Model::BufferTypeRole).toInt();
if((mode & NoChannels) && bufferType == Buffer::ChannelType)
return false;
if((mode & NoChannels) && bufferType == Buffer::ChannelType)
return false;
@@
-106,23
+119,22
@@
bool BufferViewFilter::filterAcceptBuffer(const QModelIndex &source_bufferIndex)
if((mode & NoServers) && bufferType == Buffer::StatusType)
return false;
if((mode & NoServers) && bufferType == Buffer::StatusType)
return false;
-// bool isActive = source_bufferIndex.data(
BufferTree
Model::BufferActiveRole).toBool();
+// bool isActive = source_bufferIndex.data(
Network
Model::BufferActiveRole).toBool();
// if((mode & NoActive) && isActive)
// return false;
// if((mode & NoInactive) && !isActive)
// return false;
// if((mode & NoActive) && isActive)
// return false;
// if((mode & NoInactive) && !isActive)
// return false;
-// if((mode & FullCustom)) {
-// uint bufferuid = source_bufferIndex.data(BufferTreeModel::BufferUidRole).toUInt();
-// if(!buffers.contains(bufferuid))
-// return false;
-// }
+ if((mode & FullCustom)) {
+ uint bufferuid = source_bufferIndex.data(NetworkModel::BufferUidRole).toUInt();
+ return buffers.contains(bufferuid);
+ }
return true;
}
bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const {
return true;
}
bool BufferViewFilter::filterAcceptNetwork(const QModelIndex &source_index) const {
- uint net = source_index.data(
BufferTree
Model::NetworkIdRole).toUInt();
+ uint net = source_index.data(
Network
Model::NetworkIdRole).toUInt();
return !((mode & (SomeNets | FullCustom)) && !networks.contains(net));
}
return !((mode & (SomeNets | FullCustom)) && !networks.contains(net));
}
@@
-141,8
+153,8
@@
bool BufferViewFilter::filterAcceptsRow(int source_row, const QModelIndex &sourc
}
bool BufferViewFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const {
}
bool BufferViewFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const {
- int lefttype = left.data(
BufferTree
Model::BufferTypeRole).toInt();
- int righttype = right.data(
BufferTree
Model::BufferTypeRole).toInt();
+ int lefttype = left.data(
Network
Model::BufferTypeRole).toInt();
+ int righttype = right.data(
Network
Model::BufferTypeRole).toInt();
if(lefttype != righttype)
return lefttype < righttype;
if(lefttype != righttype)
return lefttype < righttype;