2017-03-29 10:18:37 +00:00
|
|
|
#include "sdbdock.h"
|
|
|
|
#include "ui_sdbdock.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QDebug>
|
2017-04-13 15:14:02 +00:00
|
|
|
#include <QTreeWidget>
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
SdbDock::SdbDock(MainWindow *main, QWidget *parent) :
|
2017-04-13 15:14:02 +00:00
|
|
|
DockWidget(parent),
|
2017-03-29 10:18:37 +00:00
|
|
|
ui(new Ui::SdbDock)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
// Radare core found in:
|
|
|
|
this->main = main;
|
|
|
|
this->path = "";
|
|
|
|
reload("");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdbDock::reload(QString path)
|
|
|
|
{
|
|
|
|
ui->lineEdit->setText(path);
|
|
|
|
this->path = path;
|
|
|
|
/* insert root sdb keyvalue pairs */
|
|
|
|
|
|
|
|
ui->treeWidget->clear();
|
|
|
|
QList<QString> keys;
|
|
|
|
/* key-values */
|
|
|
|
keys = main->core->sdbListKeys(path);
|
2017-04-09 19:55:06 +00:00
|
|
|
foreach (QString key, keys)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
|
|
|
tempItem->setText(0, key);
|
|
|
|
tempItem->setText(1, main->core->sdbGet(path, key));
|
|
|
|
tempItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable);
|
|
|
|
ui->treeWidget->insertTopLevelItem(0, tempItem);
|
|
|
|
}
|
|
|
|
ui->treeWidget->resizeColumnToContents(0);
|
|
|
|
ui->treeWidget->resizeColumnToContents(1);
|
|
|
|
/* namespaces */
|
|
|
|
keys = main->core->sdbList(path);
|
|
|
|
keys.append("..");
|
2017-04-09 19:55:06 +00:00
|
|
|
foreach (QString key, keys)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
2017-04-09 19:55:06 +00:00
|
|
|
tempItem->setText(0, key + "/");
|
2017-03-29 10:18:37 +00:00
|
|
|
tempItem->setText(1, "");
|
|
|
|
ui->treeWidget->insertTopLevelItem(0, tempItem);
|
|
|
|
}
|
|
|
|
ui->treeWidget->resizeColumnToContents(0);
|
|
|
|
ui->treeWidget->resizeColumnToContents(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SdbDock::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
QString newpath;
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
if (column == 0)
|
|
|
|
{
|
|
|
|
if (item->text(0) == "../")
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
int idx = path.lastIndexOf("/");
|
2017-04-09 19:55:06 +00:00
|
|
|
if (idx != -1)
|
|
|
|
{
|
|
|
|
newpath = path.mid(0, idx);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
newpath = "";
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
reload(newpath);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else if (item->text(0).indexOf("/") != -1)
|
|
|
|
{
|
|
|
|
if (path != "")
|
|
|
|
{
|
|
|
|
newpath = path + "/" + item->text(0).replace("/", "");
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
newpath = path + item->text(0).replace("/", "");
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
// enter directory
|
|
|
|
reload(newpath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//__alert ("TODO: change value");
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SdbDock::~SdbDock()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void SdbDock::setup()
|
|
|
|
{
|
|
|
|
// TODO: implement
|
2017-04-25 23:28:36 +00:00
|
|
|
eprintf("%s - not implemented\n", Q_FUNC_INFO);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SdbDock::refresh()
|
|
|
|
{
|
|
|
|
// TODO: implement
|
2017-04-25 23:28:36 +00:00
|
|
|
eprintf("%s - not implemented\n", Q_FUNC_INFO);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void SdbDock::on_lockButton_clicked()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ui->lockButton->isChecked())
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
this->setAllowedAreas(Qt::NoDockWidgetArea);
|
2017-04-09 19:55:06 +00:00
|
|
|
ui->lockButton->setIcon(QIcon(":/new/prefix1/lock"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->setAllowedAreas(Qt::AllDockWidgetAreas);
|
2017-04-09 19:55:06 +00:00
|
|
|
ui->lockButton->setIcon(QIcon(":/new/prefix1/unlock"));
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SdbDock::on_treeWidget_itemChanged(QTreeWidgetItem *item, int column)
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
__alert(item->text(column));
|
2017-03-29 10:18:37 +00:00
|
|
|
// El nuevo valor esta en:
|
|
|
|
// item->text(column)
|
|
|
|
// ya sabras tu que hacer con el :P
|
|
|
|
}
|