put queried information into our model
| 386 | |
| 387 | /// put queried information into our model |
| 388 | void Update(const QString& path, vtkPVFileInformation* dir) |
| 389 | { |
| 390 | this->CurrentPath = path; |
| 391 | this->FileList.clear(); |
| 392 | |
| 393 | QList<pqFileDialogModelFileInfo> dirs; |
| 394 | QList<pqFileDialogModelFileInfo> files; |
| 395 | |
| 396 | vtkSmartPointer<vtkCollectionIterator> iter; |
| 397 | iter.TakeReference(dir->GetContents()->NewIterator()); |
| 398 | |
| 399 | for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) |
| 400 | { |
| 401 | vtkPVFileInformation* info = vtkPVFileInformation::SafeDownCast(iter->GetCurrentObject()); |
| 402 | if (!info) |
| 403 | { |
| 404 | continue; |
| 405 | } |
| 406 | if (vtkPVFileInformation::IsDirectory(info->GetType())) |
| 407 | { |
| 408 | dirs.push_back(pqFileDialogModelFileInfo(QString::fromUtf8(info->GetName()), |
| 409 | QString::fromUtf8(info->GetFullPath()), |
| 410 | static_cast<vtkPVFileInformation::FileTypes>(info->GetType()), info->GetHidden(), |
| 411 | info->GetExtension(), info->GetSize(), info->GetModificationTime())); |
| 412 | } |
| 413 | else if (info->GetType() != vtkPVFileInformation::FILE_GROUP && |
| 414 | info->GetType() != vtkPVFileInformation::DIRECTORY_GROUP) |
| 415 | { |
| 416 | files.push_back(pqFileDialogModelFileInfo(QString::fromUtf8(info->GetName()), |
| 417 | QString::fromUtf8(info->GetFullPath()), |
| 418 | static_cast<vtkPVFileInformation::FileTypes>(info->GetType()), info->GetHidden(), |
| 419 | info->GetExtension(), info->GetSize(), info->GetModificationTime())); |
| 420 | } |
| 421 | else if (info->GetType() == vtkPVFileInformation::FILE_GROUP || |
| 422 | info->GetType() == vtkPVFileInformation::DIRECTORY_GROUP) |
| 423 | { |
| 424 | QList<pqFileDialogModelFileInfo> groupFiles; |
| 425 | vtkSmartPointer<vtkCollectionIterator> childIter; |
| 426 | childIter.TakeReference(info->GetContents()->NewIterator()); |
| 427 | for (childIter->InitTraversal(); !childIter->IsDoneWithTraversal(); |
| 428 | childIter->GoToNextItem()) |
| 429 | { |
| 430 | vtkPVFileInformation* child = |
| 431 | vtkPVFileInformation::SafeDownCast(childIter->GetCurrentObject()); |
| 432 | groupFiles.push_back(pqFileDialogModelFileInfo(/*QString::fromUtf8*/ (child->GetName()), |
| 433 | /*QString::fromUtf8*/ (child->GetFullPath()), |
| 434 | static_cast<vtkPVFileInformation::FileTypes>(child->GetType()), child->GetHidden(), |
| 435 | child->GetExtension(), child->GetSize(), child->GetModificationTime())); |
| 436 | } |
| 437 | |
| 438 | const bool as_files = (info->GetType() == vtkPVFileInformation::FILE_GROUP); |
| 439 | auto& container = as_files ? files : dirs; |
| 440 | container.push_back(pqFileDialogModelFileInfo(/*QString::fromUtf8*/ (info->GetName()), |
| 441 | groupFiles[0].filePath(), |
| 442 | (as_files ? vtkPVFileInformation::SINGLE_FILE : vtkPVFileInformation::DIRECTORY), |
| 443 | info->GetHidden(), info->GetExtension(), info->GetSize(), info->GetModificationTime(), |
| 444 | groupFiles)); |
| 445 | } |