Changeset View
Changeset View
Standalone View
Standalone View
src/amarokurls/BookmarkTreeView.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
68 | void BookmarkTreeView::mouseDoubleClickEvent( QMouseEvent * event ) | 68 | void BookmarkTreeView::mouseDoubleClickEvent( QMouseEvent * event ) | ||
69 | { | 69 | { | ||
70 | QModelIndex index = m_proxyModel->mapToSource( indexAt( event->pos() ) ); | 70 | QModelIndex index = m_proxyModel->mapToSource( indexAt( event->pos() ) ); | ||
71 | 71 | | |||
72 | if( index.isValid() ) | 72 | if( index.isValid() ) | ||
73 | { | 73 | { | ||
74 | BookmarkViewItemPtr item = BookmarkModel::instance()->data( index, 0xf00d ).value<BookmarkViewItemPtr>(); | 74 | BookmarkViewItemPtr item = BookmarkModel::instance()->data( index, 0xf00d ).value<BookmarkViewItemPtr>(); | ||
75 | 75 | | |||
76 | if ( typeid( *item ) == typeid( AmarokUrl ) ) { | 76 | if ( auto bookmark = AmarokUrlPtr::dynamicCast( item ) ) | ||
77 | AmarokUrl * bookmark = static_cast< AmarokUrl* >( item.data() ); | | |||
78 | bookmark->run(); | 77 | bookmark->run(); | ||
79 | } | 78 | } | ||
80 | } | 79 | } | ||
81 | } | | |||
82 | 80 | | |||
83 | 81 | | |||
84 | void | 82 | void | ||
85 | BookmarkTreeView::keyPressEvent( QKeyEvent *event ) | 83 | BookmarkTreeView::keyPressEvent( QKeyEvent *event ) | ||
86 | { | 84 | { | ||
87 | switch( event->key() ) | 85 | switch( event->key() ) | ||
88 | { | 86 | { | ||
89 | case Qt::Key_Delete: | 87 | case Qt::Key_Delete: | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 100 | { | |||
139 | return actions; | 137 | return actions; | ||
140 | } | 138 | } | ||
141 | 139 | | |||
142 | void BookmarkTreeView::slotLoad() | 140 | void BookmarkTreeView::slotLoad() | ||
143 | { | 141 | { | ||
144 | DEBUG_BLOCK | 142 | DEBUG_BLOCK | ||
145 | foreach( BookmarkViewItemPtr item, selectedItems() ) | 143 | foreach( BookmarkViewItemPtr item, selectedItems() ) | ||
146 | { | 144 | { | ||
147 | if( typeid( * item ) == typeid( AmarokUrl ) ) | 145 | if( auto bookmark = AmarokUrlPtr::dynamicCast( item ) ) | ||
148 | { | | |||
149 | AmarokUrlPtr bookmark = AmarokUrlPtr::staticCast( item ); | | |||
150 | bookmark->run(); | 146 | bookmark->run(); | ||
151 | } | 147 | } | ||
152 | } | 148 | } | ||
153 | } | | |||
154 | 149 | | |||
155 | void BookmarkTreeView::slotDelete() | 150 | void BookmarkTreeView::slotDelete() | ||
156 | { | 151 | { | ||
157 | DEBUG_BLOCK | 152 | DEBUG_BLOCK | ||
158 | 153 | | |||
159 | //TODO FIXME Confirmation of delete | 154 | //TODO FIXME Confirmation of delete | ||
160 | 155 | | |||
161 | foreach( BookmarkViewItemPtr item, selectedItems() ) | 156 | foreach( BookmarkViewItemPtr item, selectedItems() ) | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 268 | { | |||
277 | debug() << indexes.size() << " items selected"; | 272 | debug() << indexes.size() << " items selected"; | ||
278 | foreach( const QModelIndex &index, indexes ) | 273 | foreach( const QModelIndex &index, indexes ) | ||
279 | { | 274 | { | ||
280 | const QModelIndex sourceIndex = m_proxyModel->mapToSource( index ); | 275 | const QModelIndex sourceIndex = m_proxyModel->mapToSource( index ); | ||
281 | if( sourceIndex.column() == 0 ) | 276 | if( sourceIndex.column() == 0 ) | ||
282 | { | 277 | { | ||
283 | BookmarkViewItemPtr item = BookmarkModel::instance()->data( sourceIndex, 0xf00d ).value<BookmarkViewItemPtr>(); | 278 | BookmarkViewItemPtr item = BookmarkModel::instance()->data( sourceIndex, 0xf00d ).value<BookmarkViewItemPtr>(); | ||
284 | 279 | | |||
285 | if ( typeid( * item ) == typeid( AmarokUrl ) ) { | 280 | if ( auto bookmark = AmarokUrlPtr::dynamicCast( item ) ) | ||
281 | { | ||||
286 | debug() << "a url was selected..."; | 282 | debug() << "a url was selected..."; | ||
287 | AmarokUrl bookmark = *static_cast< AmarokUrl* >( item.data() ); | 283 | emit( bookmarkSelected( *bookmark ) ); | ||
288 | emit( bookmarkSelected( bookmark ) ); | | |||
289 | } | 284 | } | ||
290 | } | 285 | } | ||
291 | } | 286 | } | ||
292 | 287 | | |||
293 | } | 288 | } | ||
294 | 289 | | |||
295 | QMenu* BookmarkTreeView::contextMenu( const QPoint& point ) | 290 | QMenu* BookmarkTreeView::contextMenu( const QPoint& point ) | ||
296 | { | 291 | { | ||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |