mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Do not display deleted files as recent files (#15)
This commit is contained in:
parent
f3448fa886
commit
bbf424a950
@ -73,33 +73,39 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
|||||||
|
|
||||||
QStringList files = settings.value("recentFileList").toStringList();
|
QStringList files = settings.value("recentFileList").toStringList();
|
||||||
|
|
||||||
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
|
QMutableListIterator<QString> it(files);
|
||||||
|
int i = 0;
|
||||||
for (int i = 0; i < numRecentFiles; ++i)
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
|
const QString& file = it.next();
|
||||||
// Get stored files
|
// Get stored files
|
||||||
//QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
|
|
||||||
|
|
||||||
// Remove all but the file name
|
// Remove all but the file name
|
||||||
QString sep = QDir::separator();
|
const QString sep = QDir::separator();
|
||||||
QStringList name_list = files[i].split(sep);
|
const QStringList name_list = file.split(sep);
|
||||||
QString name = name_list.last();
|
const QString name = name_list.last();
|
||||||
|
|
||||||
// Get file info
|
// Get file info
|
||||||
QFileInfo info(files[i]);
|
QFileInfo info(file);
|
||||||
|
if (!info.exists()) {
|
||||||
|
it.remove();
|
||||||
|
} else {
|
||||||
QListWidgetItem *item = new QListWidgetItem(
|
QListWidgetItem *item = new QListWidgetItem(
|
||||||
getIconFor(name, i),
|
getIconFor(name, i++),
|
||||||
files[i] + "\nCreated: " + info.created().toString() + "\nSize: " + formatBytecount(info.size())
|
file + "\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, file);
|
||||||
ui->recentsList->addItem(item);
|
ui->recentsList->addItem(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ui->recentsList->setSortingEnabled(true);
|
ui->recentsList->setSortingEnabled(true);
|
||||||
|
|
||||||
// Hide "create" button until the dialog works
|
// Hide "create" button until the dialog works
|
||||||
ui->createButton->hide();
|
ui->createButton->hide();
|
||||||
|
|
||||||
|
// Removes files were deleted from the stringlist. Save it again.
|
||||||
|
settings.setValue("recentFileList", files);
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFileDialog::~NewFileDialog()
|
NewFileDialog::~NewFileDialog()
|
||||||
|
Loading…
Reference in New Issue
Block a user