diff --git a/src/Cutter.pro b/src/Cutter.pro index c4144629..239fdc58 100644 --- a/src/Cutter.pro +++ b/src/Cutter.pro @@ -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 \ diff --git a/src/Main.cpp b/src/Main.cpp index 458afbc9..a686a506 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,6 +4,8 @@ int main(int argc, char *argv[]) { + qRegisterMetaType>(); + CutterApplication a(argc, argv); int ret = a.exec(); diff --git a/src/utils/StringsTask.cpp b/src/utils/StringsTask.cpp new file mode 100644 index 00000000..64a08832 --- /dev/null +++ b/src/utils/StringsTask.cpp @@ -0,0 +1,8 @@ + +#include "StringsTask.h" + +void StringsTask::runTask() +{ + auto strings = Core()->getAllStrings(); + emit stringSearchFinished(strings); +} diff --git a/src/utils/StringsTask.h b/src/utils/StringsTask.h new file mode 100644 index 00000000..169c81a3 --- /dev/null +++ b/src/utils/StringsTask.h @@ -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 &strings); + +protected: + void runTask() override; +}; + +#endif //STRINGSASYNCTASK_H diff --git a/src/widgets/StringsWidget.cpp b/src/widgets/StringsWidget.cpp index 129829a2..564602b9 100644 --- a/src/widgets/StringsWidget.cpp +++ b/src/widgets/StringsWidget.cpp @@ -172,12 +172,25 @@ void StringsWidget::on_stringsTreeView_doubleClicked(const QModelIndex &index) } void StringsWidget::refreshStrings() +{ + if (task) { + task->wait(); + } + + task = QSharedPointer(new StringsTask()); + connect(task.data(), &StringsTask::stringSearchFinished, this, &StringsWidget::stringSearchFinished); + Core()->getAsyncTaskManager()->start(task); +} + +void StringsWidget::stringSearchFinished(const QList &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; } diff --git a/src/widgets/StringsWidget.h b/src/widgets/StringsWidget.h index 90d1c99a..363b25db 100644 --- a/src/widgets/StringsWidget.h +++ b/src/widgets/StringsWidget.h @@ -5,6 +5,7 @@ #include "Cutter.h" #include "CutterDockWidget.h" +#include "utils/StringsTask.h" #include #include @@ -66,10 +67,13 @@ private slots: void on_stringsTreeView_doubleClicked(const QModelIndex &index); void refreshStrings(); + void stringSearchFinished(const QList &strings); private: std::unique_ptr ui; + QSharedPointer task; + StringsModel *model; StringsSortFilterProxyModel *proxy_model; QList strings;