2017-03-29 10:18:37 +00:00
|
|
|
#include "widgets/sectionswidget.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
#include "widgets/pieview.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2017-04-13 15:14:02 +00:00
|
|
|
#include "helpers.h"
|
|
|
|
|
|
|
|
#include <QtWidgets>
|
|
|
|
#include <QTreeWidget>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
|
2017-04-13 15:14:02 +00:00
|
|
|
QSplitter(main),
|
|
|
|
main(main)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-07-02 11:11:02 +00:00
|
|
|
IAITONOTUSED(parent);
|
2017-04-09 17:09:35 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
setupViews();
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
//setStyleSheet("QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; }");
|
2017-06-15 09:53:10 +00:00
|
|
|
setStyleSheet("QSplitter::handle { height: 2px; background-color: rgb(255, 255, 255); image: url(:/img/icons/tabs.svg); }");
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void SectionsWidget::setup()
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-13 15:14:02 +00:00
|
|
|
tree->clear();
|
|
|
|
|
|
|
|
int row = 0;
|
2017-05-03 09:09:57 +00:00
|
|
|
for (auto section : main->core->getAllSections())
|
2017-04-13 15:14:02 +00:00
|
|
|
{
|
2017-06-03 12:27:23 +00:00
|
|
|
if (!section.name.contains("."))
|
2017-05-03 09:09:57 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
fillSections(row++, section);
|
2017-04-13 15:14:02 +00:00
|
|
|
}
|
2017-05-03 09:09:57 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
//adjustColumns(sectionsWidget->tree);
|
|
|
|
//this->sectionsDock->sectionsWidget->adjustColumns();
|
|
|
|
qhelpers::adjustColumns(tree);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void SectionsWidget::setupViews()
|
|
|
|
{
|
|
|
|
// Table view
|
|
|
|
this->tree = new QTreeWidget;
|
2017-04-12 10:16:43 +00:00
|
|
|
this->tree->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2017-03-29 10:18:37 +00:00
|
|
|
//this->tree->setFont(QFont("Lucida Grande UI", 12));
|
|
|
|
//this->tree->setFont(QFont("Courier New", 11));
|
|
|
|
this->tree->setIndentation(10);
|
|
|
|
//this->tree->setStyleSheet("QTreeWidget::item { padding-top: 1px; padding-bottom: 1px; padding-left:10px; border-left:10px;} QTreeWidget::item:selected { background: gray; color: white; } QTreeWidget::item:hover { background: rgb(242, 246, 248); color: black; }");
|
|
|
|
|
|
|
|
// Setup TreeWidget
|
|
|
|
this->tree->setColumnCount(4);
|
|
|
|
QList<QString> headers;
|
|
|
|
headers << "Name" << "Size" << "Address" << "End Address";
|
|
|
|
this->tree->setHeaderLabels(headers);
|
|
|
|
|
|
|
|
this->tree->setFrameShape(QFrame::NoFrame);
|
|
|
|
this->tree->setSortingEnabled(true);
|
|
|
|
|
|
|
|
pieChart = new PieView;
|
|
|
|
pieChart->setFrameShape(QFrame::NoFrame);
|
2017-04-12 10:16:43 +00:00
|
|
|
pieChart->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2017-03-29 10:18:37 +00:00
|
|
|
this->addWidget(this->tree);
|
|
|
|
this->addWidget(pieChart);
|
|
|
|
this->setStretchFactor(0, 4);
|
|
|
|
|
|
|
|
//this->tree->setModel(model);
|
|
|
|
pieChart->setModel(this->tree->model());
|
|
|
|
|
|
|
|
QItemSelectionModel *selectionModel = new QItemSelectionModel(this->tree->model());
|
|
|
|
this->tree->setSelectionModel(selectionModel);
|
|
|
|
pieChart->setSelectionModel(selectionModel);
|
|
|
|
}
|
|
|
|
|
2017-05-03 09:09:57 +00:00
|
|
|
void SectionsWidget::fillSections(int row, const SectionDescription §ion)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-13 15:14:02 +00:00
|
|
|
// TODO: create unique colors, e. g. use HSV color space and rotate in H for 360/size
|
|
|
|
static const QList<QColor> colors = { QColor("#1ABC9C"), //TURQUOISE
|
|
|
|
QColor("#2ECC71"), //EMERALD
|
|
|
|
QColor("#3498DB"), //PETER RIVER
|
|
|
|
QColor("#9B59B6"), //AMETHYST
|
|
|
|
QColor("#34495E"), //WET ASPHALT
|
|
|
|
QColor("#F1C40F"), //SUN FLOWER
|
|
|
|
QColor("#E67E22"), //CARROT
|
|
|
|
QColor("#E74C3C"), //ALIZARIN
|
|
|
|
QColor("#ECF0F1"), //CLOUDS
|
|
|
|
QColor("#BDC3C7"), //SILVER
|
2017-04-13 15:51:58 +00:00
|
|
|
QColor("#95A5A6") //COBCRETE
|
|
|
|
};
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
2017-05-03 09:09:57 +00:00
|
|
|
tempItem->setText(0, section.name);
|
|
|
|
tempItem->setText(1, RSizeString(section.size));
|
|
|
|
tempItem->setText(2, RAddressString(section.vaddr));
|
|
|
|
tempItem->setText(3, RAddressString(section.vaddr + section.vsize));
|
2017-04-13 15:14:02 +00:00
|
|
|
tempItem->setData(0, Qt::DecorationRole, colors[row % colors.size()]);
|
2017-03-29 10:18:37 +00:00
|
|
|
this->tree->insertTopLevelItem(0, tempItem);
|
|
|
|
}
|