LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
modelitem.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 <QModelIndex>
12#include "modelsconfig.h"
13#include "modelitembase.h"
14
15namespace LC::Util
16{
17 class ModelItem;
18
19 typedef std::shared_ptr<ModelItem> ModelItem_ptr;
20 typedef std::weak_ptr<ModelItem> ModelItem_wtr;
21 typedef QVector<ModelItem_ptr> ModelItemsList_t;
22 typedef std::shared_ptr<const ModelItem> ModelItem_cptr;
23
31 class UTIL_MODELS_API ModelItem final : public ModelItemBase<ModelItem>
32 {
33 QAbstractItemModel * const Model_ = nullptr;
34 QModelIndex SrcIdx_;
35 public:
36 typedef ModelItemsList_t::iterator iterator;
37 typedef ModelItemsList_t::const_iterator const_iterator;
38
42 ModelItem () = default;
43
52 ModelItem (QAbstractItemModel *model, const QModelIndex& index, const ModelItem_wtr& parent);
53
66 ModelItem* EnsureChild (int row);
67
74 const QModelIndex& GetIndex () const;
75
80 QAbstractItemModel* GetModel () const;
81
93 void RefreshIndex (int modelStartingRow);
94
105 ModelItem_ptr FindChild (QModelIndex index) const;
106 };
107}
Provides a proxying API on top of an QAbstractItemModel.
Definition modelitem.h:32
ModelItem * EnsureChild(int row)
Ensures there is a child item at the given row.
Definition modelitem.cpp:21
QAbstractItemModel * GetModel() const
Returns the wrapped model.
Definition modelitem.cpp:45
ModelItem()=default
Constructs a default (invalid) ModelItem having no model set.
void RefreshIndex(int modelStartingRow)
Updates the wrapped index so that it points at the given row.
Definition modelitem.cpp:39
const QModelIndex & GetIndex() const
Returns the index this ModelItem instance wraps.
Definition modelitem.cpp:34
ModelItemsList_t::iterator iterator
Definition modelitem.h:36
ModelItem_ptr FindChild(QModelIndex index) const
Finds a child item for the given index.
Definition modelitem.cpp:50
ModelItemsList_t::const_iterator const_iterator
Definition modelitem.h:37
#define UTIL_MODELS_API
std::shared_ptr< ModelItem > ModelItem_ptr
Definition modelitem.h:19
QVector< ModelItem_ptr > ModelItemsList_t
Definition modelitem.h:21
std::shared_ptr< const ModelItem > ModelItem_cptr
Definition modelitem.h:22
std::weak_ptr< ModelItem > ModelItem_wtr
Definition modelitem.h:20