void FileViewList::mousePressEvent(QMouseEvent* e) {
  switch (e->button()) {
    case Qt::XButton1:
      emit Back();
      break;
    case Qt::XButton2:
      emit Forward();
      break;
    // enqueue to playlist with middleClick
    case Qt::MidButton: {
      QListView::mousePressEvent(e);

      // we need to update the menu selection
      menu_selection_ = selectionModel()->selection();

      MimeData* data = new MimeData;
      data->setUrls(UrlListFromSelection());
      data->enqueue_now_ = true;
      emit AddToPlaylist(data);
      break;
    }
    default:
      QListView::mousePressEvent(e);
      break;
  }
}
Beispiel #2
0
void FileView::ItemDoubleClick(const QModelIndex& index) {
  if (model_->isDir(index)) return;

  QString file_path = model_->filePath(index);

  MimeData* data = new MimeData;
  data->from_doubleclick_ = true;
  data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(file_path));
  data->name_for_new_playlist_ = file_path;

  emit AddToPlaylist(data);
}
MimeData* FileViewList::MimeDataFromSelection() const {
  MimeData* data = new MimeData;
  data->setUrls(UrlListFromSelection());

  QList<QString> filenames = FilenamesFromSelection();
  // if just one folder selected - use it's path as the new playlist's name
  if (filenames.size() == 1 && QFileInfo(filenames.first()).isDir()) {
    data->name_for_new_playlist_ = filenames.first();
    // otherwise, use the current root path
  } else {
    data->name_for_new_playlist_ =
        static_cast<QFileSystemModel*>(model())->rootPath();
  }

  return data;
}