OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
idtableproxymodel.hpp
Go to the documentation of this file.
1 #ifndef CSM_WOLRD_IDTABLEPROXYMODEL_H
2 #define CSM_WOLRD_IDTABLEPROXYMODEL_H
3 
4 #include <string>
5 
6 #include <boost/shared_ptr.hpp>
7 
8 #include <map>
9 
10 #include <QSortFilterProxyModel>
11 
12 #include "../filter/node.hpp"
13 
14 #include "columns.hpp"
15 
16 namespace CSMWorld
17 {
19  {
20  Q_OBJECT
21 
22  boost::shared_ptr<CSMFilter::Node> mFilter;
23  std::map<int, int> mColumnMap; // column ID, column index in this model (or -1)
24 
25  // Cache of enum values for enum columns (e.g. Modified, Record Type).
26  // Used to speed up comparisons during the sort by such columns.
27  typedef std::map<Columns::ColumnId, std::vector<std::string> > EnumColumnCache;
29 
30  protected:
31 
33 
34  private:
35 
36  void updateColumnMap();
37 
38  public:
39 
40  IdTableProxyModel (QObject *parent = 0);
41 
42  virtual QModelIndex getModelIndex (const std::string& id, int column) const;
43 
44  virtual void setSourceModel(QAbstractItemModel *model);
45 
46  void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter);
47 
48  void refreshFilter();
49 
50  protected:
51 
52  virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
53 
54  virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const;
55 
56  QString getRecordId(int sourceRow) const;
57 
58  protected slots:
59 
60  virtual void sourceRowsInserted(const QModelIndex &parent, int start, int end);
61 
62  virtual void sourceRowsRemoved(const QModelIndex &parent, int start, int end);
63 
64  virtual void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
65 
66  signals:
67 
68  void rowAdded(const std::string &id);
69  };
70 }
71 
72 #endif
static const struct @2 signals[]
std::map< int, int > mColumnMap
Definition: idtableproxymodel.hpp:23
QString getRecordId(int sourceRow) const
Definition: idtableproxymodel.cpp:114
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
Definition: idtableproxymodel.cpp:33
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const
Definition: idtableproxymodel.cpp:93
IdTableBase * mSourceModel
Definition: idtableproxymodel.hpp:32
void updateColumnMap()
Definition: idtableproxymodel.cpp:19
boost::shared_ptr< CSMFilter::Node > mFilter
Definition: idtableproxymodel.hpp:22
EnumColumnCache mEnumColumnCache
Definition: idtableproxymodel.hpp:28
virtual QModelIndex getModelIndex(const std::string &id, int column) const
Definition: idtableproxymodel.cpp:59
std::map< Columns::ColumnId, std::vector< std::string > > EnumColumnCache
Definition: idtableproxymodel.hpp:27
virtual void setSourceModel(QAbstractItemModel *model)
Definition: idtableproxymodel.cpp:66
Definition: idtableproxymodel.hpp:18
virtual void sourceRowsRemoved(const QModelIndex &parent, int start, int end)
Definition: idtableproxymodel.cpp:137
void setFilter(const boost::shared_ptr< CSMFilter::Node > &filter)
Definition: idtableproxymodel.cpp:85
IdTableProxyModel(QObject *parent=0)
Definition: idtableproxymodel.cpp:52
Definition: idtablebase.hpp:12
virtual void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: idtableproxymodel.cpp:142
void refreshFilter()
Definition: idtableproxymodel.cpp:122
void rowAdded(const std::string &id)
virtual void sourceRowsInserted(const QModelIndex &parent, int start, int end)
Definition: idtableproxymodel.cpp:128