summaryrefslogtreecommitdiffstats
path: root/depends/groupview/main.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-04 00:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-04 00:53:05 +0100
commitb82eb5873e99dce6aec735b08929e3add52e53e7 (patch)
treef8b60861bc5006cc989e65b87b22498f2b1d4412 /depends/groupview/main.h
parenta17caba2c9c2aa5960581db01e4b66472a9c019c (diff)
parent946d49675cb4725c31ab49a51f3bcae302f89a19 (diff)
downloadMultiMC-b82eb5873e99dce6aec735b08929e3add52e53e7.tar
MultiMC-b82eb5873e99dce6aec735b08929e3add52e53e7.tar.gz
MultiMC-b82eb5873e99dce6aec735b08929e3add52e53e7.tar.lz
MultiMC-b82eb5873e99dce6aec735b08929e3add52e53e7.tar.xz
MultiMC-b82eb5873e99dce6aec735b08929e3add52e53e7.zip
Add 'depends/groupview/' from commit '946d49675cb4725c31ab49a51f3bcae302f89a19'
git-subtree-dir: depends/groupview git-subtree-mainline: a17caba2c9c2aa5960581db01e4b66472a9c019c git-subtree-split: 946d49675cb4725c31ab49a51f3bcae302f89a19
Diffstat (limited to 'depends/groupview/main.h')
-rw-r--r--depends/groupview/main.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/depends/groupview/main.h b/depends/groupview/main.h
new file mode 100644
index 00000000..2a358329
--- /dev/null
+++ b/depends/groupview/main.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <QObject>
+#include <QTimer>
+#include <QList>
+#include <QStandardItem>
+#include <QDebug>
+
+#include "GroupView.h"
+
+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, GroupViewRoles::ProgressMaximumRole);
+ m_items.append(item);
+ return item;
+ }
+
+public
+slots:
+ void timeout()
+ {
+ QList<QStandardItem *> toRemove;
+ for (auto item : m_items)
+ {
+ int maximum = item->data(GroupViewRoles::ProgressMaximumRole).toInt();
+ int value = item->data(GroupViewRoles::ProgressValueRole).toInt();
+ int newvalue = std::min(value + 3, maximum);
+ item->setData(newvalue, GroupViewRoles::ProgressValueRole);
+
+ if(newvalue >= maximum)
+ {
+ toRemove.append(item);
+ }
+ }
+ for(auto remove : toRemove)
+ {
+ m_items.removeAll(remove);
+ }
+ }
+
+private:
+ QList<QStandardItem *> m_items;
+};