2017-03-29 10:18:37 +00:00
|
|
|
#include "flagswidget.h"
|
|
|
|
#include "ui_flagswidget.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
#include "helpers.h"
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QComboBox>
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
FlagsWidget::FlagsWidget(MainWindow *main, QWidget *parent) :
|
2017-04-13 15:14:02 +00:00
|
|
|
DockWidget(parent),
|
|
|
|
ui(new Ui::FlagsWidget),
|
|
|
|
main(main)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
ui->flagsTreeWidget->hideColumn(0);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FlagsWidget::~FlagsWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void FlagsWidget::setup()
|
|
|
|
{
|
|
|
|
setScrollMode();
|
|
|
|
|
|
|
|
refreshFlagspaces();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::refresh()
|
|
|
|
{
|
|
|
|
setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::clear()
|
|
|
|
{
|
|
|
|
ui->flagsTreeWidget->clear();
|
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void FlagsWidget::on_flagsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2017-04-09 17:09:35 +00:00
|
|
|
QNOTUSED(column);
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
QString offset = item->text(2);
|
|
|
|
QString name = item->text(3);
|
2017-04-28 13:09:40 +00:00
|
|
|
this->main->seek(offset, name, true);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1)
|
|
|
|
{
|
2017-04-09 17:09:35 +00:00
|
|
|
QNOTUSED(arg1);
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
refreshFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::refreshFlagspaces()
|
|
|
|
{
|
|
|
|
int cur_idx = ui->flagspaceCombo->currentIndex();
|
2017-05-03 09:09:57 +00:00
|
|
|
if (cur_idx < 0)
|
|
|
|
cur_idx = 0;
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
ui->flagspaceCombo->clear();
|
2017-05-03 09:09:57 +00:00
|
|
|
ui->flagspaceCombo->addItem(tr("(all)"));
|
|
|
|
|
|
|
|
for (auto i : main->core->getAllFlagspaces())
|
2017-04-13 15:14:02 +00:00
|
|
|
{
|
2017-05-03 09:09:57 +00:00
|
|
|
ui->flagspaceCombo->addItem(i.name, QVariant::fromValue(i));
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
if (cur_idx > 0)
|
|
|
|
ui->flagspaceCombo->setCurrentIndex(cur_idx);
|
|
|
|
|
|
|
|
refreshFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::refreshFlags()
|
|
|
|
{
|
2017-05-03 09:09:57 +00:00
|
|
|
QString flagspace;
|
|
|
|
|
|
|
|
QVariant flagspace_data = ui->flagspaceCombo->currentData();
|
|
|
|
if(flagspace_data.isValid())
|
|
|
|
flagspace = flagspace_data.value<FlagspaceDescription>().name;
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
|
|
|
|
ui->flagsTreeWidget->clear();
|
|
|
|
|
2017-04-27 18:59:27 +00:00
|
|
|
QStringList flags;
|
|
|
|
|
2017-05-03 09:09:57 +00:00
|
|
|
for (auto i : main->core->getAllFlags(flagspace))
|
2017-04-13 15:14:02 +00:00
|
|
|
{
|
2017-05-03 09:09:57 +00:00
|
|
|
QTreeWidgetItem *item = qhelpers::appendRow(ui->flagsTreeWidget, RSizeString(i.size), RAddressString(i.offset), i.name);
|
|
|
|
item->setData(0, Qt::UserRole, QVariant::fromValue(i));
|
|
|
|
|
|
|
|
flags.append(i.name);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
qhelpers::adjustColumns(ui->flagsTreeWidget);
|
|
|
|
|
2017-04-27 18:59:27 +00:00
|
|
|
main->refreshOmniBar(flags);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::setScrollMode()
|
|
|
|
{
|
|
|
|
qhelpers::setVerticalScrollMode(ui->flagsTreeWidget);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|