2018-01-11 13:49:42 +01:00
|
|
|
#include "cafInternalPdmFilePathStreamOperators.h"
|
|
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QTextStream& operator<<(QTextStream& str, const std::vector<caf::FilePath>& filePathObjects)
|
|
|
|
|
{
|
2018-01-12 14:55:59 +01:00
|
|
|
QStringList trimmedEntries;
|
|
|
|
|
|
2018-01-11 13:49:42 +01:00
|
|
|
for (const auto& filePath : filePathObjects)
|
|
|
|
|
{
|
2018-01-12 14:55:59 +01:00
|
|
|
QString text = filePath.path().trimmed();
|
|
|
|
|
|
|
|
|
|
if (text.isEmpty()) continue;
|
|
|
|
|
|
|
|
|
|
trimmedEntries.push_back(text);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-17 14:32:44 +01:00
|
|
|
for (int i = 0; i < trimmedEntries.size(); i++)
|
2018-01-12 14:55:59 +01:00
|
|
|
{
|
2018-01-17 13:37:41 +01:00
|
|
|
str << trimmedEntries[i];
|
2018-01-12 14:55:59 +01:00
|
|
|
|
2018-01-17 13:37:41 +01:00
|
|
|
if (i < trimmedEntries.size() - 1)
|
2018-01-12 14:55:59 +01:00
|
|
|
{
|
|
|
|
|
str << ";";
|
|
|
|
|
}
|
2018-01-11 13:49:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QTextStream& operator>>(QTextStream& str, std::vector<caf::FilePath>& filePathObjects)
|
|
|
|
|
{
|
|
|
|
|
QString stringSeparatedBySemicolon;
|
|
|
|
|
|
|
|
|
|
while (str.status() == QTextStream::Ok)
|
|
|
|
|
{
|
|
|
|
|
// Read QChar to avoid white space trimming when reading QString
|
|
|
|
|
QChar singleChar;
|
|
|
|
|
str >> singleChar;
|
|
|
|
|
|
2018-01-12 14:55:59 +01:00
|
|
|
if (!singleChar.isNull())
|
|
|
|
|
{
|
|
|
|
|
stringSeparatedBySemicolon += singleChar;
|
|
|
|
|
}
|
2018-01-11 13:49:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList splitBySemicolon = stringSeparatedBySemicolon.split(";");
|
2018-01-12 14:55:59 +01:00
|
|
|
for (const auto& s : splitBySemicolon)
|
2018-01-11 13:49:42 +01:00
|
|
|
{
|
2018-01-12 14:55:59 +01:00
|
|
|
QString trimmed = s.trimmed();
|
|
|
|
|
if (!trimmed.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
filePathObjects.push_back(trimmed);
|
|
|
|
|
}
|
2018-01-11 13:49:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|