diff options
author | Arno <arno@disconnect.de> | 2022-04-15 13:27:34 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2022-04-15 13:27:34 +0200 |
commit | 856119c5a43b4781b051b93a0713c152cfd99f85 (patch) | |
tree | 4e2fde4e7a76179cc243e0665091c6ad429ea640 /archivebrowser.cpp | |
parent | 62d3ca1482b202d2883eeb5e17e72300e8612477 (diff) | |
download | SheMov-856119c5a43b4781b051b93a0713c152cfd99f85.tar.gz SheMov-856119c5a43b4781b051b93a0713c152cfd99f85.tar.bz2 SheMov-856119c5a43b4781b051b93a0713c152cfd99f85.zip |
Make it run with Qt6
This is a huge commit. Changes:
* Obviously, make it compile
* Make it run (only scarcely tested)
* get rid of most of clang's warnings
Let's see what surprises are in store...
Diffstat (limited to 'archivebrowser.cpp')
-rw-r--r-- | archivebrowser.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/archivebrowser.cpp b/archivebrowser.cpp index a912eba..a30db3d 100644 --- a/archivebrowser.cpp +++ b/archivebrowser.cpp @@ -22,6 +22,7 @@ #include <QHeaderView> #include <QMenu> #include <QApplication> +#include <qactiongroup.h> #include "archivebrowser.h" #include "archivebrowsermodel.h" @@ -105,7 +106,7 @@ ArchiveBrowser::ArchiveBrowser(QWidget *parent) : QWidget(parent), mSelectedSize if(!mTree->header()->isSectionHidden(hData.value(h))){ a->setChecked(true); } - connect(a, &QAction::triggered, [=] { mTree->toggleHeader(a); }); + connect(a, &QAction::triggered, a, [=] { mTree->toggleHeader(a); }); } QIcon headerIcon = Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), 'H', true, false); QAction *headerA = new QAction(headerIcon, tr("Show headers"), this); @@ -140,6 +141,9 @@ ArchiveBrowser::ArchiveBrowser(QWidget *parent) : QWidget(parent), mSelectedSize } void ArchiveBrowser::browserSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { + if(selected.isEmpty() && deselected.isEmpty()){ + return; + } QModelIndexList selectedIdx = selectedRows(selected); QModelIndexList deselectedIdx = selectedRows(deselected); for(const QModelIndex &sel : selectedIdx){ @@ -191,13 +195,13 @@ void ArchiveBrowser::moveToBurn() { QString dirName = idx.data(ArchiveBrowserModel::NameRole).toString(); dirName.replace(' ', '.'); burnDir.mkdir(dirName); - QString burnDirS = QString("%1/%2").arg(destDirS).arg(dirName); + QString burnDirS = QString("%1/%2").arg(destDirS, dirName); QModelIndex real = mProxy->mapToSource(idx); QModelIndexList children = mModel->children(real); for(const QModelIndex &child : children){ QFileInfo current(child.data(ArchiveBrowserModel::FullPathRole).toString()); int type = child.data(ArchiveBrowserModel::FileTypeRole).toInt(); - QString destination = QString("%1/%2").arg(burnDirS).arg(current.fileName()); + QString destination = QString("%1/%2").arg(burnDirS, current.fileName()); if(type == FT_MOVIE){ QFile::rename(current.absoluteFilePath(), destination); filesToUpdate << child.data(ArchiveBrowserModel::GenericIdRole).toInt(); @@ -230,19 +234,19 @@ void ArchiveBrowser::moveToUSB(){ QString dvdDirS = QString("DVD_%1").arg(QString::number(nextDVDNo)); QDir dest(destDirS); if(dest.exists(dvdDirS)){ - QString msg = QString(tr("Something fishy is going on: %1 already exists in %2!")).arg(dvdDirS).arg(destDirS); + QString msg = QString(tr("Something fishy is going on: %1 already exists in %2!")).arg(dvdDirS, destDirS); QMessageBox::critical(this, tr("Error"), msg); return; } bool mkdir = dest.mkdir(dvdDirS); if(!mkdir){ - QString msg = QString(tr("Failed to create %1 in %2!")).arg(dvdDirS).arg(destDirS); + QString msg = QString(tr("Failed to create %1 in %2!")).arg(dvdDirS, destDirS); QMessageBox::critical(this, tr("Error"), msg); return; } // this one is .../DVD_123 - QString finalDir = QString("%1/%2").arg(destDirS).arg(dvdDirS); - QString msg = QString(tr("<p>This will do the following:</p><p><ul><li>Move %1 file(s) to %2</li><li>Update the DVD no. for %1 files</li></ul></p><p>Continue?</p>")).arg(sel.size()).arg(finalDir); + QString finalDir = QString("%1/%2").arg(destDirS, dvdDirS); + QString msg = QString(tr("<p>This will do the following:</p><p><ul><li>Move %1 file(s) to %2</li><li>Update the DVD no. for %1 files</li></ul></p><p>Continue?</p>")).arg(QString::number(sel.size()), finalDir); int retval = QMessageBox::question(this, tr("Question"), msg, QMessageBox::Yes | QMessageBox::No); if(retval == QMessageBox::Yes){ mCopyWorker->clear(); @@ -258,7 +262,7 @@ void ArchiveBrowser::moveToUSB(){ for(const QModelIndex &child : children){ QString source = child.data(ArchiveBrowserModel::FullPathRole).toString(); QFileInfo sFi(source); - QString destination = QString("%1/%2/%3").arg(finalDir).arg(dirName).arg(sFi.fileName()); + QString destination = QString("%1/%2/%3").arg(finalDir, dirName, sFi.fileName()); mCopyWorker->enqueue(source, destination); mCopyWorker->appendData(source, child.data(ArchiveBrowserModel::FileTypeRole)); mCopyWorker->appendData(source, child.data(ArchiveBrowserModel::GenericIdRole)); @@ -357,12 +361,14 @@ void ArchiveBrowser::copySuccess(QString success){ if(q == QMessageBox::Yes){ QHash<QString, QList<QVariant> > data = mCopyWorker->data(); QList<int> filesToUpdate; - for(const QString &source : data.keys()){ - int ft = data.value(source).at(0).toInt(); + auto i = data.constBegin(); + while(i != data.constEnd()){ + int ft = i.value().at(0).toInt(); if(ft == FT_MOVIE){ - QFile::remove(source); - filesToUpdate << data.value(source).at(1).toInt(); + QFile::remove(i.key()); + filesToUpdate << i.value().at(1).toInt(); } + ++i; } mModel->updateDVDNo(filesToUpdate); mModel->refresh(); |