| 40 | // pqFileDialogModelFileInfo |
| 41 | |
| 42 | class pqFileDialogModelFileInfo |
| 43 | { |
| 44 | public: |
| 45 | pqFileDialogModelFileInfo() |
| 46 | : Type(vtkPVFileInformation::INVALID) |
| 47 | , Hidden(false) |
| 48 | { |
| 49 | } |
| 50 | pqFileDialogModelFileInfo(const QString& l, const QString& filepath, |
| 51 | vtkPVFileInformation::FileTypes t, const bool& h, const QString& extension, |
| 52 | const long long& sizeVal, const time_t& modificationTimeVal, |
| 53 | const QList<pqFileDialogModelFileInfo>& g = QList<pqFileDialogModelFileInfo>()) |
| 54 | : Label(l) |
| 55 | , FilePath(filepath) |
| 56 | , Type(t) |
| 57 | , Hidden(h) |
| 58 | , Group(g) |
| 59 | , Extension(extension) |
| 60 | , ModificationTime(modificationTimeVal) |
| 61 | , Size(sizeVal) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | const QString& label() const { return this->Label; } |
| 66 | |
| 67 | const QString& filePath() const { return this->FilePath; } |
| 68 | |
| 69 | vtkPVFileInformation::FileTypes type() const { return this->Type; } |
| 70 | |
| 71 | bool isGroup() const { return !this->Group.empty(); } |
| 72 | |
| 73 | bool isHidden() const { return this->Hidden; } |
| 74 | |
| 75 | const QList<pqFileDialogModelFileInfo>& group() const { return this->Group; } |
| 76 | |
| 77 | QString extensionTypeString() const |
| 78 | { |
| 79 | if (this->Type == vtkPVFileInformation::DIRECTORY) |
| 80 | { |
| 81 | return QCoreApplication::translate("pqFileDialogModel", "Folder"); |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | return QString("%1%2%3") |
| 86 | .arg(this->Extension) |
| 87 | .arg(this->Extension.isEmpty() ? "" : " ") |
| 88 | .arg(QCoreApplication::translate("pqFileDialogModel", "File")); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | QString sizeString() const |
| 93 | { |
| 94 | if (this->Type == vtkPVFileInformation::DIRECTORY) |
| 95 | { |
| 96 | return QString(); |
| 97 | } |
| 98 | const long long kb = 1024; |
| 99 | const long long mb = 1024 * kb; |