[vlc-commits] Qt: open network fixes and simplifications
Jean-Baptiste Kempf
git at videolan.org
Fri Sep 16 18:50:40 CEST 2011
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Sep 16 18:42:37 2011 +0200| [0268197b7e6a19beda7f95d048c4b6cfb1c59368] | committer: Jean-Baptiste Kempf
Qt: open network fixes and simplifications
Close #5328
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0268197b7e6a19beda7f95d048c4b6cfb1c59368
---
modules/gui/qt4/components/open_panels.cpp | 66 +++++++++++++++-------------
modules/gui/qt4/components/open_panels.hpp | 6 +-
modules/gui/qt4/dialogs/open.cpp | 4 +-
3 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index c1a57e0..8c3b50b 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -565,40 +565,50 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf )
{
ui.setupUi( this );
+ CONNECT( ui.urlComboBox, editTextChanged( const QString& ), this, updateMRL());
- /* CONNECTs */
- CONNECT( ui.urlComboBox->lineEdit(), textChanged( const QString& ), this, updateMRL());
- CONNECT( ui.urlComboBox, currentIndexChanged( const QString& ), this, updateMRL());
-
+ /* */
if( var_InheritBool( p_intf, "qt-recentplay" ) )
{
- mrlList = new QStringListModel(
- getSettings()->value( "Open/netMRL" ).toStringList() );
- ui.urlComboBox->setModel( mrlList );
- ui.urlComboBox->clearEditText();
- CONNECT( ui.urlComboBox->lineEdit(), editingFinished(), this, updateModel() );
+ b_recentList = true;
+ ui.urlComboBox->addItems( getSettings()->value( "Open/netMRL" ).toStringList() );
+ ui.urlComboBox->setMaxCount( 10 );
}
else
- mrlList = NULL;
+ b_recentList = false;
+ /* Use a simple validator for URLs */
ui.urlComboBox->setValidator( new UrlValidator( this ) );
ui.urlComboBox->setFocus();
}
NetOpenPanel::~NetOpenPanel()
{
- if( !mrlList ) return;
+ if( !b_recentList ) return;
- QStringList tempL = mrlList->stringList();
- while( tempL.count() > 8 ) tempL.removeFirst();
+ /* Create the list with the current items */
+ QStringList mrlList;
+ for( int i = 0; i < ui.urlComboBox->count(); i++ )
+ mrlList << ui.urlComboBox->itemText( i );
- getSettings()->setValue( "Open/netMRL", tempL );
-
- delete mrlList;
+ /* Clean the list... */
+#if HAS_QT45
+ mrlList.removeDuplicates();
+#endif
+ /* ...and save the 8 last entries */
+ getSettings()->setValue( "Open/netMRL", mrlList );
}
void NetOpenPanel::clear()
-{}
+{
+ ui.urlComboBox->clear();
+}
+
+void NetOpenPanel::onAccept()
+{
+ if( ui.urlComboBox->findText( ui.urlComboBox->currentText() ) == -1 )
+ ui.urlComboBox->insertItem( 0, ui.urlComboBox->currentText());
+}
void NetOpenPanel::onFocus()
{
@@ -610,6 +620,9 @@ void NetOpenPanel::updateMRL()
{
QString url = ui.urlComboBox->lineEdit()->text();
+ if( url.isEmpty() )
+ return;
+
emit methodChanged( qfu( "network-caching" ) );
QStringList qsl;
@@ -617,20 +630,6 @@ void NetOpenPanel::updateMRL()
emit mrlUpdated( qsl, "" );
}
-void NetOpenPanel::updateModel()
-{
- assert( mrlList );
- QStringList tempL = mrlList->stringList();
- if( !tempL.contains( ui.urlComboBox->lineEdit()->text() ) )
- tempL.append( ui.urlComboBox->lineEdit()->text() );
- mrlList->setStringList( tempL );
-}
-
-void UrlValidator::fixup( QString& str ) const
-{
- str = str.trimmed();
-}
-
QValidator::State UrlValidator::validate( QString& str, int& ) const
{
if( str.contains( ' ' ) )
@@ -640,6 +639,11 @@ QValidator::State UrlValidator::validate( QString& str, int& ) const
return QValidator::Acceptable;
}
+void UrlValidator::fixup( QString& str ) const
+{
+ str = str.trimmed();
+}
+
/**************************************************************************
* Open Capture device ( DVB, PVR, V4L, and similar ) *
**************************************************************************/
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 3f317c7..6d26855 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -73,6 +73,7 @@ public:
virtual ~OpenPanel() {};
virtual void clear() = 0;
virtual void onFocus() {}
+ virtual void onAccept() {}
protected:
intf_thread_t *p_intf;
public slots:
@@ -140,13 +141,12 @@ public:
virtual ~NetOpenPanel();
virtual void clear() ;
void onFocus();
+ void onAccept();
private:
Ui::OpenNetwork ui;
- QStringListModel *mrlList;
+ bool b_recentList;
public slots:
virtual void updateMRL();
-private slots:
- void updateModel();
};
class UrlValidator : public QValidator
diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp
index 2133ae9..f5b9892 100644
--- a/modules/gui/qt4/dialogs/open.cpp
+++ b/modules/gui/qt4/dialogs/open.cpp
@@ -358,8 +358,8 @@ void OpenDialog::enqueue( bool b_enqueue )
return;
}
-/* for( int i = 0; i < OPEN_TAB_MAX; i++ )
- dynamic_cast<OpenPanel*>( ui.Tab->widget( i ) )->onAccept(); */
+ for( int i = 0; i < OPEN_TAB_MAX; i++ )
+ dynamic_cast<OpenPanel*>( ui.Tab->widget( i ) )->onAccept();
/* Sort alphabetically */
itemsMRL.sort();
More information about the vlc-commits
mailing list