You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.8 KiB
C++
105 lines
2.8 KiB
C++
#include "FITKCFDPostUnSteady.h"
|
|
#include "FITKCFDPostEnum.h"
|
|
|
|
#include <QDir>
|
|
#include <QDebug>
|
|
#include <QCollator>
|
|
|
|
namespace Interface
|
|
{
|
|
QStringList getSelectGroupFiles(const QString path)
|
|
{
|
|
QStringList groupFiles;
|
|
|
|
//截取目录路径
|
|
int indexSlash = path.lastIndexOf("/");
|
|
QString directory = path.left(indexSlash);
|
|
|
|
QDir dir(directory);
|
|
if (!dir.exists())
|
|
{
|
|
//path error
|
|
return QStringList();
|
|
}
|
|
|
|
if (dir.cd(directory))
|
|
{
|
|
dir.setFilter(QDir::Files);
|
|
dir.setSorting(QDir::Name);
|
|
|
|
//后缀名过滤
|
|
int indexDot = path.lastIndexOf(".");
|
|
QString ext = path.mid(indexDot, path.length() - indexDot);
|
|
QStringList fiter{};
|
|
fiter.append("*" + ext);
|
|
dir.setNameFilters(fiter);
|
|
|
|
//截取组名
|
|
QString regGroupName = path.mid(indexSlash + 1, path.length() - indexSlash);
|
|
int indexFirstDot = regGroupName.indexOf(".");
|
|
QString prefix = regGroupName.left(indexFirstDot);
|
|
|
|
QFileInfoList list = dir.entryInfoList();
|
|
|
|
if (list.count() > 0)
|
|
{
|
|
for (int i = 0; i < list.count(); i++)
|
|
{
|
|
QFileInfo fileInfo = list.at(i);
|
|
QString fileName = fileInfo.fileName();
|
|
if (fileName.mid(0, prefix.length()) == prefix)
|
|
{
|
|
groupFiles.append(fileInfo.absoluteFilePath());
|
|
}
|
|
}
|
|
}
|
|
|
|
//对文件列表进行排序
|
|
QCollator collator;
|
|
collator.setNumericMode(true);
|
|
std::sort(groupFiles.begin(), groupFiles.end(),
|
|
[&collator](const QString & str1, const QString & str2)
|
|
{
|
|
return collator.compare(str1, str2) < 0;
|
|
}
|
|
);
|
|
}
|
|
|
|
return groupFiles;
|
|
}
|
|
|
|
FITKCFDPostUnSteady::FITKCFDPostUnSteady(QString fileType, QString& file) :
|
|
FITKCFDPostSteady(fileType)
|
|
{
|
|
_files = getSelectGroupFiles(file);
|
|
if (_files.size() == 0)return;
|
|
}
|
|
|
|
FITKCFDPostUnSteady::~FITKCFDPostUnSteady()
|
|
{
|
|
|
|
}
|
|
|
|
FITKPostDataType FITKCFDPostUnSteady::getPostDataType()
|
|
{
|
|
return FITKPostDataType::Post_UnSteady;
|
|
}
|
|
|
|
void FITKCFDPostUnSteady::setFile(QString& fileName)
|
|
{
|
|
if (fileName.isEmpty())return;
|
|
if (!_files.contains(fileName))return;
|
|
_currentIndex = _files.indexOf(fileName);
|
|
FITKCFDPostSteady::setFile(fileName);
|
|
}
|
|
|
|
QStringList FITKCFDPostUnSteady::getFiles()
|
|
{
|
|
return _files;
|
|
}
|
|
|
|
int FITKCFDPostUnSteady::getCurrentIndex()
|
|
{
|
|
return _currentIndex;
|
|
}
|
|
} |