X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fbufferviewfilter.h;h=5bacfaf0339b9bf2efb36c0b5029ffd18bfd3487;hp=2586ff25b0dd0eba95eded74c3d14021bc5559a7;hb=eb606f89b0f97cbcb69b87e0ae749a05cd473ff2;hpb=f6f6f3e368543f0a4dce1dae772f161d7e357064 diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 2586ff25..5bacfaf0 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,21 +18,26 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _BUFFERVIEWFILTER_H_ -#define _BUFFERVIEWFILTER_H_ +#ifndef BUFFERVIEWFILTER_H_ +#define BUFFERVIEWFILTER_H_ -#include +#include #include -#include +#include +#include +#include #include -#include "buffer.h" +#include + +#include "types.h" +#include "bufferviewconfig.h" /***************************************** * Buffer View Filter *****************************************/ class BufferViewFilter : public QSortFilterProxyModel { Q_OBJECT - + public: enum Mode { NoActive = 0x01, @@ -44,32 +49,71 @@ public: NoServers = 0x40, FullCustom = 0x80 }; - Q_DECLARE_FLAGS(Modes, Mode); + Q_DECLARE_FLAGS(Modes, Mode) + + BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config = 0); - BufferViewFilter(QAbstractItemModel *model, const Modes &mode, const QList &nets); - virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - + + QVariant data(const QModelIndex &index, int role) const; + QVariant icon(const QModelIndex &index) const; +// QVariant foreground(const QModelIndex &index) const; + QVariant checkedState(const QModelIndex &index) const; + + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + bool setCheckedState(const QModelIndex &index, Qt::CheckState state); + + void setConfig(BufferViewConfig *config); + inline BufferViewConfig *config() const { return _config; } + + virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); + + QList actions(const QModelIndex &index); + public slots: - void removeBuffer(const QModelIndex &); - void invalidateFilter_(); - + void checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous); + void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); } + void checkItemsForRemoval(const QModelIndex &topLeft, const QModelIndex &bottomRight); + protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; - bool lessThan(const QModelIndex &, const QModelIndex &) const; - + 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); + void configChanged(); + +private slots: + void configInitialized(); + void showUserStateIconsChanged(); + void enableEditMode(bool enable); + private: - Modes mode; - QSet networks; - QSet buffers; + QPointer _config; + Qt::SortOrder _sortOrder; + + QPixmap _channelJoinedIcon; + QPixmap _channelPartedIcon; + QPixmap _userOfflineIcon; + QPixmap _userAwayIcon; + QPixmap _userOnlineIcon; + bool _showUserStateIcons; + + bool _editMode; + QAction _enableEditMode; + QSet _toAdd; + QSet _toTempRemove; + QSet _toRemove; bool filterAcceptBuffer(const QModelIndex &) const; bool filterAcceptNetwork(const QModelIndex &) const; - void addBuffer(const uint &); - + void addBuffer(const BufferId &) const; + static bool bufferIdLessThan(const BufferId &, const BufferId &); }; -Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes) - -#endif +Q_DECLARE_OPERATORS_FOR_FLAGS(BufferViewFilter::Modes) +#endif // BUFFERVIEWFILTER_H_