trikRuntime
fileManagerWidget.h
Go to the documentation of this file.
1 /* Copyright 2013 Roman Kurbatov
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 /* This file was modified by Yurii Litvinov to make it comply with the requirements of trikRuntime
16  * project. See git revision history for detailed changes. */
17 
18 #pragma once
19 
20 #include <QtCore/qglobal.h>
21 
22 #include <QVBoxLayout>
23 #include <QLabel>
24 #include <QListView>
25 #include <QFileSystemModel>
26 #include <QFileIconProvider>
27 
28 #include "fileSystemFilter.h"
29 #include "controller.h"
30 #include "trikGuiDialog.h"
31 
32 namespace trikGui {
33 
36 {
37  Q_OBJECT
38 
39 public:
44  explicit FileManagerWidget(Controller &controller, MainWidget::FileManagerRootType fileManagerRoot
45  , QWidget *parent = 0);
46 
47  ~FileManagerWidget() override;
48 
50  static QString menuEntry();
51 
52  void renewFocus() override;
53 
54 protected:
55  void keyPressEvent(QKeyEvent *event) override;
56 
57 private slots:
58  void onDirectoryLoaded(const QString &path);
59  void renewCurrentIndex();
60  void onSelectionChanged(QModelIndex current, QModelIndex previous);
61 
62 private:
63  void showCurrentDir();
64  void open();
65  void remove();
66  void removeAll();
67  QString currentPath();
68 
69  QVBoxLayout mLayout;
70  QLabel mCurrentPathLabel;
71  QListView mFileSystemView;
72  QFileSystemModel mFileSystemModel;
73  Controller &mController;
74  QString mRootDirPath;
75  QString mLastSelectedFile;
76  QString mDeleteAllFilesPath;
77  QString mDeleteAllFilesName;
78  FileSystemFilter mFilterProxyModel;
79 
83  class LightFileIconProvider : public QFileIconProvider {
84  public:
86  QIcon icon(IconType) const override;
87 
89  QIcon icon(const QFileInfo &) const override;
90 
92  QString type(const QFileInfo &) const override;
93  };
94 };
95 
96 }
Provides backend features like Qt Script runner for frontend.
Definition: controller.h:35
Filter to sort special "Delete all..." entry.
Definition: fileSystemFilter.h:20
FileManagerWidget(Controller &controller, MainWidget::FileManagerRootType fileManagerRoot, QWidget *parent=0)
Constructor.
Definition: fileManagerWidget.cpp:39
Base class for all trikGui dialog widgets.
Definition: trikGuiDialog.h:24
~FileManagerWidget() override
Definition: fileManagerWidget.cpp:102
static QString menuEntry()
Returns main menu entry string for this widget.
Definition: fileManagerWidget.cpp:108
void keyPressEvent(QKeyEvent *event) override
Definition: fileManagerWidget.cpp:162
void renewFocus() override
Set focus properly on this widget or one of its children.
Definition: fileManagerWidget.cpp:113
Definition: abstractIndicator.h:21
File system browser able to launch executable files and .qts scripts.
Definition: fileManagerWidget.h:35
FileManagerRootType
Definition: mainWidget.h:33