]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/infopanels.cpp
*Qt4: InfoTree for files. The timer does not function correctly yet. :D
[vlc] / modules / gui / qt4 / components / infopanels.cpp
1 /*****************************************************************************
2  * infopanels.cpp : Panels for the information dialogs
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "components/infopanels.hpp"
25 #include "qt4.hpp"
26
27 #include <QTreeWidget>
28 #include <QPushButton>
29 #include <QHeaderView>
30 #include <QList>
31
32 InputStatsPanel::InputStatsPanel( QWidget *parent, intf_thread_t *_p_intf ) :
33                                   QWidget( parent ), p_intf( _p_intf )
34 {
35     ui.setupUi( this );
36 }
37
38 InputStatsPanel::~InputStatsPanel()
39 {
40 }
41
42 void InputStatsPanel::Update( input_item_t *p_item )
43 {
44
45     vlc_mutex_lock( &p_item->p_stats->lock );
46
47 #define UPDATE( widget,format, calc... ) \
48     { QString str; ui.widget->setText( str.sprintf( format, ## calc ) );  }
49
50     UPDATE( read_text, "%8.0f kB", (float)(p_item->p_stats->i_read_bytes)/1000);
51     UPDATE( input_bitrate_text, "%6.0f kb/s",
52                     (float)(p_item->p_stats->f_input_bitrate * 8000 ));
53     UPDATE( demuxed_text, "%8.0f kB",
54                     (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
55     UPDATE( stream_bitrate_text, "%6.0f kb/s",
56                     (float)(p_item->p_stats->f_demux_bitrate * 8000 ));
57
58     /* Video */
59     UPDATE( vdecoded_text, "%5i", p_item->p_stats->i_decoded_video );
60     UPDATE( vdisplayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
61     UPDATE( vlost_frames, "%5i", p_item->p_stats->i_lost_pictures );
62
63     /* Sout */
64     UPDATE( sent_text, "%5i", p_item->p_stats->i_sent_packets );
65     UPDATE( sent_bytes_text, "%8.0f kB",
66             (float)(p_item->p_stats->i_sent_bytes)/1000 );
67     UPDATE( send_bitrate_text, "%6.0f kb/s",
68             (float)(p_item->p_stats->f_send_bitrate*8)*1000 );
69
70     /* Audio*/
71     UPDATE( adecoded_text, "%5i", p_item->p_stats->i_decoded_audio );
72     UPDATE( aplayed_text, "%5i", p_item->p_stats->i_played_abuffers );
73     UPDATE( alost_text, "%5i", p_item->p_stats->i_lost_abuffers );
74
75     vlc_mutex_unlock(& p_item->p_stats->lock );
76 }
77
78 void InputStatsPanel::Clear()
79 {
80 }
81
82 MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
83                                     QWidget( parent ), p_intf( _p_intf )
84 {
85
86 }
87 MetaPanel::~MetaPanel()
88 {
89 }
90 void MetaPanel::Update( input_item_t *p_item)
91 {
92 }
93 void MetaPanel::Clear()
94 {
95 }
96
97 char* MetaPanel::GetURI()
98 {
99     char *URI;
100     return URI;
101 }
102
103 char* MetaPanel::GetName()
104 {
105     char *Name;
106     return Name;
107 }
108
109 InfoPanel::InfoPanel( QWidget *parent, intf_thread_t *_p_intf ) :
110                                       QWidget( parent ), p_intf( _p_intf )
111 {
112      resize(400, 500);
113      QGridLayout *layout = new QGridLayout(this);
114      InfoTree = new QTreeWidget(this);
115      QList<QTreeWidgetItem *> items;
116
117      layout->addWidget(InfoTree, 0, 0 );
118      InfoTree->setColumnCount( 1 );
119      InfoTree->header()->hide();
120      InfoTree->resize(400, 400);
121
122 }
123
124 InfoPanel::~InfoPanel()
125 {
126 }
127
128 void InfoPanel::Update( input_item_t *p_item)
129 {
130     InfoTree->clear();
131     QTreeWidgetItem *current_item = NULL;
132     QTreeWidgetItem *child_item = NULL;
133
134     for( int i = 0; i< p_item->i_categories ; i++)
135     {
136         current_item = new QTreeWidgetItem();
137         current_item->setText( 0, qfu(p_item->pp_categories[i]->psz_name) );
138         InfoTree->addTopLevelItem( current_item );
139
140         for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
141         {
142             child_item = new QTreeWidgetItem ();
143             child_item->setText( 0,
144                     qfu(p_item->pp_categories[i]->pp_infos[j]->psz_name)
145                     + ": "
146                     + qfu(p_item->pp_categories[i]->pp_infos[j]->psz_value));
147
148             current_item->addChild(child_item);
149         }
150          InfoTree->setItemExpanded( current_item, true);
151     }
152 }
153
154 void InfoPanel::Clear()
155 {
156 }
157