mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Qt: edit playlist entry labels by clicking on them a second time, or with the platform's edit key (usually F2)
This commit is contained in:
parent
369f8206d1
commit
5fbf841fb2
@ -425,9 +425,7 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
|
||||
if (path.isEmpty() ||
|
||||
label.isEmpty() ||
|
||||
coreName.isEmpty() ||
|
||||
corePath.isEmpty() ||
|
||||
dbName.isEmpty() ||
|
||||
crc32.isEmpty()
|
||||
corePath.isEmpty()
|
||||
)
|
||||
return false;
|
||||
|
||||
@ -436,16 +434,24 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
|
||||
labelArray = label.toUtf8();
|
||||
coreNameArray = coreName.toUtf8();
|
||||
corePathArray = QDir::toNativeSeparators(corePath).toUtf8();
|
||||
dbNameArray = (dbName + file_path_str(FILE_PATH_LPL_EXTENSION)).toUtf8();
|
||||
crc32Array = crc32.toUtf8();
|
||||
|
||||
if (!dbName.isEmpty())
|
||||
{
|
||||
dbNameArray = (dbName + file_path_str(FILE_PATH_LPL_EXTENSION)).toUtf8();
|
||||
dbNameData = dbNameArray.constData();
|
||||
}
|
||||
|
||||
playlistPathData = playlistPathArray.constData();
|
||||
pathData = pathArray.constData();
|
||||
labelData = labelArray.constData();
|
||||
coreNameData = coreNameArray.constData();
|
||||
corePathData = corePathArray.constData();
|
||||
dbNameData = dbNameArray.constData();
|
||||
crc32Data = crc32Array.constData();
|
||||
|
||||
if (!crc32.isEmpty())
|
||||
{
|
||||
crc32Array = crc32.toUtf8();
|
||||
crc32Data = crc32Array.constData();
|
||||
}
|
||||
|
||||
if (path_is_compressed_file(pathData))
|
||||
{
|
||||
@ -1287,7 +1293,7 @@ void MainWindow::addPlaylistHashToTable(const QVector<QHash<QString, QString> >
|
||||
|
||||
labelItem = new QTableWidgetItem(hash.value("label"));
|
||||
labelItem->setData(Qt::UserRole, QVariant::fromValue<QHash<QString, QString> >(hash));
|
||||
labelItem->setFlags(labelItem->flags() & ~Qt::ItemIsEditable);
|
||||
labelItem->setFlags(labelItem->flags() | Qt::ItemIsEditable);
|
||||
|
||||
m_tableWidget->setItem(oldRowCount + i, 0, labelItem);
|
||||
}
|
||||
|
@ -202,17 +202,11 @@ TableWidget::TableWidget(QWidget *parent) :
|
||||
void TableWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
|
||||
{
|
||||
event->accept();
|
||||
emit enterPressed();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Delete)
|
||||
{
|
||||
event->accept();
|
||||
emit deletePressed();
|
||||
}
|
||||
else
|
||||
QTableWidget::keyPressEvent(event);
|
||||
|
||||
QTableWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
CoreInfoLabel::CoreInfoLabel(QString text, QWidget *parent) :
|
||||
@ -1593,6 +1587,9 @@ QTabWidget* MainWindow::browserAndPlaylistTabWidget()
|
||||
|
||||
void MainWindow::onTableWidgetEnterPressed()
|
||||
{
|
||||
/* entry is being renamed, ignore this enter press */
|
||||
if (m_tableWidget->isPersistentEditorOpen(m_tableWidget->currentIndex()))
|
||||
return;
|
||||
onRunClicked();
|
||||
}
|
||||
|
||||
@ -2361,6 +2358,29 @@ void MainWindow::onCurrentTableItemChanged(QTableWidgetItem *current, QTableWidg
|
||||
currentItemChanged(hash);
|
||||
}
|
||||
|
||||
void MainWindow::onCurrentTableItemDataChanged(QTableWidgetItem *item)
|
||||
{
|
||||
QHash<QString, QString> hash;
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
/* block this signal because setData() would trigger an infinite look here */
|
||||
disconnect(m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onCurrentTableItemDataChanged(QTableWidgetItem*)));
|
||||
|
||||
hash = item->data(Qt::UserRole).value<QHash<QString, QString> >();
|
||||
hash["label"] = item->text();
|
||||
hash["label_noext"] = QFileInfo(item->text()).completeBaseName();
|
||||
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(hash));
|
||||
|
||||
updateCurrentPlaylistEntry(hash);
|
||||
|
||||
currentItemChanged(hash);
|
||||
|
||||
connect(m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onCurrentTableItemDataChanged(QTableWidgetItem*)));
|
||||
}
|
||||
|
||||
void MainWindow::currentItemChanged(const QHash<QString, QString> &hash)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -2955,11 +2975,15 @@ void MainWindow::initContentTableWidget()
|
||||
|
||||
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
|
||||
|
||||
/* block this signal because setData() called in addPlaylistHashToTable() would trigger an infinite loop */
|
||||
disconnect(m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onCurrentTableItemDataChanged(QTableWidgetItem*)));
|
||||
|
||||
m_tableWidget->clear();
|
||||
m_tableWidget->setColumnCount(0);
|
||||
m_tableWidget->setRowCount(0);
|
||||
m_tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_tableWidget->setEditTriggers(QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
|
||||
m_tableWidget->setSortingEnabled(false);
|
||||
m_tableWidget->setColumnCount(1);
|
||||
m_tableWidget->setRowCount(0);
|
||||
@ -3005,6 +3029,8 @@ void MainWindow::initContentTableWidget()
|
||||
}
|
||||
|
||||
onSearchEnterPressed();
|
||||
|
||||
connect(m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onCurrentTableItemDataChanged(QTableWidgetItem*)));
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
|
@ -359,6 +359,7 @@ private slots:
|
||||
void onCoreLoaded();
|
||||
void onCurrentListItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void onCurrentTableItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
void onCurrentTableItemDataChanged(QTableWidgetItem *item);
|
||||
void currentItemChanged(const QHash<QString, QString> &hash);
|
||||
void onSearchEnterPressed();
|
||||
void onSearchLineEditEdited(const QString &text);
|
||||
|
Loading…
Reference in New Issue
Block a user