CuteLogger
Fast and simple logging solution for Qt based applications
filesdock.h
1/*
2 * Copyright (c) 2024 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;
39
40class FilesDock : public QDockWidget
41{
42 Q_OBJECT
43
44public:
45 explicit FilesDock(QWidget *parent = 0);
46 ~FilesDock();
47
48 struct CacheItem {
49 int mediaType {-1}; // -1 = unknown
50 };
51
52 int getCacheMediaType(const QString &key);
53 void setCacheMediaType(const QString &key, int mediaType);
54
55signals:
56 void clipOpened(QString);
57 void selectionChanged();
58
59public slots:
60 void onOpenActionTriggered();
61 void changeDirectory(const QString &path);
62
63private slots:
64 void viewCustomContextMenuRequested(const QPoint &pos);
65 void onMediaTypeClicked();
66 void onOpenOtherAdd();
67 void onOpenOtherRemove();
68
69 void on_locationsCombo_activated(int index);
70
71 void on_addLocationButton_clicked();
72
73 void on_removeLocationButton_clicked();
74
75protected:
76 void keyPressEvent(QKeyEvent *event);
77 void keyReleaseEvent(QKeyEvent *event);
78
79private:
80 void setupActions();
81 void emitDataChanged(const QVector<int> &roles);
82 void updateViewMode();
83 void onUpdateThumbnailsActionTriggered();
84 void onSelectAllActionTriggered();
85 void incrementIndex(int step);
86 void addOpenWithMenu(QMenu *menu);
87 QString firstSelectedFilePath();
88 QString firstSelectedMediaType();
89
90 Ui::FilesDock *ui;
91 QAbstractItemView *m_view;
92 PlaylistIconView *m_iconsView;
93 std::unique_ptr<QFileSystemModel> m_dirsModel;
94 FilesModel *m_filesModel;
95 QItemSelectionModel *m_selectionModel;
96 QMenu *m_mainMenu;
97 FilesProxyModel *m_filesProxyModel;
98 QHash<QString, CacheItem> m_cache;
99 QMutex m_cacheMutex;
100};
101
102#endif // FILESDOCK_H