Commit 6a42cf33 authored by Clément Stenac's avatar Clément Stenac

* Allow service discoveries to state whether they prefer being displayed as tree

* Start putting together all interface strings (Refs:#703)
parent abd5dd87
......@@ -62,6 +62,7 @@ struct input_item_t
mtime_t i_duration; /**< Duration in milliseconds*/
uint8_t i_type; /**< Type (file, disc, ...) */
vlc_bool_t b_prefers_tree; /**< Do we prefer being displayed as tree*/
int i_categories; /**< Number of info categories */
info_category_t **pp_categories; /**< Pointer to the first info category */
......
/*****************************************************************************
* vlc_intf_strings.h : Strings for main interfaces
*****************************************************************************
* Copyright (C) 2003 the VideoLAN team
* $Id: vlc_config_cat.h 16001 2006-07-09 15:01:13Z dionoea $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _VLC_ISTRINGS_H
#define _VLC_ISTRINGS_H 1
/*************** Open dialogs **************/
#define I_POP_SEL_FILES N_("Select one or more files to open")
/******************* Menus *****************/
/* Playlist popup */
#define I_POP_PLAY N_("Play")
#define I_POP_PREPARSE N_("Fetch information")
#define I_POP_DEL N_("Delete")
#define I_POP_INFO N_("Information")
#define I_POP_SORT N_("Sort")
#define I_POP_ADD N_("Add node")
#endif
......@@ -135,6 +135,9 @@ struct playlist_t
playlist_item_t * p_local_onelevel; /** < "Playlist" in ONELEVEL view */
playlist_item_t * p_ml_onelevel; /** < "Library" in ONELEVEL iew */
vlc_bool_t b_always_tree;/**< Always display as tree */
vlc_bool_t b_never_tree;/**< Never display as tree */
/* Runtime */
input_thread_t * p_input; /**< the input thread associated
* with the current item */
......@@ -410,6 +413,7 @@ VLC_EXPORT( playlist_item_t *, playlist_ChildSearchName, (playlist_item_t*, cons
VLC_EXPORT( int, playlist_NodeDelete, ( playlist_t *, playlist_item_t *, vlc_bool_t , vlc_bool_t ) );
VLC_EXPORT( int, playlist_NodeEmpty, ( playlist_t *, playlist_item_t *, vlc_bool_t ) );
VLC_EXPORT( void, playlist_NodesCreateForSD, (playlist_t *, char *, playlist_item_t **, playlist_item_t ** ) );
VLC_EXPORT( playlist_item_t *, playlist_GetPreferredNode, ( playlist_t *p_playlist, playlist_item_t *p_node ) );
/* Tree walking - These functions are only for playlist, not plugins */
playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
......
......@@ -530,6 +530,7 @@ struct module_symbols_t
int (*vlc_DictLookup_inner) (dict_t *, int, const char *);
void (*vlc_DictClear_inner) (dict_t *);
dict_t * (*vlc_DictNew_inner) (void);
playlist_item_t * (*playlist_GetPreferredNode_inner) (playlist_t *p_playlist, playlist_item_t *p_node);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
......@@ -995,6 +996,7 @@ struct module_symbols_t
# define vlc_DictLookup (p_symbols)->vlc_DictLookup_inner
# define vlc_DictClear (p_symbols)->vlc_DictClear_inner
# define vlc_DictNew (p_symbols)->vlc_DictNew_inner
# define playlist_GetPreferredNode (p_symbols)->playlist_GetPreferredNode_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
......@@ -1463,6 +1465,7 @@ struct module_symbols_t
((p_symbols)->vlc_DictLookup_inner) = vlc_DictLookup; \
((p_symbols)->vlc_DictClear_inner) = vlc_DictClear; \
((p_symbols)->vlc_DictNew_inner) = vlc_DictNew; \
((p_symbols)->playlist_GetPreferredNode_inner) = playlist_GetPreferredNode; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__playlist_ItemNew_deprecated = NULL; \
(p_symbols)->__playlist_ItemCopy_deprecated = NULL; \
......
......@@ -132,6 +132,8 @@ void StandardPLPanel::setRoot( int i_root_id )
{
playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
assert( p_item );
p_item = playlist_GetPreferredNode( THEPL, p_item );
assert( p_item );
model->rebuild( p_item );
}
......
......@@ -30,6 +30,7 @@
#include <QApplication>
#include <QSignalMapper>
#include "menus.hpp"
#include <vlc_intf_strings.h>
DialogsProvider* DialogsProvider::instance = NULL;
......@@ -198,9 +199,7 @@ void DialogsProvider::simpleOpenDialog()
FileTypes.replace(QString(";*"), QString(" *"));
QStringList fileList = QFileDialog::getOpenFileNames(
NULL,
qtr("Select one or more files to open"),
p_intf->p_vlc->psz_homedir,
NULL, qfu(I_POP_SEL_FILES ), p_intf->p_vlc->psz_homedir,
FileTypes);
QStringList files = fileList;
......
......@@ -28,6 +28,7 @@
#include "playlist_model.hpp"
#include <assert.h>
#include <QMenu>
#include <vlc_intf_strings.h>
#include "pixmaps/type_unknown.xpm"
#include "pixmaps/type_afile.xpm"
......@@ -110,7 +111,7 @@ void PLItem::remove( PLItem *removed )
int PLItem::row() const
{
if (parentItem)
if( parentItem )
return parentItem->children.indexOf(const_cast<PLItem*>(this));
return 0;
}
......@@ -285,7 +286,8 @@ QModelIndex PLModel::index( PLItem *item, int column ) const
if( !item ) return QModelIndex();
const PLItem *parent = item->parent();
if( parent )
return createIndex( parent->children.lastIndexOf( item ), column, item );
return createIndex( parent->children.lastIndexOf( item ),
column, item );
return QModelIndex();
}
......@@ -297,6 +299,11 @@ QModelIndex PLModel::parent(const QModelIndex &index) const
if( !childItem ) { msg_Err( p_playlist, "NULL CHILD \n" ); return QModelIndex(); }
PLItem *parentItem = childItem->parent();
if( !parentItem || parentItem == rootItem ) return QModelIndex();
if( ! parentItem->parentItem )
{
msg_Err( p_playlist, "No parent parent, trying row 0 ----- PLEASE REPORT THIS ------" );
return createIndex( 0, 0, parentItem );
}
QModelIndex ind = createIndex(parentItem->row(), 0, parentItem);
return ind;
}
......@@ -642,16 +649,15 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
PL_UNLOCK;
current_selection = list;
QMenu *menu = new QMenu;
menu->addAction( qtr("Play"), this, SLOT( popupPlay() ) );
menu->addAction( qtr("Fetch information"), this,
SLOT( popupPreparse() ) );
menu->addAction( qtr("Delete"), this, SLOT( popupDel() ) );
menu->addAction( qtr("Information"), this, SLOT( popupInfo() ) );
menu->addAction( qfu(I_POP_PLAY), this, SLOT( popupPlay() ) );
menu->addAction( qfu(I_POP_PREPARSE), this, SLOT( popupPreparse() ) );
menu->addAction( qfu(I_POP_DEL), this, SLOT( popupDel() ) );
menu->addAction( qfu(I_POP_INFO), this, SLOT( popupInfo() ) );
if( p_item->i_children > -1 )
{
menu->addSeparator();
menu->addAction( qtr("Sort"), this, SLOT( popupSort() ) );
menu->addAction( qtr("Add node"), this, SLOT( popupAdd() ) );
menu->addAction( qfu(I_POP_SORT), this, SLOT( popupSort() ) );
menu->addAction( qfu(I_POP_ADD), this, SLOT( popupAdd() ) );
}
menu->popup( point );
}
......
......@@ -154,6 +154,7 @@ static int Open( vlc_object_t *p_this, int i_type )
0, NULL, -1 );
break;
}
p_sys->p_input->b_prefers_tree = VLC_TRUE;
p_sys->p_node_cat = playlist_NodeAddInput( p_playlist, p_sys->p_input,
p_playlist->p_root_category,
PLAYLIST_APPEND, PLAYLIST_END );
......
......@@ -256,6 +256,7 @@ input_item_t *input_ItemNewWithType( vlc_object_t *p_obj, const char *psz_uri,
p_input->psz_name = strdup ( p_input->psz_uri );
p_input->i_type = i_type;
p_input->b_prefers_tree = VLC_FALSE;
if( p_input->i_type == ITEM_TYPE_UNKNOWN )
GuessType( p_input );
......
......@@ -304,6 +304,34 @@ void playlist_NodesCreateForSD( playlist_t *p_playlist, char *psz_name,
(*pp_node_one)->p_input->i_id = (*pp_node_cat)->p_input->i_id;
}
playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist,
playlist_item_t *p_node )
{
int i;
if( p_node->p_parent == p_playlist->p_root_category )
{
if( p_playlist->b_always_tree ||
p_node->p_input->b_prefers_tree ) return p_node;
for( i = 0 ; i< p_playlist->p_root_onelevel->i_children; i++ )
{
if( p_playlist->p_root_onelevel->pp_children[i]->p_input->i_id ==
p_node->p_input->i_id )
return p_playlist->p_root_onelevel->pp_children[i];
}
}
else if( p_node->p_parent == p_playlist->p_root_onelevel )
{
if( p_playlist->b_never_tree || !p_node->p_input->b_prefers_tree )
return p_node;
for( i = 0 ; i< p_playlist->p_root_category->i_children; i++ )
{
if( p_playlist->p_root_category->pp_children[i]->p_input->i_id ==
p_node->p_input->i_id )
return p_playlist->p_root_category->pp_children[i];
}
}
return NULL;
}
/**********************************************************************
* Tree walking functions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment