LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
flatitemsmodelbase.cpp
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
10
11namespace LC::Util
12{
14 : QAbstractItemModel { parent }
15 , Headers_ { std::move (headers) }
16 {
17 }
18
20 {
21 return index.isValid () ? 0 : Headers_.size ();
22 }
23
25 {
26 if (!index.isValid ())
27 return {};
28
29 return GetData (index.row (), index.column (), role);
30 }
31
33 {
34 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
35 return {};
36
37 return Headers_.value (section);
38 }
39
41 {
42 if (parent.isValid () ||
43 row >= GetItemsCount () ||
44 col >= Headers_.size ())
45 return {};
46
47 return createIndex (row, col);
48 }
49
51 {
52 return {};
53 }
54
55 int FlatItemsModelBase::rowCount (const QModelIndex& parent) const
56 {
57 return parent.isValid () ? 0 : GetItemsCount ();
58 }
59}
virtual int GetItemsCount() const =0
QVariant data(const QModelIndex &index, int role) const override
QModelIndex index(int row, int col, const QModelIndex &parent={}) const override
int columnCount(const QModelIndex &index={}) const override
QModelIndex parent(const QModelIndex &) const override
int rowCount(const QModelIndex &parent={}) const override
virtual QVariant GetData(int row, int col, int role) const =0
FlatItemsModelBase(QStringList headers, QObject *=nullptr)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
STL namespace.