Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
265 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule LibREDasm
updated
4 files
+29 −16 | redasm/loaders/dex/dex.cpp | |
+3 −5 | redasm/loaders/dex/dex.h | |
+1 −0 | redasm/redasm_ui.cpp | |
+7 −0 | redasm/redasm_ui.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "dialogui.h" | ||
#include "ui_dialogui.h" | ||
#include <QSortFilterProxyModel> | ||
#include <QPushButton> | ||
|
||
DialogUI::DialogUI(QWidget *parent) : QDialog(parent), ui(new Ui::DialogUI) | ||
{ | ||
ui->setupUi(this); | ||
|
||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | ||
} | ||
|
||
DialogUI::~DialogUI() { delete ui; } | ||
void DialogUI::setText(const QString &s) { ui->lblTitle->setText(s); } | ||
|
||
void DialogUI::setItems(REDasm::UI::CheckList &items) | ||
{ | ||
this->createList(new CheckedItemsModel(items)); | ||
|
||
connect(ui->pbApply, &QPushButton::clicked, this, [&]() { | ||
QListView* lvitems = static_cast<QListView*>(ui->stackedWidget->currentWidget()); | ||
QSortFilterProxyModel* filtermodel = static_cast<QSortFilterProxyModel*>(lvitems->model()); | ||
CheckedItemsModel* checkeditemsmodel = static_cast<CheckedItemsModel*>(filtermodel->sourceModel()); | ||
|
||
checkeditemsmodel->uncheckAll(); | ||
|
||
for(int i = 0; i < filtermodel->rowCount(); i++) | ||
filtermodel->setData(filtermodel->index(i, 0), Qt::Checked, Qt::CheckStateRole); | ||
}); | ||
} | ||
|
||
void DialogUI::createList(QAbstractItemModel* model) | ||
{ | ||
QSortFilterProxyModel* filtermodel = new QSortFilterProxyModel(this); | ||
filtermodel->setFilterCaseSensitivity(Qt::CaseInsensitive); | ||
filtermodel->setSourceModel(model); | ||
|
||
QListView* lvitems = new QListView(this); | ||
lvitems->setUniformItemSizes(true); | ||
model->setParent(lvitems); | ||
|
||
lvitems->setModel(filtermodel); | ||
ui->stackedWidget->addWidget(lvitems); | ||
|
||
connect(ui->leFilter, &QLineEdit::textChanged, filtermodel, &QSortFilterProxyModel::setFilterFixedString); | ||
} | ||
|
||
void DialogUI::setCanAccept(bool b) { ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(b); } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef DIALOGUI_H | ||
#define DIALOGUI_H | ||
|
||
#include <QListView> | ||
#include <QDialog> | ||
#include <redasm/redasm_ui.h> | ||
#include "models/checkeditemsmodel.h" | ||
|
||
namespace Ui { | ||
class DialogUI; | ||
} | ||
|
||
class DialogUI : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DialogUI(QWidget *parent = nullptr); | ||
~DialogUI(); | ||
|
||
public: | ||
void setText(const QString& s); | ||
void setItems(REDasm::UI::CheckList& items); | ||
|
||
private: | ||
void createList(QAbstractItemModel *model); | ||
void setCanAccept(bool b); | ||
|
||
private: | ||
Ui::DialogUI *ui; | ||
}; | ||
|
||
#endif // DIALOGUI_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>DialogUI</class> | ||
<widget class="QDialog" name="DialogUI"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>481</width> | ||
<height>392</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>DialogUI</string> | ||
</property> | ||
<property name="modal"> | ||
<bool>true</bool> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0"> | ||
<item> | ||
<widget class="QLabel" name="lblTitle"> | ||
<property name="text"> | ||
<string>TextLabel</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLineEdit" name="leFilter"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
<property name="placeholderText"> | ||
<string>Filter...</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="pbApply"> | ||
<property name="text"> | ||
<string>Apply</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="QStackedWidget" name="stackedWidget"/> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>DialogUI</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>DialogUI</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "checkeditemsmodel.h" | ||
|
||
CheckedItemsModel::CheckedItemsModel(REDasm::UI::CheckList &items, QObject *parent): QAbstractListModel(parent), m_items(items) { } | ||
|
||
void CheckedItemsModel::uncheckAll() | ||
{ | ||
this->beginResetModel(); | ||
|
||
for(auto& item : m_items) | ||
item.second = false; | ||
|
||
this->endResetModel(); | ||
} | ||
|
||
Qt::ItemFlags CheckedItemsModel::flags(const QModelIndex &index) const { return QAbstractListModel::flags(index) | Qt::ItemIsUserCheckable; } | ||
int CheckedItemsModel::rowCount(const QModelIndex &parent) const { return m_items.size(); } | ||
|
||
QVariant CheckedItemsModel::data(const QModelIndex &index, int role) const | ||
{ | ||
const auto& item = m_items[index.row()]; | ||
|
||
if(role == Qt::DisplayRole) | ||
return QString::fromStdString(item.first); | ||
if(role == Qt::CheckStateRole) | ||
return item.second ? Qt::Checked : Qt::Unchecked; | ||
|
||
return QVariant(); | ||
} | ||
|
||
bool CheckedItemsModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
{ | ||
if(role == Qt::CheckStateRole) | ||
{ | ||
auto& item = m_items[index.row()]; | ||
item.second = value == Qt::Checked ? true : false; | ||
emit dataChanged(index, index); | ||
return true; | ||
} | ||
|
||
return QAbstractListModel::setData(index, value, role); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef CHECKEDITEMSMODEL_H | ||
#define CHECKEDITEMSMODEL_H | ||
|
||
#include <QAbstractListModel> | ||
#include <redasm/redasm_ui.h> | ||
|
||
class CheckedItemsModel : public QAbstractListModel | ||
{ | ||
public: | ||
CheckedItemsModel(REDasm::UI::CheckList& items, QObject* parent = nullptr); | ||
void uncheckAll(); | ||
|
||
public: | ||
Qt::ItemFlags flags(const QModelIndex &index) const; | ||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | ||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); | ||
|
||
private: | ||
REDasm::UI::CheckList& m_items; | ||
}; | ||
|
||
#endif // CHECKEDITEMSMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters