21 if (Index_.isValid ())
27 Index_ = QPersistentModelIndex {};
32 if (Index_.isValid ())
33 Manager_.Model_.
SetField<&ProgressManager::Item::Done_> (Index_.row (), done);
38 if (Index_.isValid ())
39 Manager_.Model_.
SetField<&ProgressManager::Item::Total_> (Index_.row (), total);
44 if (Index_.isValid ())
46 const auto total = Manager_.Model_.
GetItems () [Index_.row ()].Total_;
47 Manager_.Model_.
SetField<&ProgressManager::Item::Total_> (Index_.row (), total + delta);
53 if (Index_.isValid ())
55 &ProgressManager::Item::State_,
56 &ProgressManager::Item::CustomStateText_
57 > (Index_.row (), state, std::move (customText));
62 if (Index_.isValid ())
63 Manager_.Model_.
GetMutItems () [Index_.row ()].CustomData_ = data;
68 if (!Index_.isValid ())
71 const auto done = Manager_.Model_.
GetItems () [Index_.row ()].Done_;
72 Manager_.Model_.
SetField<&ProgressManager::Item::Done_> (Index_.row (), done + 1);
94 QAbstractItemModel& Model_;
96 explicit Handler (QAbstractItemModel& model)
101 QAbstractItemModel& GetRepresentation ()
override 107 return std::make_unique<Handler> (Model_);
112 return AddRow (std::move (info), {});
117 auto name = info.
Name_;
118 const auto pos = Model_.
AddItem ({
119 .RowInfo_ = std::move (info),
123 .Icon_ = std::move (inits.
Icon_),
125 .CachedName_ = std::move (name),
129 return std::make_unique<ProgressModelRow> (*
this, Model_.
index (pos, 0));
134 return Model_.
GetItems () [index.row ()].CustomData_;
void SetCustomData(const QVariant &)
qsizetype AddItem(const T &item)
QModelIndex index(int row, int col, const QModelIndex &parent={}) const override
void SetState(ProcessState state, QString customText={})
QVariant GetCustomData(const QModelIndex &) const
QAbstractItemModel & GetModel()
void SetFields(int idx, Vs &&... values)
IJobHolderRepresentationHandler_ptr CreateDefaultHandler()
void SetGlobalData(const QVariant &data, int role)
ProgressModelRow(ProgressManager &, const QModelIndex &)
void ChangeTotalBy(qint64 delta)
void SetField(int idx, V &&value)
std::unique_ptr< IJobHolderRepresentationHandler > IJobHolderRepresentationHandler_ptr
QList< T > & GetMutItems()
std::unique_ptr< ProgressModelRow > AddRow(RowInfo)
ProgressManager(QObject *parent=nullptr)
const QList< T > & GetItems() const
void SetGlobalData(const QVariant &data, int role)