2017-03-29 10:18:37 +00:00
|
|
|
#include "importswidget.h"
|
|
|
|
#include "ui_importswidget.h"
|
|
|
|
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
#include "widgets/banned.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void CMyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-12 22:05:58 +00:00
|
|
|
QStyleOptionViewItem itemOption(option);
|
2017-03-29 10:18:37 +00:00
|
|
|
initStyleOption(&itemOption, index);
|
|
|
|
|
|
|
|
itemOption.rect.adjust(10, 0, 0, 0); // Make the item rectangle 10 pixels smaller from the left side.
|
|
|
|
|
|
|
|
// Draw your item content.
|
|
|
|
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &itemOption, painter, nullptr);
|
|
|
|
|
|
|
|
// And now you can draw a bottom border.
|
|
|
|
//painter->setPen(Qt::cyan);
|
|
|
|
QPen pen = painter->pen();
|
|
|
|
pen.setColor(Qt::white);
|
|
|
|
pen.setWidth(1);
|
|
|
|
painter->setPen(pen);
|
|
|
|
painter->drawLine(itemOption.rect.bottomLeft(), itemOption.rect.bottomRight());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Imports Widget
|
|
|
|
*/
|
|
|
|
|
|
|
|
ImportsWidget::ImportsWidget(MainWindow *main, QWidget *parent) :
|
|
|
|
QDockWidget(parent),
|
|
|
|
ui(new Ui::ImportsWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// Radare core found in:
|
|
|
|
this->main = main;
|
|
|
|
this->importsTreeWidget = ui->importsTreeWidget;
|
|
|
|
|
|
|
|
// Delegate
|
|
|
|
//CMyDelegate* delegate = new CMyDelegate(ui->importsTreeWidget);
|
|
|
|
//ui->importsTreeWidget->setItemDelegate(delegate);
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void ImportsWidget::fillImports()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->importsTreeWidget->clear();
|
2017-04-09 19:55:06 +00:00
|
|
|
for (auto i : this->main->core->getList("bin", "imports"))
|
|
|
|
{
|
|
|
|
QStringList a = i.split(",");
|
2017-03-29 10:18:37 +00:00
|
|
|
// ord,plt,name
|
2017-04-09 19:55:06 +00:00
|
|
|
if (a.length() == 6)
|
|
|
|
this->main->appendRow(this->importsTreeWidget, a[1], a[3], "", a[4]);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
highlightUnsafe();
|
|
|
|
this->main->adjustColumns(this->importsTreeWidget);
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void ImportsWidget::highlightUnsafe()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
Banned *ban = new Banned();
|
2017-04-09 19:55:06 +00:00
|
|
|
QList<QTreeWidgetItem *> clist = this->importsTreeWidget->findItems(ban->banned, Qt::MatchRegExp, 4);
|
|
|
|
foreach (QTreeWidgetItem *item, clist)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
item->setText(3, "Unsafe");
|
|
|
|
//item->setBackgroundColor(4, QColor(255, 129, 123));
|
|
|
|
//item->setForeground(4, Qt::white);
|
|
|
|
item->setForeground(4, QColor(255, 129, 123));
|
|
|
|
}
|
|
|
|
//ui->importsTreeWidget->setStyleSheet("QTreeWidget::item { padding-left:10px; padding-top: 1px; padding-bottom: 1px; border-left: 10px; }");
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void ImportsWidget::adjustColumns(QTreeWidget *tw)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
int count = tw->columnCount();
|
2017-04-09 19:55:06 +00:00
|
|
|
for (int i = 0; i != count; ++i)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->importsTreeWidget->resizeColumnToContents(i);
|
|
|
|
int width = ui->importsTreeWidget->columnWidth(i);
|
|
|
|
ui->importsTreeWidget->setColumnWidth(i, width + 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImportsWidget::~ImportsWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|