解决插入扫描时不同格式文件名重命名时导致的混乱问题
This commit is contained in:
parent
7e737416d8
commit
3a6e2d69d4
|
@ -1347,7 +1347,7 @@ void MainWindow::on_scanFinishEvent()
|
||||||
assert(ScanType_InsertScanInto == m_scanType);
|
assert(ScanType_InsertScanInto == m_scanType);
|
||||||
assert(-1 != m_scanInsertPos);
|
assert(-1 != m_scanInsertPos);
|
||||||
|
|
||||||
std::list<QString> backupFileNames;
|
std::list<QString> backupNames;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
m_thumb->getItemCount(&count);
|
m_thumb->getItemCount(&count);
|
||||||
|
@ -1363,8 +1363,12 @@ void MainWindow::on_scanFinishEvent()
|
||||||
{
|
{
|
||||||
HGChar filePath[256];
|
HGChar filePath[256];
|
||||||
HGBase_GetFilePath(fileName.toLocal8Bit().toStdString().c_str(), filePath, 256);
|
HGBase_GetFilePath(fileName.toLocal8Bit().toStdString().c_str(), filePath, 256);
|
||||||
|
HGChar name[256];
|
||||||
|
HGBase_GetFileName(fileName.toLocal8Bit().toStdString().c_str(), name, 256);
|
||||||
|
HGChar filePrefix[256];
|
||||||
|
HGBase_GetFilePrefix(name, filePrefix, 256);
|
||||||
HGChar fileSuffix[256];
|
HGChar fileSuffix[256];
|
||||||
HGBase_GetFileSuffix(fileName.toLocal8Bit().toStdString().c_str(), fileSuffix, 256);
|
HGBase_GetFileSuffix(name, fileSuffix, 256);
|
||||||
HGChar uuid[256];
|
HGChar uuid[256];
|
||||||
HGBase_GetUuid(uuid, 256);
|
HGBase_GetUuid(uuid, 256);
|
||||||
|
|
||||||
|
@ -1378,7 +1382,7 @@ void MainWindow::on_scanFinishEvent()
|
||||||
m_thumb->updateItem(fileName, newFileName, false);
|
m_thumb->updateItem(fileName, newFileName, false);
|
||||||
|
|
||||||
m_curBatchFileList.erase(iter);
|
m_curBatchFileList.erase(iter);
|
||||||
backupFileNames.push_back(fileName);
|
backupNames.push_back(filePrefix);
|
||||||
m_curBatchTmpFileList.push_back(newFileName);
|
m_curBatchTmpFileList.push_back(newFileName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1388,19 +1392,6 @@ void MainWindow::on_scanFinishEvent()
|
||||||
std::list<QString>::iterator iter;
|
std::list<QString>::iterator iter;
|
||||||
for (iter = m_curBatchTmpFileList.begin(); iter != m_curBatchTmpFileList.end(); ++iter)
|
for (iter = m_curBatchTmpFileList.begin(); iter != m_curBatchTmpFileList.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (!backupFileNames.empty())
|
|
||||||
{
|
|
||||||
QString &newFileName = backupFileNames.front();
|
|
||||||
|
|
||||||
QFile file(*iter);
|
|
||||||
file.rename(newFileName);
|
|
||||||
m_thumb->updateItem(*iter, newFileName, false);
|
|
||||||
m_curBatchFileList.push_back(newFileName);
|
|
||||||
|
|
||||||
backupFileNames.erase(backupFileNames.begin());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
HGChar filePath[256];
|
HGChar filePath[256];
|
||||||
HGBase_GetFilePath((*iter).toLocal8Bit().toStdString().c_str(), filePath, 256);
|
HGBase_GetFilePath((*iter).toLocal8Bit().toStdString().c_str(), filePath, 256);
|
||||||
HGChar fileSuffix[256];
|
HGChar fileSuffix[256];
|
||||||
|
@ -1410,27 +1401,57 @@ void MainWindow::on_scanFinishEvent()
|
||||||
QString strFileSuffix = QString::fromLocal8Bit(fileSuffix);
|
QString strFileSuffix = QString::fromLocal8Bit(fileSuffix);
|
||||||
|
|
||||||
QString newFileName;
|
QString newFileName;
|
||||||
while (1)
|
while (!backupNames.empty())
|
||||||
{
|
{
|
||||||
newFileName = strFilePath + m_aquireIntoSaveParam.m_fileNamePrefix + QString("%1.%2")
|
QString fileName = strFilePath + backupNames.front() + "." + strFileSuffix;
|
||||||
.arg(m_aquireIntoSaveParam.m_fileNameStartIndex, m_aquireIntoSaveParam.m_fileNameDigits, 10, QLatin1Char('0'))
|
QFileInfo fileInfo(fileName);
|
||||||
.arg(strFileSuffix);
|
|
||||||
QFileInfo fileInfo(newFileName);
|
|
||||||
if (fileInfo.isFile())
|
if (fileInfo.isFile())
|
||||||
{
|
{
|
||||||
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
backupNames.erase(backupNames.begin());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
newFileName = fileName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(*iter);
|
if (!newFileName.isEmpty())
|
||||||
file.rename(newFileName);
|
{
|
||||||
m_thumb->updateItem(*iter, newFileName, false);
|
QFile file(*iter);
|
||||||
m_curBatchFileList.push_back(newFileName);
|
file.rename(newFileName);
|
||||||
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
m_thumb->updateItem(*iter, newFileName, false);
|
||||||
|
m_curBatchFileList.push_back(newFileName);
|
||||||
|
backupNames.erase(backupNames.begin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
QString fileName = strFilePath + m_aquireIntoSaveParam.m_fileNamePrefix + QString("%1.%2")
|
||||||
|
.arg(m_aquireIntoSaveParam.m_fileNameStartIndex, m_aquireIntoSaveParam.m_fileNameDigits, 10, QLatin1Char('0'))
|
||||||
|
.arg(strFileSuffix);
|
||||||
|
QFileInfo fileInfo(fileName);
|
||||||
|
if (fileInfo.isFile())
|
||||||
|
{
|
||||||
|
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFileName = fileName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newFileName.isEmpty())
|
||||||
|
{
|
||||||
|
QFile file(*iter);
|
||||||
|
file.rename(newFileName);
|
||||||
|
m_thumb->updateItem(*iter, newFileName, false);
|
||||||
|
m_curBatchFileList.push_back(newFileName);
|
||||||
|
++m_aquireIntoSaveParam.m_fileNameStartIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_curBatchTmpFileList.clear();
|
m_curBatchTmpFileList.clear();
|
||||||
|
|
Loading…
Reference in New Issue