@@ -759,20 +759,20 @@ QMenu* MediaGroupListWidget::dirMenu(const char* slot) {
759759 const QModelIndex index = currentIndex ();
760760 if (index.isValid ()) selectedIndex = index.row ();
761761
762- for (int i = 0 ; i < group.count (); ++i)
763- if (i != selectedIndex) {
764- const auto & m = group.at (i);
765- if (!MediaPage::isAnalysis (m)) {
766- QString path = m.dirPath ();
767- if (m.isArchived ()) {
768- m.archivePaths (&path);
769- auto list = path.split (lc (' /' ));
770- list.removeLast ();
771- path = list.join (lc (' /' ));
772- }
773- groupDirs.insert (path);
774- }
762+ for (int i = 0 ; i < group.count (); ++i) {
763+ const Media& m = group.at (i);
764+ if (i == selectedIndex) continue ;
765+ if (MediaPage::isAnalysis (m)) continue ;
766+
767+ QString path = m.dirPath ();
768+ if (m.isArchived ()) {
769+ int index = path.lastIndexOf (u' /' ); // parent dir of zipfile
770+ if (index >= 0 ) path = path.mid (0 , index);
771+ }
772+ if (!path.isEmpty ()) {
773+ groupDirs.insert (path);
775774 }
775+ }
776776
777777 const auto & keys = groupDirs.values ();
778778 QList<QAction*> actions;
@@ -964,9 +964,6 @@ void MediaGroupListWidget::removeSelection(bool deleteFiles, bool replace) {
964964 Q_ASSERT (index >=0 && index < groupCount);
965965 const Media& m = page->group [index];
966966
967- QString path = m.path ();
968- if (m.isArchived ()) m.archivePaths (&path);
969-
970967 if (!deleteFiles) {
971968 removedIndices.insert (index);
972969 if (m.isValid ())
@@ -987,6 +984,7 @@ void MediaGroupListWidget::removeSelection(bool deleteFiles, bool replace) {
987984 continue ;
988985 }
989986
987+ QString path = m.containerPath ();
990988 {
991989 static bool skipDeleteConfirmation = false ;
992990 int button = 0 ;
@@ -1206,12 +1204,7 @@ void MediaGroupListWidget::renameFileAction() {
12061204
12071205 // names of matches
12081206 for (auto & m2 : group) {
1209- if (m2.isArchived ()) {
1210- QString fileName;
1211- m2.archivePaths (nullptr , &fileName);
1212- maybeAppend (completions, fileName);
1213- } else
1214- maybeAppend (completions, m2.name ());
1207+ maybeAppend (completions, m2.name ());
12151208 }
12161209
12171210 // also files in same directory
@@ -1265,13 +1258,7 @@ void MediaGroupListWidget::copyNameAction() {
12651258 }
12661259
12671260 const QFileInfo info (selected->path ());
1268- QString otherName;
1269- if (other->isArchived ())
1270- other->archivePaths (nullptr , &otherName);
1271- else
1272- otherName = other->name (); // TODO: should name() work with archives?
1273-
1274- QString newName = QFileInfo (otherName).completeBaseName () + " ." + info.suffix ();
1261+ const QString newName = other->completeBaseName () + u' .' + info.suffix ();
12751262 const QString oldPath = selected->path ();
12761263 if (_options.db ) {
12771264 if (_options.db ->rename (*selected, newName))
@@ -1351,16 +1338,11 @@ void MediaGroupListWidget::moveFolderAction() {
13511338 QSet<QString> moved;
13521339
13531340 for (Media& m : selectedMedia ()) {
1354- QString srcPath;
1355- if (m.isArchived ())
1356- m.archivePaths (&srcPath);
1357- else
1358- srcPath = m.dirPath ();
1359-
1341+ const QString srcPath = m.dirPath ();
13601342 if (moved.contains (srcPath)) // already moved
13611343 continue ;
13621344
1363- const QString dstPath = dirPath + " / " + QFileInfo (srcPath).fileName ();
1345+ const QString dstPath = dirPath + u ' / ' + QFileInfo (srcPath).fileName ();
13641346 moveDatabaseDir (m, dstPath);
13651347 moved += srcPath;
13661348 }
@@ -1881,11 +1863,7 @@ void MediaGroupListWidget::browseParentAction() {
18811863 }
18821864
18831865 const Media& m = g.first ();
1884- QString path;
1885- if (m.isArchived ())
1886- m.archivePaths (&path);
1887- else
1888- path = m.dirPath ();
1866+ const QString path = m.dirPath ();
18891867
18901868 MediaGroup siblings = _options.db ->mediaWithPathLike (path + lc (' %' ));
18911869 Media::sortGroup (siblings, {qq (" path" )});
@@ -2002,17 +1980,15 @@ void MediaGroupListWidget::updateItems() {
20021980 }
20031981
20041982 int fileCount = 0 ;
2005- if (m. isArchived ()) {
1983+ if (auto archive = m. parseArchivePath ()) {
20061984 // can be slow for large archives, we can cache since
20071985 // archives are immutable here
2008- QString archivePath;
2009- m.archivePaths (&archivePath);
2010- auto it = _archiveFileCount.find (archivePath);
1986+ auto it = _archiveFileCount.find (archive->parentPath );
20111987 if (it != _archiveFileCount.end ())
20121988 fileCount = *it;
20131989 else {
20141990 fileCount = m.archiveCount ();
2015- _archiveFileCount.insert (archivePath , fileCount);
1991+ _archiveFileCount.insert (archive-> parentPath . toString () , fileCount);
20161992 }
20171993 } else if (fileInfo.isFile ()) {
20181994 const auto key = fileInfo.absolutePath ();
0 commit comments