mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Qt: hook up search box to grid view
This commit is contained in:
parent
c7052f67df
commit
d17c17085c
@ -1948,7 +1948,7 @@ QHash<QString, QString> MainWindow::getSelectedCore()
|
|||||||
}
|
}
|
||||||
case CORE_SELECTION_PLAYLIST_SAVED:
|
case CORE_SELECTION_PLAYLIST_SAVED:
|
||||||
{
|
{
|
||||||
if (!contentItem || contentHash["core_path"].isEmpty())
|
if (contentHash.isEmpty() || contentHash["core_path"].isEmpty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
coreHash["core_path"] = contentHash["core_path"];
|
coreHash["core_path"] = contentHash["core_path"];
|
||||||
@ -1960,7 +1960,7 @@ QHash<QString, QString> MainWindow::getSelectedCore()
|
|||||||
QVector<QHash<QString, QString> > cores;
|
QVector<QHash<QString, QString> > cores;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!contentItem || contentHash["db_name"].isEmpty())
|
if (contentHash.isEmpty() || contentHash["db_name"].isEmpty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
cores = getPlaylistDefaultCores();
|
cores = getPlaylistDefaultCores();
|
||||||
@ -2241,7 +2241,7 @@ void MainWindow::setCoreActions()
|
|||||||
|
|
||||||
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
if (m_browserAndPlaylistTabWidget->tabText(m_browserAndPlaylistTabWidget->currentIndex()) == msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_TAB_PLAYLISTS))
|
||||||
{
|
{
|
||||||
if (currentContentItem)
|
if (!hash.isEmpty())
|
||||||
{
|
{
|
||||||
QString coreName = hash["core_name"];
|
QString coreName = hash["core_name"];
|
||||||
|
|
||||||
@ -2293,7 +2293,6 @@ void MainWindow::setCoreActions()
|
|||||||
if (defaultCores.count() > 0)
|
if (defaultCores.count() > 0)
|
||||||
{
|
{
|
||||||
QString currentPlaylistItemDataString;
|
QString currentPlaylistItemDataString;
|
||||||
QHash<QString, QString> hash;
|
|
||||||
bool allPlaylists = false;
|
bool allPlaylists = false;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
@ -2303,9 +2302,6 @@ void MainWindow::setCoreActions()
|
|||||||
allPlaylists = (currentPlaylistItemDataString == ALL_PLAYLISTS_TOKEN);
|
allPlaylists = (currentPlaylistItemDataString == ALL_PLAYLISTS_TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentContentItem)
|
|
||||||
hash = currentContentItem->data(Qt::UserRole).value<QHash<QString, QString> >();
|
|
||||||
|
|
||||||
for (row = 0; row < m_listWidget->count(); row++)
|
for (row = 0; row < m_listWidget->count(); row++)
|
||||||
{
|
{
|
||||||
if (allPlaylists)
|
if (allPlaylists)
|
||||||
@ -2461,23 +2457,14 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QList<QTableWidgetItem*> items;
|
QList<QTableWidgetItem*> items;
|
||||||
|
QVector<QPointer<GridItem> > gridItems;
|
||||||
QVector<unsigned> textUnicode = text.toUcs4();
|
QVector<unsigned> textUnicode = text.toUcs4();
|
||||||
QVector<unsigned> textHiraToKata;
|
QVector<unsigned> textHiraToKata;
|
||||||
QVector<unsigned> textKataToHira;
|
QVector<unsigned> textKataToHira;
|
||||||
|
ViewType viewType = getCurrentViewType();
|
||||||
bool foundHira = false;
|
bool foundHira = false;
|
||||||
bool foundKata = false;
|
bool foundKata = false;
|
||||||
|
|
||||||
if (text.isEmpty())
|
|
||||||
{
|
|
||||||
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
|
||||||
{
|
|
||||||
m_tableWidget->setRowHidden(i, false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
items.append(m_tableWidget->findItems(text, Qt::MatchContains));
|
|
||||||
|
|
||||||
for (i = 0; i < textUnicode.size(); i++)
|
for (i = 0; i < textUnicode.size(); i++)
|
||||||
{
|
{
|
||||||
unsigned code = textUnicode.at(i);
|
unsigned code = textUnicode.at(i);
|
||||||
@ -2499,33 +2486,109 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundHira)
|
switch(viewType)
|
||||||
{
|
{
|
||||||
items.append(m_tableWidget->findItems(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::MatchContains));
|
case VIEW_TYPE_LIST:
|
||||||
}
|
|
||||||
|
|
||||||
if (foundKata)
|
|
||||||
{
|
|
||||||
items.append(m_tableWidget->findItems(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::MatchContains));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (items.isEmpty())
|
|
||||||
{
|
|
||||||
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
|
||||||
{
|
{
|
||||||
m_tableWidget->setRowHidden(i, true);
|
if (text.isEmpty())
|
||||||
}
|
{
|
||||||
|
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
||||||
|
{
|
||||||
|
m_tableWidget->setRowHidden(i, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
items.append(m_tableWidget->findItems(text, Qt::MatchContains));
|
||||||
}
|
|
||||||
else
|
if (foundHira)
|
||||||
{
|
{
|
||||||
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
items.append(m_tableWidget->findItems(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::MatchContains));
|
||||||
{
|
}
|
||||||
if (items.contains(m_tableWidget->item(i, 0)))
|
|
||||||
m_tableWidget->setRowHidden(i, false);
|
if (foundKata)
|
||||||
|
{
|
||||||
|
items.append(m_tableWidget->findItems(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::MatchContains));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items.isEmpty())
|
||||||
|
{
|
||||||
|
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
||||||
|
{
|
||||||
|
m_tableWidget->setRowHidden(i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_tableWidget->setRowHidden(i, true);
|
{
|
||||||
|
for (i = 0; i < m_tableWidget->rowCount(); i++)
|
||||||
|
{
|
||||||
|
if (items.contains(m_tableWidget->item(i, 0)))
|
||||||
|
m_tableWidget->setRowHidden(i, false);
|
||||||
|
else
|
||||||
|
m_tableWidget->setRowHidden(i, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VIEW_TYPE_ICONS:
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (text.isEmpty())
|
||||||
|
{
|
||||||
|
for (i = 0; i < m_gridItems.size(); i++)
|
||||||
|
{
|
||||||
|
m_gridItems.at(i)->widget->show();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < m_gridItems.count(); i++)
|
||||||
|
{
|
||||||
|
const QPointer<GridItem> &item = m_gridItems.at(i);
|
||||||
|
|
||||||
|
if (item->hash.value("label").contains(text, Qt::CaseInsensitive))
|
||||||
|
gridItems.append(item);
|
||||||
|
|
||||||
|
if (foundHira)
|
||||||
|
{
|
||||||
|
if (item->hash.value("label").contains(QString::fromUcs4(textHiraToKata.constData(), textHiraToKata.size()), Qt::CaseInsensitive))
|
||||||
|
gridItems.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundKata)
|
||||||
|
{
|
||||||
|
if (item->hash.value("label").contains(QString::fromUcs4(textKataToHira.constData(), textKataToHira.size()), Qt::CaseInsensitive))
|
||||||
|
gridItems.append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gridItems.isEmpty())
|
||||||
|
{
|
||||||
|
for (i = 0; i < m_gridItems.size(); i++)
|
||||||
|
{
|
||||||
|
m_gridItems.at(i)->widget->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < m_gridItems.size(); i++)
|
||||||
|
{
|
||||||
|
const QPointer<GridItem> &item = m_gridItems.at(i);
|
||||||
|
|
||||||
|
if (gridItems.contains(item))
|
||||||
|
item->widget->show();
|
||||||
|
else
|
||||||
|
item->widget->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3228,6 +3291,8 @@ void MainWindow::initContentGridLayout()
|
|||||||
|
|
||||||
removeGridItems();
|
removeGridItems();
|
||||||
|
|
||||||
|
m_currentGridHash.clear();
|
||||||
|
|
||||||
path = item->data(Qt::UserRole).toString();
|
path = item->data(Qt::UserRole).toString();
|
||||||
|
|
||||||
if (path == ALL_PLAYLISTS_TOKEN)
|
if (path == ALL_PLAYLISTS_TOKEN)
|
||||||
@ -3270,6 +3335,8 @@ void MainWindow::initContentTableWidget()
|
|||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_currentGridHash.clear();
|
||||||
|
|
||||||
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
|
horizontal_header_labels << msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_NAME);
|
||||||
|
|
||||||
m_tableWidget->clear();
|
m_tableWidget->clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user