LMMS
Loading...
Searching...
No Matches
EffectSelectDialog.h
Go to the documentation of this file.
1/*
2 * EffectSelectDialog.h - dialog to choose effect plugin
3 *
4 * Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2023 Lost Robot <r94231/at/gmail.com>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_GUI_EFFECT_SELECT_DIALOG_H
27#define LMMS_GUI_EFFECT_SELECT_DIALOG_H
28
29#include "Effect.h"
30
31#include <QDialog>
32#include <QRegularExpression>
33#include <QSortFilterProxyModel>
34#include <QStandardItemModel>
35
36class QScrollArea;
37class QTableView;
38class QLineEdit;
39
40namespace lmms::gui
41{
42
43class DualColumnFilterProxyModel : public QSortFilterProxyModel
44{
45 Q_OBJECT
46public:
47 DualColumnFilterProxyModel(QObject* parent = nullptr) : QSortFilterProxyModel(parent)
48 {
49 }
50
51 void setEffectTypeFilter(const QString& filter)
52 {
53 m_effectTypeFilter = filter;
54 invalidateFilter();
55 }
56
57protected:
58 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
59 {
60 QModelIndex nameIndex = sourceModel()->index(source_row, 0, source_parent);
61 QModelIndex typeIndex = sourceModel()->index(source_row, 1, source_parent);
62
63 QString name = sourceModel()->data(nameIndex, Qt::DisplayRole).toString();
64 QString type = sourceModel()->data(typeIndex, Qt::DisplayRole).toString();
65
66 QRegularExpression nameRegularExpression(filterRegularExpression());
67 nameRegularExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
68
69 bool nameFilterPassed = nameRegularExpression.match(name).capturedStart() != -1;
70
71 bool typeFilterPassed = type.contains(m_effectTypeFilter, Qt::CaseInsensitive);
72
73 return nameFilterPassed && typeFilterPassed;
74 }
75
76private:
78};
79
80
81class EffectSelectDialog : public QDialog
82{
83 Q_OBJECT
84public:
85 EffectSelectDialog(QWidget* parent);
86
88
89protected slots:
90 void acceptSelection();
91 void rowChanged(const QModelIndex&, const QModelIndex&);
92 void updateSelection();
93
94 bool eventFilter(QObject* obj, QEvent* event) override;
95
96private:
99
100 QStandardItemModel m_sourceModel;
103 QTableView* m_pluginList;
104 QScrollArea* m_scrollArea;
105 QLineEdit* m_filterEdit;
106};
107
108} // namespace lmms::gui
109
110#endif
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition EffectChain.h:48
Definition Effect.h:53
Definition EffectSelectDialog.h:44
QString m_effectTypeFilter
Definition EffectSelectDialog.h:77
DualColumnFilterProxyModel(QObject *parent=nullptr)
Definition EffectSelectDialog.h:47
void setEffectTypeFilter(const QString &filter)
Definition EffectSelectDialog.h:51
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Definition EffectSelectDialog.h:58
QTableView * m_pluginList
Definition EffectSelectDialog.h:103
QLineEdit * m_filterEdit
Definition EffectSelectDialog.h:105
bool eventFilter(QObject *obj, QEvent *event) override
Definition EffectSelectDialog.cpp:308
EffectKey m_currentSelection
Definition EffectSelectDialog.h:98
QWidget * m_descriptionWidget
Definition EffectSelectDialog.h:102
void updateSelection()
Definition EffectSelectDialog.cpp:296
DualColumnFilterProxyModel m_model
Definition EffectSelectDialog.h:101
EffectKeyList m_effectKeys
Definition EffectSelectDialog.h:97
Effect * instantiateSelectedPlugin(EffectChain *parent)
Definition EffectSelectDialog.cpp:196
void acceptSelection()
Definition EffectSelectDialog.cpp:210
void rowChanged(const QModelIndex &, const QModelIndex &)
Definition EffectSelectDialog.cpp:218
EffectSelectDialog(QWidget *parent)
Definition EffectSelectDialog.cpp:50
QScrollArea * m_scrollArea
Definition EffectSelectDialog.h:104
QStandardItemModel m_sourceModel
Definition EffectSelectDialog.h:100
static const char * name
Definition pugl.h:1582
static uintptr_t parent
Definition pugl.h:1644
int source_row
Definition jpegint.h:373
Definition AudioPortAudio.cpp:223
Effect::Descriptor::SubPluginFeatures::KeyList EffectKeyList
Definition Effect.h:216
Effect::Descriptor::SubPluginFeatures::Key EffectKey
Definition Effect.h:215