blob: e512836adc2e617d4fb3541097c7583fbccee7ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#pragma once
#include <QtCore/QStringListModel>
#ifndef BINARYNINJAUI_BINDINGS
#include <QtCore/QThread>
#endif
#include <optional>
#include "completioncombobox.h"
#include "binaryninjaapi.h"
#include "uitypes.h"
#ifdef BINARYNINJAUI_BINDINGS
// QThread has issues working in the bindings on some platforms
class GetTypesListThread;
#else
/*!
\ingroup typedialog
*/
class BINARYNINJAUIAPI GetTypesListThread : public QThread
{
Q_OBJECT
QStringList m_allTypes;
std::function<void()> m_completeFunc;
std::mutex m_mutex;
bool m_done;
BinaryNinja::TypeContainer m_typeContainer;
protected:
virtual void run() override;
public:
GetTypesListThread(BinaryNinja::TypeContainer typeContainer, const std::function<void()>& completeFunc);
void cancel();
const QStringList& getTypes() const { return m_allTypes; }
};
#endif
//! A CompletionComboBox pre-configured for type name autocompletion.
//!
//! Fetches type names from a TypeContainer in a background thread and populates
//! the completer model. Respects the ui.types.substring and
//! ui.types.maxAutoFeaturesCount settings.
//!
//! Optionally manages a persistent input history stored in QSettings.
class BINARYNINJAUIAPI TypeCompletionComboBox : public CompletionComboBox
{
Q_OBJECT
QStringListModel* m_model;
GetTypesListThread* m_updateThread = nullptr;
QStringList m_historyEntries;
int m_historySize;
void customEvent(QEvent* event) override;
public:
TypeCompletionComboBox(std::optional<BinaryNinja::TypeContainer> typeContainer, QWidget* parent = nullptr,
QString existing = QString());
~TypeCompletionComboBox();
//! Commit the current text to the persistent input history.
void commitHistory();
QStringListModel* completionModel() const { return m_model; }
};
|