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();
|
|
|
|
if (cur_idx < 0)cur_idx = 0;
|
|
|
|
ui->flagspaceCombo->clear();
|
|
|
|
ui->flagspaceCombo->addItem("(all)");
|
|
|
|
for (auto i : main->core->getList("flagspaces"))
|
|
|
|
{
|
|
|
|
ui->flagspaceCombo->addItem(i);
|
|
|
|
}
|
|
|
|
if (cur_idx > 0)
|
|
|
|
ui->flagspaceCombo->setCurrentIndex(cur_idx);
|
|
|
|
|
|
|
|
refreshFlags();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlagsWidget::refreshFlags()
|
|
|
|
{
|
|
|
|
QString flagspace = ui->flagspaceCombo->currentText();
|
|
|
|
if (flagspace == "(all)")
|
|
|
|
flagspace = "";
|
|
|
|
|
|
|
|
ui->flagsTreeWidget->clear();
|
|
|
|
|
2017-04-27 18:59:27 +00:00
|
|
|
QStringList flags;
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
for (auto i : main->core->getList("flags", flagspace))
|
|
|
|
{
|
|
|
|
QStringList a = i.split(",");
|
|
|
|
if (a.length() > 3)
|
|
|
|
{
|
|
|
|
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], a[3]);
|
|
|
|
//this->omnibar->fillFlags(a[0]);
|
|
|
|
}
|
|
|
|
else if (a.length() > 2)
|
|
|
|
{
|
|
|
|
qhelpers::appendRow(ui->flagsTreeWidget, a[1], a[2], a[0], "");
|
|
|
|
//this->omnibar->fillFlags(a[0]);
|
|
|
|
}
|
2017-04-27 18:59:27 +00:00
|
|
|
|
|
|
|
flags.append(a[0]);
|
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
|
|
|
}
|