Add tooltip with filenames

This commit is contained in:
2023-11-14 16:30:38 +01:00
parent fa69f17e51
commit 2608a1bc79
3 changed files with 19 additions and 2 deletions
+4
View File
@@ -123,6 +123,10 @@ QVariant FITSFileModel::data(const QModelIndex &index, int role) const
font.setBold(m_markedFiles.contains(file));
return font;
}
if(role == Qt::ToolTipRole && index.column() == 0)
{
return QSqlQueryModel::data(index, Qt::DisplayRole);
}
return QSqlQueryModel::data(index, role);
}
+7 -1
View File
@@ -45,11 +45,17 @@ void FilesystemWidget::fileClicked(const QModelIndex &index, const QModelIndex &
emit fileSelected(index.row());
}
QVariant FileSystemModel::data(const QModelIndex &index, int role) const
{
if(role == Qt::ToolTipRole && index.column() == 0)role = Qt::DisplayRole;
return QFileSystemModel::data(index, role);
}
Filetree::Filetree(QWidget *parent) : QTreeView(parent)
{
QSettings settings;
m_rootDir = settings.value("filetree/rootDir", QDir::homePath()).toString();
m_fileSystemModel = new QFileSystemModel(this);
m_fileSystemModel = new FileSystemModel(this);
m_fileSystemModel->setRootPath(m_rootDir);
m_fileSystemModel->setNameFilters({"*.fits", "*.fit", "*.xisf", "*.jpg", "*.jpeg", "*.png", "*.cr2", "*.nef", "*.dng"});
m_fileSystemModel->setNameFilterDisables(false);
+8 -1
View File
@@ -23,10 +23,17 @@ signals:
void reverseSort();
};
class FileSystemModel : public QFileSystemModel
{
public:
explicit FileSystemModel(QObject *parent) : QFileSystemModel(parent){}
QVariant data(const QModelIndex &index, int role) const override;
};
class Filetree : public QTreeView
{
Q_OBJECT
QFileSystemModel *m_fileSystemModel;
FileSystemModel *m_fileSystemModel;
QString m_rootDir;
public:
explicit Filetree(QWidget *parent = nullptr);