File: dirfilterplugin.h

package info (click to toggle)
konqueror 4%3A25.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 61,852 kB
  • sloc: cpp: 59,368; python: 943; xml: 682; javascript: 186; sh: 165; makefile: 10
file content (133 lines) | stat: -rw-r--r-- 2,747 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
    SPDX-FileCopyrightText: 2000-2011 Dawit Alemayehu <adawit@kde.org>

    SPDX-License-Identifier: LGPL-2.0-only
*/

#ifndef DIR_FILTER_PLUGIN_H
#define DIR_FILTER_PLUGIN_H

#include <QSet>
#include <QPointer>
#include <QStringList>
#include <QWidget>
#include <QMenu>
#include <QUrl>

#include <konq_kpart_plugin.h>
#include <KParts/ListingFilterExtension>
#include <KParts/ListingNotificationExtension>

class QPushButton;
class KFileItemList;
class KLineEdit;
namespace KParts
{
class ReadOnlyPart;
}

class FilterBar : public QWidget
{
    Q_OBJECT

public:
    explicit FilterBar(QWidget *parent = nullptr);
    ~FilterBar() override;
    void selectAll();

    QMenu *typeFilterMenu();
    void setTypeFilterMenu(QMenu *);

    bool typeFilterMenuEnabled() const;
    void setEnableTypeFilterMenu(bool);

    void setNameFilter(const QString &);

public Q_SLOTS:
    void clear();

Q_SIGNALS:
    void filterChanged(const QString &nameFilter);
    void closeRequest();

protected:
    void showEvent(QShowEvent *event) override;
    void keyReleaseEvent(QKeyEvent *event) override;

private:
    KLineEdit *m_filterInput;
    QPushButton *m_typeFilterButton;
};

class SessionManager
{
public:
    struct Filters {
        QStringList typeFilters;
        QString nameFilter;
    };

    SessionManager();
    ~SessionManager();
    Filters restore(const QUrl &url);
    void save(const QUrl &url, const Filters &filters);

    bool showCount;
    bool useMultipleFilters;

protected:
    void loadSettings();
    void saveSettings();

private:
    bool m_bSettingsLoaded;
    QMap<QString, Filters> m_filters;
};

class DirFilterPlugin : public KonqParts::Plugin
{
    Q_OBJECT

public:

    DirFilterPlugin(QObject *parent, const QVariantList &);
    ~DirFilterPlugin() override;

private Q_SLOTS:
    void slotReset();
    void slotOpenURL();
    void slotOpenURLCompleted();
    void slotShowPopup();
    void slotShowCount();
    void slotShowFilterBar();
    void slotMultipleFilters();
    void slotItemSelected(QAction *);
    void slotNameFilterChanged(const QString &);
    void slotCloseRequest();
    void slotListingEvent(KParts::ListingNotificationExtension::NotificationEventType, const KFileItemList &);

private:
    void setFilterBar();

    struct MimeInfo {
        MimeInfo() : action(nullptr), useAsFilter(false) {}

        QAction *action;
        bool useAsFilter;

        QString iconName;
        QString mimeComment;

        QSet<QString> filenames;
    };
    typedef QMap<QString, MimeInfo> MimeInfoMap;

    FilterBar *m_filterBar;
    QWidget *m_focusWidget;
    QPointer<KParts::ReadOnlyPart> m_part;
    QPointer<KParts::ListingFilterExtension> m_listingExt;
    MimeInfoMap m_pMimeInfo;
};

#endif