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", (float)(p_item->p_stats->i_read_bytes)/1000);
55 UPDATE( input_bitrate_text, "%6.0f",
56 (float)(p_item->p_stats->f_input_bitrate * 8000 ));
57 UPDATE( demuxed_text, "%8.0f",
58 (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
59 UPDATE( stream_bitrate_text, "%6.0f",
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",
70 (float)(p_item->p_stats->i_sent_bytes)/1000 );
71 UPDATE( send_bitrate_text, "%6.0f",
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 )
90 QGridLayout *l = new QGridLayout( this );
91 #define ADD_META( string, widget ) { \
92 l->addWidget( new QLabel( qfu( string ) ), line, 0 ); \
93 widget = new QLabel( "" ); \
94 l->addWidget( widget, line, 1 ); \
96 ADD_META( _( "Name" ), name_text );
97 ADD_META( _( "URI" ), uri_text );
98 ADD_META( VLC_META_ARTIST, artist_text );
99 ADD_META( VLC_META_GENRE, genre_text );
100 ADD_META( VLC_META_COPYRIGHT, copyright_text );
101 ADD_META( VLC_META_COLLECTION, collection_text );
102 ADD_META( VLC_META_SEQ_NUM, seqnum_text );
103 ADD_META( VLC_META_DESCRIPTION, description_text );
104 ADD_META( VLC_META_RATING, rating_text );
105 ADD_META( VLC_META_DATE, date_text );
106 ADD_META( VLC_META_LANGUAGE, language_text );
107 ADD_META( VLC_META_NOW_PLAYING, nowplaying_text );
108 ADD_META( VLC_META_PUBLISHER, publisher_text );
109 ADD_META( VLC_META_SETTING, setting_text );
112 MetaPanel::~MetaPanel()
116 void MetaPanel::update( input_item_t *p_item )
118 #define UPDATE_META( meta, widget ) { \
119 char* psz_meta = p_item->p_meta->psz_##meta; \
120 if( !EMPTY_STR( psz_meta ) ) \
121 widget->setText( qfu( psz_meta ) ); \
123 widget->setText( "" ); }
125 if( !EMPTY_STR( p_item->psz_name ) )
126 name_text->setText( qfu( p_item->psz_name ) );
127 else name_text->setText( "" );
128 if( !EMPTY_STR( p_item->psz_uri ) )
129 uri_text->setText( qfu( p_item->psz_uri ) );
130 else uri_text->setText( "" );
131 UPDATE_META( artist, artist_text );
132 UPDATE_META( genre, genre_text );
133 UPDATE_META( copyright, copyright_text );
134 UPDATE_META( album, collection_text );
135 UPDATE_META( tracknum, seqnum_text );
136 UPDATE_META( description, description_text );
137 UPDATE_META( rating, rating_text );
138 UPDATE_META( date, date_text );
139 UPDATE_META( language, language_text );
140 UPDATE_META( nowplaying, nowplaying_text );
141 UPDATE_META( publisher, publisher_text );
142 UPDATE_META( setting, setting_text );
147 void MetaPanel::clear()
151 InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
152 QWidget( parent ), p_intf( _p_intf )
155 QGridLayout *layout = new QGridLayout(this);
156 InfoTree = new QTreeWidget(this);
157 QList<QTreeWidgetItem *> items;
159 layout->addWidget(InfoTree, 0, 0 );
160 InfoTree->setColumnCount( 1 );
161 InfoTree->header()->hide();
162 // InfoTree->resize(400, 400);
165 InfoPanel::~InfoPanel()
169 void InfoPanel::update( input_item_t *p_item)
172 QTreeWidgetItem *current_item = NULL;
173 QTreeWidgetItem *child_item = NULL;
175 for( int i = 0; i< p_item->i_categories ; i++)
177 current_item = new QTreeWidgetItem();
178 current_item->setText( 0, qfu(p_item->pp_categories[i]->psz_name) );
179 InfoTree->addTopLevelItem( current_item );
181 for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
183 child_item = new QTreeWidgetItem ();
184 child_item->setText( 0,
185 qfu(p_item->pp_categories[i]->pp_infos[j]->psz_name)
187 + qfu(p_item->pp_categories[i]->pp_infos[j]->psz_value));
189 current_item->addChild(child_item);
191 InfoTree->setItemExpanded( current_item, true);
195 void InfoPanel::clear()
200 /***************************************************************************
202 ***************************************************************************/
204 InfoTab::InfoTab( QWidget *parent, intf_thread_t *_p_intf, bool _stats ) :
205 QTabWidget( parent ), stats( _stats ), p_intf( _p_intf )
207 // setGeometry(0, 0, 400, 500);
209 MP = new MetaPanel(NULL, p_intf);
210 addTab(MP, qtr("&General"));
211 IP = new InfoPanel(NULL, p_intf);
212 addTab(IP, qtr("&Details"));
215 ISP = new InputStatsPanel( NULL, p_intf );
216 addTab(ISP, qtr("&Stats"));
224 /* This function should be called approximately twice a second.
225 * p_item should be locked
226 * Stats will always be updated */
227 void InfoTab::update( input_item_t *p_item, bool update_info,
231 IP->update( p_item );
233 MP->update( p_item );
235 ISP->update( p_item );
238 void InfoTab::clear()
242 if( stats ) ISP->clear();