Changeset ac471f21023adf4d3784ab3856b9a6040689d65c
- Timestamp:
- 14/10/06 18:44:55 (2 years ago)
- git-parent:
- Files:
-
- modules/gui/qt4/components/playlist/selector.cpp (modified) (1 diff)
- modules/gui/qt4/components/playlist/standardpanel.cpp (modified) (1 diff)
- modules/gui/qt4/dialogs/playlist.cpp (modified) (2 diffs)
- modules/gui/qt4/dialogs/playlist.hpp (modified) (1 diff)
- modules/gui/qt4/main_interface.cpp (modified) (3 diffs)
- modules/gui/qt4/main_interface.hpp (modified) (1 diff)
- modules/gui/qt4/playlist_model.cpp (modified) (9 diffs)
- modules/gui/qt4/playlist_model.hpp (modified) (3 diffs)
- src/playlist/item.c (modified) (1 diff)
- src/playlist/tree.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/gui/qt4/components/playlist/selector.cpp
r6523dc2 rac471f2 39 39 view->setModel( model ); 40 40 41 view->setDragEnabled(true); 42 view->setAcceptDrops(true); 43 view->setDropIndicatorShown(true); 44 41 45 CONNECT( view, activated( const QModelIndex& ), 42 46 this, setSource( const QModelIndex& ) ); modules/gui/qt4/components/playlist/standardpanel.cpp
ra01c61f rac471f2 57 57 view->header()->setSortIndicatorShown( true ); 58 58 view->header()->setClickable( true ); 59 59 60 view->setSelectionMode( QAbstractItemView::ExtendedSelection ); 61 view->setDragEnabled(true); 62 view->setAcceptDrops(true); 63 view->setDropIndicatorShown(true); 60 64 61 65 CONNECT( view, activated( const QModelIndex& ) , modules/gui/qt4/dialogs/playlist.cpp
ra01c61f rac471f2 31 31 #include "menus.hpp" 32 32 33 #include <QUrl> 33 34 #include <QHBoxLayout> 34 35 #include <QSignalMapper> … … 76 77 QApplication::postEvent( p_intf->p_sys->p_mi, event ); 77 78 } 79 80 81 void PlaylistDialog::dropEvent(QDropEvent *event) 82 { 83 const QMimeData *mimeData = event->mimeData(); 84 foreach( QUrl url, mimeData->urls() ) { 85 QString s = url.toString(); 86 if( s.length() > 0 ) { 87 playlist_PlaylistAdd( THEPL, qtu(s), NULL, 88 PLAYLIST_APPEND, PLAYLIST_END ); 89 } 90 } 91 event->acceptProposedAction(); 92 } 93 void PlaylistDialog::dragEnterEvent(QDragEnterEvent *event) 94 { 95 event->acceptProposedAction(); 96 } 97 void PlaylistDialog::dragMoveEvent(QDragMoveEvent *event) 98 { 99 event->acceptProposedAction(); 100 } 101 void PlaylistDialog::dragLeaveEvent(QDragLeaveEvent *event) 102 { 103 event->accept(); 104 } 105 106 modules/gui/qt4/dialogs/playlist.hpp
r7f994b8 rac471f2 50 50 void createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ); 51 51 PlaylistDialog( intf_thread_t * ); 52 53 void dropEvent( QDropEvent *); 54 void dragEnterEvent( QDragEnterEvent * ); 55 void dragMoveEvent( QDragMoveEvent * ); 56 void dragLeaveEvent( QDragLeaveEvent * ); 57 52 58 static PlaylistDialog *instance; 53 59 modules/gui/qt4/main_interface.cpp
r141dd1d rac471f2 37 37 #include <QStatusBar> 38 38 #include <QKeyEvent> 39 #include <QUrl> 39 40 40 41 #include <assert.h> … … 84 85 settings = new QSettings( "VideoLAN", "VLC" ); 85 86 settings->beginGroup( "MainWindow" ); 87 88 setAcceptDrops(true); 86 89 87 90 need_components_update = false; … … 138 141 } 139 142 143 void MainInterface::dropEvent(QDropEvent *event) 144 { 145 const QMimeData *mimeData = event->mimeData(); 146 147 /* D&D of a subtitles file, add it on the fly */ 148 if( mimeData->urls().size() == 1 ) 149 { 150 if( THEMIM->getIM()->hasInput() ) 151 { 152 if( input_AddSubtitles( THEMIM->getInput(), 153 qtu( mimeData->urls()[0].toString() ), 154 VLC_TRUE ) ) 155 { 156 event->acceptProposedAction(); 157 return; 158 } 159 } 160 } 161 bool first = true; 162 foreach( QUrl url, mimeData->urls() ) { 163 QString s = url.toString(); 164 if( s.length() > 0 ) { 165 playlist_PlaylistAdd( THEPL, qtu(s), NULL, 166 PLAYLIST_APPEND | (first ? PLAYLIST_GO:0), 167 PLAYLIST_END ); 168 first = false; 169 } 170 } 171 event->acceptProposedAction(); 172 } 173 void MainInterface::dragEnterEvent(QDragEnterEvent *event) 174 { 175 event->acceptProposedAction(); 176 } 177 void MainInterface::dragMoveEvent(QDragMoveEvent *event) 178 { 179 event->acceptProposedAction(); 180 } 181 void MainInterface::dragLeaveEvent(QDragLeaveEvent *event) 182 { 183 event->accept(); 184 } 185 186 187 140 188 MainInterface::~MainInterface() 141 189 { modules/gui/qt4/main_interface.hpp
r141dd1d rac471f2 58 58 protected: 59 59 void resizeEvent( QResizeEvent * ); 60 void dropEvent( QDropEvent *); 61 void dragEnterEvent( QDragEnterEvent * ); 62 void dragMoveEvent( QDragMoveEvent * ); 63 void dragLeaveEvent( QDragLeaveEvent * ); 60 64 void closeEvent( QCloseEvent *); 61 65 Ui::MainInterfaceUI ui; modules/gui/qt4/playlist_model.cpp
r7810e78 rac471f2 21 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 22 *****************************************************************************/ 23 #define PLI_NAME( p ) p ? p->p_input->psz_name : "null" 23 24 24 25 #include <assert.h> … … 99 100 if( signal ) 100 101 model->beginInsertRows( model->index( this , 0 ), i_pos, i_pos ); 101 children. append(item );102 children.insert( i_pos, item ); 102 103 if( signal ) 103 104 model->endInsertRows(); … … 182 183 } 183 184 185 Qt::DropActions PLModel::supportedDropActions() const 186 { 187 return Qt::CopyAction; 188 } 189 190 Qt::ItemFlags PLModel::flags(const QModelIndex &index) const 191 { 192 Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); 193 if( index.isValid() ) 194 return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags; 195 else 196 return Qt::ItemIsDropEnabled | defaultFlags; 197 } 198 199 QStringList PLModel::mimeTypes() const 200 { 201 QStringList types; 202 types << "vlc/playlist-item-id"; 203 return types; 204 } 205 206 QMimeData *PLModel::mimeData(const QModelIndexList &indexes) const 207 { 208 QMimeData *mimeData = new QMimeData(); 209 QByteArray encodedData; 210 QDataStream stream(&encodedData, QIODevice::WriteOnly); 211 212 foreach (QModelIndex index, indexes) { 213 if (index.isValid() && index.column() == 0 ) 214 stream << itemId(index); 215 } 216 mimeData->setData("vlc/playlist-item-id", encodedData); 217 return mimeData; 218 } 219 220 bool PLModel::dropMimeData(const QMimeData *data, Qt::DropAction action, 221 int row, int column, const QModelIndex &target) 222 { 223 if ( data->hasFormat("vlc/playlist-item-id") ) 224 { 225 if (action == Qt::IgnoreAction) 226 return true; 227 228 PLItem *targetItem; 229 if( target.isValid() ) 230 targetItem = static_cast<PLItem*>( target.internalPointer() ); 231 else 232 targetItem = rootItem; 233 234 QByteArray encodedData = data->data("vlc/playlist-item-id"); 235 QDataStream stream(&encodedData, QIODevice::ReadOnly); 236 237 PLItem *newParentItem; 238 while (!stream.atEnd()) 239 { 240 int i; 241 int srcId; 242 stream >> srcId; 243 244 PL_LOCK; 245 playlist_item_t *p_target = 246 playlist_ItemGetById( p_playlist, targetItem->i_id ); 247 playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId ); 248 249 if( !p_target || !p_src ) 250 { 251 PL_UNLOCK; 252 return false; 253 } 254 255 if( p_target->i_children == -1 ) /* A leaf */ 256 { 257 PLItem *parentItem = targetItem->parent(); 258 assert( parentItem ); 259 playlist_item_t *p_parent = 260 playlist_ItemGetById( p_playlist, parentItem->i_id ); 261 if( !p_parent ) 262 { 263 PL_UNLOCK; 264 return false; 265 } 266 for( i = 0 ; i< p_parent->i_children ; i++ ) 267 if( p_parent->pp_children[i] == p_target ) break; 268 playlist_TreeMove( p_playlist, p_src, p_parent, i ); 269 newParentItem = parentItem; 270 } 271 else 272 { 273 /* \todo: if we drop on a top-level node, use copy instead ? */ 274 playlist_TreeMove( p_playlist, p_src, p_target, 0 ); 275 i = 0; 276 newParentItem = targetItem; 277 } 278 /* Remove from source */ 279 PLItem *srcItem = FindByInput( rootItem, p_src->p_input->i_id ); 280 srcItem->remove( srcItem ); 281 /* Display at new destination */ 282 PLItem *newItem = new PLItem( p_src, newParentItem, this ); 283 newParentItem->insertChild( newItem, i, true ); 284 UpdateTreeItem( p_src, newItem, true ); 285 if( p_src->i_children != -1 ) 286 UpdateNodeChildren( newItem ); 287 PL_UNLOCK; 288 } 289 } 290 return true; 291 } 292 293 184 294 void PLModel::addCallbacks() 185 295 { … … 230 340 QVariant PLModel::data(const QModelIndex &index, int role) const 231 341 { 232 assert( index.isValid());342 if(!index.isValid() ) return QVariant(); 233 343 PLItem *item = static_cast<PLItem*>(index.internalPointer()); 234 344 if( role == Qt::DisplayRole ) … … 261 371 assert( index.isValid() ); 262 372 return static_cast<PLItem*>(index.internalPointer())->i_id; 263 }264 265 Qt::ItemFlags PLModel::flags(const QModelIndex &index) const266 {267 if( !index.isValid() ) return Qt::ItemIsEnabled;268 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;269 373 } 270 374 … … 450 554 int type = event->type(); 451 555 if( type != ItemUpdate_Type && type != ItemAppend_Type && 452 type != ItemDelete_Type )556 type != ItemDelete_Type && type != PLUpdate_Type ) 453 557 return; 454 558 … … 459 563 else if( type == ItemAppend_Type ) 460 564 ProcessItemAppend( ple->p_add ); 565 else if( type == ItemDelete_Type ) 566 ProcessItemRemoval( ple->i_id ); 461 567 else 462 ProcessItemRemoval( ple->i_id);568 rebuild(); 463 569 } 464 570 … … 670 776 case 1: i_mode = SORT_ARTIST;break; 671 777 case 2: i_mode = SORT_DURATION; break; 778 default: i_mode = SORT_TITLE_NODES_FIRST; break; 672 779 } 673 780 if( p_root ) … … 757 864 { 758 865 PLModel *p_model = (PLModel *) param; 759 // p_model->b_need_update = VLC_TRUE; 866 PLEvent *event = new PLEvent( PLUpdate_Type, 0 ); 867 QApplication::postEvent( p_model, static_cast<QEvent*>(event) ); 760 868 return VLC_SUCCESS; 761 869 } modules/gui/qt4/playlist_model.hpp
r48f7e0b rac471f2 28 28 #include <QObject> 29 29 #include <QEvent> 30 #include <QMimeData> 30 31 31 32 #include <vlc/vlc.h> … … 73 74 static int ItemDelete_Type = QEvent::User + 3; 74 75 static int ItemAppend_Type = QEvent::User + 4; 76 static int PLUpdate_Type = QEvent::User + 5; 75 77 76 78 class PLEvent : public QEvent … … 122 124 void search( QString search ); 123 125 void sort( int column, Qt::SortOrder order ); 126 127 /* DnD handling */ 128 Qt::DropActions supportedDropActions() const; 129 QMimeData* mimeData(const QModelIndexList &indexes) const; 130 bool dropMimeData(const QMimeData *data, Qt::DropAction action, 131 int row, int column, const QModelIndex &target); 132 QStringList mimeTypes() const; 124 133 125 134 void sendArt( QString url ); src/playlist/item.c
r2e0102d rac471f2 483 483 /* Attach to new parent */ 484 484 INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item ); 485 p_item->p_parent = p_node; 485 486 486 487 return VLC_SUCCESS; src/playlist/tree.c
radb0d2e rac471f2 431 431 vlc_bool_t b_ena_ok = VLC_TRUE, b_unplayed_ok = VLC_TRUE; 432 432 p_next = GetNextItem( p_playlist, p_root, p_next ); 433 PL_DEBUG( "Got next item %s, testing suitability", PLI_NAME(p_next) ); 433 434 if( !p_next || p_next == p_root ) 434 435 break; … … 521 522 else 522 523 p_parent = p_root; 523 524 PL_DEBUG( "Parent %s has %i children", PLI_NAME(p_parent), 525 p_parent->i_children ); 524 526 for( i= 0 ; i < p_parent->i_children ; i++ ) 525 527 {
