[vlc-commits] Qt: EPG: change program using epg events
Francois Cartegnie
git at videolan.org
Wed Dec 28 13:39:15 CET 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Dec 28 13:38:18 2016 +0100| [b2ebaf3c4a063ba0d9647d5302720d0390015f9e] | committer: Francois Cartegnie
Qt: EPG: change program using epg events
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b2ebaf3c4a063ba0d9647d5302720d0390015f9e
---
modules/gui/qt/components/epg/EPGItem.cpp | 7 ++++++-
modules/gui/qt/components/epg/EPGItem.hpp | 5 +++--
modules/gui/qt/components/epg/EPGProgram.cpp | 5 +++++
modules/gui/qt/components/epg/EPGProgram.hpp | 1 +
modules/gui/qt/components/epg/EPGView.cpp | 5 +++++
modules/gui/qt/components/epg/EPGView.hpp | 2 ++
modules/gui/qt/components/epg/EPGWidget.cpp | 5 +++++
modules/gui/qt/components/epg/EPGWidget.hpp | 2 ++
modules/gui/qt/dialogs/epg.cpp | 1 +
modules/gui/qt/input_manager.cpp | 8 ++++++++
modules/gui/qt/input_manager.hpp | 2 ++
11 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt/components/epg/EPGItem.cpp b/modules/gui/qt/components/epg/EPGItem.cpp
index c3ec4c2..b3bc737 100644
--- a/modules/gui/qt/components/epg/EPGItem.cpp
+++ b/modules/gui/qt/components/epg/EPGItem.cpp
@@ -35,7 +35,7 @@
#include "qt.hpp"
-EPGItem::EPGItem( const vlc_epg_event_t *data, EPGView *view, const EPGProgram *prog )
+EPGItem::EPGItem( const vlc_epg_event_t *data, EPGView *view, EPGProgram *prog )
: QGraphicsItem()
{
m_view = view;
@@ -230,6 +230,11 @@ void EPGItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
hoverEnterEvent( event );
}
+void EPGItem::mouseDoubleClickEvent( QGraphicsSceneMouseEvent * )
+{
+ program->activate();
+}
+
void EPGItem::focusInEvent( QFocusEvent * event )
{
event->accept();
diff --git a/modules/gui/qt/components/epg/EPGItem.hpp b/modules/gui/qt/components/epg/EPGItem.hpp
index 92d0c8c..1cee117 100644
--- a/modules/gui/qt/components/epg/EPGItem.hpp
+++ b/modules/gui/qt/components/epg/EPGItem.hpp
@@ -38,7 +38,7 @@ class EPGProgram;
class EPGItem : public QGraphicsItem
{
public:
- EPGItem( const vlc_epg_event_t *data, EPGView *view, const EPGProgram * );
+ EPGItem( const vlc_epg_event_t *data, EPGView *view, EPGProgram * );
QRectF boundingRect() const Q_DECL_OVERRIDE;
void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 ) Q_DECL_OVERRIDE;
@@ -60,11 +60,12 @@ public:
protected:
void focusInEvent( QFocusEvent * event ) Q_DECL_OVERRIDE;
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent * ) Q_DECL_OVERRIDE;
void hoverEnterEvent ( QGraphicsSceneHoverEvent * ) Q_DECL_OVERRIDE;
void hoverLeaveEvent ( QGraphicsSceneHoverEvent * ) Q_DECL_OVERRIDE;
private:
- const EPGProgram *program;
+ EPGProgram *program;
EPGView *m_view;
QRectF m_boundingRect;
diff --git a/modules/gui/qt/components/epg/EPGProgram.cpp b/modules/gui/qt/components/epg/EPGProgram.cpp
index 3309cc0..c65f2ee 100644
--- a/modules/gui/qt/components/epg/EPGProgram.cpp
+++ b/modules/gui/qt/components/epg/EPGProgram.cpp
@@ -64,6 +64,11 @@ void EPGProgram::setPosition( size_t i )
pos = i;
}
+void EPGProgram::activate()
+{
+ view->programActivated( sourceid );
+}
+
void EPGProgram::pruneEvents( const QDateTime &date )
{
QMap<QDateTime, const EPGItem *>::iterator it = eventsbytime.begin();
diff --git a/modules/gui/qt/components/epg/EPGProgram.hpp b/modules/gui/qt/components/epg/EPGProgram.hpp
index 9e7aa1d..8265877 100644
--- a/modules/gui/qt/components/epg/EPGProgram.hpp
+++ b/modules/gui/qt/components/epg/EPGProgram.hpp
@@ -45,6 +45,7 @@ class EPGProgram : public QObject
void updateEventPos();
size_t getPosition() const;
void setPosition( size_t );
+ void activate();
const EPGItem * getCurrent() const;
const QString & getName() const;
static bool lessThan( const EPGProgram *, const EPGProgram * );
diff --git a/modules/gui/qt/components/epg/EPGView.cpp b/modules/gui/qt/components/epg/EPGView.cpp
index f6d82a2..16bc016 100644
--- a/modules/gui/qt/components/epg/EPGView.cpp
+++ b/modules/gui/qt/components/epg/EPGView.cpp
@@ -214,3 +214,8 @@ void EPGView::focusItem( EPGItem *epgItem )
{
emit itemFocused( epgItem );
}
+
+void EPGView::activateProgram( int id )
+{
+ emit programActivated( id );
+}
diff --git a/modules/gui/qt/components/epg/EPGView.hpp b/modules/gui/qt/components/epg/EPGView.hpp
index 89737c1..2f04eff 100644
--- a/modules/gui/qt/components/epg/EPGView.hpp
+++ b/modules/gui/qt/components/epg/EPGView.hpp
@@ -67,11 +67,13 @@ public:
void reset();
void cleanup();
bool hasValidData() const;
+ void activateProgram( int );
signals:
void rangeChanged( const QDateTime&, const QDateTime& );
void itemFocused( EPGItem * );
void programAdded( const EPGProgram * );
+ void programActivated( int );
protected:
void walkItems( bool );
diff --git a/modules/gui/qt/components/epg/EPGWidget.cpp b/modules/gui/qt/components/epg/EPGWidget.cpp
index 4482835..f6c0c4a 100644
--- a/modules/gui/qt/components/epg/EPGWidget.cpp
+++ b/modules/gui/qt/components/epg/EPGWidget.cpp
@@ -80,6 +80,7 @@ EPGWidget::EPGWidget( QWidget *parent ) : QWidget( parent )
connect( m_epgView, SIGNAL( itemFocused(EPGItem*)),
this, SIGNAL(itemSelectionChanged(EPGItem*)) );
CONNECT( m_epgView, programAdded(const EPGProgram *), m_channelsWidget, addProgram(const EPGProgram *) );
+ CONNECT( m_epgView, programActivated(int), this, activateProgram(int) );
}
void EPGWidget::reset()
@@ -120,3 +121,7 @@ void EPGWidget::updateEPG( input_item_t *p_input_item )
m_epgView->cleanup();
}
+void EPGWidget::activateProgram( int id )
+{
+ emit programActivated( id );
+}
diff --git a/modules/gui/qt/components/epg/EPGWidget.hpp b/modules/gui/qt/components/epg/EPGWidget.hpp
index 14f1a36..ba5f497 100644
--- a/modules/gui/qt/components/epg/EPGWidget.hpp
+++ b/modules/gui/qt/components/epg/EPGWidget.hpp
@@ -51,6 +51,7 @@ public:
public slots:
void setZoom( int level );
void updateEPG( input_item_t * );
+ void activateProgram( int );
private:
EPGRuler* m_rulerWidget;
@@ -63,6 +64,7 @@ private:
signals:
void itemSelectionChanged( EPGItem * );
+ void programActivated( int );
};
#endif // EPGWIDGET_H
diff --git a/modules/gui/qt/dialogs/epg.cpp b/modules/gui/qt/dialogs/epg.cpp
index 67f0950..76354c8 100644
--- a/modules/gui/qt/dialogs/epg.cpp
+++ b/modules/gui/qt/dialogs/epg.cpp
@@ -76,6 +76,7 @@ EpgDialog::EpgDialog( intf_thread_t *_p_intf ): QVLCFrame( _p_intf )
layout->addWidget( descBox );
CONNECT( epg, itemSelectionChanged( EPGItem *), this, displayEvent( EPGItem *) );
+ CONNECT( epg, programActivated(int), THEMIM->getIM(), changeProgram(int) );
CONNECT( THEMIM->getIM(), epgChanged(), this, scheduleUpdate() );
CONNECT( THEMIM, inputChanged( bool ), this, inputChanged() );
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 0f01f95..55e0553 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -831,6 +831,14 @@ void InputManager::sectionMenu()
* Teletext Functions
*/
+void InputManager::changeProgram( int program )
+{
+ if( hasInput() )
+ {
+ var_SetInteger( p_input, "program", program );
+ }
+}
+
/* Set a new Teletext Page */
void InputManager::telexSetPage( int page )
{
diff --git a/modules/gui/qt/input_manager.hpp b/modules/gui/qt/input_manager.hpp
index e9339c1..078a82c 100644
--- a/modules/gui/qt/input_manager.hpp
+++ b/modules/gui/qt/input_manager.hpp
@@ -202,6 +202,8 @@ public slots:
void sectionNext();
void sectionPrev();
void sectionMenu();
+ /* Program */
+ void changeProgram( int );
/* Teletext */
void telexSetPage( int ); ///< Goto teletext page
void telexSetTransparency( bool ); ///< Transparency on teletext background
More information about the vlc-commits
mailing list