]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist_model.cpp
Qt: reindent
[vlc] / modules / gui / qt4 / components / playlist / playlist_model.cpp
index fb74cf66fc46955e36e542ab6996fc704e964252..ca718aeafaee94e92871145562310ec83c0f3a8c 100644 (file)
@@ -353,7 +353,7 @@ QVariant PLModel::data( const QModelIndex &index, const int role ) const
     else if( role == Qt::FontRole )
     {
         QFont f;
-        f.setPointSize( f.pointSize() - 2 );
+        f.setPointSize( f.pointSize() - 1 );
         if( isCurrent( index ) )
             f.setBold( true );
         return QVariant( f );
@@ -911,6 +911,9 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
         return false;
     }
 
+    input_item_t *p_input = p_item->p_input;
+    vlc_gc_incref( p_input );
+
     i_popup_item = index.isValid() ? p_item->i_id : -1;
     i_popup_parent = index.isValid() ?
         ( p_item->p_parent ? p_item->p_parent->i_id : -1 ) :
@@ -932,8 +935,9 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
                         qtr(I_POP_STREAM), this, SLOT( popupStream() ) );
         menu.addAction( qtr(I_POP_SAVE), this, SLOT( popupSave() ) );
         menu.addAction( QIcon( ":/menu/info" ), qtr(I_POP_INFO), this, SLOT( popupInfo() ) );
-        menu.addAction( QIcon( ":/type/folder-grey" ),
-                        qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
+        if( !strncasecmp( p_input->psz_uri, "file://", 7 ) )
+            menu.addAction( QIcon( ":/type/folder-grey" ),
+                            qtr( I_POP_EXPLORE ), this, SLOT( popupExplore() ) );
         menu.addSeparator();
     }
     if( canEdit() )
@@ -980,6 +984,8 @@ bool PLModel::popup( const QModelIndex & index, const QPoint &point, const QMode
         }
         menu.addMenu( sortingMenu );
     }
+    vlc_gc_decref( p_input );
+
     if( !menu.isEmpty() )
     {
         menu.exec( point ); return true;
@@ -1041,29 +1047,35 @@ void PLModel::popupExplore()
 {
     PL_LOCK;
     playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
-                                                    i_popup_item );
+            i_popup_item );
     if( p_item )
     {
-       input_item_t *p_input = p_item->p_input;
-       char *psz_meta = input_item_GetURI( p_input );
-       PL_UNLOCK;
-       if( psz_meta )
-       {
-           const char *psz_access;
-           const char *psz_demux;
-           char  *psz_path;
-           input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
-
-           if( !EMPTY_STR( psz_access ) && (
+        input_item_t *p_input = p_item->p_input;
+        char *psz_meta = input_item_GetURI( p_input );
+        PL_UNLOCK;
+        if( psz_meta )
+        {
+            const char *psz_access;
+            const char *psz_demux;
+            char  *psz_path;
+            input_SplitMRL( &psz_access, &psz_demux, &psz_path, psz_meta );
+
+            if( !EMPTY_STR( psz_access ) && (
                    !strncasecmp( psz_access, "file", 4 ) ||
                    !strncasecmp( psz_access, "dire", 4 ) ))
-           {
-               QFileInfo info( qfu( decode_URI( psz_path ) ) );
-               QDesktopServices::openUrl(
-                               QUrl::fromLocalFile( info.absolutePath() ) );
-           }
-           free( psz_meta );
-       }
+            {
+#ifdef WIN32
+                /* Qt openURL doesn't know to open files that starts with a / or \ */
+                if( psz_path[0] == '/' || psz_path[0] == '\\'  )
+                    psz_path++;
+#endif
+
+                QFileInfo info( qfu( decode_URI( psz_path ) ) );
+                QDesktopServices::openUrl(
+                        QUrl::fromLocalFile( info.absolutePath() ) );
+            }
+            free( psz_meta );
+        }
     }
     else
         PL_UNLOCK;
@@ -1076,13 +1088,12 @@ void PLModel::popupAddNode()
         qtr( I_NEW_DIR ), qtr( I_NEW_DIR_NAME ),
         QLineEdit::Normal, QString(), &ok);
     if( !ok || name.isEmpty() ) return;
+
     PL_LOCK;
     playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
                                                     i_popup_parent );
     if( p_item )
-    {
         playlist_NodeCreate( p_playlist, qtu( name ), p_item, PLAYLIST_END, 0, NULL );
-    }
     PL_UNLOCK;
 }