]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/info_panels.cpp
Qt: allow to change the art
[vlc] / modules / gui / qt4 / components / info_panels.cpp
index 5b78c9b7665806573681e43f2496aae80de4aeb7..f1391162fef4d8b68590e7d4c2db736fc0c7b478 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * infopanels.cpp : Panels for the information dialogs
+ * info_panels.cpp : Panels for the information dialogs
  ****************************************************************************
  * Copyright (C) 2006-2007 the VideoLAN team
  * $Id$
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+
+#define __STDC_FORMAT_MACROS 1
+#define __STDC_CONSTANT_MACROS 1
+
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 #include "components/info_panels.hpp"
 #include "components/interface_widgets.hpp"
 
+#include <assert.h>
+#include <vlc_url.h>
+#include <vlc_meta.h>
+
 #include <QTreeWidget>
-#include <QListView>
-#include <QPushButton>
 #include <QHeaderView>
 #include <QList>
 #include <QStringList>
@@ -40,7 +46,7 @@
 #include <QLineEdit>
 #include <QLabel>
 #include <QSpinBox>
-#include <QTabWidget>
+#include <QTextEdit>
 
 /************************************************************************
  * Single panels
@@ -55,123 +61,141 @@ MetaPanel::MetaPanel( QWidget *parent,
                       : QWidget( parent ), p_intf( _p_intf )
 {
     QGridLayout *metaLayout = new QGridLayout( this );
+    metaLayout->setVerticalSpacing( 0 );
+
+    QFont smallFont = QApplication::font();
+    smallFont.setPointSize( smallFont.pointSize() - 1 );
+    smallFont.setBold( true );
 
     int line = 0; /* Counter for GridLayout */
     p_input = NULL;
+    QLabel *label;
 
-#define ADD_META( string, widget ) {                                      \
-    metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
+#define ADD_META( string, widget, col, colspan ) {                        \
+    label = new QLabel( qtr( string ) ); label->setFont( smallFont );     \
+    label->setContentsMargins( 3, 2, 0, 0 );                              \
+    metaLayout->addWidget( label, line++, col, 1, colspan );              \
     widget = new QLineEdit;                                               \
-    metaLayout->addWidget( widget, line, 1, 1, 9 );                       \
-    line++;            }
+    metaLayout->addWidget( widget, line, col, 1, colspan );               \
+    CONNECT( widget, textEdited( QString ), this, enterEditMode() );      \
+}
 
     /* Title, artist and album*/
-    ADD_META( VLC_META_TITLE, title_text ); /* OK */
-    ADD_META( VLC_META_ARTIST, artist_text ); /* OK */
-    ADD_META( VLC_META_ALBUM, collection_text ); /* OK */
+    ADD_META( VLC_META_TITLE, title_text, 0, 10 ); line++;
+    ADD_META( VLC_META_ARTIST, artist_text, 0, 10 ); line++;
+    ADD_META( VLC_META_ALBUM, collection_text, 0, 7 );
+
+    /* Date */
+    label = new QLabel( qtr( VLC_META_DATE ) );
+    label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
+    metaLayout->addWidget( label, line - 1, 7, 1, 2 );
+
+    /* Date (Should be in years) */
+    date_text = new QLineEdit;
+    date_text->setAlignment( Qt::AlignRight );
+    date_text->setInputMask("0000");
+    date_text->setMaximumWidth( 128 );
+    metaLayout->addWidget( date_text, line, 7, 1, -1 );
+    line++;
 
     /* Genre Name */
     /* TODO List id3genres.h is not includable yet ? */
-    genre_text = new QLineEdit;
-    metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 );
-    metaLayout->addWidget( genre_text, line, 1, 1, 3 );
+    ADD_META( VLC_META_GENRE, genre_text, 0, 7 );
 
     /* Number - on the same line */
-    metaLayout->addWidget( new QLabel( qtr( VLC_META_TRACK_NUMBER )  + " :" ),
-                  line, 5, 1, 2  );
+    label = new QLabel( qtr( VLC_META_TRACK_NUMBER ) );
+    label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
+    metaLayout->addWidget( label, line - 1, 7, 1, 3  );
+
     seqnum_text = new QLineEdit;
-    seqnum_text->setInputMask("0000");
-    seqnum_text->setAlignment( Qt::AlignRight );
-    metaLayout->addWidget( seqnum_text, line, 7, 1, 3 );
-    line++;
+    seqnum_text->setMaximumWidth( 60 );
+    metaLayout->addWidget( seqnum_text, line, 7, 1, 1 );
 
-    /* Date (Should be in years) */
-    date_text = new QLineEdit;
-    date_text->setInputMask("0000");
-    date_text->setAlignment( Qt::AlignRight );
-    metaLayout->addWidget( new QLabel( qtr( VLC_META_DATE ) + " :" ), line, 0 );
-    metaLayout->addWidget( date_text, line, 1, 1, 3 );
+    label = new QLabel( "/" ); label->setFont( smallFont );
+    metaLayout->addWidget( label, line, 8, 1, 1 );
+
+    seqtot_text = new QLineEdit;
+    seqtot_text->setMaximumWidth( 60 );
+    metaLayout->addWidget( seqtot_text, line, 9, 1, 1 );
+    line++;
 
     /* Rating - on the same line */
     /*
-    metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) + " :" ), line, 4, 1, 2 );
+    metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) ), line, 4, 1, 2 );
     rating_text = new QSpinBox; setSpinBounds( rating_text );
     metaLayout->addWidget( rating_text, line, 6, 1, 1 );
     */
-    /* Language on the same line */
-    metaLayout->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 5, 1, 2 );
-    language_text = new QLineEdit;
-    language_text->setReadOnly( true );
-    metaLayout->addWidget( language_text, line,  7, 1, 3 );
-    line++;
 
-    /* ART_URL */
-    art_cover = new CoverArtLabel( VLC_OBJECT( p_intf ) );
-    metaLayout->addWidget( art_cover, line, 8, 4, 2, Qt::AlignRight );
+    /* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */
+    ADD_META( VLC_META_NOW_PLAYING, nowplaying_text, 0, 7 );
+    nowplaying_text->setReadOnly( true ); line--;
 
-/* Settings is unused */
-/*    l->addWidget( new QLabel( qtr( VLC_META_SETTING ) + " :" ), line, 5 );
-    setting_text = new QLineEdit;
-    l->addWidget( setting_text, line, 6, 1, 4 ); */
+    /* Language on the same line */
+    ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++;
+    ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 ); line++;
 
-/* Less used metadata */
-#define ADD_META_2( string, widget ) {                                    \
-    metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
-    widget = new QLineEdit;                                               \
-    metaLayout->addWidget( widget, line, 1, 1, 7 );                       \
-    line++;            }
+    lblURL = new QLabel;
+    lblURL->setOpenExternalLinks( true );
+    lblURL->setTextFormat( Qt::RichText );
+    metaLayout->addWidget( lblURL, line -1, 7, 1, -1 );
 
-    /* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */
-    ADD_META_2( VLC_META_NOW_PLAYING, nowplaying_text );
-    nowplaying_text->setReadOnly( true );
-    ADD_META_2( VLC_META_PUBLISHER, publisher_text );
-    ADD_META_2( VLC_META_COPYRIGHT, copyright_text );
-    ADD_META_2( N_("Comments"), description_text );
+    ADD_META( VLC_META_COPYRIGHT, copyright_text, 0,  7 ); line++;
 
-/* useless metadata */
+    /* ART_URL */
+    art_cover = new CoverArtLabel( this, p_intf );
+    metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignLeft );
+
+    ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++;
+
+    label = new QLabel( qtr( N_("Comments") ) ); label->setFont( smallFont );
+    label->setContentsMargins( 3, 2, 0, 0 );
+    metaLayout->addWidget( label, line++, 0, 1, 7 );
+    description_text = new QTextEdit;
+    description_text->setAcceptRichText( false );
+    metaLayout->addWidget( description_text, line, 0, 1, 7 );
+    // CONNECT( description_text, textChanged(), this, enterEditMode() ); //FIXME
+    line++;
 
-    //ADD_META_2( VLC_META_ENCODED_BY, encodedby_text );
-    /*  ADD_META( TRACKID )  Useless ? */
-    /*  ADD_URI - DO not show it, done outside */
+    /* VLC_META_SETTING: Useless */
+    /* ADD_META( TRACKID )  Useless ? */
+    /* ADD_URI - Do not show it, done outside */
 
-    metaLayout->setColumnStretch( 1, 2 );
+    metaLayout->setColumnStretch( 1, 20 );
     metaLayout->setColumnMinimumWidth ( 1, 80 );
+    metaLayout->setRowStretch( line, 10 );
 #undef ADD_META
-#undef ADD_META_2
 
-    CONNECT( title_text, textEdited( QString ), this, enterEditMode() );
-    CONNECT( artist_text, textEdited( QString ), this, enterEditMode() );
-    CONNECT( collection_text, textEdited( QString ), this, enterEditMode() );
-    CONNECT( genre_text, textEdited( QString ), this, enterEditMode() );
     CONNECT( seqnum_text, textEdited( QString ), this, enterEditMode() );
+    CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() );
 
     CONNECT( date_text, textEdited( QString ), this, enterEditMode() );
-    CONNECT( description_text, textEdited( QString ), this, enterEditMode() );
+    CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() );
 /*    CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/
 
     /* We are not yet in Edit Mode */
     b_inEditMode = false;
 }
 
-MetaPanel::~MetaPanel(){}
-
 /**
  * Update all the MetaData and art on an "item-changed" event
  **/
 void MetaPanel::update( input_item_t *p_item )
 {
+    if( !p_item )
+    {
+        clear();
+        return;
+    }
+
     /* Don't update if you are in edit mode */
     if( b_inEditMode ) return;
     else p_input = p_item;
 
     char *psz_meta;
-#define UPDATE_META( meta, widget ) {               \
-    psz_meta = input_item_Get##meta( p_item );      \
-    if( !EMPTY_STR( psz_meta ) )                    \
-        widget->setText( qfu( psz_meta ) );         \
-    else                                            \
-        widget->setText( "" ); }                    \
-    free( psz_meta );
+#define UPDATE_META( meta, widget ) {                                   \
+    psz_meta = input_item_Get##meta( p_item );                          \
+    widget->setText( !EMPTY_STR( psz_meta ) ? qfu( psz_meta ) : "" );   \
+    free( psz_meta ); }
 
 #define UPDATE_META_INT( meta, widget ) {           \
     psz_meta = input_item_Get##meta( p_item );      \
@@ -180,27 +204,19 @@ void MetaPanel::update( input_item_t *p_item )
     free( psz_meta );
 
     /* Name / Title */
-    psz_meta = input_item_GetTitle( p_item );
-    char *psz_name = input_item_GetName( p_item );
-    if( !EMPTY_STR( psz_meta ) )
+    psz_meta = input_item_GetTitleFbName( p_item );
+    if( psz_meta )
+    {
         title_text->setText( qfu( psz_meta ) );
-    else if( !EMPTY_STR( psz_name ) )
-        title_text->setText( qfu( psz_name ) );
-    else title_text->setText( "" );
-    free( psz_meta );
-    free( psz_name );
+        free( psz_meta );
+    }
+    else
+        title_text->setText( "" );
 
     /* URL / URI */
-    psz_meta = input_item_GetURL( p_item );
+    psz_meta = input_item_GetURI( p_item );
     if( !EMPTY_STR( psz_meta ) )
-        emit uriSet( QString( psz_meta ) );
-    else
-    {
-        free( psz_meta );
-        psz_meta = input_item_GetURI( p_item );
-        if( !EMPTY_STR( psz_meta ) )
-            emit uriSet( QString( psz_meta ) );
-    }
+         emit uriSet( qfu( psz_meta ) );
     free( psz_meta );
 
     /* Other classic though */
@@ -212,18 +228,44 @@ void MetaPanel::update( input_item_t *p_item )
     UPDATE_META( Language, language_text );
     UPDATE_META( NowPlaying, nowplaying_text );
     UPDATE_META( Publisher, publisher_text );
-//    UPDATE_META( Setting, setting_text );
-//    UPDATE_META( EncodedBy, encodedby_text );
+    UPDATE_META( EncodedBy, encodedby_text );
 
     UPDATE_META( Date, date_text );
     UPDATE_META( TrackNum, seqnum_text );
+    UPDATE_META( TrackTotal, seqtot_text );
+//    UPDATE_META( Setting, setting_text );
 //    UPDATE_META_INT( Rating, rating_text );
 
+    /* URL */
+    psz_meta = input_item_GetURL( p_item );
+    if( !EMPTY_STR( psz_meta ) )
+    {
+        QString newURL = qfu(psz_meta);
+        if( currentURL != newURL )
+        {
+            currentURL = newURL;
+            lblURL->setText( "<a href='" + currentURL + "'>" +
+                             currentURL.remove( QRegExp( ".*://") ) + "</a>" );
+        }
+    }
+    free( psz_meta );
 #undef UPDATE_META_INT
 #undef UPDATE_META
 
-    /* Update Art */
-    art_cover->update( p_item );
+    // If a artURL is available as a local file, directly display it !
+
+    QString file;
+    char *psz_art = input_item_GetArtURL( p_item );
+    if( psz_art )
+    {
+        char *psz = make_path( psz_art );
+        free( psz_art );
+        file = qfu( psz );
+        free( psz );
+    }
+
+    art_cover->showArtUpdate( file );
+    art_cover->setItem( p_item );
 }
 
 /**
@@ -231,52 +273,24 @@ void MetaPanel::update( input_item_t *p_item )
  **/
 void MetaPanel::saveMeta()
 {
-    playlist_t *p_playlist;
-
-    meta_export_t p_export;
-    p_export.p_item = p_input;
-
     if( p_input == NULL )
         return;
 
-    /* we can write meta data only in a file */
-    vlc_mutex_lock( &p_input->lock );
-    int i_type = p_input->i_type;
-    vlc_mutex_unlock( &p_input->lock );
-    if( i_type == ITEM_TYPE_FILE )
-    {
-        char *psz_uri_orig = input_item_GetURI( p_input );
-        char *psz_uri = psz_uri_orig;
-        if( !strncmp( psz_uri, "file://", 7 ) )
-            psz_uri += 7; /* strlen("file://") = 7 */
-
-        p_export.psz_file = strndup( psz_uri, PATH_MAX );
-        free( psz_uri_orig );
-    }
-    else
-        return;
-
     /* now we read the modified meta data */
     input_item_SetTitle(  p_input, qtu( title_text->text() ) );
     input_item_SetArtist( p_input, qtu( artist_text->text() ) );
     input_item_SetAlbum(  p_input, qtu( collection_text->text() ) );
     input_item_SetGenre(  p_input, qtu( genre_text->text() ) );
     input_item_SetTrackNum(  p_input, qtu( seqnum_text->text() ) );
+    input_item_SetTrackTotal(  p_input, qtu( seqtot_text->text() ) );
     input_item_SetDate(  p_input, qtu( date_text->text() ) );
 
     input_item_SetCopyright( p_input, qtu( copyright_text->text() ) );
     input_item_SetPublisher( p_input, qtu( publisher_text->text() ) );
-    input_item_SetDescription( p_input, qtu( description_text->text() ) );
+    input_item_SetDescription( p_input, qtu( description_text->toPlainText() ) );
 
-    p_playlist = pl_Yield( p_intf );
-    PL_LOCK;
-    p_playlist->p_private = &p_export;
-
-    module_t *p_mod = module_Need( p_playlist, "meta writer", NULL, 0 );
-    if( p_mod )
-        module_Unneed( p_playlist, p_mod );
-    PL_UNLOCK;
-    pl_Release( p_intf );
+    playlist_t *p_playlist = pl_Get( p_intf );
+    input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
 
     /* Reset the status of the mode. No need to emit any signal because parent
        is the only caller */
@@ -291,7 +305,6 @@ bool MetaPanel::isInEditMode()
 
 void MetaPanel::enterEditMode()
 {
-    msg_Dbg( p_intf, "Entering Edit MetaData Mode" );
     setEditMode( true );
 }
 
@@ -312,22 +325,22 @@ void MetaPanel::clear()
     copyright_text->clear();
     collection_text->clear();
     seqnum_text->clear();
+    seqtot_text->clear();
     description_text->clear();
     date_text->clear();
     language_text->clear();
     nowplaying_text->clear();
     publisher_text->clear();
-    art_cover->update( NULL );
+    encodedby_text->clear();
 
     setEditMode( false );
+    emit uriSet( "" );
 }
 
 /**
  * Second Panel - Shows the extra metadata in a tree, non editable.
  **/
-ExtraMetaPanel::ExtraMetaPanel( QWidget *parent,
-                                intf_thread_t *_p_intf )
-                                : QWidget( parent ), p_intf( _p_intf )
+ExtraMetaPanel::ExtraMetaPanel( QWidget *parent ) : QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
@@ -340,12 +353,7 @@ ExtraMetaPanel::ExtraMetaPanel( QWidget *parent,
      extraMetaTree->setAlternatingRowColors( true );
      extraMetaTree->setColumnCount( 2 );
      extraMetaTree->resizeColumnToContents( 0 );
-     extraMetaTree->header()->hide();
-/*     QStringList headerList = ( QStringList() << qtr( "Type" )
- *                                             << qtr( "Value" ) );
- * Useless, add this header if you think it would help the user          **
- */
-
+     extraMetaTree->setHeaderHidden( true );
      layout->addWidget( extraMetaTree, 1, 0 );
 }
 
@@ -354,7 +362,12 @@ ExtraMetaPanel::ExtraMetaPanel( QWidget *parent,
  **/
 void ExtraMetaPanel::update( input_item_t *p_item )
 {
-    QStringList tempItem;
+    if( !p_item )
+    {
+        clear();
+        return;
+    }
+
     QList<QTreeWidgetItem *> items;
 
     extraMetaTree->clear();
@@ -367,13 +380,12 @@ void ExtraMetaPanel::update( input_item_t *p_item )
         return;
     }
 
-    vlc_dictionary_t * p_dict = &p_meta->extra_tags;
-    char ** ppsz_allkey = vlc_dictionary_all_keys( p_dict );
+    char ** ppsz_allkey = vlc_meta_CopyExtraNames( p_meta);
 
     for( int i = 0; ppsz_allkey[i] ; i++ )
     {
-        const char * psz_value = (const char *)vlc_dictionary_value_for_key(
-                p_dict, ppsz_allkey[i] );
+        const char * psz_value = vlc_meta_GetExtra( p_meta, ppsz_allkey[i] );
+        QStringList tempItem;
         tempItem.append( qfu( ppsz_allkey[i] ) + " : ");
         tempItem.append( qfu( psz_value ) );
         items.append( new QTreeWidgetItem ( extraMetaTree, tempItem ) );
@@ -398,9 +410,7 @@ void ExtraMetaPanel::clear()
  * Third panel - Stream info
  * Display all codecs and muxers info that we could gather.
  **/
-InfoPanel::InfoPanel( QWidget *parent,
-                      intf_thread_t *_p_intf )
-                      : QWidget( parent ), p_intf( _p_intf )
+InfoPanel::InfoPanel( QWidget *parent ) : QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
@@ -415,18 +425,21 @@ InfoPanel::InfoPanel( QWidget *parent,
      InfoTree = new QTreeWidget(this);
      InfoTree->setColumnCount( 1 );
      InfoTree->header()->hide();
+     InfoTree->header()->setResizeMode(QHeaderView::ResizeToContents);
      layout->addWidget(InfoTree, 1, 0 );
 }
 
-InfoPanel::~InfoPanel()
-{
-}
-
 /**
  * Update the Codecs information on parent->update()
  **/
 void InfoPanel::update( input_item_t *p_item)
 {
+    if( !p_item )
+    {
+        clear();
+        return;
+    }
+
     InfoTree->clear();
     QTreeWidgetItem *current_item = NULL;
     QTreeWidgetItem *child_item = NULL;
@@ -447,7 +460,7 @@ void InfoPanel::update( input_item_t *p_item)
 
             current_item->addChild(child_item);
         }
-         InfoTree->setItemExpanded( current_item, true);
+        InfoTree->setItemExpanded( current_item, true);
     }
 }
 
@@ -472,22 +485,18 @@ void InfoPanel::saveCodecsInfo()
  * Fourth Panel - Stats
  * Displays the Statistics for reading/streaming/encoding/displaying in a tree
  */
-InputStatsPanel::InputStatsPanel( QWidget *parent,
-                                  intf_thread_t *_p_intf )
-                                  : QWidget( parent ), p_intf( _p_intf )
+InputStatsPanel::InputStatsPanel( QWidget *parent ): QWidget( parent )
 {
      QGridLayout *layout = new QGridLayout(this);
 
-     QList<QTreeWidgetItem *> items;
-
-     QLabel *topLabel = new QLabel( qtr( "Statistics about the currently "
-                 "playing media or stream." ) );
+     QLabel *topLabel = new QLabel( qtr( "Current"
+                 " media / stream " "statistics") );
      topLabel->setWordWrap( true );
      layout->addWidget( topLabel, 0, 0 );
 
      StatsTree = new QTreeWidget(this);
      StatsTree->setColumnCount( 3 );
-     StatsTree->header()->hide();
+     StatsTree->setHeaderHidden( true );
 
 #define CREATE_TREE_ITEM( itemName, itemText, itemValue, unit ) {              \
     itemName =                                                                 \
@@ -506,36 +515,43 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
     /* Create the main categories */
     CREATE_CATEGORY( audio, qtr("Audio") );
     CREATE_CATEGORY( video, qtr("Video") );
-    CREATE_CATEGORY( input, qtr("Input") );
-    CREATE_CATEGORY( streaming, qtr("Streaming") );
+    CREATE_CATEGORY( input, qtr("Input/Read") );
+    CREATE_CATEGORY( streaming, qtr("Output/Written/Sent") );
 
-    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Read at media"),
-                           "0", input , "kB" );
+    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Media data size"),
+                           "0", input , "KiB" );
     CREATE_AND_ADD_TO_CAT( input_bitrate_stat, qtr("Input bitrate"),
                            "0", input, "kb/s" );
-    CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed"), "0", input, "kB") ;
-    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Stream bitrate"),
+    CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed data size"), "0", input, "KiB") ;
+    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Content bitrate"),
                            "0", input, "kb/s" );
-
-    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded blocks"),
-                           "0", video, "" );
-    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed frames"),
-                           "0", video, "" );
-    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost frames"),
-                           "0", video, "" );
-    CREATE_AND_ADD_TO_CAT( vfps_stat, qtr("FPS"), "0", video, "" );
-
-    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent packets"), "0", streaming, "" );
-    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent bytes"),
-                           "0", streaming, "kB" );
-    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Sent bitrate"),
+    CREATE_AND_ADD_TO_CAT( corrupted_stat, qtr("Discarded (corrupted)"),
+                           "0", input, "" );
+    CREATE_AND_ADD_TO_CAT( discontinuity_stat, qtr("Dropped (discontinued)"),
+                           "0", input, "" );
+
+    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded"),
+                           "0", video, qtr("blocks") );
+    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed"),
+                           "0", video, qtr("frames") );
+    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost"),
+                           "0", video, qtr("frames") );
+
+    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent"), "0", streaming, qtr("packets") );
+    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent"),
+                           "0", streaming, "KiB" );
+    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Upstream rate"),
                            "0", streaming, "kb/s" );
 
-    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded blocks"),
-                           "0", audio, "" );
-    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played buffers"),
-                           "0", audio, "" );
-    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost buffers"), "0", audio, "" );
+    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded"),
+                           "0", audio, qtr("blocks") );
+    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played"),
+                           "0", audio, qtr("buffers") );
+    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost"), "0", audio, qtr("buffers") );
+
+#undef CREATE_AND_ADD_TO_CAT
+#undef CREATE_CATEGORY
+#undef CREATE_TREE_ITEM
 
     input->setExpanded( true );
     video->setExpanded( true );
@@ -543,52 +559,50 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
     audio->setExpanded( true );
 
     StatsTree->resizeColumnToContents( 0 );
-    StatsTree->setColumnWidth( 1 , 100 );
+    StatsTree->setColumnWidth( 1 , 200 );
 
     layout->addWidget(StatsTree, 1, 0 );
 }
 
-InputStatsPanel::~InputStatsPanel()
-{
-}
-
 /**
  * Update the Statistics
  **/
 void InputStatsPanel::update( input_item_t *p_item )
 {
+    if ( !isVisible() ) return;
+    assert( p_item );
     vlc_mutex_lock( &p_item->p_stats->lock );
 
-#define UPDATE( widget, format, calc... ) \
+#define UPDATE_INT( widget, calc... ) \
+    { widget->setText( 1, QString::number( (qulonglong)calc ) ); }
+
+#define UPDATE_FLOAT( widget, format, calc... ) \
     { QString str; widget->setText( 1 , str.sprintf( format, ## calc ) );  }
 
-    UPDATE( read_media_stat, "%8.0f",
-            (float)(p_item->p_stats->i_read_bytes)/1000);
-    UPDATE( input_bitrate_stat, "%6.0f",
-                    (float)(p_item->p_stats->f_input_bitrate * 8000 ));
-    UPDATE( demuxed_stat, "%8.0f",
-                    (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
-    UPDATE( stream_bitrate_stat, "%6.0f",
-                    (float)(p_item->p_stats->f_demux_bitrate * 8000 ));
+    UPDATE_INT( read_media_stat, (p_item->p_stats->i_read_bytes / 1024 ) );
+    UPDATE_FLOAT( input_bitrate_stat,  "%6.0f", (float)(p_item->p_stats->f_input_bitrate *  8000  ));
+    UPDATE_INT( demuxed_stat,    (p_item->p_stats->i_demux_read_bytes / 1024 ) );
+    UPDATE_FLOAT( stream_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_demux_bitrate *  8000  ));
+    UPDATE_INT( corrupted_stat,      p_item->p_stats->i_demux_corrupted );
+    UPDATE_INT( discontinuity_stat,  p_item->p_stats->i_demux_discontinuity );
 
     /* Video */
-    UPDATE( vdecoded_stat, "%5i", p_item->p_stats->i_decoded_video );
-    UPDATE( vdisplayed_stat, "%5i", p_item->p_stats->i_displayed_pictures );
-    UPDATE( vlost_frames_stat, "%5i", p_item->p_stats->i_lost_pictures );
-/*  UPDATE( vfps_stat, "%5f", p_item->p_stats->i_lost_pictures );
-input_Control( p_input_thread, INPUT_GET_VIDEO_FPS, &f_fps */
+    UPDATE_INT( vdecoded_stat,     p_item->p_stats->i_decoded_video );
+    UPDATE_INT( vdisplayed_stat,   p_item->p_stats->i_displayed_pictures );
+    UPDATE_INT( vlost_frames_stat, p_item->p_stats->i_lost_pictures );
 
     /* Sout */
-    UPDATE( send_stat, "%5i", p_item->p_stats->i_sent_packets );
-    UPDATE( send_bytes_stat, "%8.0f",
-            (float)(p_item->p_stats->i_sent_bytes)/1000 );
-    UPDATE( send_bitrate_stat, "%6.0f",
-            (float)(p_item->p_stats->f_send_bitrate*8)*1000 );
+    UPDATE_INT( send_stat,        p_item->p_stats->i_sent_packets );
+    UPDATE_INT( send_bytes_stat,  (p_item->p_stats->i_sent_bytes)/ 1024 );
+    UPDATE_FLOAT( send_bitrate_stat, "%6.0f", (float)(p_item->p_stats->f_send_bitrate * 8000 ) );
 
     /* Audio*/
-    UPDATE( adecoded_stat, "%5i", p_item->p_stats->i_decoded_audio );
-    UPDATE( aplayed_stat, "%5i", p_item->p_stats->i_played_abuffers );
-    UPDATE( alost_stat, "%5i", p_item->p_stats->i_lost_abuffers );
+    UPDATE_INT( adecoded_stat, p_item->p_stats->i_decoded_audio );
+    UPDATE_INT( aplayed_stat,  p_item->p_stats->i_played_abuffers );
+    UPDATE_INT( alost_stat,    p_item->p_stats->i_lost_abuffers );
+
+#undef UPDATE_INT
+#undef UPDATE_FLOAT
 
     vlc_mutex_unlock(& p_item->p_stats->lock );
 }
@@ -596,3 +610,4 @@ input_Control( p_input_thread, INPUT_GET_VIDEO_FPS, &f_fps */
 void InputStatsPanel::clear()
 {
 }
+