forked from len0rd/rockbox
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
This commit is contained in:
parent
e71a441762
commit
1155851ffb
1 changed files with 22 additions and 30 deletions
|
@ -36,26 +36,20 @@ InfoWidget::InfoWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
void InfoWidget::updateInfo(void)
|
void InfoWidget::updateInfo(void)
|
||||||
{
|
{
|
||||||
LOG_INFO() << "updating server info";
|
LOG_INFO() << "updating install info";
|
||||||
|
|
||||||
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
|
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
|
||||||
QSettings log(mp + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
|
QSettings log(mp + "/.rockbox/rbutil.log", QSettings::IniFormat, this);
|
||||||
QStringList groups = log.childGroups();
|
QStringList groups = log.childGroups();
|
||||||
QList<QTreeWidgetItem *> items;
|
|
||||||
QTreeWidgetItem *w, *w2;
|
QTreeWidgetItem *w, *w2;
|
||||||
QString min, max;
|
QString min, max;
|
||||||
int olditems = 0;
|
QTreeWidgetItem *loading = new QTreeWidgetItem;
|
||||||
|
loading->setText(0, tr("Loading, please wait ..."));
|
||||||
|
ui.treeInfo->clear();
|
||||||
|
ui.treeInfo->addTopLevelItem(loading);
|
||||||
|
ui.treeInfo->resizeColumnToContents(0);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
// remove old list entries (if any)
|
|
||||||
int l = ui.treeInfo->topLevelItemCount();
|
|
||||||
while(l--) {
|
|
||||||
QTreeWidgetItem *m;
|
|
||||||
m = ui.treeInfo->takeTopLevelItem(l);
|
|
||||||
// delete childs (single level deep, no recursion here)
|
|
||||||
int n = m->childCount();
|
|
||||||
while(n--)
|
|
||||||
delete m->child(n);
|
|
||||||
}
|
|
||||||
// get and populate new items
|
// get and populate new items
|
||||||
for(int a = 0; a < groups.size(); a++) {
|
for(int a = 0; a < groups.size(); a++) {
|
||||||
log.beginGroup(groups.at(a));
|
log.beginGroup(groups.at(a));
|
||||||
|
@ -63,40 +57,38 @@ void InfoWidget::updateInfo(void)
|
||||||
w = new QTreeWidgetItem;
|
w = new QTreeWidgetItem;
|
||||||
w->setFlags(Qt::ItemIsEnabled);
|
w->setFlags(Qt::ItemIsEnabled);
|
||||||
w->setText(0, groups.at(a));
|
w->setText(0, groups.at(a));
|
||||||
items.append(w);
|
ui.treeInfo->addTopLevelItem(w);
|
||||||
// get minimum and maximum version information so we can hilight old files
|
// get minimum and maximum version information so we can hilight old files
|
||||||
min = max = log.value(keys.at(0)).toString();
|
min = max = log.value(keys.at(0)).toString();
|
||||||
for(int b = 0; b < keys.size(); b++) {
|
for(int b = 0; b < keys.size(); b++) {
|
||||||
if(log.value(keys.at(b)).toString() > max)
|
QString v = log.value(keys.at(b)).toString();
|
||||||
max = log.value(keys.at(b)).toString();
|
if(v > max)
|
||||||
if(log.value(keys.at(b)).toString() < min)
|
max = v;
|
||||||
min = log.value(keys.at(b)).toString();
|
if(v < min)
|
||||||
}
|
min = v;
|
||||||
|
|
||||||
for(int b = 0; b < keys.size(); b++) {
|
QString file = mp + "/" + keys.at(b);
|
||||||
QString file;
|
if(QFileInfo(file).isDir()) {
|
||||||
file = mp + "/" + keys.at(b);
|
// ignore folders
|
||||||
if(QFileInfo(file).isDir())
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
w2 = new QTreeWidgetItem(w, QStringList() << "/"
|
w2 = new QTreeWidgetItem(w, QStringList() << "/"
|
||||||
+ keys.at(b) << log.value(keys.at(b)).toString());
|
+ keys.at(b) << v);
|
||||||
if(log.value(keys.at(b)).toString() != max) {
|
if(v != max) {
|
||||||
w2->setForeground(0, QBrush(QColor(255, 0, 0)));
|
w2->setForeground(0, QBrush(QColor(255, 0, 0)));
|
||||||
w2->setForeground(1, QBrush(QColor(255, 0, 0)));
|
w2->setForeground(1, QBrush(QColor(255, 0, 0)));
|
||||||
olditems++;
|
|
||||||
}
|
}
|
||||||
items.append(w2);
|
w->addChild(w2);
|
||||||
}
|
}
|
||||||
log.endGroup();
|
log.endGroup();
|
||||||
if(min != max)
|
if(min != max)
|
||||||
w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
|
w->setData(1, Qt::DisplayRole, QString("%1 / %2").arg(min, max));
|
||||||
else
|
else
|
||||||
w->setData(1, Qt::DisplayRole, max);
|
w->setData(1, Qt::DisplayRole, max);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
ui.treeInfo->insertTopLevelItems(0, items);
|
ui.treeInfo->takeTopLevelItem(0);
|
||||||
ui.treeInfo->expandAll();
|
|
||||||
ui.treeInfo->resizeColumnToContents(0);
|
ui.treeInfo->resizeColumnToContents(0);
|
||||||
ui.treeInfo->collapseAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue