本文整理汇总了C++中meta::TrackPtr::editor方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::editor方法的具体用法?C++ TrackPtr::editor怎么用?C++ TrackPtr::editor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::editor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rx
void Playlist::PrettyItemDelegate::setModelData( QWidget * editor, QAbstractItemModel * model, const QModelIndex &index ) const
{
Q_UNUSED( model )
InlineEditorWidget * inlineEditor = qobject_cast<InlineEditorWidget *>( editor );
if( !inlineEditor )
return;
QMap<int, QString> changeMap = inlineEditor->changedValues();
debug() << "got inline editor!!";
debug() << "changed values map: " << changeMap;
//ok, now get the track, figure out if it is editable and if so, apply new values.
//It's as simple as that! :-)
Meta::TrackPtr track = index.data( TrackRole ).value<Meta::TrackPtr>();
if( !track )
return;
// this does not require TrackEditor
if( changeMap.contains( Rating ) )
{
int rating = changeMap.value( Rating ).toInt();
track->statistics()->setRating( rating );
changeMap.remove( Rating );
}
Meta::TrackEditorPtr ec = track->editor();
if( !ec )
return;
QList<int> columns = changeMap.keys();
foreach( int column, columns )
{
QString value = changeMap.value( column );
switch( column )
{
case Album:
ec->setAlbum( value );
break;
case Artist:
ec->setArtist( value );
break;
case Comment:
ec->setComment( value );
break;
case Composer:
ec->setComposer( value );
break;
case DiscNumber:
{
int discNumber = value.toInt();
ec->setDiscNumber( discNumber );
break;
}
case Genre:
ec->setGenre( value );
break;
case Rating:
break; // we've already set the rating, this even shouldn't be here
case Title:
ec->setTitle( value );
break;
case TitleWithTrackNum:
{
debug() << "parse TitleWithTrackNum";
//we need to parse out the track number and the track name (and check
//if the string is even valid...)
//QRegExp rx("(\\d+)\\s-\\s(.*))");
QRegExp rx("(\\d+)(\\s-\\s)(.*)");
if ( rx.indexIn( value ) != -1) {
int trackNumber = rx.cap( 1 ).toInt();
QString trackName = rx.cap( 3 );
debug() << "split TitleWithTrackNum into " << trackNumber << " and " << trackName;
ec->setTrackNumber( trackNumber );
ec->setTitle( trackName );
}
break;
}
case TrackNumber:
{
int TrackNumber = value.toInt();
ec->setTrackNumber( TrackNumber );
break;
}
case Year:
ec->setYear( value.toInt() );
break;
case Bpm:
ec->setBpm( value.toFloat() );
break;
}
}
示例2: ac
void
CurrentTrack::setupLayoutActions( Meta::TrackPtr track )
{
if( !track )
return;
PERF_LOG( "Begin actions layout setup" );
//first, add any global CurrentTrackActions (iow, actions that are shown for all tracks)
QList<QAction *> actions = The::globalCurrentTrackActions()->actions();
using namespace Capabilities;
QScopedPointer<ActionsCapability> ac( track->create<ActionsCapability>() );
if( ac )
{
QList<QAction*> trackActions = ac->actions();
// ensure that the actions get deleted afterwards
foreach( QAction* action, trackActions )
{
if( !action->parent() )
action->setParent( this );
actions << action;
}
}
QScopedPointer<BookmarkThisCapability> btc( track->create<BookmarkThisCapability>() );
if( btc && btc->bookmarkAction() )
{
actions << btc->bookmarkAction();
}
if( m_showEditTrackDetailsAction && track->editor() )
{
QAction *editAction = new QAction( KIcon("media-track-edit-amarok"),
i18n("Edit Track Details"), this );
connect( editAction, SIGNAL(triggered()), SLOT(editTrack()) );
m_customActions << editAction;
}
if( track->has<FindInSourceCapability>() )
{
if( !m_findInSourceSignalMapper )
{
m_findInSourceSignalMapper = new QSignalMapper( this );
connect( m_findInSourceSignalMapper, SIGNAL(mapped(QString)), SLOT(findInSource(QString)) );
}
Meta::AlbumPtr album = track->album();
Meta::ArtistPtr artist = track->artist();
Meta::ComposerPtr composer = track->composer();
Meta::GenrePtr genre = track->genre();
Meta::YearPtr year = track->year();
QAction *act( 0 );
if( album && !album->name().isEmpty() )
{
act = new QAction( KIcon("current-track-amarok"), i18n("Show Album in Media Sources"), this );
connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) );
m_findInSourceSignalMapper->setMapping( act, QLatin1String("album") );
m_customActions << act;
}
if( artist && !artist->name().isEmpty() )
{
act = new QAction( KIcon("filename-artist-amarok"), i18n("Show Artist in Media Sources"), this );
connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) );
m_findInSourceSignalMapper->setMapping( act, QLatin1String("artist") );
m_customActions << act;
KPluginInfo::List services = The::pluginManager()->plugins( QLatin1String("Service") );
foreach( const KPluginInfo &service, services )
{
if( service.pluginName() == QLatin1String("amarok_service_amazonstore") )
{
if( service.isPluginEnabled() )
{
act = new QAction( KIcon("view-services-amazon-amarok"),
i18n("Search for Artist in the MP3 Music Store"), this );
connect( act, SIGNAL(triggered()), this, SLOT(findInStore()) );
m_customActions << act;
}
break;
}
}
}
if( composer && !composer->name().isEmpty() && (composer->name() != i18n("Unknown Composer")) )
{
act = new QAction( KIcon("filename-composer-amarok"), i18n("Show Composer in Media Sources"), this );
connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) );
m_findInSourceSignalMapper->setMapping( act, QLatin1String("composer") );
m_customActions << act;
}
if( genre && !genre->name().isEmpty() )
{
act = new QAction( KIcon("filename-genre-amarok"), i18n("Show Genre in Media Sources"), this );
connect( act, SIGNAL(triggered()), m_findInSourceSignalMapper, SLOT(map()) );
m_findInSourceSignalMapper->setMapping( act, QLatin1String("genre") );
m_customActions << act;
}
if( year && !year->name().isEmpty() )
{
//.........这里部分代码省略.........