LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
flatitemsmodelbase.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QAbstractItemModel>
12 #include "modelsconfig.h"
13 
14 namespace LC::Util
15 {
16  class UTIL_MODELS_API FlatItemsModelBase : public QAbstractItemModel
17  {
18  const QStringList Headers_;
19 
20  QHash<int, QVariant> GlobalData_;
21  public:
22  constexpr static auto DataRole = Qt::UserRole;
23 
24  explicit FlatItemsModelBase (QStringList headers, QObject* = nullptr);
25 
26  int columnCount (const QModelIndex& index = {}) const override;
27  QVariant data (const QModelIndex& index, int role) const override;
28  QVariant headerData (int section, Qt::Orientation orientation, int role) const override;
29  QModelIndex index (int row, int col, const QModelIndex& parent = {}) const override;
30  QModelIndex parent (const QModelIndex&) const override;
31  int rowCount (const QModelIndex& parent = {}) const override;
32 
33  void SetGlobalData (const QVariant& data, int role);
34  protected:
35  virtual int GetItemsCount () const = 0;
36  virtual QVariant GetData (int row, int col, int role) const = 0;
37  };
38 }
#define UTIL_MODELS_API
Definition: modelsconfig.h:16