CuteLogger
Fast and simple logging solution for Qt based applications
filesdock.h
1/*
2 * Copyright (c) 2024-2025 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef FILESDOCK_H
19#define FILESDOCK_H
20
21#include <QDockWidget>
22#include <QUndoCommand>
23#include <QTimer>
24#include <QFileSystemModel>
25#include <QHash>
26#include <QMutex>
27
28namespace Ui {
29class FilesDock;
30}
31
32class QAbstractItemView;
33class QItemSelectionModel;
34class QMenu;
35class PlaylistIconView;
36class FilesModel;
37class FilesProxyModel;
38class QSortFilterProxyModel;
39class LineEditClear;
40class QLabel;
41
42class FilesDock : public QDockWidget
43{
44 Q_OBJECT
45
46public:
47 explicit FilesDock(QWidget *parent = 0);
48 ~FilesDock();
49
50 struct CacheItem {
51 int mediaType {-1}; // -1 = unknown
52 };
53
54 int getCacheMediaType(const QString &key);
55 void setCacheMediaType(const QString &key, int mediaType);
56
57signals:
58 void selectionChanged();
59
60public slots:
61 void onOpenActionTriggered();
62 void changeDirectory(const QString &path, bool updateLocation = true);
63 void changeFilesDirectory(const QModelIndex &index);
64
65private slots:
66 void viewCustomContextMenuRequested(const QPoint &pos);
67 void onMediaTypeClicked();
68 void onOpenOtherAdd();
69 void onOpenOtherRemove();
70 void clearStatus();
71 void updateStatus();
72 void onLocationsEditingFinished();
73
74 void on_locationsCombo_activated(int index);
75
76 void on_addLocationButton_clicked();
77
78 void on_removeLocationButton_clicked();
79
80protected:
81 void keyPressEvent(QKeyEvent *event);
82 void keyReleaseEvent(QKeyEvent *event);
83
84private:
85 void setupActions();
86 void emitDataChanged(const QVector<int> &roles);
87 void updateViewMode();
88 void onUpdateThumbnailsActionTriggered();
89 void onSelectAllActionTriggered();
90 void incrementIndex(int step);
91 void addOpenWithMenu(QMenu *menu);
92 QString firstSelectedFilePath();
93 QString firstSelectedMediaType();
94 void openClip(const QString &filePath);
95
96 Ui::FilesDock *ui;
97 QAbstractItemView *m_view;
98 PlaylistIconView *m_iconsView;
99 std::unique_ptr<QFileSystemModel> m_dirsModel;
100 FilesModel *m_filesModel;
101 QItemSelectionModel *m_selectionModel;
102 QMenu *m_mainMenu;
103 FilesProxyModel *m_filesProxyModel;
104 QHash<QString, CacheItem> m_cache;
105 QMutex m_cacheMutex;
106 LineEditClear *m_searchField;
107 QLabel *m_label;
108};
109
110#endif // FILESDOCK_H