diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-18 18:17:00 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-04-18 19:35:35 +0200 |
commit | 1155851ffbd11585c1e2fd376fd77d5a6fe627fc (patch) | |
tree | f2d5eb6fc2c2680ab4bcc660d89e273bd1c66ea1 /utils/rbutilqt/gui/infowidget.cpp | |
parent | e71a4417628278313584789e5c9a463bd2b4bb0a (diff) | |
download | rockbox-1155851ffbd11585c1e2fd376fd77d5a6fe627fc.tar.gz rockbox-1155851ffbd11585c1e2fd376fd77d5a6fe627fc.zip |
rbutil: Make "Info" tab more responsive.
Loading the information can take a bit depending on the speed of the
disk. To make the application not appear as frozen update the UI more
often, and display a "Loading" text during data retrieval.
Change-Id: I012487d031ea71e62b583ca1c40220ea709e7034
Diffstat (limited to 'utils/rbutilqt/gui/infowidget.cpp')
-rw-r--r-- | utils/rbutilqt/gui/infowidget.cpp | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/utils/rbutilqt/gui/infowidget.cpp b/utils/rbutilqt/gui/infowidget.cpp index 25b0503090..b0e76a7bf4 100644 --- a/utils/rbutilqt/gui/infowidget.cpp +++ b/utils/rbutilqt/gui/infowidget.cpp | |||
@@ -36,26 +36,20 @@ InfoWidget::InfoWidget(QWidget *parent) : QWidget(parent) | |||
36 | 36 | ||
37 | void InfoWidget::updateInfo(void) | 37 | void InfoWidget::updateInfo(void) |
38 | { | 38 | { |
39 | LOG_INFO() << "updating server info"; | 39 | LOG_INFO() << "updating install info"; |
40 | 40 | ||
41 | QString mp = RbSettings::value(RbSettings::Mountpoint).toString(); | 41 | QString mp = RbSettings::value(RbSettings::Mountpoint).toString(); |
42 | QSettings log(mp + "/.rockbox/rbutil.log", QSettings::IniFormat, this); | 42 | QSettings log(mp + "/.rockbox/rbutil.log", QSettings::IniFormat, this); |
43 | QStringList groups = log.childGroups(); | 43 | QStringList groups = log.childGroups(); |
44 | QList<QTreeWidgetItem *> items; | ||
45 | QTreeWidgetItem *w, *w2; | 44 | QTreeWidgetItem *w, *w2; |
46 | QString min, max; | 45 | QString min, max; |
47 | int olditems = 0; | 46 | QTreeWidgetItem *loading = new QTreeWidgetItem; |
47 | loading->setText(0, tr("Loading, please wait ...")); | ||
48 | ui.treeInfo->clear(); | ||
49 | ui.treeInfo->addTopLevelItem(loading); | ||
50 | ui.treeInfo->resizeColumnToContents(0); | ||
51 | QCoreApplication::processEvents(); | ||
48 | 52 | ||
49 | // remove old list entries (if any) | ||
50 | int l = ui.treeInfo->topLevelItemCount(); | ||
51 | while(l--) { | ||
52 | QTreeWidgetItem *m; | ||
53 | m = ui.treeInfo->takeTopLevelItem(l); | ||
54 | // delete childs (single level deep, no recursion here) | ||
55 | int n = m->childCount(); | ||
56 | while(n--) | ||
57 | delete m->child(n); | ||
58 | } | ||
59 | // get and populate new items | 53 | // get and populate new items |
60 | for(int a = 0; a < groups.size(); a++) { | 54 | for(int a = 0; a < groups.size(); a++) { |
61 | log.beginGroup(groups.at(a)); | 55 | log.beginGroup(groups.at(a)); |
@@ -63,40 +57,38 @@ void InfoWidget::updateInfo(void) | |||
63 | w = new QTreeWidgetItem; | 57 | w = new QTreeWidgetItem; |
64 | w->setFlags(Qt::ItemIsEnabled); | 58 | w->setFlags(Qt::ItemIsEnabled); |
65 | w->setText(0, groups.at(a)); | 59 | w->setText(0, groups.at(a)); |
66 | items.append(w); | 60 | ui.treeInfo->addTopLevelItem(w); |
67 | // get minimum and maximum version information so we can hilight old files | 61 | // get minimum and maximum version information so we can hilight old files |
68 | min = max = log.value(keys.at(0)).toString(); | 62 | min = max = log.value(keys.at(0)).toString(); |
69 | for(int b = 0; b < keys.size(); b++) { | 63 | for(int b = 0; b < keys.size(); b++) { |
70 | if(log.value(keys.at(b)).toString() > max) | 64 | QString v = log.value(keys.at(b)).toString(); |
71 | max = log.value(keys.at(b)).toString(); | 65 | if(v > max) |
72 | if(log.value(keys.at(b)).toString() < min) | 66 | max = v; |
73 | min = log.value(keys.at(b)).toString(); | 67 | if(v < min) |
74 | } | 68 | min = v; |
75 | 69 | ||
76 | for(int b = 0; b < keys.size(); b++) { | 70 | QString file = mp + "/" + keys.at(b); |
77 | QString file; | 71 | if(QFileInfo(file).isDir()) { |
78 | file = mp + "/" + keys.at(b); | 72 | // ignore folders |
79 | if(QFileInfo(file).isDir()) | ||
80 | continue; | 73 | continue; |
74 | } | ||
81 | w2 = new QTreeWidgetItem(w, QStringList() << "/" | 75 | w2 = new QTreeWidgetItem(w, QStringList() << "/" |
82 | + keys.at(b) << log.value(keys.at(b)).toString()); | 76 | + keys.at(b) << v); |
83 | if(log.value(keys.at(b)).toString() != max) { | 77 | if(v != max) { |
84 | w2->setForeground(0, QBrush(QColor(255, 0, 0))); | 78 | w2->setForeground(0, QBrush(QColor(255, 0, 0))); |
85 | w2->setForeground(1, QBrush(QColor(255, 0, 0))); | 79 | w2->setForeground(1, QBrush(QColor(255, 0, 0))); |
86 | olditems++; | ||
87 | } | 80 | } |
88 | items.append(w2); | 81 | w->addChild(w2); |
89 | } | 82 | } |
90 | log.endGroup(); | 83 | log.endGroup(); |
91 | if(min != max) | 84 | if(min != max) |
92 | w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max)); | 85 | w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max)); |
93 | else | 86 | else |
94 | w->setData(1, Qt::DisplayRole, max); | 87 | w->setData(1, Qt::DisplayRole, max); |
88 | QCoreApplication::processEvents(); | ||
95 | } | 89 | } |
96 | ui.treeInfo->insertTopLevelItems(0, items); | 90 | ui.treeInfo->takeTopLevelItem(0); |
97 | ui.treeInfo->expandAll(); | ||
98 | ui.treeInfo->resizeColumnToContents(0); | 91 | ui.treeInfo->resizeColumnToContents(0); |
99 | ui.treeInfo->collapseAll(); | ||
100 | } | 92 | } |
101 | 93 | ||
102 | 94 | ||