mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 12:26:11 +00:00
Fetch Strings asynchronously
This commit is contained in:
parent
2e26ead446
commit
cc3ad67096
@ -166,7 +166,8 @@ SOURCES += \
|
|||||||
widgets/StackWidget.cpp \
|
widgets/StackWidget.cpp \
|
||||||
widgets/RegistersWidget.cpp \
|
widgets/RegistersWidget.cpp \
|
||||||
widgets/BacktraceWidget.cpp \
|
widgets/BacktraceWidget.cpp \
|
||||||
dialogs/OpenFileDialog.cpp
|
dialogs/OpenFileDialog.cpp \
|
||||||
|
utils/StringsTask.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
Cutter.h \
|
Cutter.h \
|
||||||
@ -247,7 +248,8 @@ HEADERS += \
|
|||||||
widgets/StackWidget.h \
|
widgets/StackWidget.h \
|
||||||
widgets/RegistersWidget.h \
|
widgets/RegistersWidget.h \
|
||||||
widgets/BacktraceWidget.h \
|
widgets/BacktraceWidget.h \
|
||||||
dialogs/OpenFileDialog.h
|
dialogs/OpenFileDialog.h \
|
||||||
|
utils/StringsTask.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
dialogs/AboutDialog.ui \
|
dialogs/AboutDialog.ui \
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
qRegisterMetaType<QList<StringDescription>>();
|
||||||
|
|
||||||
CutterApplication a(argc, argv);
|
CutterApplication a(argc, argv);
|
||||||
|
|
||||||
int ret = a.exec();
|
int ret = a.exec();
|
||||||
|
8
src/utils/StringsTask.cpp
Normal file
8
src/utils/StringsTask.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
#include "StringsTask.h"
|
||||||
|
|
||||||
|
void StringsTask::runTask()
|
||||||
|
{
|
||||||
|
auto strings = Core()->getAllStrings();
|
||||||
|
emit stringSearchFinished(strings);
|
||||||
|
}
|
22
src/utils/StringsTask.h
Normal file
22
src/utils/StringsTask.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
#ifndef STRINGSASYNCTASK_H
|
||||||
|
#define STRINGSASYNCTASK_H
|
||||||
|
|
||||||
|
#include "utils/AsyncTask.h"
|
||||||
|
#include "Cutter.h"
|
||||||
|
|
||||||
|
class StringsTask : public AsyncTask
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString getTitle() override { return tr("Searching for Strings"); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void stringSearchFinished(const QList<StringDescription> &strings);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void runTask() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //STRINGSASYNCTASK_H
|
@ -172,12 +172,25 @@ void StringsWidget::on_stringsTreeView_doubleClicked(const QModelIndex &index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StringsWidget::refreshStrings()
|
void StringsWidget::refreshStrings()
|
||||||
|
{
|
||||||
|
if (task) {
|
||||||
|
task->wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
task = QSharedPointer<StringsTask>(new StringsTask());
|
||||||
|
connect(task.data(), &StringsTask::stringSearchFinished, this, &StringsWidget::stringSearchFinished);
|
||||||
|
Core()->getAsyncTaskManager()->start(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StringsWidget::stringSearchFinished(const QList<StringDescription> &strings)
|
||||||
{
|
{
|
||||||
model->beginReload();
|
model->beginReload();
|
||||||
strings = Core()->getAllStrings();
|
this->strings = strings;
|
||||||
model->endReload();
|
model->endReload();
|
||||||
|
|
||||||
qhelpers::adjustColumns(ui->stringsTreeView, 5, 0);
|
qhelpers::adjustColumns(ui->stringsTreeView, 5, 0);
|
||||||
if (ui->stringsTreeView->columnWidth(1) > 300)
|
if (ui->stringsTreeView->columnWidth(1) > 300)
|
||||||
ui->stringsTreeView->setColumnWidth(1, 300);
|
ui->stringsTreeView->setColumnWidth(1, 300);
|
||||||
|
|
||||||
|
task = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "Cutter.h"
|
#include "Cutter.h"
|
||||||
#include "CutterDockWidget.h"
|
#include "CutterDockWidget.h"
|
||||||
|
#include "utils/StringsTask.h"
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@ -66,10 +67,13 @@ private slots:
|
|||||||
void on_stringsTreeView_doubleClicked(const QModelIndex &index);
|
void on_stringsTreeView_doubleClicked(const QModelIndex &index);
|
||||||
|
|
||||||
void refreshStrings();
|
void refreshStrings();
|
||||||
|
void stringSearchFinished(const QList<StringDescription> &strings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::StringsWidget> ui;
|
std::unique_ptr<Ui::StringsWidget> ui;
|
||||||
|
|
||||||
|
QSharedPointer<StringsTask> task;
|
||||||
|
|
||||||
StringsModel *model;
|
StringsModel *model;
|
||||||
StringsSortFilterProxyModel *proxy_model;
|
StringsSortFilterProxyModel *proxy_model;
|
||||||
QList<StringDescription> strings;
|
QList<StringDescription> strings;
|
||||||
|
Loading…
Reference in New Issue
Block a user