mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 16:11:02 +08:00
renamed gui classes from My* to Prof*
This commit is contained in:
parent
1435e80cef
commit
98035ae705
@ -10,6 +10,7 @@
|
||||
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
||||
* ----------------- :
|
||||
* change log : * 2016/06/26 Victor Zarubkin: moved sources from graphics_view.h
|
||||
* : and renamed classes from My* to Prof*.
|
||||
* : *
|
||||
* ----------------- :
|
||||
* license : TODO: add license text
|
||||
@ -20,31 +21,31 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GlobalSignals GLOBALS;
|
||||
const ProfViewGlobalSignals GLOBALS;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MyPolygon::MyPolygon(QGraphicsItem* _parent) : QGraphicsPolygonItem(_parent)
|
||||
ProfGraphicsPolygonItem::ProfGraphicsPolygonItem(QGraphicsItem* _parent) : QGraphicsPolygonItem(_parent)
|
||||
{
|
||||
}
|
||||
|
||||
MyPolygon::~MyPolygon()
|
||||
ProfGraphicsPolygonItem::~ProfGraphicsPolygonItem()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MyText::MyText(const char* _text, QGraphicsItem* _parent) : QGraphicsSimpleTextItem(_text, _parent), QObject()
|
||||
ProfGraphicsTextItem::ProfGraphicsTextItem(const char* _text, QGraphicsItem* _parent) : QGraphicsSimpleTextItem(_text, _parent), QObject()
|
||||
{
|
||||
connect(&GLOBALS, &GlobalSignals::scaleIncreased, this, &MyText::onScaleIncrease);
|
||||
connect(&GLOBALS, &GlobalSignals::scaleDecreased, this, &MyText::onScaleDecrease);
|
||||
connect(&GLOBALS, &ProfViewGlobalSignals::scaleIncreased, this, &ProfGraphicsTextItem::onScaleIncrease);
|
||||
connect(&GLOBALS, &ProfViewGlobalSignals::scaleDecreased, this, &ProfGraphicsTextItem::onScaleDecrease);
|
||||
}
|
||||
|
||||
MyText::~MyText()
|
||||
ProfGraphicsTextItem::~ProfGraphicsTextItem()
|
||||
{
|
||||
}
|
||||
|
||||
void MyText::onScaleIncrease(qreal _scale)
|
||||
void ProfGraphicsTextItem::onScaleIncrease(qreal _scale)
|
||||
{
|
||||
setScale(100.0 / _scale);
|
||||
|
||||
@ -57,7 +58,7 @@ void MyText::onScaleIncrease(qreal _scale)
|
||||
}
|
||||
}
|
||||
|
||||
void MyText::onScaleDecrease(qreal _scale)
|
||||
void ProfGraphicsTextItem::onScaleDecrease(qreal _scale)
|
||||
{
|
||||
setScale(100.0 / _scale);
|
||||
|
||||
@ -76,27 +77,27 @@ const qreal LEFT = -2500000;
|
||||
const qreal WIDTH = 5000000;
|
||||
const int N_ITEMS = 200000;
|
||||
|
||||
MyGraphicsScene::MyGraphicsScene(QGraphicsView* _parent) : QGraphicsScene(_parent), m_start(0)
|
||||
ProfGraphicsScene::ProfGraphicsScene(QGraphicsView* _parent) : QGraphicsScene(_parent), m_start(0)
|
||||
{
|
||||
setSceneRect(QRectF(LEFT, -200, WIDTH, 220));
|
||||
test();
|
||||
}
|
||||
|
||||
MyGraphicsScene::MyGraphicsScene(const thread_blocks_tree_t& _blocksTree, QGraphicsView* _parent) : QGraphicsScene(_parent), m_start(0)
|
||||
ProfGraphicsScene::ProfGraphicsScene(const thread_blocks_tree_t& _blocksTree, QGraphicsView* _parent) : QGraphicsScene(_parent), m_start(0)
|
||||
{
|
||||
setTree(_blocksTree);
|
||||
}
|
||||
|
||||
MyGraphicsScene::~MyGraphicsScene()
|
||||
ProfGraphicsScene::~ProfGraphicsScene()
|
||||
{
|
||||
}
|
||||
|
||||
void MyGraphicsScene::test()
|
||||
void ProfGraphicsScene::test()
|
||||
{
|
||||
QPolygonF poly(QRectF(-5, -180, 10, 180));
|
||||
for (int i = 0; i < N_ITEMS; ++i)
|
||||
{
|
||||
MyPolygon* item = new MyPolygon();
|
||||
ProfGraphicsPolygonItem* item = new ProfGraphicsPolygonItem();
|
||||
int h = 50 + rand() % 131;
|
||||
item->setPolygon(QRectF(-5, -h, 10, h));
|
||||
item->setPos(LEFT + i * 10, 0);
|
||||
@ -105,7 +106,7 @@ void MyGraphicsScene::test()
|
||||
}
|
||||
}
|
||||
|
||||
void MyGraphicsScene::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
void ProfGraphicsScene::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
{
|
||||
m_start = -1;
|
||||
profiler::timestamp_t finish = 0;
|
||||
@ -129,12 +130,12 @@ void MyGraphicsScene::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
}
|
||||
}
|
||||
|
||||
void MyGraphicsScene::setTree(const BlocksTree::children_t& _children, qreal _y, int _level)
|
||||
void ProfGraphicsScene::setTree(const BlocksTree::children_t& _children, qreal _y, int _level)
|
||||
{
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
++items_couinter;
|
||||
MyPolygon* item = new MyPolygon();
|
||||
ProfGraphicsPolygonItem* item = new ProfGraphicsPolygonItem();
|
||||
|
||||
const qreal xbegin = time2position(child.node->block()->getBegin());
|
||||
const qreal height = 100 - _level * 5;
|
||||
@ -151,7 +152,7 @@ void MyGraphicsScene::setTree(const BlocksTree::children_t& _children, qreal _y,
|
||||
item->setPen(QPen(Qt::NoPen)); // disable borders painting
|
||||
|
||||
addItem(item);
|
||||
MyText* text = new MyText(child.node->getBlockName(), item);
|
||||
ProfGraphicsTextItem* text = new ProfGraphicsTextItem(child.node->getBlockName(), item);
|
||||
QRectF textRect = text->boundingRect();
|
||||
text->setPos(0, _level * 5);
|
||||
|
||||
@ -165,34 +166,34 @@ void MyGraphicsScene::setTree(const BlocksTree::children_t& _children, qreal _y,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MyGraphicsView::MyGraphicsView() : QGraphicsView(), m_scale(100), m_scaleCoeff(1.25)
|
||||
ProfGraphicsView::ProfGraphicsView() : QGraphicsView(), m_scale(100), m_scaleCoeff(1.25)
|
||||
{
|
||||
initMode();
|
||||
setScene(new MyGraphicsScene(this));
|
||||
setScene(new ProfGraphicsScene(this));
|
||||
centerOn(0, 0);
|
||||
}
|
||||
|
||||
MyGraphicsView::MyGraphicsView(const thread_blocks_tree_t& _blocksTree) : QGraphicsView(), m_scale(100), m_scaleCoeff(1.25)
|
||||
ProfGraphicsView::ProfGraphicsView(const thread_blocks_tree_t& _blocksTree) : QGraphicsView(), m_scale(100), m_scaleCoeff(1.25)
|
||||
{
|
||||
initMode();
|
||||
setScene(new MyGraphicsScene(_blocksTree, this));
|
||||
setScene(new ProfGraphicsScene(_blocksTree, this));
|
||||
centerOn(0, 0);
|
||||
}
|
||||
|
||||
MyGraphicsView::~MyGraphicsView()
|
||||
ProfGraphicsView::~ProfGraphicsView()
|
||||
{
|
||||
}
|
||||
|
||||
void MyGraphicsView::initMode()
|
||||
void ProfGraphicsView::initMode()
|
||||
{
|
||||
setCacheMode(QGraphicsView::CacheBackground);
|
||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||
}
|
||||
|
||||
void MyGraphicsView::wheelEvent(QWheelEvent* _event)
|
||||
void ProfGraphicsView::wheelEvent(QWheelEvent* _event)
|
||||
{
|
||||
//MyGraphicsScene* myscene = (MyGraphicsScene*)scene();
|
||||
//ProfGraphicsScene* myscene = (ProfGraphicsScene*)scene();
|
||||
if (_event->delta() > 0)
|
||||
{
|
||||
scale(m_scaleCoeff, m_scaleCoeff);
|
||||
|
@ -10,6 +10,7 @@
|
||||
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
||||
* ----------------- :
|
||||
* change log : * 2016/06/26 Victor Zarubkin: moved sources from graphics_view.h
|
||||
* : and renamed classes from My* to Prof*.
|
||||
* : *
|
||||
* ----------------- :
|
||||
* license : TODO: add license text
|
||||
@ -27,43 +28,43 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GlobalSignals : public QObject
|
||||
class ProfViewGlobalSignals : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
GlobalSignals() : QObject() {}
|
||||
virtual ~GlobalSignals() {}
|
||||
ProfViewGlobalSignals() : QObject() {}
|
||||
virtual ~ProfViewGlobalSignals() {}
|
||||
|
||||
signals:
|
||||
|
||||
void scaleIncreased(qreal _scale) const;
|
||||
void scaleDecreased(qreal _scale) const;
|
||||
|
||||
}; // END of class GlobalSignals.
|
||||
}; // END of class ProfViewGlobalSignals.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyPolygon : public QGraphicsPolygonItem
|
||||
class ProfGraphicsPolygonItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
|
||||
MyPolygon(QGraphicsItem* _parent = nullptr);
|
||||
virtual ~MyPolygon();
|
||||
ProfGraphicsPolygonItem(QGraphicsItem* _parent = nullptr);
|
||||
virtual ~ProfGraphicsPolygonItem();
|
||||
|
||||
}; // END of class MyPolygon.
|
||||
}; // END of class ProfGraphicsPolygonItem.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyText : public QObject, public QGraphicsSimpleTextItem
|
||||
class ProfGraphicsTextItem : public QObject, public QGraphicsSimpleTextItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
MyText(const char* _text, QGraphicsItem* _parent = nullptr);
|
||||
virtual ~MyText();
|
||||
ProfGraphicsTextItem(const char* _text, QGraphicsItem* _parent = nullptr);
|
||||
virtual ~ProfGraphicsTextItem();
|
||||
|
||||
private slots:
|
||||
|
||||
@ -71,11 +72,11 @@ private slots:
|
||||
|
||||
void onScaleDecrease(qreal _scale);
|
||||
|
||||
}; // END of class MyText.
|
||||
}; // END of class ProfGraphicsTextItem.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyGraphicsScene : public QGraphicsScene
|
||||
class ProfGraphicsScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -87,9 +88,9 @@ public:
|
||||
|
||||
int items_couinter = 0;
|
||||
|
||||
MyGraphicsScene(QGraphicsView* _parent);
|
||||
MyGraphicsScene(const thread_blocks_tree_t& _blocksTree, QGraphicsView* _parent);
|
||||
virtual ~MyGraphicsScene();
|
||||
ProfGraphicsScene(QGraphicsView* _parent);
|
||||
ProfGraphicsScene(const thread_blocks_tree_t& _blocksTree, QGraphicsView* _parent);
|
||||
virtual ~ProfGraphicsScene();
|
||||
|
||||
void test();
|
||||
|
||||
@ -104,11 +105,11 @@ private:
|
||||
|
||||
void setTree(const BlocksTree::children_t& _children, qreal _y, int _level = 0);
|
||||
|
||||
}; // END of class MyGraphicsScene.
|
||||
}; // END of class ProfGraphicsScene.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyGraphicsView : public QGraphicsView
|
||||
class ProfGraphicsView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -119,15 +120,15 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
MyGraphicsView();
|
||||
MyGraphicsView(const thread_blocks_tree_t& _blocksTree);
|
||||
virtual ~MyGraphicsView();
|
||||
ProfGraphicsView();
|
||||
ProfGraphicsView(const thread_blocks_tree_t& _blocksTree);
|
||||
virtual ~ProfGraphicsView();
|
||||
|
||||
void initMode();
|
||||
|
||||
void wheelEvent(QWheelEvent* _event);
|
||||
|
||||
}; // END of class MyGraphicsView.
|
||||
}; // END of class ProfGraphicsView.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
* : for displyaing easy_profiler blocks tree.
|
||||
* ----------------- :
|
||||
* change log : * 2016/06/26 Victor Zarubkin: moved sources from tree_view.h
|
||||
* : and renamed classes from My* to Prof*.
|
||||
* : *
|
||||
* ----------------- :
|
||||
* license : TODO: add license text
|
||||
@ -21,16 +22,16 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MyTreeItem::MyTreeItem(const BlocksTree* _block, QTreeWidgetItem* _parent) : QTreeWidgetItem(_parent), m_block(_block)
|
||||
ProfTreeWidgetItem::ProfTreeWidgetItem(const BlocksTree* _block, QTreeWidgetItem* _parent) : QTreeWidgetItem(_parent), m_block(_block)
|
||||
{
|
||||
}
|
||||
|
||||
const BlocksTree* MyTreeItem::block() const
|
||||
const BlocksTree* ProfTreeWidgetItem::block() const
|
||||
{
|
||||
return m_block;
|
||||
}
|
||||
|
||||
void MyTreeItem::setTimeSmart(int _column, const ::profiler::timestamp_t& _time)
|
||||
void ProfTreeWidgetItem::setTimeSmart(int _column, const ::profiler::timestamp_t& _time)
|
||||
{
|
||||
setData(_column, Qt::UserRole, _time);
|
||||
|
||||
@ -54,7 +55,7 @@ void MyTreeItem::setTimeSmart(int _column, const ::profiler::timestamp_t& _time)
|
||||
}
|
||||
}
|
||||
|
||||
void MyTreeItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time)
|
||||
void ProfTreeWidgetItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time)
|
||||
{
|
||||
setData(_column, Qt::UserRole, _time);
|
||||
setToolTip(_column, QString("%1 ns").arg(_time));
|
||||
@ -63,7 +64,7 @@ void MyTreeItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MyTreeWidget::MyTreeWidget(const thread_blocks_tree_t& _blocksTree, QWidget* _parent) : QTreeWidget(_parent), m_beginTime(-1)
|
||||
ProfTreeWidget::ProfTreeWidget(const thread_blocks_tree_t& _blocksTree, QWidget* _parent) : QTreeWidget(_parent), m_beginTime(-1)
|
||||
{
|
||||
setAlternatingRowColors(true);
|
||||
setItemsExpandable(true);
|
||||
@ -88,16 +89,16 @@ MyTreeWidget::MyTreeWidget(const thread_blocks_tree_t& _blocksTree, QWidget* _pa
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
sortByColumn(2, Qt::AscendingOrder);
|
||||
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &MyTreeWidget::onItemExpand);
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &ProfTreeWidget::onItemExpand);
|
||||
}
|
||||
|
||||
void MyTreeWidget::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
void ProfTreeWidget::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
{
|
||||
m_itemblocks.clear();
|
||||
|
||||
clear();
|
||||
|
||||
disconnect(this, &QTreeWidget::itemExpanded, this, &MyTreeWidget::onItemExpand);
|
||||
disconnect(this, &QTreeWidget::itemExpanded, this, &ProfTreeWidget::onItemExpand);
|
||||
setSortingEnabled(false);
|
||||
setTreeInternal(_blocksTree);
|
||||
|
||||
@ -105,10 +106,10 @@ void MyTreeWidget::setTree(const thread_blocks_tree_t& _blocksTree)
|
||||
sortByColumn(0, Qt::AscendingOrder);
|
||||
sortByColumn(2, Qt::AscendingOrder);
|
||||
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &MyTreeWidget::onItemExpand);
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &ProfTreeWidget::onItemExpand);
|
||||
}
|
||||
|
||||
void MyTreeWidget::setTreeInternal(const thread_blocks_tree_t& _blocksTree)
|
||||
void ProfTreeWidget::setTreeInternal(const thread_blocks_tree_t& _blocksTree)
|
||||
{
|
||||
for (const auto& threadTree : _blocksTree)
|
||||
{
|
||||
@ -121,14 +122,14 @@ void MyTreeWidget::setTreeInternal(const thread_blocks_tree_t& _blocksTree)
|
||||
|
||||
for (const auto& threadTree : _blocksTree)
|
||||
{
|
||||
auto item = new MyTreeItem(&threadTree.second);
|
||||
auto item = new ProfTreeWidgetItem(&threadTree.second);
|
||||
item->setText(0, QString("Thread %1").arg(threadTree.first));
|
||||
setTreeInternal(threadTree.second.children, item);
|
||||
addTopLevelItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void MyTreeWidget::setTreeInternal(const BlocksTree::children_t& _children, MyTreeItem* _parent)
|
||||
void ProfTreeWidget::setTreeInternal(const BlocksTree::children_t& _children, ProfTreeWidgetItem* _parent)
|
||||
{
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
@ -136,7 +137,7 @@ void MyTreeWidget::setTreeInternal(const BlocksTree::children_t& _children, MyTr
|
||||
const auto beginTime = child.node->block()->getBegin() - m_beginTime;
|
||||
const auto endTime = child.node->block()->getEnd() - m_beginTime;
|
||||
|
||||
auto item = new MyTreeItem(&child, _parent);
|
||||
auto item = new ProfTreeWidgetItem(&child, _parent);
|
||||
item->setText(0, child.node->getBlockName());
|
||||
item->setTimeSmart(1, child.node->block()->duration());
|
||||
item->setTimeMs(2, child.node->block()->getBegin() - m_beginTime);
|
||||
@ -159,10 +160,10 @@ void MyTreeWidget::setTreeInternal(const BlocksTree::children_t& _children, MyTr
|
||||
}
|
||||
}
|
||||
|
||||
void MyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
{
|
||||
const auto col = currentColumn();
|
||||
auto item = static_cast<MyTreeItem*>(currentItem());
|
||||
auto item = static_cast<ProfTreeWidgetItem*>(currentItem());
|
||||
|
||||
if (item == nullptr || col < 0)
|
||||
{
|
||||
@ -172,11 +173,11 @@ void MyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
QMenu menu;
|
||||
|
||||
auto action = new QAction("Expand all", nullptr);
|
||||
connect(action, &QAction::triggered, this, &MyTreeWidget::onExpandAllClicked);
|
||||
connect(action, &QAction::triggered, this, &ProfTreeWidget::onExpandAllClicked);
|
||||
menu.addAction(action);
|
||||
|
||||
action = new QAction("Collapse all", nullptr);
|
||||
connect(action, &QAction::triggered, this, &MyTreeWidget::onCollapseAllClicked);
|
||||
connect(action, &QAction::triggered, this, &ProfTreeWidget::onCollapseAllClicked);
|
||||
menu.addAction(action);
|
||||
|
||||
switch (col)
|
||||
@ -184,8 +185,8 @@ void MyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
case 4:
|
||||
{
|
||||
menu.addSeparator();
|
||||
auto itemAction = new ItemAction("Jump to such item", item);
|
||||
connect(itemAction, &ItemAction::clicked, this, &MyTreeWidget::onJumpToMinItemClicked);
|
||||
auto itemAction = new ProfItemAction("Jump to such item", item);
|
||||
connect(itemAction, &ProfItemAction::clicked, this, &ProfTreeWidget::onJumpToMinItemClicked);
|
||||
menu.addAction(itemAction);
|
||||
break;
|
||||
}
|
||||
@ -193,8 +194,8 @@ void MyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
case 5:
|
||||
{
|
||||
menu.addSeparator();
|
||||
auto itemAction = new ItemAction("Jump to such item", item);
|
||||
connect(itemAction, &ItemAction::clicked, this, &MyTreeWidget::onJumpToMaxItemClicked);
|
||||
auto itemAction = new ProfItemAction("Jump to such item", item);
|
||||
connect(itemAction, &ProfItemAction::clicked, this, &ProfTreeWidget::onJumpToMaxItemClicked);
|
||||
menu.addAction(itemAction);
|
||||
break;
|
||||
}
|
||||
@ -205,7 +206,7 @@ void MyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
_event->accept();
|
||||
}
|
||||
|
||||
void MyTreeWidget::onJumpToMinItemClicked(MyTreeItem* _item)
|
||||
void ProfTreeWidget::onJumpToMinItemClicked(ProfTreeWidgetItem* _item)
|
||||
{
|
||||
auto it = m_itemblocks.find(_item->block()->total_statistics->min_duration_block);
|
||||
if (it != m_itemblocks.end())
|
||||
@ -215,7 +216,7 @@ void MyTreeWidget::onJumpToMinItemClicked(MyTreeItem* _item)
|
||||
}
|
||||
}
|
||||
|
||||
void MyTreeWidget::onJumpToMaxItemClicked(MyTreeItem* _item)
|
||||
void ProfTreeWidget::onJumpToMaxItemClicked(ProfTreeWidgetItem* _item)
|
||||
{
|
||||
auto it = m_itemblocks.find(_item->block()->total_statistics->max_duration_block);
|
||||
if (it != m_itemblocks.end())
|
||||
@ -225,20 +226,20 @@ void MyTreeWidget::onJumpToMaxItemClicked(MyTreeItem* _item)
|
||||
}
|
||||
}
|
||||
|
||||
void MyTreeWidget::onCollapseAllClicked(bool)
|
||||
void ProfTreeWidget::onCollapseAllClicked(bool)
|
||||
{
|
||||
collapseAll();
|
||||
}
|
||||
|
||||
void MyTreeWidget::onExpandAllClicked(bool)
|
||||
void ProfTreeWidget::onExpandAllClicked(bool)
|
||||
{
|
||||
disconnect(this, &QTreeWidget::itemExpanded, this, &MyTreeWidget::onItemExpand);
|
||||
disconnect(this, &QTreeWidget::itemExpanded, this, &ProfTreeWidget::onItemExpand);
|
||||
expandAll();
|
||||
resizeColumnToContents(0);
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &MyTreeWidget::onItemExpand);
|
||||
connect(this, &QTreeWidget::itemExpanded, this, &ProfTreeWidget::onItemExpand);
|
||||
}
|
||||
|
||||
void MyTreeWidget::onItemExpand(QTreeWidgetItem*)
|
||||
void ProfTreeWidget::onItemExpand(QTreeWidgetItem*)
|
||||
{
|
||||
resizeColumnToContents(0);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
* : for displyaing easy_profiler blocks tree.
|
||||
* ----------------- :
|
||||
* change log : * 2016/06/26 Victor Zarubkin: moved sources from tree_view.h
|
||||
* : and renamed classes from My* to Prof*.
|
||||
* : *
|
||||
* ----------------- :
|
||||
* license : TODO: add license text
|
||||
@ -26,47 +27,51 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <const size_t SIZEOF_T>
|
||||
struct no_hasher {
|
||||
template <class T> inline size_t operator () (const T& _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
namespace btw {
|
||||
|
||||
template <const size_t SIZEOF_T>
|
||||
struct no_hasher {
|
||||
template <class T> inline size_t operator () (const T& _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _WIN64
|
||||
template <> struct no_hasher<8> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
template <> struct no_hasher<8> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <> struct no_hasher<4> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
template <> struct no_hasher<4> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct no_hasher<2> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
template <> struct no_hasher<2> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct no_hasher<1> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
template <> struct no_hasher<1> {
|
||||
template <class T> inline size_t operator () (T _data) const {
|
||||
return (size_t)_data;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct do_no_hash {
|
||||
typedef no_hasher<sizeof(T)> hasher_t;
|
||||
};
|
||||
template <class T>
|
||||
struct do_no_hash {
|
||||
typedef no_hasher<sizeof(T)> hasher_t;
|
||||
};
|
||||
|
||||
} // END of namespace btw.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyTreeItem : public QTreeWidgetItem
|
||||
class ProfTreeWidgetItem : public QTreeWidgetItem
|
||||
{
|
||||
//Q_OBJECT
|
||||
|
||||
@ -74,7 +79,7 @@ class MyTreeItem : public QTreeWidgetItem
|
||||
|
||||
public:
|
||||
|
||||
MyTreeItem(const BlocksTree* _block, QTreeWidgetItem* _parent = nullptr);
|
||||
ProfTreeWidgetItem(const BlocksTree* _block, QTreeWidgetItem* _parent = nullptr);
|
||||
|
||||
const BlocksTree* block() const;
|
||||
|
||||
@ -105,23 +110,23 @@ public:
|
||||
|
||||
void setTimeMs(int _column, const ::profiler::timestamp_t& _time);
|
||||
|
||||
}; // END of class MyTreeItem.
|
||||
}; // END of class ProfTreeWidgetItem.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ItemAction : public QAction
|
||||
class ProfItemAction : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
MyTreeItem* m_item;
|
||||
ProfTreeWidgetItem* m_item;
|
||||
|
||||
public:
|
||||
|
||||
ItemAction(const char* _label, MyTreeItem* _item) : QAction(_label, nullptr), m_item(_item)
|
||||
ProfItemAction(const char* _label, ProfTreeWidgetItem* _item) : QAction(_label, nullptr), m_item(_item)
|
||||
{
|
||||
connect(this, &QAction::triggered, this, &ItemAction::onToggle);
|
||||
connect(this, &QAction::triggered, this, &ProfItemAction::onToggle);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -133,25 +138,25 @@ private:
|
||||
|
||||
signals:
|
||||
|
||||
void clicked(MyTreeItem* _item);
|
||||
void clicked(ProfTreeWidgetItem* _item);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class MyTreeWidget : public QTreeWidget
|
||||
class ProfTreeWidget : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
|
||||
typedef ::std::unordered_map<const ::profiler::SerilizedBlock*, MyTreeItem*, do_no_hash<const ::profiler::SerilizedBlock*>::hasher_t> BlockItemMap;
|
||||
typedef ::std::unordered_map<const ::profiler::SerilizedBlock*, ProfTreeWidgetItem*, ::btw::do_no_hash<const ::profiler::SerilizedBlock*>::hasher_t> BlockItemMap;
|
||||
|
||||
BlockItemMap m_itemblocks;
|
||||
::profiler::timestamp_t m_beginTime;
|
||||
|
||||
public:
|
||||
|
||||
MyTreeWidget(const thread_blocks_tree_t& _blocksTree, QWidget* _parent = nullptr);
|
||||
ProfTreeWidget(const thread_blocks_tree_t& _blocksTree, QWidget* _parent = nullptr);
|
||||
|
||||
void setTree(const thread_blocks_tree_t& _blocksTree);
|
||||
|
||||
@ -159,15 +164,15 @@ protected:
|
||||
|
||||
void setTreeInternal(const thread_blocks_tree_t& _blocksTree);
|
||||
|
||||
void setTreeInternal(const BlocksTree::children_t& _children, MyTreeItem* _parent);
|
||||
void setTreeInternal(const BlocksTree::children_t& _children, ProfTreeWidgetItem* _parent);
|
||||
|
||||
void contextMenuEvent(QContextMenuEvent* _event);
|
||||
|
||||
private slots:
|
||||
|
||||
void onJumpToMinItemClicked(MyTreeItem* _item);
|
||||
void onJumpToMinItemClicked(ProfTreeWidgetItem* _item);
|
||||
|
||||
void onJumpToMaxItemClicked(MyTreeItem* _item);
|
||||
void onJumpToMaxItemClicked(ProfTreeWidgetItem* _item);
|
||||
|
||||
void onCollapseAllClicked(bool);
|
||||
|
||||
@ -175,7 +180,7 @@ private slots:
|
||||
|
||||
void onItemExpand(QTreeWidgetItem*);
|
||||
|
||||
}; // END of class MyTreeWidget.
|
||||
}; // END of class ProfTreeWidget.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -46,7 +46,7 @@ int main(int argc, char **argv)
|
||||
srand(*rseed);
|
||||
delete rseed;
|
||||
|
||||
MyGraphicsView gview;
|
||||
ProfGraphicsView gview;
|
||||
gview.show();
|
||||
|
||||
return app.exec();
|
||||
@ -55,7 +55,7 @@ int main(int argc, char **argv)
|
||||
thread_blocks_tree_t threaded_trees;
|
||||
int blocks_counter = fillTreesFromFile("test.prof", threaded_trees, true);
|
||||
|
||||
MyGraphicsView gview(threaded_trees);
|
||||
ProfGraphicsView gview(threaded_trees);
|
||||
gview.show();
|
||||
|
||||
return app.exec();
|
||||
@ -66,7 +66,7 @@ int main(int argc, char **argv)
|
||||
thread_blocks_tree_t threaded_trees;
|
||||
int blocks_counter = fillTreesFromFile("test.prof", threaded_trees, true);
|
||||
|
||||
MyTreeWidget view(threaded_trees);
|
||||
ProfTreeWidget view(threaded_trees);
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
|
Loading…
x
Reference in New Issue
Block a user