QTfrontend/ui/page/pagevideos.cpp
changeset 14893 b5a9dd36c7ea
parent 14892 a414d37278df
child 14947 05cde9ba4183
--- a/QTfrontend/ui/page/pagevideos.cpp	Mon May 06 00:43:27 2019 +0200
+++ b/QTfrontend/ui/page/pagevideos.cpp	Mon May 06 01:25:50 2019 +0200
@@ -292,6 +292,7 @@
         VideoItem * item = nameItem(row);
         item->seen = true;
         item->desc = "";
+        setName(item, item->name);
         updateSize(row);
     }
 
@@ -426,8 +427,16 @@
         }
     }
     else
+        newPrefix = newName;
+    for (int i = 0; i < filesTable->rowCount(); i++)
     {
-        newPrefix = newName;
+        // don't allow rename if duplicate prefix
+        VideoItem * iterateItem = nameItem(i);
+        if ((i != row) && (newPrefix == iterateItem->prefix))
+        {
+            setName(item, oldName);
+            return;
+        }
     }
 #ifdef Q_OS_WIN
     // there is a bug in qt, QDir::rename() doesn't fail on such names but damages files
@@ -460,6 +469,15 @@
     item->setText(newName);
     nameChangedFromCode = false;
     item->name = newName;
+    // try to extract prefix
+    if (item->ready())
+        item->prefix = item->name;
+    else
+        item->prefix = item->pRecorder->name;
+    // remove extension
+    int pt = item->prefix.lastIndexOf('.');
+    if (pt != -1)
+        item->prefix.truncate(pt);
 }
 
 int PageVideos::appendRow(const QString & name)
@@ -546,7 +564,7 @@
         desc += item->desc + '\n';
     }
 
-    if (item->prefix.isEmpty())
+    if (item->prefix.isNull() || item->prefix.isEmpty())
     {
         // try to extract prefix from file name instead
         if (item->ready())