|
|
|
@ -15,6 +15,8 @@
@@ -15,6 +15,8 @@
|
|
|
|
|
#include <QAbstractItemView> |
|
|
|
|
#include <QApplication> |
|
|
|
|
#include <QClipboard> |
|
|
|
|
#include <QFileDialog> |
|
|
|
|
#include <QDesktopServices> |
|
|
|
|
|
|
|
|
|
QString GUIUtil::dateTimeStr(qint64 nTime) |
|
|
|
|
{ |
|
|
|
@ -121,3 +123,50 @@ void GUIUtil::copyEntryData(QAbstractItemView *view, int column, int role)
@@ -121,3 +123,50 @@ void GUIUtil::copyEntryData(QAbstractItemView *view, int column, int role)
|
|
|
|
|
QApplication::clipboard()->setText(selection.at(0).data(role).toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption, |
|
|
|
|
const QString &dir, |
|
|
|
|
const QString &filter, |
|
|
|
|
QString *selectedSuffixOut) |
|
|
|
|
{ |
|
|
|
|
QString selectedFilter; |
|
|
|
|
QString myDir; |
|
|
|
|
if(dir.isEmpty()) // Default to user documents location
|
|
|
|
|
{ |
|
|
|
|
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
myDir = dir; |
|
|
|
|
} |
|
|
|
|
QString result = QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter); |
|
|
|
|
|
|
|
|
|
/* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */ |
|
|
|
|
QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); |
|
|
|
|
QString selectedSuffix; |
|
|
|
|
if(filter_re.exactMatch(selectedFilter)) |
|
|
|
|
{ |
|
|
|
|
selectedSuffix = filter_re.cap(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Add suffix if needed */ |
|
|
|
|
QFileInfo info(result); |
|
|
|
|
if(!result.isEmpty()) |
|
|
|
|
{ |
|
|
|
|
if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) |
|
|
|
|
{ |
|
|
|
|
/* No suffix specified, add selected suffix */ |
|
|
|
|
if(!result.endsWith(".")) |
|
|
|
|
result.append("."); |
|
|
|
|
result.append(selectedSuffix); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Return selected suffix if asked to */ |
|
|
|
|
if(selectedSuffixOut) |
|
|
|
|
{ |
|
|
|
|
*selectedSuffixOut = selectedSuffix; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|