1 /*****************************************************************************
2 * infopanels.cpp : Panels for the information dialogs
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "components/infopanels.hpp"
28 #include <QTreeWidget>
29 #include <QPushButton>
30 #include <QHeaderView>
33 /************************************************************************
35 ************************************************************************/
37 InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
38 QWidget( parent ), p_intf( _p_intf )
43 InputStatsPanel::~InputStatsPanel()
47 void InputStatsPanel::update( input_item_t *p_item )
49 vlc_mutex_lock( &p_item->p_stats->lock );
51 #define UPDATE( widget,format, calc... ) \
52 { QString str; ui.widget->setText( str.sprintf( format, ## calc ) ); }
54 UPDATE( read_text, "%8.0f kB", (float)(p_item->p_stats->i_read_bytes)/1000);
55 UPDATE( input_bitrate_text, "%6.0f kb/s",
56 (float)(p_item->p_stats->f_input_bitrate * 8000 ));
57 UPDATE( demuxed_text, "%8.0f kB",
58 (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
59 UPDATE( stream_bitrate_text, "%6.0f kb/s",
60 (float)(p_item->p_stats->f_demux_bitrate * 8000 ));
63 UPDATE( vdecoded_text, "%5i", p_item->p_stats->i_decoded_video );
64 UPDATE( vdisplayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
65 UPDATE( vlost_frames, "%5i", p_item->p_stats->i_lost_pictures );
68 UPDATE( sent_text, "%5i", p_item->p_stats->i_sent_packets );
69 UPDATE( sent_bytes_text, "%8.0f kB",
70 (float)(p_item->p_stats->i_sent_bytes)/1000 );
71 UPDATE( send_bitrate_text, "%6.0f kb/s",
72 (float)(p_item->p_stats->f_send_bitrate*8)*1000 );
75 UPDATE( adecoded_text, "%5i", p_item->p_stats->i_decoded_audio );
76 UPDATE( aplayed_text, "%5i", p_item->p_stats->i_played_abuffers );
77 UPDATE( alost_text, "%5i", p_item->p_stats->i_lost_abuffers );
79 vlc_mutex_unlock(& p_item->p_stats->lock );
82 void InputStatsPanel::clear()
86 MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
87 QWidget( parent ), p_intf( _p_intf )
91 MetaPanel::~MetaPanel()
94 void MetaPanel::update( input_item_t *p_item )
97 void MetaPanel::clear()
101 char* MetaPanel::getURI()
107 char* MetaPanel::getName()
114 InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
115 QWidget( parent ), p_intf( _p_intf )
118 QGridLayout *layout = new QGridLayout(this);
119 InfoTree = new QTreeWidget(this);
120 QList<QTreeWidgetItem *> items;
122 layout->addWidget(InfoTree, 0, 0 );
123 InfoTree->setColumnCount( 1 );
124 InfoTree->header()->hide();
125 // InfoTree->resize(400, 400);
128 InfoPanel::~InfoPanel()
132 void InfoPanel::update( input_item_t *p_item)
135 QTreeWidgetItem *current_item = NULL;
136 QTreeWidgetItem *child_item = NULL;
138 for( int i = 0; i< p_item->i_categories ; i++)
140 current_item = new QTreeWidgetItem();
141 current_item->setText( 0, qfu(p_item->pp_categories[i]->psz_name) );
142 InfoTree->addTopLevelItem( current_item );
144 for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
146 child_item = new QTreeWidgetItem ();
147 child_item->setText( 0,
148 qfu(p_item->pp_categories[i]->pp_infos[j]->psz_name)
150 + qfu(p_item->pp_categories[i]->pp_infos[j]->psz_value));
152 current_item->addChild(child_item);
154 InfoTree->setItemExpanded( current_item, true);
158 void InfoPanel::clear()
163 /***************************************************************************
165 ***************************************************************************/
167 InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf, bool _stats ) :
168 QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
170 // setGeometry(0, 0, 400, 500);
172 MP = new MetaPanel(NULL, p_intf);
173 addTab(MP, qtr("&Meta"));
176 ISP = new InputStatsPanel( NULL, p_intf );
177 addTab(ISP, qtr("&Stats"));
180 IP = new InfoPanel(NULL, p_intf);
181 addTab(IP, qtr("&Info"));
188 /* This function should be called approximately twice a second.
189 * p_item should be locked
190 * Stats will always be updated */
191 void InfoTab::update( input_item_t *p_item, bool update_info,
195 IP->update( p_item );
197 MP->update( p_item );
199 ISP->update( p_item );
202 void InfoTab::clear()
206 if( stats ) ISP->clear();