Small tweaks

This commit is contained in:
Petr Mrázek
2014-02-02 10:26:38 +01:00
parent 179451d591
commit b2bf50a6d7
4 changed files with 56 additions and 42 deletions

19
main.h
View File

@@ -30,20 +30,23 @@ public
slots:
void timeout()
{
QList<QStandardItem *> toRemove;
for (auto item : m_items)
{
int maximum = item->data(CategorizedViewRoles::ProgressMaximumRole).toInt();
int value = item->data(CategorizedViewRoles::ProgressValueRole).toInt();
value += qrand() % 3;
if (value >= item->data(CategorizedViewRoles::ProgressMaximumRole).toInt())
int newvalue = std::min(value + 3, maximum);
item->setData(newvalue, CategorizedViewRoles::ProgressValueRole);
if(newvalue >= maximum)
{
item->setData(item->data(CategorizedViewRoles::ProgressMaximumRole).toInt(),
CategorizedViewRoles::ProgressValueRole);
}
else
{
item->setData(value, CategorizedViewRoles::ProgressValueRole);
toRemove.append(item);
}
}
for(auto remove : toRemove)
{
m_items.removeAll(remove);
}
}
private: