mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-07 15:32:13 +00:00
Use human readable byte sizes for previous sessions
This commit is contained in:
parent
2ef8b47423
commit
5178046df2
@ -45,6 +45,19 @@ static QIcon getIconFor(QString str, int pos)
|
|||||||
pixPaint.drawText(0, 0, w, h - 2, Qt::AlignCenter, QString(str).toUpper().mid(0, 2));
|
pixPaint.drawText(0, 0, w, h - 2, Qt::AlignCenter, QString(str).toUpper().mid(0, 2));
|
||||||
return QIcon(pixmap);
|
return QIcon(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString formatBytecount(const long bytecount)
|
||||||
|
{
|
||||||
|
const int exp = log(bytecount) / log(1000);
|
||||||
|
constexpr char suffixes[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E'};
|
||||||
|
|
||||||
|
QString str;
|
||||||
|
QTextStream stream(&str);
|
||||||
|
stream << qSetRealNumberPrecision(3) << bytecount / pow(1000, exp)
|
||||||
|
<< ' ' << suffixes[exp] << 'B';
|
||||||
|
return stream.readAll();
|
||||||
|
}
|
||||||
|
|
||||||
NewFileDialog::NewFileDialog(QWidget *parent) :
|
NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::NewFileDialog)
|
ui(new Ui::NewFileDialog)
|
||||||
@ -75,7 +88,10 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
|||||||
// Get file info
|
// Get file info
|
||||||
QFileInfo info(files[i]);
|
QFileInfo info(files[i]);
|
||||||
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(getIconFor(name, i), files[i] + "\nCreated: " + info.created().toString() + "\nSize: " + QString::number(info.size()));
|
QListWidgetItem *item = new QListWidgetItem(
|
||||||
|
getIconFor(name, i),
|
||||||
|
files[i] + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
||||||
|
);
|
||||||
//":/img/icons/target.svg"), name );
|
//":/img/icons/target.svg"), name );
|
||||||
item->setData(Qt::UserRole, files[i]);
|
item->setData(Qt::UserRole, files[i]);
|
||||||
ui->recentsList->addItem(item);
|
ui->recentsList->addItem(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user