Skip to content

Commit

Permalink
feat: Add search for rc files
Browse files Browse the repository at this point in the history
For now, only search inside the list of data IDs.
We may extend this later on if useful/needed.

Fix #25
  • Loading branch information
narnaud committed Nov 18, 2024
1 parent d51e8a1 commit 637aeb4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/gui/rcui/rcfileview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include "rcfileview.h"
#include "../searchableviewinterface.h"
#include "acceleratormodel.h"
#include "assetmodel.h"
#include "datamodel.h"
Expand Down Expand Up @@ -47,12 +48,15 @@ class DataProxy : public QSortFilterProxyModel

RcFileView::RcFileView(QWidget *parent)
: QWidget(parent)
, FindInterface(FindInterface::CanSearch)
, ui(new Ui::RcFileView)
, m_dataProxyModel(new DataProxy(this))
, m_contentProxyModel(new QSortFilterProxyModel(this))
{
ui->setupUi(this);

m_searchableViewInterface = new Gui::SearchableViewInterface(ui->dataView);

ui->dataView->setSortingEnabled(true);
ui->dataView->setContextMenuPolicy(Qt::CustomContextMenu);
ui->dataView->setModel(m_dataProxyModel);
Expand Down Expand Up @@ -127,6 +131,11 @@ QPlainTextEdit *RcFileView::textEdit() const
return ui->textEdit;
}

void RcFileView::find(const QString &text, int options)
{
m_searchableViewInterface->find(text, options);
}

void RcFileView::changeDataItem(const QModelIndex &current)
{
int type = NoData;
Expand Down
11 changes: 10 additions & 1 deletion src/gui/rcui/rcfileview.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#pragma once

#include "../findinterface.h"

#include <QWidget>
#include <memory>

Expand All @@ -23,13 +25,17 @@ struct Data;
struct RcFile;
}

namespace Gui {
class SearchableViewInterface;
}

namespace RcUi {

namespace Ui {
class RcFileView;
}

class RcFileView : public QWidget
class RcFileView : public QWidget, public Gui::FindInterface
{
Q_OBJECT

Expand All @@ -41,6 +47,8 @@ class RcFileView : public QWidget

QPlainTextEdit *textEdit() const;

void find(const QString &text, int options) override;

signals:
void languageChanged(const QString &language);

Expand All @@ -65,6 +73,7 @@ class RcFileView : public QWidget
QSortFilterProxyModel *const m_dataProxyModel;
QSortFilterProxyModel *const m_contentProxyModel;
QAbstractItemModel *m_contentModel = nullptr;
Gui::SearchableViewInterface *m_searchableViewInterface = nullptr;
};

} // namespace RcUi

0 comments on commit 637aeb4

Please sign in to comment.