Stellarium 0.14.3
FieldConcatModel.hpp
1 /*
2  * Copyright (C) 2010 Timothy Reaves
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef _FIELDCONCATMODEL_HPP_
20 #define _FIELDCONCATMODEL_HPP_
21 
22 #include <QObject>
23 #include <QAbstractTableModel>
24 #include <QModelIndexList>
25 #include <QStringList>
26 
27 class QModelIndex;
28 class QSqlRecord;
29 class QSqlTableModel;
30 class QVariant;
31 
39 class FieldConcatModel : public QAbstractTableModel {
40  Q_OBJECT
41 
42 public:
48  FieldConcatModel(QSqlTableModel *backingModel, QStringList fieldNames, QString seperationString = " | ", QObject *parent = 0);
49  virtual ~FieldConcatModel();
50  virtual int columnCount(const QModelIndex& parent = QModelIndex() ) const;
51  QString displayStringForRecord(QSqlRecord& record) const;
52  virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const;
53  int idForDisplayString(QString displayString);
54  virtual int rowCount(const QModelIndex& parent = QModelIndex() ) const;
55  void setFilter(const QString& filter);
56 /*
57 signals:
58  void destroyed();
59  void dataChanged(QModelIndex,QModelIndex);
60  void headerDataChanged(Qt::Orientation,int,int);
61  void rowsInserted(QModelIndex,int,int);
62  void rowsAboutToBeRemoved(QModelIndex,int,int);
63  void rowsRemoved(QModelIndex,int,int);
64  void columnsAboutToBeRemoved(QModelIndex,int,int);
65  void columnsRemoved(QModelIndex,int,int);
66  void columnsInserted(QModelIndex,int,int);
67 
68  void modelReset();
69  void layoutChanged();
70 */
71 private:
72  QStringList fields;
73  QString seperator;
74  QSqlTableModel *dataModel;
75 };
76 
77 #endif // _FIELDCONCATMODEL_HPP_
FieldConcatModel(QSqlTableModel *backingModel, QStringList fieldNames, QString seperationString=" | ", QObject *parent=0)
the default constructor
Allows for concatinating fields from a model for disply.