searchwidget.h 2.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
 * Copyright (C) 2003 Richard Lärkäng <nouseforaname@home.se>
 * Copyright (C) 2003-2004 Scott Wheeler <wheeler@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
17 18 19 20

#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H

21 22
#include <ktoolbar.h>

23
#include <QFrame>
24 25
#include <QList>

26 27
#include "playlistsearch.h"

28
class QEvent;
29

30
class KComboBox;
31
class KLineEdit;
Michael Pyne's avatar
Michael Pyne committed
32
class SearchWidget;
33

34
class SearchLine : public QFrame
35 36 37
{
    Q_OBJECT

Michael Pyne's avatar
Michael Pyne committed
38 39
    friend class SearchWidget;

40
public:
41
    enum Mode { Default = 0, CaseSensitive = 1, Pattern = 2 };
42

43
    explicit SearchLine(QWidget *parent, bool simple = false);
44 45 46 47 48

    PlaylistSearch::Component searchComponent() const;
    void setSearchComponent(const PlaylistSearch::Component &component);

    void updateColumns();
Scott Wheeler's avatar
Scott Wheeler committed
49 50

public slots:
51
    void clear();
52
    virtual void setFocus();
53

54
protected:
55
    virtual bool eventFilter(QObject *watched, QEvent *e) override;
56

57 58
signals:
    void signalQueryChanged();
59
    void signalDownPressed();
60

61 62 63
private slots:
    void slotActivate();

64
private:
65
    bool m_simple;
66 67 68
    KLineEdit *m_lineEdit;
    KComboBox *m_searchFieldsBox;
    KComboBox *m_caseSensitive;
69
    QList<int> m_columnList;
70 71
};

72
class SearchWidget : public KToolBar
73 74 75 76
{
    Q_OBJECT

public:
77
    explicit SearchWidget(QWidget *parent);
78

79
    PlaylistSearch search(const PlaylistList &playlists) const;
80
    void setSearch(const PlaylistSearch &search);
81

82 83 84
    virtual QString searchText() const;
    virtual void setSearchText(const QString &text);

85 86
public slots:
    void clear();
87
    void setEnabled(bool enable);
88
    virtual void setFocus();
89

90
signals:
91
    void signalQueryChanged();
Michael Pyne's avatar
Michael Pyne committed
92
    void returnPressed();
93 94 95 96

    // This signal is only emitted when the Show/Hide action is triggered.
    // Minimizing/closing the JuK window will not trigger this signal.

97
    void signalShown(bool shown);
98

99 100
    void signalDownPressed();

101
private:
102
    void updateColumns();
103 104

private:
105
    SearchLine m_searchLine;
106
    QStringList m_columnHeaders;
107
};
108 109

#endif
110 111

// vim: set et sw=4 tw=0 sta: