Commit 7db11385 authored by zorglub's avatar zorglub
Browse files

A bit of cleanup in the info stuff

parent 4b94daab
......@@ -5,6 +5,7 @@
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.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
......@@ -29,6 +30,10 @@
#include <QHeaderView>
#include <QList>
/************************************************************************
* Single panels
************************************************************************/
InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
QWidget( parent ), p_intf( _p_intf )
{
......@@ -39,9 +44,8 @@ InputStatsPanel::~InputStatsPanel()
{
}
void InputStatsPanel::Update( input_item_t *p_item )
void InputStatsPanel::update( input_item_t *p_item )
{
vlc_mutex_lock( &p_item->p_stats->lock );
#define UPDATE( widget,format, calc... ) \
......@@ -75,7 +79,7 @@ void InputStatsPanel::Update( input_item_t *p_item )
vlc_mutex_unlock(& p_item->p_stats->lock );
}
void InputStatsPanel::Clear()
void InputStatsPanel::clear()
{
}
......@@ -87,29 +91,30 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
MetaPanel::~MetaPanel()
{
}
void MetaPanel::Update( input_item_t *p_item)
void MetaPanel::update( input_item_t *p_item )
{
}
void MetaPanel::Clear()
void MetaPanel::clear()
{
}
char* MetaPanel::GetURI()
char* MetaPanel::getURI()
{
char *URI;
return URI;
}
char* MetaPanel::GetName()
char* MetaPanel::getName()
{
char *Name;
return Name;
}
InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
QWidget( parent ), p_intf( _p_intf )
{
resize(400, 500);
// resize(400, 500);
QGridLayout *layout = new QGridLayout(this);
InfoTree = new QTreeWidget(this);
QList<QTreeWidgetItem *> items;
......@@ -117,15 +122,14 @@ InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
layout->addWidget(InfoTree, 0, 0 );
InfoTree->setColumnCount( 1 );
InfoTree->header()->hide();
InfoTree->resize(400, 400);
// InfoTree->resize(400, 400);
}
InfoPanel::~InfoPanel()
{
}
void InfoPanel::Update( input_item_t *p_item)
void InfoPanel::update( input_item_t *p_item)
{
InfoTree->clear();
QTreeWidgetItem *current_item = NULL;
......@@ -151,7 +155,53 @@ void InfoPanel::Update( input_item_t *p_item)
}
}
void InfoPanel::Clear()
void InfoPanel::clear()
{
InfoTree->clear();
}
/***************************************************************************
* Tab widget
***************************************************************************/
InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf, bool _stats ) :
QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
{
// setGeometry(0, 0, 400, 500);
MP = new MetaPanel(NULL, p_intf);
addTab(MP, qtr("&Meta"));
if( stats )
{
ISP = new InputStatsPanel( NULL, p_intf );
addTab(ISP, qtr("&Stats"));
}
IP = new InfoPanel(NULL, p_intf);
addTab(IP, qtr("&Info"));
}
InfoTab::~InfoTab()
{
}
/* This function should be called approximately twice a second.
* p_item should be locked
* Stats will always be updated */
void InfoTab::update( input_item_t *p_item, bool update_info,
bool update_meta )
{
if( update_info )
IP->update( p_item );
if( update_meta )
MP->update( p_item );
if( stats )
ISP->update( p_item );
}
void InfoTab::clear()
{
IP->clear();
MP->clear();
if( stats ) ISP->clear();
}
......@@ -28,7 +28,7 @@
#include <vlc_meta.h>
#include <QWidget>
#include <QTabWidget>
#include "ui/input_stats.h"
......@@ -44,10 +44,9 @@ public:
private:
intf_thread_t *p_intf;
Ui::InputStats ui;
public slots:
void Update( input_item_t * );
void Clear();
void update( input_item_t * );
void clear();
};
class MetaPanel: public QWidget
......@@ -60,11 +59,11 @@ private:
intf_thread_t *p_intf;
public slots:
void Update( input_item_t * );
void Clear();
void update( input_item_t * );
void clear();
char* GetURI();
char* GetName();
char* getURI();
char* getName();
};
class InfoPanel: public QWidget
......@@ -78,8 +77,25 @@ private:
QTreeWidget *InfoTree;
public slots:
void Update( input_item_t * );
void Clear();
void update( input_item_t * );
void clear();
};
class InfoTab: public QTabWidget
{
Q_OBJECT;
public:
InfoTab( QWidget *, intf_thread_t *, bool );
virtual ~InfoTab();
void update( input_item_t *, bool, bool );
void clear();
private:
bool stats;
intf_thread_t *p_intf;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
int i_runs;
};
#endif
......@@ -30,17 +30,18 @@
#include "components/infopanels.hpp"
#include "qt4.hpp"
/* This is the dialog Windows */
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param );
StreamInfoDialog *StreamInfoDialog::instance = NULL;
StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) :
QVLCFrame( _p_intf ), main_input( _main_input )
StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf ) :QVLCFrame( _p_intf )
{
i_runs = 0;
setWindowTitle( _("Stream information" ) );
QGridLayout *layout = new QGridLayout(this);
setGeometry(0,0,470,550);
IT = new InfoTab( this, p_intf) ;
IT = new InfoTab( this, p_intf, true ) ;
QPushButton *closeButton = new QPushButton(qtr("&Close"));
layout->addWidget(IT,0,0,1,3);
layout->addWidget(closeButton,1,2);
......@@ -48,50 +49,47 @@ StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf, bool _main_input ) :
BUTTONACT( closeButton, close() );
ON_TIMEOUT( update() );
p_input = NULL;
}
void StreamInfoDialog::update()
{
IT->update();
var_AddCallback( THEPL, "item-change", ItemChanged, this );
}
StreamInfoDialog::~StreamInfoDialog()
{
var_DelCallback( THEPL, "item-change", ItemChanged, this );
}
void StreamInfoDialog::close()
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
this->toggleVisible();
StreamInfoDialog *p_d = (StreamInfoDialog *)param;
p_d->need_update = VLC_TRUE;
return VLC_SUCCESS;
}
/* This is the tab Widget Inside the windows*/
InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf ) :
QTabWidget( parent ), p_intf( _p_intf )
void StreamInfoDialog::update()
{
setGeometry(0, 0, 400, 500);
// Timer runs at 150 ms, dont' update more than 2 times per second
i_runs++;
if( i_runs % 3 != 0 ) return;
input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead )
{
IT->clear();
return;
}
ISP = new InputStatsPanel( NULL, p_intf );
MP = new MetaPanel(NULL, p_intf);
IP = new InfoPanel(NULL, p_intf);
vlc_object_yield( p_input );
vlc_mutex_lock( &p_input->input.p_item->lock );
addTab(MP, qtr("&Meta"));
addTab(ISP, qtr("&Stats"));
addTab(IP, qtr("&Info"));
}
IT->update( p_input->input.p_item, need_update, need_update );
need_update = false;
InfoTab::~InfoTab()
{
vlc_mutex_unlock( &p_input->input.p_item->lock );
vlc_object_release( p_input );
}
void InfoTab::update()
void StreamInfoDialog::close()
{
if( p_intf )
p_input = MainInputManager::getInstance( p_intf )->getInput();
if( p_input && !p_input->b_dead )
{
ISP->Update( p_input->input.p_item );
// FIXME should not be updated here
IP->Update( p_input->input.p_item );
}
this->toggleVisible();
}
......@@ -27,45 +27,26 @@
#include <QTabWidget>
#include <QBoxLayout>
class InputStatsPanel;
class MetaPanel;
class InfoPanel;
class InfoTab: public QTabWidget
{
Q_OBJECT;
public:
InfoTab( QWidget *, intf_thread_t * );
virtual ~InfoTab();
private:
intf_thread_t *p_intf;
input_thread_t *p_input;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
public slots:
void update();
};
class InfoTab;
class StreamInfoDialog : public QVLCFrame
{
Q_OBJECT;
public:
static StreamInfoDialog * getInstance( intf_thread_t *p_intf, bool a )
static StreamInfoDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new StreamInfoDialog( p_intf, a );
instance = new StreamInfoDialog( p_intf);
return instance;
}
virtual ~StreamInfoDialog();
bool need_update;
private:
StreamInfoDialog( intf_thread_t *, bool );
StreamInfoDialog( intf_thread_t * );
input_thread_t *p_input;
InfoTab *IT;
bool main_input;
static StreamInfoDialog *instance;
int i_runs;
public slots:
void update();
void close();
......
......@@ -154,7 +154,7 @@ void DialogsProvider::quit()
void DialogsProvider::streaminfoDialog()
{
StreamInfoDialog::getInstance( p_intf, true )->toggleVisible();
StreamInfoDialog::getInstance( p_intf )->toggleVisible();
}
void DialogsProvider::streamingDialog()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment