Changeset View
Changeset View
Standalone View
Standalone View
src/amarokurls/BookmarkModel.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 76 | { | |||
---|---|---|---|---|---|
103 | default: | 103 | default: | ||
104 | break; | 104 | break; | ||
105 | } | 105 | } | ||
106 | } | 106 | } | ||
107 | else if( role == Qt::DecorationRole ) | 107 | else if( role == Qt::DecorationRole ) | ||
108 | { | 108 | { | ||
109 | if( index.column() == Name ) | 109 | if( index.column() == Name ) | ||
110 | { | 110 | { | ||
111 | if ( typeid( * item ) == typeid( BookmarkGroup ) ) | 111 | if ( BookmarkGroupPtr::dynamicCast( item ) ) | ||
112 | return QVariant( QIcon::fromTheme( "folder-bookmark" ) ); | 112 | return QVariant( QIcon::fromTheme( "folder-bookmark" ) ); | ||
113 | else if ( typeid( * item ) == typeid( AmarokUrl ) ) | 113 | else if ( auto url = AmarokUrlPtr::dynamicCast( item ) ) | ||
114 | { | | |||
115 | AmarokUrl * url = static_cast<AmarokUrl *>( item.data() ); | | |||
116 | return The::amarokUrlHandler()->iconForCommand( url->command() ); | 114 | return The::amarokUrlHandler()->iconForCommand( url->command() ); | ||
117 | } | 115 | } | ||
118 | } | 116 | } | ||
119 | } | | |||
120 | 117 | | |||
121 | return QVariant(); | 118 | return QVariant(); | ||
122 | } | 119 | } | ||
123 | 120 | | |||
124 | 121 | | |||
125 | QModelIndex | 122 | QModelIndex | ||
126 | BookmarkModel::createIndex( int row, int column, const BookmarkViewItemPtr &item ) const | 123 | BookmarkModel::createIndex( int row, int column, const BookmarkViewItemPtr &item ) const | ||
127 | { | 124 | { | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | |||||
231 | Qt::ItemFlags | 228 | Qt::ItemFlags | ||
232 | BookmarkModel::flags( const QModelIndex & index ) const | 229 | BookmarkModel::flags( const QModelIndex & index ) const | ||
233 | { | 230 | { | ||
234 | 231 | | |||
235 | if (!index.isValid()) | 232 | if (!index.isValid()) | ||
236 | return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; | 233 | return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled; | ||
237 | BookmarkViewItemPtr item = BookmarkViewItemPtr::staticCast( m_viewItems.value( index.internalId() ) ); | 234 | BookmarkViewItemPtr item = BookmarkViewItemPtr::staticCast( m_viewItems.value( index.internalId() ) ); | ||
238 | 235 | | |||
239 | if ( typeid( * item ) == typeid( BookmarkGroup ) ) | 236 | if ( BookmarkGroupPtr::dynamicCast( item ) ) | ||
240 | { | 237 | { | ||
241 | if ( index.column() != Command ) | 238 | if ( index.column() != Command ) | ||
242 | return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; | 239 | return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; | ||
243 | else | 240 | else | ||
244 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; | 241 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; | ||
245 | } | 242 | } | ||
246 | else | 243 | else | ||
247 | { | 244 | { | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 327 | { | |||
333 | 330 | | |||
334 | BookmarkGroupList groups; | 331 | BookmarkGroupList groups; | ||
335 | BookmarkList bookmarks; | 332 | BookmarkList bookmarks; | ||
336 | 333 | | |||
337 | foreach( const QModelIndex &index, indexes ) { | 334 | foreach( const QModelIndex &index, indexes ) { | ||
338 | 335 | | |||
339 | BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); | 336 | BookmarkViewItemPtr item = m_viewItems.value( index.internalId() ); | ||
340 | 337 | | |||
341 | if ( typeid( * item ) == typeid( BookmarkGroup ) ) { | 338 | if ( auto group = BookmarkGroupPtr::dynamicCast( item ) ) | ||
342 | BookmarkGroupPtr playlistGroup = BookmarkGroupPtr::staticCast( item ); | 339 | groups << group; | ||
343 | groups << playlistGroup; | 340 | else if( auto bookmark = AmarokUrlPtr::dynamicCast( item ) ) | ||
344 | } | | |||
345 | else | | |||
346 | { | | |||
347 | AmarokUrlPtr bookmark = AmarokUrlPtr::dynamicCast( item ); | | |||
348 | if( bookmark ) | | |||
349 | bookmarks << bookmark; | 341 | bookmarks << bookmark; | ||
350 | } | 342 | } | ||
351 | } | | |||
352 | 343 | | |||
353 | debug() << "adding " << groups.count() << " groups and " << bookmarks.count() << " bookmarks"; | 344 | debug() << "adding " << groups.count() << " groups and " << bookmarks.count() << " bookmarks"; | ||
354 | 345 | | |||
355 | mime->setBookmarkGroups( groups ); | 346 | mime->setBookmarkGroups( groups ); | ||
356 | mime->setBookmarks( bookmarks ); | 347 | mime->setBookmarks( bookmarks ); | ||
357 | 348 | | |||
358 | return mime; | 349 | return mime; | ||
359 | } | 350 | } | ||
▲ Show 20 Lines • Show All 347 Lines • Show Last 20 Lines |