Commit bfe67ff4 authored by Mathieu Westphal's avatar Mathieu Westphal Committed by Kitware Robot
Browse files

Merge topic 'fixup_favorites_fetch_dir_release_2' into release

c8437df9

 Only fetch favorites from server on creation

Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Timothee Chabat's avatarTimothee Chabat <timothee.chabat@kitware.com>
Acked-by: Cory Quammen's avatarCory Quammen <cory.quammen@kitware.com>
Merge-request: !5520
parents bdbeda7d c8437df9
......@@ -89,8 +89,20 @@ pqFileDialogFavoriteModel::pqFileDialogFavoriteModel(
for (QVariant const& fileInfo : fileInfos)
{
auto fileInfoList = fileInfo.toList();
QString path = fileInfoList[1].toString();
// If it is the Examples dir placeholder, replace it with the real path to the examples.
if (path == "_examples_path_")
{
// this will not be stored in the favorites
path = QString::fromStdString(vtkPVFileInformation::GetParaViewExampleFilesDirectory());
}
// Check type and existence on creation
int type = this->FileDialogModel->fileType(path);
this->FavoriteList.push_back(pqFileDialogFavoriteModelFileInfo{
fileInfoList[0].toString(), fileInfoList[1].toString(), fileInfoList[2].toInt() });
fileInfoList[0].toString(), fileInfoList[1].toString(), type });
}
}
else
......@@ -156,7 +168,6 @@ QVariant pqFileDialogFavoriteModel::data(const QModelIndex& idx, int role) const
}
QString temp;
bool exist = this->FileDialogModel->dirExists(dir, temp);
switch (role)
{
case Qt::DisplayRole:
......@@ -165,16 +176,16 @@ QVariant pqFileDialogFavoriteModel::data(const QModelIndex& idx, int role) const
case Qt::UserRole:
return dir;
case Qt::ItemDataRole::ToolTipRole:
if (exist)
if (file.Type != vtkPVFileInformation::INVALID)
{
return dir;
}
else
{
return dir + " (Warning: does not exist)";
return dir + " (Warning: invalid)";
}
case Qt::ItemDataRole::FontRole:
if (exist)
if (file.Type != vtkPVFileInformation::INVALID)
{
return {};
}
......@@ -186,7 +197,7 @@ QVariant pqFileDialogFavoriteModel::data(const QModelIndex& idx, int role) const
}
case Qt::ItemDataRole::ForegroundRole:
if (exist)
if (file.Type != vtkPVFileInformation::INVALID)
{
return {};
}
......@@ -198,14 +209,7 @@ QVariant pqFileDialogFavoriteModel::data(const QModelIndex& idx, int role) const
}
case Qt::DecorationRole:
if (exist)
{
return Icons()->icon(static_cast<vtkPVFileInformation::FileTypes>(file.Type));
}
else
{
return QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
}
return Icons()->icon(static_cast<vtkPVFileInformation::FileTypes>(file.Type));
}
return QVariant();
......
......@@ -174,6 +174,7 @@ private:
pqFileDialogModelIconProvider::pqFileDialogModelIconProvider()
{
QStyle* style = QApplication::style();
this->InvalidIcon = style->standardIcon(QStyle::SP_MessageBoxWarning);
this->FolderLinkIcon = style->standardIcon(QStyle::SP_DirLinkIcon);
this->FileLinkIcon = style->standardIcon(QStyle::SP_FileLinkIcon);
this->DomainIcon.addPixmap(QPixmap(":/pqCore/Icons/pqDomain16.png"));
......@@ -184,6 +185,8 @@ QIcon pqFileDialogModelIconProvider::icon(IconType t) const
{
switch (t)
{
case Invalid:
return this->InvalidIcon;
case Computer:
return QFileIconProvider::icon(QFileIconProvider::Computer);
case Drive:
......@@ -208,6 +211,10 @@ QIcon pqFileDialogModelIconProvider::icon(IconType t) const
QIcon pqFileDialogModelIconProvider::icon(vtkPVFileInformation::FileTypes f) const
{
if (f == vtkPVFileInformation::INVALID)
{
return icon(pqFileDialogModelIconProvider::Invalid);
}
if (f == vtkPVFileInformation::DIRECTORY_LINK)
{
return icon(pqFileDialogModelIconProvider::FolderLink);
......
......@@ -203,6 +203,7 @@ class pqFileDialogModelIconProvider : protected QFileIconProvider
public:
enum IconType
{
Invalid,
Computer,
Drive,
Folder,
......@@ -221,6 +222,7 @@ protected:
QIcon icon(const QFileInfo& info) const override;
QIcon icon(QFileIconProvider::IconType ico) const override;
QIcon InvalidIcon;
QIcon FolderLinkIcon;
QIcon FileLinkIcon;
QIcon DomainIcon;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment