X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdatabackup%2Fbackupwidget.cpp;h=81a96f8637a6240f725f4b5338e6ccfec5ec992c;hb=29ceabd2afc227e0fb8b586c567eeaf7921b542e;hp=64e4a88bad025dbacc9e4147346d6e173bdfe8f0;hpb=a6c1dd8bf93a54b38ad03095f99dcfc4f8e03e15;p=kdenlive diff --git a/src/databackup/backupwidget.cpp b/src/databackup/backupwidget.cpp index 64e4a88b..81a96f86 100644 --- a/src/databackup/backupwidget.cpp +++ b/src/databackup/backupwidget.cpp @@ -24,26 +24,23 @@ #include -BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, const QString projectId, QWidget * parent) : +BackupWidget::BackupWidget(const KUrl &projectUrl, const KUrl &projectFolder, const QString &projectId, QWidget * parent) : QDialog(parent) { setupUi(this); setWindowTitle(i18n("Restore Backup File")); - KUrl backupFile; - if (projectUrl.isEmpty()) { // No url, means we opened the backup dialog from an empty project info_label->setText(i18n("Showing all backup files in folder")); - m_projectWildcard = "*"; - } - else { + m_projectWildcard = '*'; + } else { info_label->setText(i18n("Showing backup files for %1", projectUrl.fileName())); m_projectWildcard = projectUrl.fileName().section('.', 0, -2); - if (!projectId.isEmpty()) m_projectWildcard.append("-" + projectId); + if (!projectId.isEmpty()) m_projectWildcard.append('-' + projectId); else { // No project id, it was lost, add wildcard - m_projectWildcard.append("*"); + m_projectWildcard.append('*'); } } project_url->setUrl(projectFolder); @@ -56,17 +53,13 @@ BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, const QString pr slotParseBackupFiles(); connect(backup_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotDisplayBackupPreview())); - connect(project_url, SIGNAL(textChanged(const QString &)), this, SLOT(slotParseBackupFiles())); + connect(project_url, SIGNAL(textChanged(QString)), this, SLOT(slotParseBackupFiles())); backup_list->setCurrentRow(0); backup_list->setMinimumHeight(QFontMetrics(font()).lineSpacing() * 12); - } - - BackupWidget::~BackupWidget() { - } void BackupWidget::slotParseBackupFiles() @@ -83,11 +76,11 @@ void BackupWidget::slotParseBackupFiles() backup_list->clear(); QListWidgetItem *item; QString label; - for (int i = 0; i < resultList.count(); i++) { + for (int i = 0; i < resultList.count(); ++i) { label = resultList.at(i).lastModified().toString(Qt::SystemLocaleLongDate); - if (m_projectWildcard.startsWith("*")) { + if (m_projectWildcard.startsWith(QLatin1Char('*'))) { // Displaying all backup files, so add project name in the entries - label.prepend(resultList.at(i).fileName().section("-", 0, -7) + ".kdenlive - "); + label.prepend(resultList.at(i).fileName().section('-', 0, -7) + ".kdenlive - "); } item = new QListWidgetItem(label, backup_list); item->setData(Qt::UserRole, resultList.at(i).absoluteFilePath()); @@ -101,13 +94,17 @@ void BackupWidget::slotDisplayBackupPreview() backup_preview->setPixmap(QPixmap()); return; } - QString path = backup_list->currentItem()->data(Qt::UserRole).toString(); + const QString path = backup_list->currentItem()->data(Qt::UserRole).toString(); QPixmap pix(path + ".png"); backup_preview->setPixmap(pix); } -QString BackupWidget::selectedFile() +QString BackupWidget::selectedFile() const { - if (!backup_list->currentItem()) return QString(); + if (!backup_list->currentItem()) + return QString(); return backup_list->currentItem()->data(Qt::UserRole).toString(); -} \ No newline at end of file +} + + +#include "backupwidget.moc"