[vlc-commits] Qt: info_panels: use validation mask for tracknumber/total input

Francois Cartegnie git at videolan.org
Tue Dec 18 22:56:50 CET 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 18 21:54:11 2012 +0100| [b74a7b1a177f9d610b021fdefe1963c0f1752151] | committer: Francois Cartegnie

Qt: info_panels: use validation mask for tracknumber/total input

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b74a7b1a177f9d610b021fdefe1963c0f1752151
---

 modules/gui/qt4/components/info_panels.cpp |   37 +++++++++++++++-------------
 modules/gui/qt4/components/info_panels.hpp |    3 +--
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index f139116..7df44b2 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -107,16 +107,12 @@ MetaPanel::MetaPanel( QWidget *parent,
     label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
     metaLayout->addWidget( label, line - 1, 7, 1, 3  );
 
-    seqnum_text = new QLineEdit;
-    seqnum_text->setMaximumWidth( 60 );
-    metaLayout->addWidget( seqnum_text, line, 7, 1, 1 );
+    tracknumber_text = new QLineEdit;
+    tracknumber_text->setAlignment( Qt::AlignRight );
+    tracknumber_text->setInputMask("0000/0000");
+    tracknumber_text->setMaximumWidth( 128 );
+    metaLayout->addWidget( tracknumber_text, line, 7, 1, -1 );
 
-    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 */
@@ -165,8 +161,7 @@ MetaPanel::MetaPanel( QWidget *parent,
     metaLayout->setRowStretch( line, 10 );
 #undef ADD_META
 
-    CONNECT( seqnum_text, textEdited( QString ), this, enterEditMode() );
-    CONNECT( seqtot_text, textEdited( QString ), this, enterEditMode() );
+    CONNECT( tracknumber_text, textEdited( QString ), this, enterEditMode() );
 
     CONNECT( date_text, textEdited( QString ), this, enterEditMode() );
     CONNECT( THEMIM->getIM(), artChanged( QString ), this, enterEditMode() );
@@ -231,8 +226,16 @@ void MetaPanel::update( input_item_t *p_item )
     UPDATE_META( EncodedBy, encodedby_text );
 
     UPDATE_META( Date, date_text );
-    UPDATE_META( TrackNum, seqnum_text );
-    UPDATE_META( TrackTotal, seqtot_text );
+
+    QString trackposition( "%1/%2" );
+    psz_meta = input_item_GetTrackNum( p_item );
+    trackposition = trackposition.arg( psz_meta );
+    free( psz_meta );
+    psz_meta = input_item_GetTrackTotal( p_item );
+    trackposition = trackposition.arg( psz_meta );
+    free( psz_meta );
+    tracknumber_text->setText( trackposition );
+
 //    UPDATE_META( Setting, setting_text );
 //    UPDATE_META_INT( Rating, rating_text );
 
@@ -281,8 +284,9 @@ void MetaPanel::saveMeta()
     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() ) );
+    QStringList trackparts = tracknumber_text->text().split( "/" );
+    input_item_SetTrackNum( p_input, qtu( trackparts[0] ) );
+    input_item_SetTrackTotal( p_input, qtu( trackparts[1] ) );
     input_item_SetDate(  p_input, qtu( date_text->text() ) );
 
     input_item_SetCopyright( p_input, qtu( copyright_text->text() ) );
@@ -324,8 +328,7 @@ void MetaPanel::clear()
     genre_text->clear();
     copyright_text->clear();
     collection_text->clear();
-    seqnum_text->clear();
-    seqtot_text->clear();
+    tracknumber_text->clear();
     description_text->clear();
     date_text->clear();
     language_text->clear();
diff --git a/modules/gui/qt4/components/info_panels.hpp b/modules/gui/qt4/components/info_panels.hpp
index 390fd61..ce30edf 100644
--- a/modules/gui/qt4/components/info_panels.hpp
+++ b/modules/gui/qt4/components/info_panels.hpp
@@ -72,8 +72,7 @@ private:
     QLineEdit *genre_text;
     QLineEdit *copyright_text;
     QLineEdit *collection_text;
-    QLineEdit *seqnum_text;
-    QLineEdit *seqtot_text;
+    QLineEdit *tracknumber_text;
 
     QTextEdit *description_text;
 //    QSpinBox *rating_text;



More information about the vlc-commits mailing list