add elapsed time to the image name

Add elapsed time to the image name when inserting an image.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2016-11-20 11:29:54 +08:00
parent 3ae3462597
commit de8b54afa7

View File

@ -9,6 +9,7 @@
#include <QMimeData> #include <QMimeData>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonDocument> #include <QJsonDocument>
#include <QDateTime>
VUtils::VUtils() VUtils::VUtils()
{ {
@ -71,6 +72,9 @@ QString VUtils::generateImageFileName(const QString &path, const QString &title,
QString baseName(title.toLower()); QString baseName(title.toLower());
baseName.replace(regExp, "_"); baseName.replace(regExp, "_");
baseName.prepend('_'); baseName.prepend('_');
// Add current time to make the name be most likely unique
baseName = baseName + '_' + QString::number(QDateTime::currentDateTime().toTime_t());
QString imageName = baseName + "." + format.toLower(); QString imageName = baseName + "." + format.toLower();
QString filePath = QDir(path).filePath(imageName); QString filePath = QDir(path).filePath(imageName);
int index = 1; int index = 1;