[vlc-devel] commit: Qt4: remove proto combo from open net tab ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Nov 25 21:38:09 CET 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 25 22:35:23 2009 +0200| [3ae0e266205878bd66b004ee23b40b2c2433b74e] | committer: Rémi Denis-Courmont
Qt4: remove proto combo from open net tab
Now, we get the URL directly. This is much simpler and much less
confusing. Also a few missing network protocols.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3ae0e266205878bd66b004ee23b40b2c2433b74e
---
modules/gui/qt4/components/open_panels.cpp | 135 +++++++++------------------
modules/gui/qt4/components/open_panels.hpp | 14 ---
modules/gui/qt4/ui/open_net.ui | 32 ++-----
3 files changed, 52 insertions(+), 129 deletions(-)
diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index db28924..9d11c8e 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -492,30 +492,16 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
ui.setupUi( this );
/* CONNECTs */
- CONNECT( ui.protocolCombo, activated( int ),
- this, updateProtocol( int ) );
- CONNECT( ui.addressText, textChanged( const QString& ), this, updateMRL());
-
- ui.protocolCombo->addItem( "" );
- ui.protocolCombo->addItem("HTTP", QVariant("http"));
- ui.protocolCombo->addItem("HTTPS", QVariant("https"));
- ui.protocolCombo->addItem("MMS", QVariant("mms"));
- ui.protocolCombo->addItem("FTP", QVariant("ftp"));
- ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
- ui.protocolCombo->addItem("RTP", QVariant("rtp"));
- ui.protocolCombo->addItem("UDP", QVariant("udp"));
- ui.protocolCombo->addItem("RTMP", QVariant("rtmp"));
-
- updateProtocol( ui.protocolCombo->currentIndex() );
+ CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
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 );
+ ui.urlText->setCompleter( completer );
- CONNECT( ui.addressText, editingFinished(), this, updateCompleter() );
+ CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
}
else
mrlList = NULL;
@@ -536,80 +522,49 @@ NetOpenPanel::~NetOpenPanel()
void NetOpenPanel::clear()
{}
-/* update the widgets according the type of protocol */
-void NetOpenPanel::updateProtocol( int idx_proto ) {
- QString addr = ui.addressText->text();
- QString proto = ui.protocolCombo->itemData( idx_proto ).toString();
-
- if( idx_proto == NO_PROTO ) return;
-
- /* If we already have a protocol in the address, replace it */
- if( addr.contains( "://"))
- {
- if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
- addr.replace( QRegExp("^.*://@*"), proto + "://");
- else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
- ( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
- !addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
- addr.replace( QRegExp("^.*://"), proto + "://@");
- else
- addr.replace( QRegExp("^.*://"), proto + "://");
- addr.replace( QRegExp("@+"), "@");
- ui.addressText->setText( addr );
- }
- updateMRL();
+static int strcmp_void( const void *k, const void *e )
+{
+ return strcmp( (const char *)k, (const char *)e );
}
-void NetOpenPanel::updateMRL() {
- QString mrl = "";
- QString addr = ui.addressText->text();
- int idx_proto = ui.protocolCombo->currentIndex();
- if( addr.contains( "://"))
- {
- /* Match the correct item in the comboBox */
- ui.protocolCombo->setCurrentIndex(
- ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
- mrl = addr;
- }
- else
+void NetOpenPanel::updateMRL()
+{
+ static const struct caching_map
{
- switch( idx_proto ) {
- case HTTP_PROTO:
- mrl = "http://" + addr;
- emit methodChanged("http-caching");
- break;
- case HTTPS_PROTO:
- mrl = "https://" + addr;
- emit methodChanged("http-caching");
- break;
- case MMS_PROTO:
- mrl = "mms://" + addr;
- emit methodChanged("mms-caching");
- break;
- case FTP_PROTO:
- mrl = "ftp://" + addr;
- emit methodChanged("ftp-caching");
- break;
- case RTSP_PROTO:
- mrl = "rtsp://" + addr;
- emit methodChanged("rtsp-caching");
- break;
- case RTP_PROTO:
- case UDP_PROTO:
- mrl = qfu(((idx_proto == RTP_PROTO) ? "rtp" : "udp"));
- mrl += qfu( "://" );
- mrl += addr;
- emit methodChanged(idx_proto == RTP_PROTO
- ? "rtp-caching" : "udp-caching");
- break;
- case RTMP_PROTO:
- mrl = "rtmp://" + addr;
- emit methodChanged("rtmp-caching");
- break;
- }
- }
-
- QStringList qsl; qsl<< mrl;
+ char proto[6];
+ char caching[6];
+ } schemes[] =
+ { /* KEEP alphabetical order on first column!! */
+ { "ftp", "ftp" },
+ { "ftps", "ftp" },
+ { "http", "http" },
+ { "https", "http" },
+ { "mms", "mms" },
+ { "mmsh", "mms" },
+ { "mmst", "mms" },
+ { "mmsu", "mms" },
+ { "sftp", "sftp" },
+ { "smb", "smb" },
+ { "rtmp", "rtmp" },
+ { "rtp", "rtp" },
+ { "rtsp", "rtsp" },
+ { "udp", "udp" },
+ };
+
+ QString url = ui.urlText->text();
+ if( !url.contains( "://") )
+ return; /* nothing to do this far */
+
+ /* Match the correct item in the comboBox */
+ QString proto = url.section( ':', 0, 0 );
+ const struct caching_map *r = (const struct caching_map *)
+ bsearch( qtu(proto), schemes, sizeof(schemes) / sizeof(schemes[0]),
+ sizeof(schemes[0]), strcmp_void );
+ if( r != NULL )
+ emit methodChanged( qfu( r->caching ) + qfu( "-caching" ) );
+
+ QStringList qsl;
+ qsl << url;
emit mrlUpdated( qsl, "" );
}
@@ -617,8 +572,8 @@ void NetOpenPanel::updateCompleter()
{
assert( mrlList );
QStringList tempL = mrlList->stringList();
- if( !tempL.contains( ui.addressText->text() ) )
- tempL.append( ui.addressText->text() );
+ if( !tempL.contains( ui.urlText->text() ) )
+ tempL.append( ui.urlText->text() );
mrlList->setStringList( tempL );
}
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 475d06e..fee9fee 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -48,19 +48,6 @@
enum
{
- NO_PROTO,
- HTTP_PROTO,
- HTTPS_PROTO,
- MMS_PROTO,
- FTP_PROTO,
- RTSP_PROTO,
- RTP_PROTO,
- UDP_PROTO,
- RTMP_PROTO
-};
-
-enum
-{
V4L_DEVICE,
V4L2_DEVICE,
PVR_DEVICE,
@@ -154,7 +141,6 @@ private:
public slots:
virtual void updateMRL();
private slots:
- void updateProtocol( int );
void updateCompleter();
};
diff --git a/modules/gui/qt4/ui/open_net.ui b/modules/gui/qt4/ui/open_net.ui
index af668b4..a7de63b 100644
--- a/modules/gui/qt4/ui/open_net.ui
+++ b/modules/gui/qt4/ui/open_net.ui
@@ -20,25 +20,8 @@
<string>Network Protocol</string>
</property>
<layout class="QGridLayout" >
- <item row="1" column="0" >
- <widget class="QComboBox" name="protocolCombo" >
- <property name="toolTip" >
- <string>Select the protocol for the URL.</string>
- </property>
- </widget>
- </item>
<item row="0" column="0" >
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Protocol</string>
- </property>
- <property name="buddy" >
- <cstring>protocolCombo</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QLabel" name="label_2" >
+ <widget class="QLabel" name="label_1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
@@ -46,17 +29,17 @@
</sizepolicy>
</property>
<property name="text" >
- <string>Address</string>
+ <string>URL</string>
</property>
<property name="buddy" >
- <cstring>addressText</cstring>
+ <cstring>urlText</cstring>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="QLineEdit" name="addressText" >
+ <item row="1" column="0" >
+ <widget class="QLineEdit" name="urlText" >
<property name="toolTip" >
- <string>Enter the URL of the network stream here, with or without the protocol.</string>
+ <string>Enter the URL of the network stream here.</string>
</property>
</widget>
</item>
@@ -82,8 +65,7 @@
</layout>
</widget>
<tabstops>
- <tabstop>protocolCombo</tabstop>
- <tabstop>addressText</tabstop>
+ <tabstop>urlText</tabstop>
</tabstops>
<resources/>
<connections/>
More information about the vlc-devel
mailing list