WSL/SLF GitLab Repository

IniFolderView.h 2.04 KB
Newer Older
Mathias Bavay's avatar
Mathias Bavay committed
1
//SPDX-License-Identifier: GPL-3.0-or-later
2
3
4
5
6
/*****************************************************************************/
/*  Copyright 2019 WSL Institute for Snow and Avalanche Research  SLF-DAVOS  */
/*****************************************************************************/
/* This file is part of INIshell.
   INIshell is free software: you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
9
10
11
12
13
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   INIshell is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15

16
17
   You should have received a copy of the GNU General Public License
   along with INIshell.  If not, see <http://www.gnu.org/licenses/>.
18
19
20
21
22
23
24
*/

/*
 * This is a static panel (that can not be generated from XML) to navigate a folder structure.
 * 2019-10
 */

25
26
#ifndef INIFOLDERVIEW_H
#define INIFOLDERVIEW_H
27
28
29

#include <QFileSystemModel>
#include <QLabel>
30
#include <QMenu>
31
#include <QStack>
Michael Reisecker's avatar
Michael Reisecker committed
32
#include <QString>
33
34
35
#include <QTreeView>
#include <QWidget>

36
class IniFolderView : public QWidget {
37
38
39
	Q_OBJECT

	public:
40
		explicit IniFolderView(QWidget *parent = nullptr);
41
		void setEnabled(const bool &enabled);
42
43
		QLabel * getInfoLabel() const noexcept { return path_label_; } //for info why the view is disabled

44
45
	private:
		void setTreeIndex(const QModelIndex &index, const bool &no_stack = false);
46
		void createContextMenu();
47
		void updateLastPath();
48

49
50
51
52
		QFileSystemModel *filesystem_model_ = nullptr;
		QTreeView *filesystem_tree_ = nullptr;
		QLabel *path_label_ = nullptr;
		QStack<QModelIndex> prev_index_stack_;
53
		QMenu ini_folder_context_menu_;
54
55
56

	private slots:
		void onFilesysDoubleclicked(const QModelIndex &index);
57
		void onContextMenuRequest(QPoint);
58
59
60
		void onUpClicked();
		void onHomeClicked();
		void onBackClicked();
61
		void onWorkingClicked();
62
63
};

64
#endif //INIFOLDERVIEW_H