]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/customwidgets.hpp
Use VLC_VAR_CLASS when applicable.
[vlc] / modules / gui / qt4 / util / customwidgets.hpp
index 7c137edc969828e60c89912396832ef84c6753ef..3037efa6488421389fcda04deeeb40f183670411 100644 (file)
@@ -3,7 +3,7 @@
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * Copyright (C) 2004 Daniel Molkentin <molkentin@kde.org>
- * $Id: qvlcframe.hpp 16283 2006-08-17 18:16:09Z zorglub $
+ * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  * The "ClickLineEdit" control is based on code by  Daniel Molkentin
@@ -21,7 +21,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
 
 #ifndef _CUSTOMWIDGETS_H_
 #define _CUSTOMWIDGETS_H_
@@ -55,6 +56,24 @@ private:
     bool mDrawClickMsg;
 };
 
+class QToolButton;
+class SearchLineEdit : public QFrame
+{
+    Q_OBJECT
+public:
+    SearchLineEdit( QWidget *parent );
+
+private:
+    ClickLineEdit *searchLine;
+    QToolButton   *clearButton;
+
+private slots:
+    void updateText( const QString& );
+
+signals:
+    void textChanged( const QString& );
+};
+
 /*****************************************************************
  * Custom views
  *****************************************************************/
@@ -64,30 +83,51 @@ private:
 #include <QPoint>
 #include <QModelIndex>
 
+/**
+  Special QTreeView that can emit rightClicked()
+  */
 class QVLCTreeView : public QTreeView
 {
     Q_OBJECT;
 public:
-    QVLCTreeView( QWidget * parent ) : QTreeView( parent )
+    void mouseReleaseEvent( QMouseEvent* e )
     {
-    };
-    virtual ~QVLCTreeView()   {};
+        if( e->button() & Qt::RightButton )
+            return; /* Do NOT forward to QTreeView!! */
+        QTreeView::mouseReleaseEvent( e );
+    }
 
-    void mouseReleaseEvent(QMouseEvent* e )
+    void mousePressEvent( QMouseEvent* e )
     {
         if( e->button() & Qt::RightButton )
         {
-            emit rightClicked( indexAt( QPoint( e->x(), e->y() ) ),
-                               QCursor::pos() );
+            QModelIndex index = indexAt( QPoint( e->x(), e->y() ) );
+            if( index.isValid() )
+                setSelection( visualRect( index ), QItemSelectionModel::ClearAndSelect );
+            emit rightClicked( index, QCursor::pos() );
+            return;
         }
+        if( e->button() & Qt::LeftButton )
+        {
+            if( !indexAt( QPoint( e->x(), e->y() ) ).isValid() )
+                clearSelection();
+        }
+        QTreeView::mousePressEvent( e );
     }
+
 signals:
     void rightClicked( QModelIndex, QPoint  );
 };
 
+/* VLC Key/Wheel hotkeys interactions */
+
 class QKeyEvent;
+class QWheelEvent;
+
+int qtKeyModifiersToVLC( QInputEvent* e );
 int qtEventToVLCKey( QKeyEvent *e );
+int qtWheelEventToVLCKey( QWheelEvent *e );
 QString VLCKeyToString( int val );
-int qtKeyModifiersToVLC( QInputEvent* e );
 
 #endif
+