ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ProjectView.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <QFileSystemModel>
11 #include <QTreeView>
12 
13 #include "ProjectViewContextMenu.h"
14 
16 
17 class ProjectView final : public QTreeView
18 {
19  Q_OBJECT
20 
21  friend class ProjectViewContextMenu;
22 
23  public:
24  explicit ProjectView(QWidget *parent = nullptr) : QTreeView(parent)
25  {
26  m_fileSystemModel = new QFileSystemModel;
27  QTreeView::setModel(m_fileSystemModel);
28 
29  m_contextMenu = new ProjectViewContextMenu(this);
30  setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
31 
32  for (int i{1}; i < size().width(); ++i)
33  {
34  hideColumn(i);
35  }
36  connect(this,
37  &QTreeView::customContextMenuRequested,
38  m_contextMenu,
40  }
41 
42  void setRootPath(const QString &path)
43  {
44  m_fileSystemModel->setRootPath(path);
45  setRootIndex(m_fileSystemModel->index(path));
46  }
47 
48  QString relativePathAt(const QModelIndex &index) const
49  {
50  return m_fileSystemModel->filePath(index);
51  }
52 
53  QString absolutePathAt(const QModelIndex &index) const
54  {
55  return m_fileSystemModel->rootDirectory().filePath(relativePathAt(index));
56  }
57 
58  private:
59  QFileSystemModel *m_fileSystemModel;
60  ProjectViewContextMenu *m_contextMenu;
61 };
int size
void requested(const QPoint &pos)
QString absolutePathAt(const QModelIndex &index) const
Definition: ProjectView.h:53
ProjectView(QWidget *parent=nullptr)
Definition: ProjectView.h:24
void setRootPath(const QString &path)
Definition: ProjectView.h:42
friend class ProjectViewContextMenu
Definition: ProjectView.h:21
QString relativePathAt(const QModelIndex &index) const
Definition: ProjectView.h:48
static const std::string path
Definition: PointCloud.cpp:59