2016-08-04 23:12:41 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : blocks_tree_widget.h
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/06/26
|
|
|
|
* copyright : (c) 2016 Victor Zarubkin
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : The file contains declaration of TreeWidget and it's auxiliary classes
|
|
|
|
* : 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*.
|
|
|
|
* :
|
2016-06-27 22:11:26 +03:00
|
|
|
* : * 2016/06/27 Victor Zarubkin: Added possibility to colorize rows
|
|
|
|
* : with profiler blocks' colors.
|
2016-06-30 02:57:57 +03:00
|
|
|
* :
|
|
|
|
* : * 2016/06/29 Victor Zarubkin: Added clearSilent() method.
|
|
|
|
* :
|
2016-08-04 23:12:41 +03:00
|
|
|
* : *
|
|
|
|
* ----------------- :
|
|
|
|
* license : TODO: add license text
|
2016-06-26 18:56:40 +03:00
|
|
|
************************************************************************/
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
#ifndef MY____TREE___VIEW_H
|
|
|
|
#define MY____TREE___VIEW_H
|
|
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QAction>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unordered_map>
|
2016-06-27 22:11:26 +03:00
|
|
|
#include <vector>
|
2016-06-26 18:46:51 +03:00
|
|
|
#include "profiler/reader.h"
|
2016-07-31 18:48:41 +03:00
|
|
|
#include "common_types.h"
|
2016-08-03 23:00:04 +03:00
|
|
|
#include "globals.h"
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
class ProfTreeWidgetItem : public QTreeWidgetItem
|
2016-06-26 18:46:51 +03:00
|
|
|
{
|
2016-06-27 22:11:26 +03:00
|
|
|
typedef QTreeWidgetItem Parent;
|
|
|
|
typedef ProfTreeWidgetItem This;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
const ::profiler::BlocksTree* m_block;
|
|
|
|
QRgb m_customBGColor;
|
|
|
|
QRgb m_customTextColor;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
using Parent::setBackgroundColor;
|
|
|
|
using Parent::setTextColor;
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
ProfTreeWidgetItem(const ::profiler::BlocksTree* _treeBlock, Parent* _parent = nullptr);
|
2016-06-26 20:54:16 +03:00
|
|
|
virtual ~ProfTreeWidgetItem();
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
bool operator < (const Parent& _other) const override;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
const ::profiler::BlocksTree* block() const;
|
|
|
|
|
|
|
|
::profiler::timestamp_t duration() const;
|
2016-08-07 19:38:31 +03:00
|
|
|
::profiler::timestamp_t selfDuration() const;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
void setTimeSmart(int _column, const ::profiler::timestamp_t& _time);
|
|
|
|
|
|
|
|
void setTimeMs(int _column, const ::profiler::timestamp_t& _time);
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void setBackgroundColor(QRgb _color);
|
2016-06-27 22:11:26 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void setTextColor(QRgb _color);
|
2016-06-27 22:11:26 +03:00
|
|
|
|
|
|
|
void colorize(bool _colorize);
|
|
|
|
|
2016-07-31 18:48:41 +03:00
|
|
|
void collapseAll();
|
|
|
|
|
|
|
|
void expandAll();
|
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
}; // END of class ProfTreeWidgetItem.
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
#define DECLARE_QACTION(ClassName, DataType) \
|
|
|
|
class ClassName : public QAction { \
|
|
|
|
Q_OBJECT \
|
|
|
|
private: \
|
|
|
|
DataType m_item; \
|
|
|
|
public: \
|
|
|
|
ClassName(const char* _label, DataType _item) : QAction(_label, nullptr), m_item(_item) { \
|
|
|
|
connect(this, &QAction::triggered, this, &ClassName::onToggle); } \
|
|
|
|
ClassName(const QString& _label, DataType _item) : QAction(_label, nullptr), m_item(_item) { \
|
|
|
|
connect(this, &QAction::triggered, this, &ClassName::onToggle); } \
|
|
|
|
virtual ~ClassName() {}\
|
|
|
|
private: \
|
2016-08-04 23:12:41 +03:00
|
|
|
void onToggle(bool) { emit clicked(m_item); }
|
2016-08-03 23:00:04 +03:00
|
|
|
|
2016-08-04 23:12:41 +03:00
|
|
|
DECLARE_QACTION(ProfItemAction, ProfTreeWidgetItem*) signals: void clicked(ProfTreeWidgetItem* _item); };
|
|
|
|
DECLARE_QACTION(ProfHideShowColumnAction, int) signals: void clicked(int _item); };
|
2016-08-03 23:00:04 +03:00
|
|
|
|
|
|
|
#undef DECLARE_QACTION
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
class ProfTreeWidget : public QTreeWidget
|
2016-06-26 18:46:51 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
typedef QTreeWidget Parent;
|
|
|
|
typedef ProfTreeWidget This;
|
|
|
|
|
2016-06-26 18:46:51 +03:00
|
|
|
protected:
|
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
typedef ::std::vector<ProfTreeWidgetItem*> Items;
|
2016-08-03 23:00:04 +03:00
|
|
|
typedef ::std::unordered_map<::profiler::thread_id_t, ProfTreeWidgetItem*, ::profiler_gui::do_no_hash<::profiler::thread_id_t>::hasher_t> RootsMap;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
Items m_items;
|
2016-08-03 23:00:04 +03:00
|
|
|
RootsMap m_roots;
|
2016-06-26 18:46:51 +03:00
|
|
|
::profiler::timestamp_t m_beginTime;
|
2016-06-27 22:11:26 +03:00
|
|
|
bool m_bColorRows;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
ProfTreeWidget(QWidget* _parent = nullptr);
|
2016-08-03 23:00:04 +03:00
|
|
|
ProfTreeWidget(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, QWidget* _parent = nullptr);
|
2016-06-26 20:54:16 +03:00
|
|
|
virtual ~ProfTreeWidget();
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-08-04 22:38:45 +03:00
|
|
|
void clearSilent(bool _global = false);
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-07-31 18:48:41 +03:00
|
|
|
public slots:
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void setTree(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree);
|
2016-07-31 18:48:41 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _session_begin_time, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict);
|
2016-07-31 18:48:41 +03:00
|
|
|
|
2016-06-26 18:46:51 +03:00
|
|
|
protected:
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
size_t setTreeInternal(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree);
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
size_t setTreeInternal(const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict);
|
2016-07-31 18:48:41 +03:00
|
|
|
|
2016-08-07 19:38:31 +03:00
|
|
|
size_t setTreeInternal(const ::profiler::BlocksTree::children_t& _children, ProfTreeWidgetItem* _parent, ProfTreeWidgetItem* _frame, ProfTreeWidgetItem* _thread, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration);
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
void contextMenuEvent(QContextMenuEvent* _event) override;
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
void onJumpToMinItemClicked(ProfTreeWidgetItem* _item);
|
2016-06-26 18:46:51 +03:00
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
void onJumpToMaxItemClicked(ProfTreeWidgetItem* _item);
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
void onCollapseAllClicked(bool);
|
|
|
|
|
|
|
|
void onExpandAllClicked(bool);
|
|
|
|
|
2016-07-31 18:48:41 +03:00
|
|
|
void onCollapseAllChildrenClicked(bool);
|
|
|
|
|
|
|
|
void onExpandAllChildrenClicked(bool);
|
|
|
|
|
2016-06-26 18:46:51 +03:00
|
|
|
void onItemExpand(QTreeWidgetItem*);
|
|
|
|
|
2016-06-27 22:11:26 +03:00
|
|
|
void onColorizeRowsTriggered(bool _colorize);
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
void onSelectedThreadChange(::profiler::thread_id_t _id);
|
|
|
|
|
|
|
|
void resizeColumnsToContents();
|
|
|
|
|
|
|
|
void onHideShowColumn(int _column);
|
|
|
|
|
2016-08-04 23:12:41 +03:00
|
|
|
protected:
|
|
|
|
|
2016-08-07 19:38:31 +03:00
|
|
|
void loadSettings();
|
2016-08-04 23:12:41 +03:00
|
|
|
void saveSettings();
|
|
|
|
|
2016-06-26 19:06:53 +03:00
|
|
|
}; // END of class ProfTreeWidget.
|
2016-06-26 18:46:51 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif // MY____TREE___VIEW_H
|