setSourceModel(model);
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(source_rowsInserted(const QModelIndex &, int, int)));
- // setSortCaseSensitivity(Qt::CaseInsensitive);
setDynamicSortFilter(true);
}
}
void BufferViewFilter::addBuffer(const BufferId &bufferId) {
- if(config()->bufferList().contains(bufferId))
+ if(!config() || config()->bufferList().contains(bufferId))
return;
int pos = config()->bufferList().count();
}
void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, int end) {
- if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
+ if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType)
return;
if(!config() || !config()->addNewBuffersAutomatically())
return;
+ QModelIndex child;
for(int row = start; row <= end; row++) {
- addBuffer(parent.child(row, 0).data(NetworkModel::BufferIdRole).value<BufferId>());
+ child = sourceModel()->index(row, 0, parent);
+ addBuffer(sourceModel()->data(child, NetworkModel::BufferIdRole).value<BufferId>());
}
}
if(leftType != rightType)
return leftType < rightType;
else
- return Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString() < Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString();
+ return QString::compare(Client::networkModel()->data(leftIndex, Qt::DisplayRole).toString(), Client::networkModel()->data(rightIndex, Qt::DisplayRole).toString(), Qt::CaseInsensitive) < 0;
}