LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
mergemodel.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2013 Georg Rudoy
4  *
5  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #ifndef UTIL_MERGEMODEL_H
31 #define UTIL_MERGEMODEL_H
32 #include <deque>
33 #include <QPointer>
34 #include <QAbstractProxyModel>
35 #include <QStringList>
36 #include <util/utilconfig.h>
37 
38 namespace LeechCraft
39 {
40  namespace Util
41  {
53  class UTIL_API MergeModel : public QAbstractItemModel
54  {
55  Q_OBJECT
56 
57  mutable bool DefaultAcceptsRowImpl_;
58  protected:
59  typedef std::deque<QPointer<QAbstractItemModel>> models_t;
61  private:
62  QStringList Headers_;
63  public:
64  typedef models_t::iterator iterator;
65  typedef models_t::const_iterator const_iterator;
66 
67  MergeModel (const QStringList&, QObject* = 0);
68  virtual ~MergeModel ();
69 
70  virtual int columnCount (const QModelIndex& = QModelIndex ()) const;
71  virtual QVariant headerData (int, Qt::Orientation, int = Qt::DisplayRole) const;
72  virtual QVariant data (const QModelIndex&, int = Qt::DisplayRole) const;
73  virtual Qt::ItemFlags flags (const QModelIndex&) const;
74  virtual QModelIndex index (int, int, const QModelIndex& = QModelIndex ()) const;
75  virtual QModelIndex parent (const QModelIndex&) const;
76  virtual int rowCount (const QModelIndex& = QModelIndex ()) const;
77 
84  virtual QModelIndex mapFromSource (const QModelIndex& index) const;
85 
92  virtual QModelIndex mapToSource (const QModelIndex& index) const;
93 
102  virtual void setSourceModel (QAbstractItemModel*);
103 
108  void SetHeaders (const QStringList& headers);
109 
121  void AddModel (QAbstractItemModel *model);
122 
128  void RemoveModel (QAbstractItemModel *model);
129 
134  size_t Size () const;
135 
142  const_iterator FindModel (const QAbstractItemModel *model) const;
143 
150  iterator FindModel (const QAbstractItemModel *model);
151 
159  int GetStartingRow (const_iterator it) const;
160 
176  const_iterator GetModelForRow (int row, int *starting = 0) const;
177 
189  iterator GetModelForRow (int row, int *starting = 0);
190 
199  QList<QAbstractItemModel*> GetAllModels () const;
200  public Q_SLOTS:
201  virtual void handleColumnsAboutToBeInserted (const QModelIndex&, int, int);
202  virtual void handleColumnsAboutToBeRemoved (const QModelIndex&, int, int);
203  virtual void handleColumnsInserted (const QModelIndex&, int, int);
204  virtual void handleColumnsRemoved (const QModelIndex&, int, int);
205  virtual void handleDataChanged (const QModelIndex&, const QModelIndex&);
206  virtual void handleRowsAboutToBeInserted (const QModelIndex&, int, int);
207  virtual void handleRowsAboutToBeRemoved (const QModelIndex&, int, int);
208  virtual void handleRowsInserted (const QModelIndex&, int, int);
209  virtual void handleRowsRemoved (const QModelIndex&, int, int);
210  protected:
217  virtual bool AcceptsRow (QAbstractItemModel *model, int row) const;
218  private:
219  int RowCount (QAbstractItemModel*) const;
220  };
221  };
222 };
223 
224 #endif
225 
#define UTIL_API
Definition: utilconfig.h:37
models_t::const_iterator const_iterator
Definition: mergemodel.h:65
models_t::iterator iterator
Definition: mergemodel.h:64
std::deque< QPointer< QAbstractItemModel > > models_t
Definition: mergemodel.h:59