When pressing Ctrl+C on a playlist item, copy the text of all visible columns, rather than just the text of the "current" one. Fixes issue 2558
This commit is contained in:
parent
281d69581c
commit
7166f0d922
@ -23,6 +23,7 @@
|
|||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include <QCleanlooksStyle>
|
#include <QCleanlooksStyle>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -467,11 +468,9 @@ bool CompareSelectionRanges(const QItemSelectionRange& a, const QItemSelectionRa
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistView::keyPressEvent(QKeyEvent* event) {
|
void PlaylistView::keyPressEvent(QKeyEvent* event) {
|
||||||
if (!model()) {
|
if (!model() || state() == QAbstractItemView::EditingState) {
|
||||||
QTreeView::keyPressEvent(event);
|
QTreeView::keyPressEvent(event);
|
||||||
} else if (state() == QAbstractItemView::EditingState) {
|
} else if (event == QKeySequence::Delete) {
|
||||||
QTreeView::keyPressEvent(event);
|
|
||||||
} else if (event->matches(QKeySequence::Delete)) {
|
|
||||||
RemoveSelected();
|
RemoveSelected();
|
||||||
event->accept();
|
event->accept();
|
||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
@ -479,6 +478,8 @@ void PlaylistView::keyPressEvent(QKeyEvent* event) {
|
|||||||
RemoveSelected();
|
RemoveSelected();
|
||||||
event->accept();
|
event->accept();
|
||||||
#endif
|
#endif
|
||||||
|
} else if (event == QKeySequence::Copy) {
|
||||||
|
CopyCurrentSongToClipboard();
|
||||||
} else if (event->key() == Qt::Key_Enter ||
|
} else if (event->key() == Qt::Key_Enter ||
|
||||||
event->key() == Qt::Key_Return) {
|
event->key() == Qt::Key_Return) {
|
||||||
if (currentIndex().isValid())
|
if (currentIndex().isValid())
|
||||||
@ -1006,3 +1007,30 @@ void PlaylistView::SetColumnAlignment(int section, Qt::Alignment alignment) {
|
|||||||
Qt::Alignment PlaylistView::column_alignment(int section) const {
|
Qt::Alignment PlaylistView::column_alignment(int section) const {
|
||||||
return column_alignment_.value(section, Qt::AlignLeft | Qt::AlignVCenter);
|
return column_alignment_.value(section, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaylistView::CopyCurrentSongToClipboard() const {
|
||||||
|
// Get the display text of all visible columns.
|
||||||
|
QStringList columns;
|
||||||
|
|
||||||
|
for (int i=0 ; i<header()->count() ; ++i) {
|
||||||
|
if (header()->isSectionHidden(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVariant data = model()->data(
|
||||||
|
currentIndex().sibling(currentIndex().row(), i));
|
||||||
|
if (data.type() == QVariant::String) {
|
||||||
|
columns << data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the song's URL
|
||||||
|
const QUrl url = model()->data(currentIndex().sibling(
|
||||||
|
currentIndex().row(), Playlist::Column_Filename)).toUrl();
|
||||||
|
|
||||||
|
QMimeData* mime_data = new QMimeData;
|
||||||
|
mime_data->setUrls(QList<QUrl>() << url);
|
||||||
|
mime_data->setText(columns.join(" - "));
|
||||||
|
|
||||||
|
QApplication::clipboard()->setMimeData(mime_data);
|
||||||
|
}
|
||||||
|
@ -82,7 +82,6 @@ class PlaylistView : public QTreeView {
|
|||||||
// QTreeView
|
// QTreeView
|
||||||
void drawTree(QPainter* painter, const QRegion& region) const;
|
void drawTree(QPainter* painter, const QRegion& region) const;
|
||||||
void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||||
void keyPressEvent(QKeyEvent* event);
|
|
||||||
void setModel(QAbstractItemModel* model);
|
void setModel(QAbstractItemModel* model);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -95,6 +94,8 @@ class PlaylistView : public QTreeView {
|
|||||||
void DynamicModeChanged(bool dynamic);
|
void DynamicModeChanged(bool dynamic);
|
||||||
void SetColumnAlignment(int section, Qt::Alignment alignment);
|
void SetColumnAlignment(int section, Qt::Alignment alignment);
|
||||||
|
|
||||||
|
void CopyCurrentSongToClipboard() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PlayItem(const QModelIndex& index);
|
void PlayItem(const QModelIndex& index);
|
||||||
void PlayPause();
|
void PlayPause();
|
||||||
@ -106,6 +107,7 @@ class PlaylistView : public QTreeView {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
|
void keyPressEvent(QKeyEvent* event);
|
||||||
void contextMenuEvent(QContextMenuEvent* e);
|
void contextMenuEvent(QContextMenuEvent* e);
|
||||||
void hideEvent(QHideEvent* event);
|
void hideEvent(QHideEvent* event);
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user