mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-14 08:16:03 +02:00
Add helper function for QFileSelector
This commit is contained in:
parent
3ad6084b37
commit
5049bac6ff
2 changed files with 13 additions and 2 deletions
|
@ -38,6 +38,16 @@ const QStringList& FileUtils::getFileSelectors() {
|
|||
|
||||
}
|
||||
|
||||
QString FileUtils::selectFile(const QString& path) {
|
||||
QFileSelector fileSelector;
|
||||
fileSelector.setExtraSelectors(FileUtils::getFileSelectors());
|
||||
QString result = fileSelector.select(path);
|
||||
if (path != result) {
|
||||
qDebug() << "Using" << result << "instead of" << path;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString FileUtils::readFile(const QString& filename) {
|
||||
QFile file(filename);
|
||||
|
@ -51,7 +61,7 @@ QStringList FileUtils::readLines(const QString& filename, QString::SplitBehavior
|
|||
return readFile(filename).split(QRegularExpression("[\\r\\n]"), QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
void FileUtils::locateFile(QString filePath) {
|
||||
void FileUtils::locateFile(const QString& filePath) {
|
||||
|
||||
// adapted from
|
||||
// http://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt
|
||||
|
|
|
@ -18,7 +18,8 @@ class FileUtils {
|
|||
|
||||
public:
|
||||
static const QStringList& getFileSelectors();
|
||||
static void locateFile(QString fileName);
|
||||
static QString selectFile(const QString& fileName);
|
||||
static void locateFile(const QString& fileName);
|
||||
static QString standardPath(QString subfolder);
|
||||
static QString readFile(const QString& filename);
|
||||
static QStringList readLines(const QString& filename, QString::SplitBehavior splitBehavior = QString::KeepEmptyParts);
|
||||
|
|
Loading…
Reference in a new issue