void ListWidget::dropEvent( QDropEvent *event )
{
	QListWidget::dropEvent( event );
	if ( event->source() != this )
		emit itemsDropped();
	setDragDropMode( QAbstractItemView::InternalMove );
	modified = true;
}
	PlayListWidget::PlayListWidget(kt::MediaFileCollection* collection, kt::MediaPlayer* player, QWidget* parent) 
		: QWidget(parent),
		player(player),
		menu(0),
		collection(collection)
	{
		QVBoxLayout* layout = new QVBoxLayout(this);
		layout->setMargin(0);
		layout->setSpacing(0);
		
		
		QAction* remove_action = new QAction(KIcon("list-remove"),i18n("Remove"),this);
		connect(remove_action,SIGNAL(triggered(bool)),this,SLOT(removeFiles()));
		QAction* add_action = new QAction(KIcon("document-open"),i18n("Add Media"),this);
		connect(add_action,SIGNAL(triggered(bool)),this,SLOT(addMedia()));
		QAction* clear_action = new QAction(KIcon("edit-clear-list"),i18n("Clear Playlist"),this);
		connect(clear_action,SIGNAL(triggered(bool)),this,SLOT(clearPlayList()));
		
		tool_bar = new QToolBar(this);
		tool_bar->addAction(add_action);
		tool_bar->addAction(remove_action);
		tool_bar->addAction(clear_action);
		random_mode = new QCheckBox(i18n("Random play order"),tool_bar);
		connect(random_mode,SIGNAL(toggled(bool)),this,SIGNAL(randomModeActivated(bool)));
		tool_bar->addWidget(random_mode);
		layout->addWidget(tool_bar);
		
		play_list = new PlayList(collection,player,this);
		connect(play_list,SIGNAL(itemsDropped()),this,SLOT(onItemsDropped()));
		proxy_model = new QSortFilterProxyModel(this);
		proxy_model->setSourceModel(play_list);
		proxy_model->setSortRole(Qt::UserRole);
		
		view = new QTreeView(this);
		view->setModel(proxy_model);
		view->setDragEnabled(true);
		view->setDropIndicatorShown(true);
		view->setAcceptDrops(true);
		view->setAlternatingRowColors(true);
		view->setRootIsDecorated(false);
		view->setContextMenuPolicy(Qt::CustomContextMenu);
		view->setSelectionMode(QAbstractItemView::ExtendedSelection);
		view->setSortingEnabled(true);
		layout->addWidget(view);
		connect(view,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showContextMenu(QPoint)));
		
		connect(view->selectionModel(),SIGNAL(selectionChanged(const QItemSelection & , const QItemSelection & )),
				this,SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
		connect(view,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(doubleClicked(QModelIndex)));
		
		menu = new KMenu(this);
		menu->addAction(remove_action);
		menu->addSeparator();
		menu->addAction(add_action);
		menu->addAction(clear_action);
	}