MultiMC5/main.h

52 lines
1.0 KiB
C
Raw Normal View History

2014-01-31 21:51:45 +00:00
#pragma once
2013-12-30 22:39:10 +00:00
#include <QObject>
#include <QTimer>
#include <QList>
#include <QStandardItem>
#include <QDebug>
2014-01-31 21:51:45 +00:00
#include "GroupView.h"
2013-12-30 22:39:10 +00:00
class Progresser : public QObject
{
Q_OBJECT
public:
explicit Progresser(QObject *parent = 0) : QObject(parent)
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
timer->start(50);
}
QStandardItem *addTrackedIndex(QStandardItem *item)
{
item->setData(1000, CategorizedViewRoles::ProgressMaximumRole);
m_items.append(item);
return item;
}
2014-01-31 21:51:45 +00:00
public
slots:
2013-12-30 22:39:10 +00:00
void timeout()
{
2014-01-31 21:58:57 +00:00
for (auto item : m_items)
2013-12-30 22:39:10 +00:00
{
int value = item->data(CategorizedViewRoles::ProgressValueRole).toInt();
value += qrand() % 3;
if (value >= item->data(CategorizedViewRoles::ProgressMaximumRole).toInt())
{
item->setData(item->data(CategorizedViewRoles::ProgressMaximumRole).toInt(),
CategorizedViewRoles::ProgressValueRole);
}
else
{
item->setData(value, CategorizedViewRoles::ProgressValueRole);
}
}
}
private:
QList<QStandardItem *> m_items;
};