[vlc-devel] commit: [Qt] Implement a kind of rememberance in Open Network Dialog. ( Jean-Baptiste Kempf )

git version control git at videolan.org
Sun Nov 2 20:18:05 CET 2008


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sat Nov  1 23:16:53 2008 +0100| [bc01f89575b94140e2d59a4b1167320ea954d222] | committer: Jean-Baptiste Kempf 

[Qt] Implement a kind of rememberance in Open Network Dialog.

The code is suboptimal since it does save more often than when accept() is called. This will be fixed in the future.

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

 modules/gui/qt4/components/open_panels.cpp |   32 +++++++++++++++++++++++++--
 modules/gui/qt4/components/open_panels.hpp |    3 ++
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 47eedfb..3376c42 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -44,6 +44,7 @@
 #include <QDirModel>
 #include <QScrollArea>
 #include <QUrl>
+#include <QStringListModel>
 
 #define I_DEVICE_TOOLTIP N_("Select the device or the VIDEO_TS directory")
 
@@ -447,10 +448,29 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
 
     updateProtocol( ui.protocolCombo->currentIndex() );
+
+    if( config_GetInt( p_intf, "qt-recentplay" ) )
+    {
+        mrlList = new QStringListModel(
+                getSettings()->value( "Open/netMRL" ).toStringList() );
+        QCompleter *completer = new QCompleter( mrlList, this );
+        ui.addressText->setCompleter( completer );
+
+        CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
+    }
+    else
+        mrlList = NULL;
 }
 
 NetOpenPanel::~NetOpenPanel()
-{}
+{
+    if( !mrlList ) return;
+
+    QStringList tempL = mrlList->stringList();
+    while( tempL.size() > 8 ) tempL.removeFirst();
+
+    getSettings()->setValue( "Open/netMRL", tempL );
+}
 
 void NetOpenPanel::clear()
 {}
@@ -557,14 +577,20 @@ void NetOpenPanel::updateMRL() {
         }
     }
 
-    // Encode the boring stuffs
-
     if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
         mrl += " :access-filter=timeshift";
     }
     emit mrlUpdated( mrl );
 }
 
+void NetOpenPanel::updateCompleter()
+{
+    assert( mrlList );
+    QStringList tempL = mrlList->stringList();
+    tempL.append( ui.addressText->text() );
+    mrlList->setStringList( tempL );
+}
+
 /**************************************************************************
  * 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 fb59a96..95a9b93 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -81,6 +81,7 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
 class QWidget;
 class QLineEdit;
 class QString;
+class QStringListModel;
 
 class OpenPanel: public QWidget
 {
@@ -143,10 +144,12 @@ public:
     virtual void clear() ;
 private:
     Ui::OpenNetwork ui;
+    QStringListModel *mrlList;
 public slots:
     virtual void updateMRL();
 private slots:
     void updateProtocol( int );
+    void updateCompleter();
 };
 
 class DiscOpenPanel: public OpenPanel




More information about the vlc-devel mailing list