The file browser listed only *_master.h5, *_process.h5 and *.cbf, and the open dialog had no filter covering frames numbered in their extension, so a marCCD or ADSC sweep written as name.001 / name.0001 was invisible in both, as were .cbf.gz, .mccd, .osc, .sfrm, .nxs, .cxi and .xtc in the browser. One list of wildcards (reader/FileNamePatterns.h) now serves both: the HDF5 masters and processing results, .nxs, .cxi, .xtc, the raw frame extensions and frame numbers of three to five digits. The open dialog offers it first as "All supported", plus any .h5 and .geom for the files of an XFEL run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQrPqZ52Tp6rzzZGxf3
66 lines
2.9 KiB
C++
66 lines
2.9 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QFileSystemModel>
|
|
#include <QSortFilterProxyModel>
|
|
#include <QHash>
|
|
#include <QDateTime>
|
|
|
|
class QLineEdit;
|
|
class QTreeView;
|
|
class QModelIndex;
|
|
|
|
// Left-side dock alternative to the Processing (reprocessing settings) panel: a directory tree rooted at a
|
|
// configurable data root, filtered down to subdirectories and the files the viewer opens, for browsing to and opening a dataset without caring about reprocessing. Backed by QFileSystemModel,
|
|
// which only lists a directory once it is expanded - so a root with hundreds of sibling directories
|
|
// (e.g. an SLS beamline's /sls/mx/data/) costs one readdir at each level actually opened, never a
|
|
// recursive scan of the whole tree.
|
|
//
|
|
// New files show up by themselves: F5 (or the refresh button) re-lists the root and every expanded
|
|
// directory at once, and a timer does the same every few seconds while the panel is visible. The model's
|
|
// own inotify watching covers a local disk, but not files written by another host onto NFS/GPFS/Lustre,
|
|
// which is exactly how a detector writer fills a beamline's data directory - hence the polling.
|
|
class JFJochViewerFileBrowser : public QWidget {
|
|
Q_OBJECT
|
|
|
|
QLineEdit *root_edit_;
|
|
QLineEdit *filter_edit_;
|
|
QTreeView *tree_;
|
|
QFileSystemModel *model_;
|
|
QSortFilterProxyModel *proxy_;
|
|
// Modification time of each directory when it was last listed, so a poll re-lists only those that changed.
|
|
QHash<QString, QDateTime> listed_mtime_;
|
|
|
|
void SetRoot(const QString &path);
|
|
void CollectExpanded(const QModelIndex &parent, QStringList &dirs) const;
|
|
[[nodiscard]] static QString DefaultRoot();
|
|
// An SLS account eNNNNN browses its proposal group's raw data, which is pNNNNN with the
|
|
// same five digits; empty for any other user name, on any platform.
|
|
[[nodiscard]] static QString SlsDataRoot(const QString &user);
|
|
|
|
public slots:
|
|
// "Reset all settings to defaults": back to the root a fresh start would pick.
|
|
void ResetToDefaultRoot();
|
|
// Re-list the root and the expanded directories; unless forced, only those modified since last time.
|
|
void Refresh(bool force = true);
|
|
|
|
private slots:
|
|
void onBrowseClicked();
|
|
void onRootEditingFinished();
|
|
void onDoubleClicked(const QModelIndex &index);
|
|
|
|
signals:
|
|
// Mirrors JFJochViewerMenu::fileOpenSelected, so the window wires it to LoadFile the same way.
|
|
void openDataset(const QString &filename, qint64 image_number, qint64 summation, bool retry);
|
|
|
|
public:
|
|
explicit JFJochViewerFileBrowser(QWidget *parent = nullptr);
|
|
|
|
// A dataset opened elsewhere (menu, D-Bus) and lying inside the current root moves the tree's
|
|
// selection to it; one outside the root leaves the browser exactly as it was.
|
|
void FollowPath(const QString &path);
|
|
};
|