]> git.sesse.net Git - vlc/blob - modules/gui/qt4/util/customwidgets.hpp
qt4: missing const for QString.
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
1 /*****************************************************************************
2  * customwidgets.h: Custom widgets
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
6  * $Id$
7  *
8  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
9  * The "ClickLineEdit" control is based on code by  Daniel Molkentin
10  * <molkentin@kde.org> for libkdepim
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifndef _CUSTOMWIDGETS_H_
28 #define _CUSTOMWIDGETS_H_
29
30 #include <QLineEdit>
31
32 /**
33   This class provides a QLineEdit which contains a greyed-out hinting
34   text as long as the user didn't enter any text
35
36   @short LineEdit with customizable "Click here" text
37   @author Daniel Molkentin
38 */
39 class ClickLineEdit : public QLineEdit
40 {
41     Q_OBJECT
42     Q_PROPERTY( QString clickMessage READ clickMessage WRITE setClickMessage )
43 public:
44     ClickLineEdit( const QString &msg, QWidget *parent );
45     virtual ~ClickLineEdit() {};
46     void setClickMessage( const QString &msg );
47     QString clickMessage() const { return mClickMessage; }
48     virtual void setText( const QString& txt );
49 protected:
50     virtual void paintEvent( QPaintEvent *e );
51     virtual void dropEvent( QDropEvent *ev );
52     virtual void focusInEvent( QFocusEvent *ev );
53     virtual void focusOutEvent( QFocusEvent *ev );
54 private:
55     QString mClickMessage;
56     bool mDrawClickMsg;
57 };
58
59 class QToolButton;
60 class SearchLineEdit : public QFrame
61 {
62     Q_OBJECT
63 public:
64     SearchLineEdit( QWidget *parent );
65
66 private:
67     ClickLineEdit *searchLine;
68     QToolButton   *clearButton;
69
70 private slots:
71     void updateText( const QString& );
72
73 signals:
74     void textChanged( const QString& );
75 };
76
77 /*****************************************************************
78  * Custom views
79  *****************************************************************/
80 #include <QMouseEvent>
81 #include <QTreeView>
82 #include <QCursor>
83 #include <QPoint>
84 #include <QModelIndex>
85
86 /**
87   Special QTreeView that can emit rightClicked()
88   */
89 class QVLCTreeView : public QTreeView
90 {
91     Q_OBJECT;
92 public:
93     void mouseReleaseEvent( QMouseEvent* e )
94     {
95         if( e->button() & Qt::RightButton )
96         {
97             emit rightClicked( indexAt( QPoint( e->x(), e->y() ) ),
98                                QCursor::pos() );
99         }
100         QTreeView::mouseReleaseEvent( e );
101     }
102
103     void mousePressEvent( QMouseEvent* e )
104     {
105         if( e->button() & Qt::LeftButton )
106         {
107             if( !indexAt( QPoint( e->x(), e->y() ) ).isValid() )
108                 clearSelection();
109         }
110         QTreeView::mousePressEvent( e );
111     }
112
113 signals:
114     void rightClicked( QModelIndex, QPoint  );
115 };
116
117 /* VLC Key/Wheel hotkeys interactions */
118
119 class QKeyEvent;
120 class QWheelEvent;
121
122 int qtKeyModifiersToVLC( QInputEvent* e );
123 int qtEventToVLCKey( QKeyEvent *e );
124 int qtWheelEventToVLCKey( QWheelEvent *e );
125 QString VLCKeyToString( int val );
126
127 #endif
128