mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 04:16:12 +00:00
Fetch Strings asynchronously
This commit is contained in:
parent
2e26ead446
commit
cc3ad67096
@ -166,7 +166,8 @@ SOURCES += \
|
||||
widgets/StackWidget.cpp \
|
||||
widgets/RegistersWidget.cpp \
|
||||
widgets/BacktraceWidget.cpp \
|
||||
dialogs/OpenFileDialog.cpp
|
||||
dialogs/OpenFileDialog.cpp \
|
||||
utils/StringsTask.cpp
|
||||
|
||||
HEADERS += \
|
||||
Cutter.h \
|
||||
@ -247,7 +248,8 @@ HEADERS += \
|
||||
widgets/StackWidget.h \
|
||||
widgets/RegistersWidget.h \
|
||||
widgets/BacktraceWidget.h \
|
||||
dialogs/OpenFileDialog.h
|
||||
dialogs/OpenFileDialog.h \
|
||||
utils/StringsTask.h
|
||||
|
||||
FORMS += \
|
||||
dialogs/AboutDialog.ui \
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qRegisterMetaType<QList<StringDescription>>();
|
||||
|
||||
CutterApplication a(argc, argv);
|
||||
|
||||
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()
|
||||
{
|
||||
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();
|
||||
strings = Core()->getAllStrings();
|
||||
this->strings = strings;
|
||||
model->endReload();
|
||||
|
||||
qhelpers::adjustColumns(ui->stringsTreeView, 5, 0);
|
||||
if (ui->stringsTreeView->columnWidth(1) > 300)
|
||||
ui->stringsTreeView->setColumnWidth(1, 300);
|
||||
|
||||
task = nullptr;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "Cutter.h"
|
||||
#include "CutterDockWidget.h"
|
||||
#include "utils/StringsTask.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
@ -66,10 +67,13 @@ private slots:
|
||||
void on_stringsTreeView_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void refreshStrings();
|
||||
void stringSearchFinished(const QList<StringDescription> &strings);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::StringsWidget> ui;
|
||||
|
||||
QSharedPointer<StringsTask> task;
|
||||
|
||||
StringsModel *model;
|
||||
StringsSortFilterProxyModel *proxy_model;
|
||||
QList<StringDescription> strings;
|
||||
|
Loading…
Reference in New Issue
Block a user