0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 16:11:02 +08:00

#0 [Gui] Large portion of refactoring; Replaced bunch of threads with thread pool; Small fixes for arbitrary values viewer

This commit is contained in:
Victor Zarubkin 2018-01-28 20:52:17 +03:00
parent 1f6d3c2a7d
commit 1a333e4f01
42 changed files with 1356 additions and 1067 deletions

View File

@ -42,6 +42,10 @@ if (Qt5Widgets_FOUND)
graphics_slider_area.cpp
main_window.h
main_window.cpp
thread_pool.h
thread_pool.cpp
thread_pool_task.h
thread_pool_task.cpp
tree_widget_item.h
tree_widget_item.cpp
tree_widget_loader.h

View File

@ -71,6 +71,9 @@
//////////////////////////////////////////////////////////////////////////
EASY_CONSTEXPR int ChartBound = 2; ///< Top and bottom bounds for chart
EASY_CONSTEXPR int ChartBounds = ChartBound << 1;
void getChartPoints(const ArbitraryValuesCollection& _collection, Points& _points, qreal& _minValue, qreal& _maxValue)
{
_minValue = 1e300;
@ -151,7 +154,7 @@ ArbitraryValuesCollection::ArbitraryValuesCollection()
ArbitraryValuesCollection::~ArbitraryValuesCollection()
{
join();
}
const ArbitraryValuesMap& ArbitraryValuesCollection::valuesMap() const
@ -196,9 +199,13 @@ void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, p
m_jobType = ValuesJob;
if (_valueId == 0)
m_collectorThread = std::thread(&This::collectByName, this, _threadId, _valueName);
{
m_worker.enqueue([this, _threadId, _valueName] { collectByName(_threadId, _valueName); }, m_bInterrupt);
}
else
m_collectorThread = std::thread(&This::collectById, this, _threadId, _valueId);
{
m_worker.enqueue([this, _threadId, _valueId] { collectById(_threadId, _valueId); }, m_bInterrupt);
}
}
void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime)
@ -213,9 +220,13 @@ void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, p
m_jobType = ValuesJob | PointsJob;
if (_valueId == 0)
m_collectorThread = std::thread(&This::collectByName, this, _threadId, _valueName);
{
m_worker.enqueue([this, _threadId, _valueName] { collectByName(_threadId, _valueName); }, m_bInterrupt);
}
else
m_collectorThread = std::thread(&This::collectById, this, _threadId, _valueId);
{
m_worker.enqueue([this, _threadId, _valueId] { collectById(_threadId, _valueId); }, m_bInterrupt);
}
}
bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime)
@ -223,8 +234,7 @@ bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime
if (status() != Ready || m_values.empty())
return false;
if (m_collectorThread.joinable())
m_collectorThread.join();
m_worker.dequeue();
setStatus(InProgress);
m_points.clear();
@ -233,38 +243,22 @@ bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime
m_maxValue = -1e300;
m_jobType = PointsJob;
m_collectorThread = std::thread([this]
m_worker.enqueue([this]
{
getChartPoints(*this, m_points, m_minValue, m_maxValue);
setStatus(Ready);
});
}, m_bInterrupt);
return true;
}
void ArbitraryValuesCollection::interrupt()
{
if (m_collectorThread.joinable())
{
m_bInterrupt.store(true, std::memory_order_release);
m_collectorThread.join();
m_bInterrupt.store(false, std::memory_order_release);
m_worker.dequeue();
setStatus(Idle);
m_jobType = None;
m_values.clear();
}
}
void ArbitraryValuesCollection::join()
{
if (m_collectorThread.joinable())
{
m_bInterrupt.store(true, std::memory_order_release);
m_collectorThread.join();
m_bInterrupt.store(false, std::memory_order_release);
}
}
void ArbitraryValuesCollection::setStatus(JobStatus _status)
{
@ -438,8 +432,8 @@ void ArbitraryValuesChartItem::paint(QPainter* _painter, const QStyleOptionGraph
if (!EASY_GLOBALS.scene.empty)
{
const auto range = bindMode ? widget->sliderWidth() : widget->range();
paintMouseIndicator(_painter, m_boundingRect.top(), bottom, width, m_boundingRect.height(), font_h,
widget->value(), range);
paintMouseIndicator(_painter, m_boundingRect.top(), bottom, width,
m_boundingRect.height(), font_h, widget->value(), range);
}
_painter->setPen(Qt::darkGray);
@ -456,21 +450,25 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
return;
const auto x = m_mousePos.x();
const auto y = m_mousePos.y();
auto y = m_mousePos.y();
// Horizontal
const bool visibleY = (_top < y && y < _bottom);
if (visibleY)
y = estd::clamp(_top, y, _bottom);
//if (visibleY)
{
_height -= ChartBounds;
const int half_font_h = _font_h >> 1;
const auto value = m_minValue + ((_bottom - 2 - y) / (_height - 4)) * (m_maxValue - m_minValue);
const auto yvalue = estd::clamp(_top + ChartBound, y, _bottom - ChartBound);
const auto value = m_minValue + ((_bottom - ChartBound - yvalue) / _height) * (m_maxValue - m_minValue);
const auto mouseStr = QString::number(value, 'f', 3);
const int textWidth = _painter->fontMetrics().width(mouseStr) + 3;
const QRectF rect(0, y - _font_h - 2, _width, 4 + (_font_h << 1));
const QRectF rect(0, y - _font_h - 2, _width - 3, 4 + (_font_h << 1));
_painter->setPen(Qt::blue);
qreal left = 0, right = _width;
qreal left = 0, right = _width - 3;
const Qt::AlignmentFlag alignment = x < textWidth ? Qt::AlignRight : Qt::AlignLeft;
if (y > _bottom - half_font_h)
@ -485,11 +483,12 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
{
_painter->drawText(rect, alignment | Qt::AlignVCenter, mouseStr);
if (x < textWidth)
right = _width - textWidth;
right = _width - textWidth - 3;
else
left = textWidth;
}
if (visibleY)
_painter->drawLine(QLineF(left, y, right, y));
}
@ -507,8 +506,8 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
else if (x > (_width - textWidthHalf))
left = _width - textWidth;
if (!visibleY)
_painter->setPen(Qt::blue);
//if (!visibleY)
// _painter->setPen(Qt::blue);
const QRectF rect(left, _bottom + 2, textWidth, _font_h);
_painter->drawText(rect, Qt::AlignCenter, mouseStr);
@ -526,9 +525,21 @@ bool ArbitraryValuesChartItem::updateImage()
m_imageScaleUpdate = widget->range() / widget->sliderWidth();
m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum();
m_workerThread = std::thread(&This::updateImageAsync, this, m_boundingRect, widget->getWindowScale(),
widget->minimum(), widget->maximum(), widget->range(), widget->value(), widget->sliderWidth(),
widget->bindMode(), EASY_GLOBALS.begin_time, EASY_GLOBALS.auto_adjust_chart_height);
// Ugly, but doen't use exceeded count of threads
const auto rect = m_boundingRect;
const auto scale = widget->getWindowScale();
const auto left = widget->minimum();
const auto right = widget->maximum();
const auto value = widget->value();
const auto window = widget->sliderWidth();
const auto bindMode = widget->bindMode();
const auto beginTime = EASY_GLOBALS.begin_time;
const auto autoHeight = EASY_GLOBALS.auto_adjust_chart_height;
m_worker.enqueue([this, rect, scale, left, right, value, window, bindMode, beginTime, autoHeight]
{
updateImageAsync(rect, scale, left, right, right - left, value, window, bindMode,
beginTime, autoHeight);
}, m_bReady);
return true;
}
@ -708,8 +719,8 @@ void ArbitraryValuesChartItem::updateImageAsync(QRectF _boundingRect, qreal _cur
{
y = maxValue - y;
y /= height;
y *= _boundingRect.height() - 4;
y += 2;
y *= _boundingRect.height() - ChartBounds;
y += ChartBound;
}
return y;
@ -878,7 +889,7 @@ GraphicsChart::GraphicsChart(QWidget* _parent)
m_chartItem->setPos(0, 0);
m_chartItem->setBoundingRect(0, rect.top() + margin(), scene()->width(), rect.height() - margins() - 1);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::autoAdjustChartChanged, this, &This::onAutoAdjustChartChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::autoAdjustChartChanged, this, &This::onAutoAdjustChartChanged);
m_chartItem->updateImage();
}
@ -1040,7 +1051,7 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent)
//m_treeWidget->setSortingEnabled(false);
m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count));
m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
m_treeWidget->setItemDelegateForColumn(0, new EasyTreeViewFirstColumnItemDelegate(this));
m_treeWidget->setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this));
auto headerItem = new QTreeWidgetItem();
headerItem->setText(int_cast(ArbitraryColumns::Type), "Type");
@ -1056,9 +1067,9 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent)
connect(m_treeWidget, &QTreeWidget::currentItemChanged, this, &This::onCurrentItemChanged);
auto globalEvents = &EASY_GLOBALS.events;
connect(globalEvents, &profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::selectedBlockIdChanged, this, &This::onSelectedBlockIdChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::fileOpened, this, &This::rebuild);
connect(globalEvents, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChanged);
connect(globalEvents, &profiler_gui::GlobalSignals::selectedBlockIdChanged, this, &This::onSelectedBlockIdChanged);
connect(globalEvents, &profiler_gui::GlobalSignals::fileOpened, this, &This::rebuild);
loadSettings();
@ -1182,7 +1193,6 @@ void ArbitraryValuesWidget::onCollectionsTimeout()
{
if (item->collection()->status() != ArbitraryValuesCollection::InProgress)
{
item->collection()->join();
collections.push_back(CollectionPaintData {item->collection(), item->color(),
ChartType::Line, item == m_treeWidget->currentItem()});
}

View File

@ -67,10 +67,10 @@
#include <unordered_map>
#include <vector>
#include <string>
#include <thread>
#include <atomic>
#include <memory>
#include "graphics_slider_area.h"
#include "thread_pool_task.h"
//////////////////////////////////////////////////////////////////////////
@ -91,7 +91,7 @@ private:
ArbitraryValuesMap m_values;
Points m_points;
std::thread m_collectorThread;
ThreadPoolTask m_worker;
profiler::timestamp_t m_beginTime;
qreal m_minValue;
qreal m_maxValue;
@ -116,7 +116,6 @@ public:
void collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime);
bool calculatePoints(profiler::timestamp_t _beginTime);
void interrupt();
void join();
private:

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
* :
* : * 2016/06/30 Victor Zarubkin: Replaced doubles with floats (in ProfBlockItem) for less memory consumption.
* :
* : * 2016/09/15 Victor Zarubkin: Moved sources of EasyGraphicsItem and EasyChronometerItem to separate files.
* : * 2016/09/15 Victor Zarubkin: Moved sources of BlocksGraphicsItem and GraphicsRulerItem to separate files.
* :
* : *
* ----------------- :
@ -81,10 +81,10 @@
//////////////////////////////////////////////////////////////////////////
class QGraphicsProxyWidget;
class EasyGraphicsView;
class EasyGraphicsItem;
class EasyGraphicsScrollbar;
class EasyChronometerItem;
class BlocksGraphicsView;
class BlocksGraphicsItem;
class BlocksGraphicsScrollbar;
class GraphicsRulerItem;
//////////////////////////////////////////////////////////////////////////
@ -100,35 +100,35 @@ public: \
void setBoundingRect(const QRectF& _rect) { m_boundingRect = _rect; } \
}
EASY_QGRAPHICSITEM(EasyBackgroundItem);
EASY_QGRAPHICSITEM(EasyTimelineIndicatorItem);
EASY_QGRAPHICSITEM(EasyThreadNameItem);
EASY_QGRAPHICSITEM(BackgroundItem);
EASY_QGRAPHICSITEM(TimelineIndicatorItem);
EASY_QGRAPHICSITEM(ThreadNameItem);
#undef EASY_QGRAPHICSITEM
//////////////////////////////////////////////////////////////////////////
struct EasyBoldLabel : public QLabel {
EasyBoldLabel(const QString& _text, QWidget* _parent = nullptr);
virtual ~EasyBoldLabel();
struct BoldLabel : public QLabel {
BoldLabel(const QString& _text, QWidget* _parent = nullptr);
~BoldLabel() override;
};
//////////////////////////////////////////////////////////////////////////
class EasyGraphicsView : public QGraphicsView
class BlocksGraphicsView : public QGraphicsView
{
Q_OBJECT
private:
using Parent = QGraphicsView;
using This = EasyGraphicsView;
using Items = ::std::vector<EasyGraphicsItem*>;
using This = BlocksGraphicsView;
using Items = ::std::vector<BlocksGraphicsItem*>;
//using Keys = ::std::unordered_set<int, ::estd::hash<int> >;
Items m_items; ///< Array of all EasyGraphicsItem items
Items m_items; ///< Array of all BlocksGraphicsItem items
//Keys m_keys; ///< Pressed keyboard keys
::profiler_gui::TreeBlocks m_selectedBlocks; ///< Array of items which were selected by selection zone (EasyChronometerItem)
::profiler_gui::TreeBlocks m_selectedBlocks; ///< Array of items which were selected by selection zone (GraphicsRulerItem)
QTimer m_flickerTimer; ///< Timer for flicking behavior
QTimer m_idleTimer; ///<
QRectF m_visibleSceneRect; ///< Visible scene rectangle
@ -142,9 +142,9 @@ private:
QPoint m_mousePressPos; ///< Last mouse global position (used by mousePressEvent and mouseMoveEvent)
QPoint m_mouseMovePath; ///< Mouse move path between press and release of any button
Qt::MouseButtons m_mouseButtons; ///< Pressed mouse buttons
EasyGraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar widget
EasyChronometerItem* m_chronometerItem; ///< Pointer to the EasyChronometerItem which is displayed when you press right mouse button and move mouse left or right. This item is used to select blocks to display in tree widget.
EasyChronometerItem* m_chronometerItemAux; ///< Pointer to the EasyChronometerItem which is displayed when you double click left mouse button and move mouse left or right. This item is used only to measure time.
BlocksGraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar widget
GraphicsRulerItem* m_selectionItem; ///< Pointer to the GraphicsRulerItem which is displayed when you press right mouse button and move mouse left or right. This item is used to select blocks to display in tree widget.
GraphicsRulerItem* m_rulerItem; ///< Pointer to the GraphicsRulerItem which is displayed when you double click left mouse button and move mouse left or right. This item is used only to measure time.
QGraphicsProxyWidget* m_popupWidget; ///<
int m_flickerSpeedX; ///< Current flicking speed x
int m_flickerSpeedY; ///< Current flicking speed y
@ -156,8 +156,8 @@ private:
public:
explicit EasyGraphicsView(QWidget* _parent = nullptr);
~EasyGraphicsView() override;
explicit BlocksGraphicsView(QWidget* _parent = nullptr);
~BlocksGraphicsView() override;
// Public virtual methods
@ -180,7 +180,7 @@ public:
qreal chronoTime() const;
qreal chronoTimeAux() const;
void setScrollbar(EasyGraphicsScrollbar* _scrollbar);
void setScrollbar(BlocksGraphicsScrollbar* _scrollbar);
void clear();
void setTree(const ::profiler::thread_blocks_tree_t& _blocksTree);
@ -207,16 +207,16 @@ private:
void removePopup(bool _removeFromScene = false);
EasyChronometerItem* createChronometer(bool _main = true);
bool moveChrono(EasyChronometerItem* _chronometerItem, qreal _mouseX);
GraphicsRulerItem* createChronometer(bool _main = true);
bool moveChrono(GraphicsRulerItem* _chronometerItem, qreal _mouseX);
void initMode();
int updateVisibleSceneRect();
void updateTimelineStep(qreal _windowWidth);
void scaleTo(qreal _scale);
void scrollTo(const EasyGraphicsItem* _item);
void scrollTo(const BlocksGraphicsItem* _item);
qreal mapToDiagram(qreal x) const;
void onWheel(qreal _scenePos, int _wheelDelta);
qreal setTree(EasyGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level);
qreal setTree(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level);
private slots:
@ -270,30 +270,30 @@ public:
//return PROF_FROM_MILLISECONDS(_pos);
}
}; // END of class EasyGraphicsView.
}; // END of class BlocksGraphicsView.
//////////////////////////////////////////////////////////////////////////
class EasyThreadNamesWidget : public QGraphicsView
class ThreadNamesWidget : public QGraphicsView
{
Q_OBJECT
private:
using Parent = QGraphicsView;
using This = EasyThreadNamesWidget;
using This = ThreadNamesWidget;
QTimer m_idleTimer; ///<
uint64_t m_idleTime; ///<
EasyGraphicsView* m_view; ///<
BlocksGraphicsView* m_view; ///<
QGraphicsProxyWidget* m_popupWidget; ///<
int m_maxLength; ///<
const int m_additionalHeight; ///<
public:
explicit EasyThreadNamesWidget(EasyGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr);
~EasyThreadNamesWidget() override;
explicit ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr);
~ThreadNamesWidget() override;
void mousePressEvent(QMouseEvent* _event) override;
void mouseDoubleClickEvent(QMouseEvent* _event) override;
@ -307,7 +307,7 @@ public:
void clear();
const EasyGraphicsView* view() const
const BlocksGraphicsView* view() const
{
return m_view;
}
@ -323,27 +323,27 @@ private slots:
void onIdleTimeout();
void repaintScene();
}; // END of class EasyThreadNamesWidget.
}; // END of class ThreadNamesWidget.
//////////////////////////////////////////////////////////////////////////
class EasyGraphicsViewWidget : public QWidget
class DiagramWidget : public QWidget
{
Q_OBJECT
private:
class QSplitter* m_splitter;
EasyGraphicsScrollbar* m_scrollbar;
EasyGraphicsView* m_view;
EasyThreadNamesWidget* m_threadNamesWidget;
BlocksGraphicsScrollbar* m_scrollbar;
BlocksGraphicsView* m_view;
ThreadNamesWidget* m_threadNamesWidget;
public:
explicit EasyGraphicsViewWidget(QWidget* _parent = nullptr);
~EasyGraphicsViewWidget() override;
explicit DiagramWidget(QWidget* _parent = nullptr);
~DiagramWidget() override;
EasyGraphicsView* view();
BlocksGraphicsView* view();
void clear();
void save(class QSettings& settings);
@ -353,7 +353,7 @@ private:
void initWidget();
}; // END of class EasyGraphicsViewWidget.
}; // END of class DiagramWidget.
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyTreeWidget and it's auxiliary classes
* description : The file contains implementation of BlocksTreeWidget and it's auxiliary classes
* : for displyaing easy_profiler blocks tree.
* ----------------- :
* change log : * 2016/06/26 Victor Zarubkin: Moved sources from tree_view.h
@ -79,6 +79,7 @@
#include <QByteArray>
#include <QDebug>
#include <QApplication>
#include <thread>
#include "blocks_tree_widget.h"
#include "globals.h"
@ -136,13 +137,13 @@ const bool SIMPLIFIED_REGIME_COLUMNS[COL_COLUMNS_NUMBER] = {
//////////////////////////////////////////////////////////////////////////
EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
BlocksTreeWidget::BlocksTreeWidget(QWidget* _parent)
: Parent(_parent)
, m_beginTime(::std::numeric_limits<decltype(m_beginTime)>::max())
, m_lastFound(nullptr)
, m_progress(nullptr)
, m_hintLabel(nullptr)
, m_mode(EasyTreeMode_Plain)
, m_mode(TreeMode::Plain)
, m_bLocked(false)
, m_bSilentExpandCollapse(false)
{
@ -159,7 +160,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
auto header_item = new QTreeWidgetItem();
auto f = header()->font();
f.setBold(true);
header()->setFont(f);// ::profiler_gui::EFont("Helvetica", 9, QFont::Bold));
header()->setFont(f);// profiler_gui::EFont("Helvetica", 9, QFont::Bold));
header_item->setText(COL_NAME, "Name");
@ -199,7 +200,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setText(COL_ACTIVE_TIME, "Active time");
header_item->setText(COL_ACTIVE_PERCENT, "Active %");
auto color = QColor::fromRgb(::profiler::colors::DeepOrange900);
auto color = QColor::fromRgb(profiler::colors::DeepOrange900);
header_item->setForeground(COL_MIN_PER_THREAD, color);
header_item->setForeground(COL_MAX_PER_THREAD, color);
header_item->setForeground(COL_AVERAGE_PER_THREAD, color);
@ -207,7 +208,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setForeground(COL_PERCENT_SUM_PER_THREAD, color);
header_item->setForeground(COL_DURATION_SUM_PER_THREAD, color);
color = QColor::fromRgb(::profiler::colors::Blue900);
color = QColor::fromRgb(profiler::colors::Blue900);
header_item->setForeground(COL_MIN_PER_FRAME, color);
header_item->setForeground(COL_MAX_PER_FRAME, color);
header_item->setForeground(COL_AVERAGE_PER_FRAME, color);
@ -216,7 +217,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setForeground(COL_DURATION_SUM_PER_FRAME, color);
header_item->setForeground(COL_PERCENT_PER_FRAME, color);
color = QColor::fromRgb(::profiler::colors::Teal900);
color = QColor::fromRgb(profiler::colors::Teal900);
header_item->setForeground(COL_MIN_PER_PARENT, color);
header_item->setForeground(COL_MAX_PER_PARENT, color);
header_item->setForeground(COL_AVERAGE_PER_PARENT, color);
@ -227,8 +228,8 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
setHeaderItem(header_item);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedThreadChanged, this, &This::onSelectedThreadChange, Qt::QueuedConnection);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange, Qt::QueuedConnection);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedThreadChanged, this, &This::onSelectedThreadChange, Qt::QueuedConnection);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange, Qt::QueuedConnection);
connect(&m_fillTimer, &QTimer::timeout, this, &This::onFillTimerTimeout);
loadSettings();
@ -236,7 +237,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
m_columnsHiddenStatus[0] = 0;
setColumnHidden(0, false);
if (m_mode == EasyTreeMode_Full)
if (m_mode == TreeMode::Full)
{
for (int i = 1; i < COL_COLUMNS_NUMBER; ++i)
m_columnsHiddenStatus[i] = isColumnHidden(i) ? 1 : 0;
@ -266,14 +267,14 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
setItemDelegateForColumn(0, new EasyItemDelegate(this));
}
EasyTreeWidget::~EasyTreeWidget()
BlocksTreeWidget::~BlocksTreeWidget()
{
saveSettings();
}
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onFillTimerTimeout()
void BlocksTreeWidget::onFillTimerTimeout()
{
if (m_hierarchyBuilder.done())
{
@ -300,7 +301,7 @@ void EasyTreeWidget::onFillTimerTimeout()
setSortingEnabled(true);
sortByColumn(COL_BEGIN, Qt::AscendingOrder); // sort by begin time
if (m_mode == EasyTreeMode_Plain) // and after that, sort by frame %
if (m_mode == TreeMode::Plain) // and after that, sort by frame %
sortByColumn(COL_PERCENT_PER_FRAME, Qt::DescendingOrder);
//resizeColumnToContents(COL_NAME);
@ -318,7 +319,7 @@ void EasyTreeWidget::onFillTimerTimeout()
}
}
void EasyTreeWidget::setTree(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree)
void BlocksTreeWidget::setTree(const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree)
{
clearSilent();
@ -346,7 +347,7 @@ void EasyTreeWidget::setTree(const unsigned int _blocksNumber, const ::profiler:
//}
}
void EasyTreeWidget::setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _session_begin_time, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict)
void BlocksTreeWidget::setTreeBlocks(const profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _session_begin_time, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict)
{
clearSilent();
@ -389,7 +390,7 @@ void EasyTreeWidget::setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, ::
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::clearSilent(bool _global)
void BlocksTreeWidget::clearSilent(bool _global)
{
const QSignalBlocker b(this);
@ -419,7 +420,7 @@ void EasyTreeWidget::clearSilent(bool _global)
#ifdef EASY_TREE_WIDGET__USE_VECTOR
auto& gui_block = item->guiBlock();
gui_block.expanded = false;
::profiler_gui::set_max(gui_block.tree_item);
profiler_gui::set_max(gui_block.tree_item);
#else
item.second->guiBlock().expanded = false;
#endif
@ -427,7 +428,7 @@ void EasyTreeWidget::clearSilent(bool _global)
#ifdef EASY_TREE_WIDGET__USE_VECTOR
else for (auto item : m_items)
{
::profiler_gui::set_max(item->guiBlock().tree_item);
profiler_gui::set_max(item->guiBlock().tree_item);
}
#endif
}
@ -461,7 +462,7 @@ void EasyTreeWidget::clearSilent(bool _global)
//////////////////////////////////////////////////////////////////////////
int EasyTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
int BlocksTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
{
if (m_bLocked || _str.isEmpty())
return 0;
@ -511,7 +512,7 @@ int EasyTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
return itemsList.size();
}
int EasyTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
int BlocksTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
{
if (m_bLocked || _str.isEmpty())
return 0;
@ -559,7 +560,7 @@ int EasyTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
void BlocksTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
{
if (m_bLocked)
{
@ -568,7 +569,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
}
const auto col = currentColumn();
auto item = static_cast<EasyTreeWidgetItem*>(currentItem());
auto item = static_cast<TreeWidgetItem*>(currentItem());
QMenu menu;
menu.setToolTipsVisible(true);
QAction* action = nullptr;
@ -604,16 +605,16 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto actionHierarchy = new QAction("Hierarchy mode", actionGroup);
actionHierarchy->setCheckable(true);
actionHierarchy->setChecked(m_mode == EasyTreeMode_Full);
actionHierarchy->setChecked(m_mode == TreeMode::Full);
actionHierarchy->setToolTip("Display full blocks hierarchy");
actionHierarchy->setData((quint32)EasyTreeMode_Full);
actionHierarchy->setData((quint32)TreeMode::Full);
menu.addAction(actionHierarchy);
auto actionPlain = new QAction("Plain mode", actionGroup);
actionPlain->setCheckable(true);
actionPlain->setChecked(m_mode == EasyTreeMode_Plain);
actionPlain->setChecked(m_mode == TreeMode::Plain);
actionPlain->setToolTip("Display plain list of blocks per frame.\nSome columns are disabled with this mode.");
actionPlain->setData((quint32)EasyTreeMode_Plain);
actionPlain->setData((quint32)TreeMode::Plain);
menu.addAction(actionPlain);
connect(actionHierarchy, &QAction::triggered, this, &This::onModeChange);
@ -635,7 +636,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
case COL_MAX_PER_FRAME:
{
auto& block = item->block();
auto i = ::profiler_gui::numeric_max<uint32_t>();
auto i = profiler_gui::numeric_max<uint32_t>();
switch (col)
{
case COL_MIN_PER_THREAD: i = block.per_thread_stats->min_duration_block; break;
@ -646,7 +647,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
case COL_MAX_PER_FRAME: i = block.per_frame_stats->max_duration_block; break;
}
if (i != ::profiler_gui::numeric_max(i))
if (i != profiler_gui::numeric_max(i))
{
menu.addSeparator();
auto itemAction = new QAction("Jump to such item", nullptr);
@ -676,12 +677,12 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
action->setToolTip(ToolTipValue);\
connect(action, &QAction::triggered, this, &This::onBlockStatusChangeClicked)
ADD_STATUS_ACTION("Off", ::profiler::OFF, "Do not profile this block.");
ADD_STATUS_ACTION("On", ::profiler::ON, "Profile this block\nif parent enabled children.");
ADD_STATUS_ACTION("Force-On", ::profiler::FORCE_ON, "Always profile this block even\nif it's parent disabled children.");
ADD_STATUS_ACTION("Off-recursive", ::profiler::OFF_RECURSIVE, "Do not profile neither this block\nnor it's children.");
ADD_STATUS_ACTION("On-without-children", ::profiler::ON_WITHOUT_CHILDREN, "Profile this block, but\ndo not profile it's children.");
ADD_STATUS_ACTION("Force-On-without-children", ::profiler::FORCE_ON_WITHOUT_CHILDREN, "Always profile this block, but\ndo not profile it's children.");
ADD_STATUS_ACTION("Off", profiler::OFF, "Do not profile this block.");
ADD_STATUS_ACTION("On", profiler::ON, "Profile this block\nif parent enabled children.");
ADD_STATUS_ACTION("Force-On", profiler::FORCE_ON, "Always profile this block even\nif it's parent disabled children.");
ADD_STATUS_ACTION("Off-recursive", profiler::OFF_RECURSIVE, "Do not profile neither this block\nnor it's children.");
ADD_STATUS_ACTION("On-without-children", profiler::ON_WITHOUT_CHILDREN, "Profile this block, but\ndo not profile it's children.");
ADD_STATUS_ACTION("Force-On-without-children", profiler::FORCE_ON_WITHOUT_CHILDREN, "Always profile this block, but\ndo not profile it's children.");
#undef ADD_STATUS_ACTION
submenu->setEnabled(EASY_GLOBALS.connected);
@ -698,7 +699,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
columnAction->setData(i);
columnAction->setCheckable(true);
columnAction->setChecked(m_columnsHiddenStatus[i] == 0);
if ((m_mode == EasyTreeMode_Full || SIMPLIFIED_REGIME_COLUMNS[i]))
if ((m_mode == TreeMode::Full || SIMPLIFIED_REGIME_COLUMNS[i]))
connect(columnAction, &QAction::triggered, this, &This::onHideShowColumn);
else
columnAction->setEnabled(false);
@ -712,19 +713,19 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::resizeEvent(QResizeEvent* _event)
void BlocksTreeWidget::resizeEvent(QResizeEvent* _event)
{
Parent::resizeEvent(_event);
alignProgressBar();
}
void EasyTreeWidget::moveEvent(QMoveEvent* _event)
void BlocksTreeWidget::moveEvent(QMoveEvent* _event)
{
Parent::moveEvent(_event);
alignProgressBar();
}
void EasyTreeWidget::alignProgressBar()
void BlocksTreeWidget::alignProgressBar()
{
auto center = rect().center();
auto pos = mapToGlobal(center);
@ -735,7 +736,7 @@ void EasyTreeWidget::alignProgressBar()
m_hintLabel->move(center.x() - (m_hintLabel->width() >> 1), std::max(center.y() - (m_hintLabel->height() >> 1), header()->height()));
}
void EasyTreeWidget::destroyProgressDialog()
void BlocksTreeWidget::destroyProgressDialog()
{
if (m_progress != nullptr)
{
@ -745,7 +746,7 @@ void EasyTreeWidget::destroyProgressDialog()
}
}
void EasyTreeWidget::createProgressDialog()
void BlocksTreeWidget::createProgressDialog()
{
destroyProgressDialog();
@ -760,7 +761,7 @@ void EasyTreeWidget::createProgressDialog()
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onJumpToItemClicked(bool)
void BlocksTreeWidget::onJumpToItemClicked(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action == nullptr)
@ -771,11 +772,11 @@ void EasyTreeWidget::onJumpToItemClicked(bool)
if (block_index < EASY_GLOBALS.gui_blocks.size())
EASY_GLOBALS.selected_block_id = easyBlock(block_index).tree.node->id();
else
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
emit EASY_GLOBALS.events.selectedBlockChanged(block_index);
}
void EasyTreeWidget::onCollapseAllClicked(bool)
void BlocksTreeWidget::onCollapseAllClicked(bool)
{
const QSignalBlocker b(this);
@ -796,7 +797,7 @@ void EasyTreeWidget::onCollapseAllClicked(bool)
}
}
void EasyTreeWidget::onExpandAllClicked(bool)
void BlocksTreeWidget::onExpandAllClicked(bool)
{
const QSignalBlocker blocker(this);
@ -821,9 +822,9 @@ void EasyTreeWidget::onExpandAllClicked(bool)
}
}
void EasyTreeWidget::onCollapseAllChildrenClicked(bool)
void BlocksTreeWidget::onCollapseAllChildrenClicked(bool)
{
auto current = static_cast<EasyTreeWidgetItem*>(currentItem());
auto current = static_cast<TreeWidgetItem*>(currentItem());
if (current != nullptr)
{
const QSignalBlocker b(this);
@ -836,9 +837,9 @@ void EasyTreeWidget::onCollapseAllChildrenClicked(bool)
}
}
void EasyTreeWidget::onExpandAllChildrenClicked(bool)
void BlocksTreeWidget::onExpandAllChildrenClicked(bool)
{
auto current = static_cast<EasyTreeWidgetItem*>(currentItem());
auto current = static_cast<TreeWidgetItem*>(currentItem());
if (current != nullptr)
{
const QSignalBlocker b(this);
@ -854,12 +855,12 @@ void EasyTreeWidget::onExpandAllChildrenClicked(bool)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onBlockStatusChangeClicked(bool _checked)
void BlocksTreeWidget::onBlockStatusChangeClicked(bool _checked)
{
if (!_checked)
return;
auto item = static_cast<EasyTreeWidgetItem*>(currentItem());
auto item = static_cast<TreeWidgetItem*>(currentItem());
if (item == nullptr)
return;
@ -867,14 +868,14 @@ void EasyTreeWidget::onBlockStatusChangeClicked(bool _checked)
if (action != nullptr)
{
auto& desc = easyDescriptor(item->block().node->id());
desc.setStatus(static_cast<::profiler::EasyBlockStatus>(action->data().toUInt()));
desc.setStatus(static_cast<profiler::EasyBlockStatus>(action->data().toUInt()));
emit EASY_GLOBALS.events.blockStatusChanged(desc.id(), desc.status());
}
}
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item)
void BlocksTreeWidget::onItemExpand(QTreeWidgetItem* _item)
{
if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr)
{
@ -882,7 +883,7 @@ void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item)
return;
}
static_cast<EasyTreeWidgetItem*>(_item)->guiBlock().expanded = true;
static_cast<TreeWidgetItem*>(_item)->guiBlock().expanded = true;
if (!m_bSilentExpandCollapse)
{
@ -891,12 +892,12 @@ void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item)
}
}
void EasyTreeWidget::onItemCollapse(QTreeWidgetItem* _item)
void BlocksTreeWidget::onItemCollapse(QTreeWidgetItem* _item)
{
if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr)
return;
static_cast<EasyTreeWidgetItem*>(_item)->guiBlock().expanded = false;
static_cast<TreeWidgetItem*>(_item)->guiBlock().expanded = false;
if (!m_bSilentExpandCollapse)
emit EASY_GLOBALS.events.itemsExpandStateChanged();
@ -904,36 +905,36 @@ void EasyTreeWidget::onItemCollapse(QTreeWidgetItem* _item)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _previous)
void BlocksTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _previous)
{
if (_previous != nullptr)
static_cast<EasyTreeWidgetItem*>(_previous)->setBold(false);
static_cast<TreeWidgetItem*>(_previous)->setBold(false);
if (_item == nullptr)
{
::profiler_gui::set_max(EASY_GLOBALS.selected_block);
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
profiler_gui::set_max(EASY_GLOBALS.selected_block);
profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
}
else
{
auto item = static_cast<EasyTreeWidgetItem*>(_item);
auto item = static_cast<TreeWidgetItem*>(_item);
item->setBold(true);
EASY_GLOBALS.selected_block = item->block_index();
if (EASY_GLOBALS.selected_block < EASY_GLOBALS.gui_blocks.size())
EASY_GLOBALS.selected_block_id = easyBlock(EASY_GLOBALS.selected_block).tree.node->id();
else
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
}
disconnect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
emit EASY_GLOBALS.events.selectedBlockChanged(EASY_GLOBALS.selected_block);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
}
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onSelectedThreadChange(::profiler::thread_id_t _id)
void BlocksTreeWidget::onSelectedThreadChange(profiler::thread_id_t _id)
{
for (auto& it : m_roots)
{
@ -950,11 +951,11 @@ void EasyTreeWidget::onSelectedThreadChange(::profiler::thread_id_t _id)
f->setFocus();
}
void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index)
void BlocksTreeWidget::onSelectedBlockChange(uint32_t _block_index)
{
disconnect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
EasyTreeWidgetItem* item = nullptr;
TreeWidgetItem* item = nullptr;
if (_block_index < EASY_GLOBALS.gui_blocks.size())
{
@ -969,7 +970,7 @@ void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index)
#endif
}
auto previous = static_cast<EasyTreeWidgetItem*>(currentItem());
auto previous = static_cast<TreeWidgetItem*>(currentItem());
if (previous != nullptr)
previous->setBold(false);
@ -1012,7 +1013,7 @@ void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::resizeColumnsToContents()
void BlocksTreeWidget::resizeColumnsToContents()
{
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
{
@ -1022,7 +1023,7 @@ void EasyTreeWidget::resizeColumnsToContents()
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onHideShowColumn(bool)
void BlocksTreeWidget::onHideShowColumn(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action == nullptr)
@ -1034,19 +1035,19 @@ void EasyTreeWidget::onHideShowColumn(bool)
m_columnsHiddenStatus[col] = hideCol ? 1 : 0;
}
void EasyTreeWidget::onModeChange(bool)
void BlocksTreeWidget::onModeChange(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action == nullptr)
return;
const auto prev = m_mode;
m_mode = static_cast<EasyTreeMode>(action->data().toUInt());
m_mode = static_cast<TreeMode>(action->data().toUInt());
if (m_mode == prev)
return;
if (m_mode == EasyTreeMode_Full)
if (m_mode == TreeMode::Full)
{
for (int i = 1; i < COL_COLUMNS_NUMBER; ++i)
setColumnHidden(i, m_columnsHiddenStatus[i] != 0);
@ -1062,14 +1063,14 @@ void EasyTreeWidget::onModeChange(bool)
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::loadSettings()
void BlocksTreeWidget::loadSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget");
auto val = settings.value("regime");
if (!val.isNull())
m_mode = static_cast<EasyTreeMode>(val.toUInt());
m_mode = static_cast<TreeMode>(val.toUInt());
val = settings.value("columns");
if (!val.isNull())
@ -1085,9 +1086,9 @@ void EasyTreeWidget::loadSettings()
settings.endGroup();
}
void EasyTreeWidget::saveSettings()
void BlocksTreeWidget::saveSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget");
settings.setValue("regime", static_cast<uint8_t>(m_mode));
settings.setValue("columns", QByteArray(m_columnsHiddenStatus, COL_COLUMNS_NUMBER));
@ -1098,8 +1099,8 @@ void EasyTreeWidget::saveSettings()
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
, m_tree(new EasyTreeWidget(this))
HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
, m_tree(new BlocksTreeWidget(this))
, m_searchBox(new QLineEdit(this))
, m_foundNumber(new QLabel("Found 0 matches", this))
, m_searchButton(nullptr)
@ -1138,7 +1139,7 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
menu->addAction(a);
auto tb = new QToolBar(this);
tb->setIconSize(::profiler_gui::ICONS_SIZE);
tb->setIconSize(profiler_gui::ICONS_SIZE);
tb->setContentsMargins(0, 0, 0, 0);
tb->addAction(m_searchButton);
tb->addWidget(m_searchBox);
@ -1157,15 +1158,15 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
}
EasyHierarchyWidget::~EasyHierarchyWidget()
HierarchyWidget::~HierarchyWidget()
{
saveSettings();
}
void EasyHierarchyWidget::loadSettings()
void HierarchyWidget::loadSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyHierarchyWidget");
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("HierarchyWidget");
auto val = settings.value("case_sensitive");
if (!val.isNull())
@ -1174,15 +1175,15 @@ void EasyHierarchyWidget::loadSettings()
settings.endGroup();
}
void EasyHierarchyWidget::saveSettings()
void HierarchyWidget::saveSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyHierarchyWidget");
QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("HierarchyWidget");
settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
settings.endGroup();
}
void EasyHierarchyWidget::keyPressEvent(QKeyEvent* _event)
void HierarchyWidget::keyPressEvent(QKeyEvent* _event)
{
if (_event->key() == Qt::Key_F3)
{
@ -1197,25 +1198,25 @@ void EasyHierarchyWidget::keyPressEvent(QKeyEvent* _event)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void EasyHierarchyWidget::contextMenuEvent(QContextMenuEvent* _event)
void HierarchyWidget::contextMenuEvent(QContextMenuEvent* _event)
{
m_tree->contextMenuEvent(_event);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EasyTreeWidget* EasyHierarchyWidget::tree()
BlocksTreeWidget* HierarchyWidget::tree()
{
return m_tree;
}
void EasyHierarchyWidget::clear(bool _global)
void HierarchyWidget::clear(bool _global)
{
m_tree->clearSilent(_global);
m_foundNumber->setText(QString("Found 0 matches"));
}
void EasyHierarchyWidget::onSeachBoxReturnPressed()
void HierarchyWidget::onSeachBoxReturnPressed()
{
if (m_searchButton->data().toBool() == true)
findNext(true);
@ -1223,7 +1224,7 @@ void EasyHierarchyWidget::onSeachBoxReturnPressed()
findPrev(true);
}
void EasyHierarchyWidget::findNext(bool)
void HierarchyWidget::findNext(bool)
{
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -1233,7 +1234,7 @@ void EasyHierarchyWidget::findNext(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
}
void EasyHierarchyWidget::findPrev(bool)
void HierarchyWidget::findPrev(bool)
{
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -1243,7 +1244,7 @@ void EasyHierarchyWidget::findPrev(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
}
void EasyHierarchyWidget::findNextFromMenu(bool _checked)
void HierarchyWidget::findNextFromMenu(bool _checked)
{
if (!_checked)
return;
@ -1260,7 +1261,7 @@ void EasyHierarchyWidget::findNextFromMenu(bool _checked)
findNext(true);
}
void EasyHierarchyWidget::findPrevFromMenu(bool _checked)
void HierarchyWidget::findPrevFromMenu(bool _checked)
{
if (!_checked)
return;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyTreeWidget and it's auxiliary classes
* description : The file contains declaration of BlocksTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks tree.
* ----------------- :
* change log : * 2016/06/26 Victor Zarubkin: moved sources from tree_view.h
@ -73,16 +73,16 @@
//////////////////////////////////////////////////////////////////////////
class EasyTreeWidget : public QTreeWidget
class BlocksTreeWidget : public QTreeWidget
{
Q_OBJECT
using Parent = QTreeWidget;
using This = EasyTreeWidget;
using This = BlocksTreeWidget;
protected:
EasyTreeWidgetLoader m_hierarchyBuilder;
TreeWidgetLoader m_hierarchyBuilder;
Items m_items;
RootsMap m_roots;
::profiler_gui::TreeBlocks m_inputBlocks;
@ -92,15 +92,15 @@ protected:
::profiler::timestamp_t m_beginTime;
class QProgressDialog* m_progress;
class QLabel* m_hintLabel;
EasyTreeMode m_mode;
TreeMode m_mode;
bool m_bLocked;
bool m_bSilentExpandCollapse;
char m_columnsHiddenStatus[COL_COLUMNS_NUMBER];
public:
explicit EasyTreeWidget(QWidget* _parent = nullptr);
~EasyTreeWidget() override;
explicit BlocksTreeWidget(QWidget* _parent = nullptr);
~BlocksTreeWidget() override;
void contextMenuEvent(QContextMenuEvent* _event) override;
void dragEnterEvent(QDragEnterEvent*) override {}
@ -160,20 +160,20 @@ private:
void destroyProgressDialog();
void createProgressDialog();
}; // END of class EasyTreeWidget.
}; // END of class BlocksTreeWidget.
//////////////////////////////////////////////////////////////////////////
class EasyHierarchyWidget : public QWidget
class HierarchyWidget : public QWidget
{
Q_OBJECT
using Parent = QWidget;
using This = EasyHierarchyWidget;
using This = HierarchyWidget;
private:
EasyTreeWidget* m_tree;
BlocksTreeWidget* m_tree;
class QLineEdit* m_searchBox;
class QLabel* m_foundNumber;
class QAction* m_searchButton;
@ -183,8 +183,8 @@ public:
// Public virtual methods
explicit EasyHierarchyWidget(QWidget* _parent = nullptr);
~EasyHierarchyWidget() override;
explicit HierarchyWidget(QWidget* _parent = nullptr);
~HierarchyWidget() override;
void keyPressEvent(QKeyEvent* _event) override;
void contextMenuEvent(QContextMenuEvent* _event) override;
@ -194,7 +194,7 @@ public:
// Public non-virtual methods
EasyTreeWidget* tree();
BlocksTreeWidget* tree();
void clear(bool _global = false);
private slots:
@ -214,7 +214,7 @@ private:
void loadSettings();
void saveSettings();
}; // END of class EasyHierarchyWidget.
}; // END of class HierarchyWidget.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyDescTreeWidget and it's auxiliary classes
* description : The file contains implementation of DescriptorsTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks descriptors tree.
* ----------------- :
* change log : * 2016/09/17 Victor Zarubkin: initial commit.
@ -187,20 +187,20 @@ const char* statusText(::profiler::EasyBlockStatus _status)
//////////////////////////////////////////////////////////////////////////
EasyDescWidgetItem::EasyDescWidgetItem(::profiler::block_id_t _desc, Parent* _parent)
DescriptorsTreeItem::DescriptorsTreeItem(::profiler::block_id_t _desc, Parent* _parent)
: Parent(_parent, QTreeWidgetItem::UserType)
, m_desc(_desc)
, m_type(EasyDescWidgetItem::Type::File)
, m_type(DescriptorsTreeItem::Type::File)
{
}
EasyDescWidgetItem::~EasyDescWidgetItem()
DescriptorsTreeItem::~DescriptorsTreeItem()
{
}
bool EasyDescWidgetItem::operator < (const Parent& _other) const
bool DescriptorsTreeItem::operator < (const Parent& _other) const
{
const auto col = treeWidget()->sortColumn();
@ -216,7 +216,7 @@ bool EasyDescWidgetItem::operator < (const Parent& _other) const
return Parent::operator < (_other);
}
QVariant EasyDescWidgetItem::data(int _column, int _role) const
QVariant DescriptorsTreeItem::data(int _column, int _role) const
{
if (_column == DESC_COL_TYPE)
{
@ -247,7 +247,7 @@ QVariant EasyDescWidgetItem::data(int _column, int _role) const
//////////////////////////////////////////////////////////////////////////
EasyDescTreeWidget::EasyDescTreeWidget(QWidget* _parent)
DescriptorsTreeWidget::DescriptorsTreeWidget(QWidget* _parent)
: Parent(_parent)
, m_lastFound(nullptr)
, m_lastSearchColumn(-1)
@ -269,18 +269,18 @@ EasyDescTreeWidget::EasyDescTreeWidget(QWidget* _parent)
header_item->setText(DESC_COL_STATUS, "Status");
setHeaderItem(header_item);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::blockStatusChanged, this, &This::onBlockStatusChange);
connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::blockStatusChanged, this, &This::onBlockStatusChange);
connect(this, &Parent::itemExpanded, this, &This::onItemExpand);
connect(this, &Parent::itemDoubleClicked, this, &This::onDoubleClick);
connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
loadSettings();
setItemDelegateForColumn(0, new EasyTreeViewFirstColumnItemDelegate(this));
setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this));
}
EasyDescTreeWidget::~EasyDescTreeWidget()
DescriptorsTreeWidget::~DescriptorsTreeWidget()
{
if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && !::profiler_gui::is_max(EASY_GLOBALS.selected_block_id))
{
@ -293,19 +293,19 @@ EasyDescTreeWidget::~EasyDescTreeWidget()
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::setSearchColumn(int column)
void DescriptorsTreeWidget::setSearchColumn(int column)
{
m_searchColumn = column;
}
int EasyDescTreeWidget::searchColumn() const
int DescriptorsTreeWidget::searchColumn() const
{
return m_searchColumn;
}
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
void DescriptorsTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
{
_event->accept();
@ -322,7 +322,7 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto item = currentItem();
if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE)
{
const auto& desc = easyDescriptor(static_cast<EasyDescWidgetItem*>(item)->desc());
const auto& desc = easyDescriptor(static_cast<DescriptorsTreeItem*>(item)->desc());
menu.addSeparator();
auto submenu = menu.addMenu("Change status");
@ -354,7 +354,7 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::clearSilent(bool _global)
void DescriptorsTreeWidget::clearSilent(bool _global)
{
const QSignalBlocker b(this);
@ -396,12 +396,12 @@ void EasyDescTreeWidget::clearSilent(bool _global)
struct FileItems
{
using Items = ::std::unordered_map<int, EasyDescWidgetItem*, ::estd::hash<int> >;
using Items = ::std::unordered_map<int, DescriptorsTreeItem*, ::estd::hash<int> >;
Items children;
QTreeWidgetItem* item = nullptr;
};
void EasyDescTreeWidget::build()
void DescriptorsTreeWidget::build()
{
auto f = font();
f.setBold(true);
@ -421,16 +421,16 @@ void EasyDescTreeWidget::build()
auto& p = fileItems[desc->file()];
if (p.item == nullptr)
{
auto item = new EasyDescWidgetItem(0);
auto item = new DescriptorsTreeItem(0);
item->setText(DESC_COL_FILE_LINE, QString(desc->file()).remove(QRegExp("^(\\.{2}\\\\+|\\/+)+")));
item->setType(EasyDescWidgetItem::Type::File);
item->setType(DescriptorsTreeItem::Type::File);
p.item = item;
}
auto it = p.children.find(desc->line());
if (it == p.children.end())
{
auto item = new EasyDescWidgetItem(desc->id(), p.item);
auto item = new DescriptorsTreeItem(desc->id(), p.item);
item->setText(DESC_COL_FILE_LINE, QString::number(desc->line()));
item->setData(DESC_COL_FILE_LINE, Qt::UserRole, desc->line());
item->setText(DESC_COL_NAME, desc->name());
@ -438,15 +438,15 @@ void EasyDescTreeWidget::build()
switch (desc->type())
{
case ::profiler::BlockType::Block:
item->setType(EasyDescWidgetItem::Type::Block);
item->setType(DescriptorsTreeItem::Type::Block);
break;
case ::profiler::BlockType::Event:
item->setType(EasyDescWidgetItem::Type::Event);
item->setType(DescriptorsTreeItem::Type::Event);
break;
case ::profiler::BlockType::Value:
item->setType(EasyDescWidgetItem::Type::Value);
item->setType(DescriptorsTreeItem::Type::Value);
break;
}
@ -482,21 +482,21 @@ void EasyDescTreeWidget::build()
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onItemExpand(QTreeWidgetItem*)
void DescriptorsTreeWidget::onItemExpand(QTreeWidgetItem*)
{
resizeColumnsToContents();
}
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column)
void DescriptorsTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column)
{
if (!EASY_GLOBALS.connected)
return;
if (_column >= DESC_COL_TYPE && _item->parent() != nullptr)
{
auto item = static_cast<EasyDescWidgetItem*>(_item);
auto item = static_cast<DescriptorsTreeItem*>(_item);
auto& desc = easyDescriptor(item->desc());
desc.setStatus(nextStatus(desc.status()));
@ -511,7 +511,7 @@ void EasyDescTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column)
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev)
void DescriptorsTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev)
{
if (_prev != nullptr)
{
@ -529,7 +529,7 @@ void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidget
if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && _item->parent() != nullptr)
{
const auto id = static_cast<EasyDescWidgetItem*>(_item)->desc();
const auto id = static_cast<DescriptorsTreeItem*>(_item)->desc();
if (EASY_GLOBALS.selected_block_id != id)
{
EASY_GLOBALS.selected_block_id = id;
@ -546,7 +546,7 @@ void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidget
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked)
void DescriptorsTreeWidget::onBlockStatusChangeClicked(bool _checked)
{
if (!_checked || !EASY_GLOBALS.connected)
return;
@ -558,7 +558,7 @@ void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked)
auto action = qobject_cast<QAction*>(sender());
if (action != nullptr)
{
auto& desc = easyDescriptor(static_cast<EasyDescWidgetItem*>(item)->desc());
auto& desc = easyDescriptor(static_cast<DescriptorsTreeItem*>(item)->desc());
desc.setStatus(static_cast<::profiler::EasyBlockStatus>(action->data().toUInt()));
item->setText(DESC_COL_STATUS, statusText(desc.status()));
item->setForeground(DESC_COL_STATUS, QColor::fromRgba(statusColor(desc.status())));
@ -569,7 +569,7 @@ void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked)
}
}
void EasyDescTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status)
void DescriptorsTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status)
{
if (m_bLocked)
return;
@ -585,7 +585,7 @@ void EasyDescTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profi
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::resizeColumnsToContents()
void DescriptorsTreeWidget::resizeColumnsToContents()
{
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
resizeColumnToContents(i);
@ -593,7 +593,7 @@ void EasyDescTreeWidget::resizeColumnsToContents()
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index)
void DescriptorsTreeWidget::onSelectedBlockChange(uint32_t _block_index)
{
if (::profiler_gui::is_max(_block_index))
{
@ -611,7 +611,7 @@ void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index)
//////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::resetHighlight()
void DescriptorsTreeWidget::resetHighlight()
{
for (auto item : m_highlightItems) {
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
@ -620,7 +620,7 @@ void EasyDescTreeWidget::resetHighlight()
m_highlightItems.clear();
}
void EasyDescTreeWidget::loadSettings()
void DescriptorsTreeWidget::loadSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("desc_tree_widget");
@ -632,7 +632,7 @@ void EasyDescTreeWidget::loadSettings()
settings.endGroup();
}
void EasyDescTreeWidget::saveSettings()
void DescriptorsTreeWidget::saveSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("desc_tree_widget");
@ -644,7 +644,7 @@ void EasyDescTreeWidget::saveSettings()
//////////////////////////////////////////////////////////////////////////
int EasyDescTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
int DescriptorsTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
{
if (_str.isEmpty())
{
@ -705,7 +705,7 @@ int EasyDescTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
return itemsList.size();
}
int EasyDescTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
int DescriptorsTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
{
if (_str.isEmpty())
{
@ -765,9 +765,9 @@ int EasyDescTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
//////////////////////////////////////////////////////////////////////////
EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_parent)
, m_splitter(new QSplitter(Qt::Vertical, this))
, m_tree(new EasyDescTreeWidget(this))
, m_tree(new DescriptorsTreeWidget(this))
, m_values(new ArbitraryValuesWidget(this))
, m_searchBox(new QLineEdit(this))
, m_foundNumber(new QLabel("Found 0 matches", this))
@ -789,7 +789,7 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
auto refreshButton = tb->addAction(QIcon(imagePath("reload")), tr("Refresh blocks list"));
refreshButton->setEnabled(EASY_GLOBALS.connected);
refreshButton->setToolTip(tr("Refresh blocks list.\nConnection needed."));
connect(refreshButton, &QAction::triggered, &EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::blocksRefreshRequired);
connect(refreshButton, &QAction::triggered, &EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::blocksRefreshRequired);
@ -856,21 +856,21 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
lay->addWidget(m_splitter);
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled);
connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled);
loadSettings();
caseSensitiveSwitch->setChecked(m_bCaseSensitiveSearch);
}
EasyDescWidget::~EasyDescWidget()
BlockDescriptorsWidget::~BlockDescriptorsWidget()
{
saveSettings();
}
void EasyDescWidget::loadSettings()
void BlockDescriptorsWidget::loadSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyDescWidget");
settings.beginGroup("BlockDescriptorsWidget");
auto val = settings.value("case_sensitive");
if (!val.isNull())
@ -887,17 +887,17 @@ void EasyDescWidget::loadSettings()
settings.endGroup();
}
void EasyDescWidget::saveSettings()
void BlockDescriptorsWidget::saveSettings()
{
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyDescWidget");
settings.beginGroup("BlockDescriptorsWidget");
settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
settings.setValue("vsplitter/geometry", m_splitter->saveGeometry());
settings.setValue("vsplitter/state", m_splitter->saveState());
settings.endGroup();
}
void EasyDescWidget::keyPressEvent(QKeyEvent* _event)
void BlockDescriptorsWidget::keyPressEvent(QKeyEvent* _event)
{
if (_event->key() == Qt::Key_F3)
{
@ -910,12 +910,12 @@ void EasyDescWidget::keyPressEvent(QKeyEvent* _event)
_event->accept();
}
void EasyDescWidget::contextMenuEvent(QContextMenuEvent* _event)
void BlockDescriptorsWidget::contextMenuEvent(QContextMenuEvent* _event)
{
m_tree->contextMenuEvent(_event);
}
void EasyDescWidget::build()
void BlockDescriptorsWidget::build()
{
m_tree->clearSilent(false);
m_foundNumber->setText(QString("Found 0 matches"));
@ -923,14 +923,14 @@ void EasyDescWidget::build()
m_values->rebuild();
}
void EasyDescWidget::clear()
void BlockDescriptorsWidget::clear()
{
m_tree->clearSilent(true);
m_foundNumber->setText(QString("Found 0 matches"));
m_values->clear();
}
void EasyDescWidget::onSeachBoxReturnPressed()
void BlockDescriptorsWidget::onSeachBoxReturnPressed()
{
if (m_searchButton->data().toBool() == true)
findNext(true);
@ -938,14 +938,14 @@ void EasyDescWidget::onSeachBoxReturnPressed()
findPrev(true);
}
void EasyDescWidget::onSearchColumnChange(bool)
void BlockDescriptorsWidget::onSearchColumnChange(bool)
{
auto action = qobject_cast<QAction*>(sender());
if (action != nullptr)
m_tree->setSearchColumn(action->data().toInt());
}
void EasyDescWidget::findNext(bool)
void BlockDescriptorsWidget::findNext(bool)
{
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -955,7 +955,7 @@ void EasyDescWidget::findNext(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
}
void EasyDescWidget::findPrev(bool)
void BlockDescriptorsWidget::findPrev(bool)
{
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -965,7 +965,7 @@ void EasyDescWidget::findPrev(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches));
}
void EasyDescWidget::findNextFromMenu(bool _checked)
void BlockDescriptorsWidget::findNextFromMenu(bool _checked)
{
if (!_checked)
return;
@ -982,7 +982,7 @@ void EasyDescWidget::findNextFromMenu(bool _checked)
findNext(true);
}
void EasyDescWidget::findPrevFromMenu(bool _checked)
void BlockDescriptorsWidget::findPrevFromMenu(bool _checked)
{
if (!_checked)
return;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyDescTreeWidget and it's auxiliary classes
* description : The file contains declaration of DescriptorsTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks descriptors tree.
* ----------------- :
* change log : * 2016/09/17 Victor Zarubkin: initial commit.
@ -67,10 +67,10 @@
//////////////////////////////////////////////////////////////////////////
class EasyDescWidgetItem : public QTreeWidgetItem
class DescriptorsTreeItem : public QTreeWidgetItem
{
using Parent = QTreeWidgetItem;
using This = EasyDescWidgetItem;
using This = DescriptorsTreeItem;
public:
@ -89,8 +89,8 @@ private:
public:
explicit EasyDescWidgetItem(::profiler::block_id_t _desc, Parent* _parent = nullptr);
~EasyDescWidgetItem() override;
explicit DescriptorsTreeItem(::profiler::block_id_t _desc, Parent* _parent = nullptr);
~DescriptorsTreeItem() override;
bool operator < (const Parent& _other) const override;
QVariant data(int _column, int _role) const override;
@ -109,18 +109,18 @@ public:
m_type = _type;
}
}; // END of class EasyDescWidgetItem.
}; // END of class DescriptorsTreeItem.
//////////////////////////////////////////////////////////////////////////
class EasyDescTreeWidget : public QTreeWidget
class DescriptorsTreeWidget : public QTreeWidget
{
Q_OBJECT
using Parent = QTreeWidget;
using This = EasyDescTreeWidget;
using This = DescriptorsTreeWidget;
using Items = ::std::vector<EasyDescWidgetItem*>;
using Items = ::std::vector<DescriptorsTreeItem*>;
using TreeItems = ::std::vector<QTreeWidgetItem*>;
using ExpandedFiles = ::std::unordered_set<::std::string>;
@ -139,8 +139,8 @@ public:
// Public virtual methods
explicit EasyDescTreeWidget(QWidget* _parent = nullptr);
~EasyDescTreeWidget() override;
explicit DescriptorsTreeWidget(QWidget* _parent = nullptr);
~DescriptorsTreeWidget() override;
void contextMenuEvent(QContextMenuEvent* _event) override;
public:
@ -175,21 +175,21 @@ private:
void loadSettings();
void saveSettings();
}; // END of class EasyDescTreeWidget.
}; // END of class DescriptorsTreeWidget.
//////////////////////////////////////////////////////////////////////////
class EasyDescWidget : public QWidget
class BlockDescriptorsWidget : public QWidget
{
Q_OBJECT
using Parent = QWidget;
using This = EasyDescWidget;
using This = BlockDescriptorsWidget;
private:
class QSplitter* m_splitter;
EasyDescTreeWidget* m_tree;
DescriptorsTreeWidget* m_tree;
class ArbitraryValuesWidget* m_values;
class QLineEdit* m_searchBox;
class QLabel* m_foundNumber;
@ -200,8 +200,8 @@ public:
// Public virtual methods
explicit EasyDescWidget(QWidget* _parent = nullptr);
~EasyDescWidget() override;
explicit BlockDescriptorsWidget(QWidget* _parent = nullptr);
~BlockDescriptorsWidget() override;
void keyPressEvent(QKeyEvent* _event) override;
void contextMenuEvent(QContextMenuEvent* _event) override;
@ -228,7 +228,7 @@ private:
void loadSettings();
void saveSettings();
}; // END of class EasyDescWidget.
}; // END of class BlockDescriptorsWidget.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyChronometerItem.
* description : The file contains implementation of GraphicsRulerItem.
* ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.cpp
* :
@ -72,7 +72,7 @@
//////////////////////////////////////////////////////////////////////////
EasyChronometerItem::EasyChronometerItem(bool _main)
GraphicsRulerItem::GraphicsRulerItem(bool _main)
: Parent()
, m_color(::profiler_gui::CHRONOMETER_COLOR)
, m_left(0)
@ -86,16 +86,16 @@ EasyChronometerItem::EasyChronometerItem(bool _main)
m_indicator.reserve(3);
}
EasyChronometerItem::~EasyChronometerItem()
GraphicsRulerItem::~GraphicsRulerItem()
{
}
QRectF EasyChronometerItem::boundingRect() const
QRectF GraphicsRulerItem::boundingRect() const
{
return m_boundingRect;
}
void EasyChronometerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
void GraphicsRulerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{
auto const sceneView = view();
const auto currentScale = sceneView->scale();
@ -290,7 +290,7 @@ void EasyChronometerItem::paint(QPainter* _painter, const QStyleOptionGraphicsIt
// END Paint!~~~~~~~~~~~~~~~~~~~~~~
}
void EasyChronometerItem::hide()
void GraphicsRulerItem::hide()
{
m_bHoverIndicator = false;
m_bHoverLeftBorder = false;
@ -299,7 +299,7 @@ void EasyChronometerItem::hide()
Parent::hide();
}
bool EasyChronometerItem::indicatorContains(const QPointF& _pos) const
bool GraphicsRulerItem::indicatorContains(const QPointF& _pos) const
{
if (m_indicator.empty())
return false;
@ -308,56 +308,56 @@ bool EasyChronometerItem::indicatorContains(const QPointF& _pos) const
return m_indicator.containsPoint(QPointF(itemX, _pos.y()), Qt::OddEvenFill);
}
void EasyChronometerItem::setHoverLeft(bool _hover)
void GraphicsRulerItem::setHoverLeft(bool _hover)
{
m_bHoverLeftBorder = _hover;
}
void EasyChronometerItem::setHoverRight(bool _hover)
void GraphicsRulerItem::setHoverRight(bool _hover)
{
m_bHoverRightBorder = _hover;
}
bool EasyChronometerItem::hoverLeft(qreal _x) const
bool GraphicsRulerItem::hoverLeft(qreal _x) const
{
const auto dx = fabs(_x - m_left) * view()->scale();
return dx < 4;
}
bool EasyChronometerItem::hoverRight(qreal _x) const
bool GraphicsRulerItem::hoverRight(qreal _x) const
{
const auto dx = fabs(_x - m_right) * view()->scale();
return dx < 4;
}
QPointF EasyChronometerItem::toItem(const QPointF& _pos) const
QPointF GraphicsRulerItem::toItem(const QPointF& _pos) const
{
const auto sceneView = view();
return QPointF((_pos.x() - sceneView->offset()) * sceneView->scale() - x(), _pos.y());
}
qreal EasyChronometerItem::toItem(qreal _x) const
qreal GraphicsRulerItem::toItem(qreal _x) const
{
const auto sceneView = view();
return (_x - sceneView->offset()) * sceneView->scale() - x();
}
void EasyChronometerItem::setColor(const QColor& _color)
void GraphicsRulerItem::setColor(const QColor& _color)
{
m_color = _color;
}
void EasyChronometerItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
void GraphicsRulerItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{
m_boundingRect.setRect(x, y, w, h);
}
void EasyChronometerItem::setBoundingRect(const QRectF& _rect)
void GraphicsRulerItem::setBoundingRect(const QRectF& _rect)
{
m_boundingRect = _rect;
}
void EasyChronometerItem::setLeftRight(qreal _left, qreal _right)
void GraphicsRulerItem::setLeftRight(qreal _left, qreal _right)
{
if (_left < _right)
{
@ -371,24 +371,24 @@ void EasyChronometerItem::setLeftRight(qreal _left, qreal _right)
}
}
void EasyChronometerItem::setReverse(bool _reverse)
void GraphicsRulerItem::setReverse(bool _reverse)
{
m_bReverse = _reverse;
}
void EasyChronometerItem::setHoverIndicator(bool _hover)
void GraphicsRulerItem::setHoverIndicator(bool _hover)
{
m_bHoverIndicator = _hover;
}
const EasyGraphicsView* EasyChronometerItem::view() const
const BlocksGraphicsView* GraphicsRulerItem::view() const
{
return static_cast<const EasyGraphicsView*>(scene()->parent());
return static_cast<const BlocksGraphicsView*>(scene()->parent());
}
EasyGraphicsView* EasyChronometerItem::view()
BlocksGraphicsView* GraphicsRulerItem::view()
{
return static_cast<EasyGraphicsView*>(scene()->parent());
return static_cast<BlocksGraphicsView*>(scene()->parent());
}
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyChronometerItem - an item
* description : The file contains declaration of GraphicsRulerItem - an item
* : used to display selected interval on graphics scene.
* ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h
@ -67,12 +67,12 @@
class QWidget;
class QPainter;
class QStyleOptionGraphicsItem;
class EasyGraphicsView;
class BlocksGraphicsView;
class EasyChronometerItem : public QGraphicsItem
class GraphicsRulerItem : public QGraphicsItem
{
typedef QGraphicsItem Parent;
typedef EasyChronometerItem This;
typedef GraphicsRulerItem This;
QPolygonF m_indicator; ///< Indicator displayed when this chrono item is out of screen (displaying only for main item)
QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem)
@ -86,8 +86,8 @@ class EasyChronometerItem : public QGraphicsItem
public:
explicit EasyChronometerItem(bool _main = true);
virtual ~EasyChronometerItem();
explicit GraphicsRulerItem(bool _main = true);
virtual ~GraphicsRulerItem();
// Public virtual methods
@ -159,11 +159,11 @@ public:
private:
///< Returns pointer to the EasyGraphicsView widget.
const EasyGraphicsView* view() const;
EasyGraphicsView* view();
///< Returns pointer to the BlocksGraphicsView widget.
const BlocksGraphicsView* view() const;
BlocksGraphicsView* view();
}; // END of class EasyChronometerItem.
}; // END of class GraphicsRulerItem.
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : This file contains implementation of EasyFrameRateViewer widget.
* description : This file contains implementation of FpsViewerWidget widget.
* ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* :
@ -64,36 +64,36 @@ const int INTERVAL_WIDTH = 20;
//////////////////////////////////////////////////////////////////////////
EasyFPSGraphicsItem::EasyFPSGraphicsItem() : Parent(nullptr)
FpsGraphicsItem::FpsGraphicsItem() : Parent(nullptr)
{
}
EasyFPSGraphicsItem::~EasyFPSGraphicsItem()
FpsGraphicsItem::~FpsGraphicsItem()
{
}
//////////////////////////////////////////////////////////////////////////
QRectF EasyFPSGraphicsItem::boundingRect() const
QRectF FpsGraphicsItem::boundingRect() const
{
return m_boundingRect;
}
void EasyFPSGraphicsItem::setBoundingRect(const QRectF& _boundingRect)
void FpsGraphicsItem::setBoundingRect(const QRectF& _boundingRect)
{
m_boundingRect = _boundingRect;
}
void EasyFPSGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
void FpsGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{
m_boundingRect.setRect(x, y, w, h);
}
//////////////////////////////////////////////////////////////////////////
void EasyFPSGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
void FpsGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{
if (m_frames.empty())
return;
@ -232,12 +232,12 @@ void EasyFPSGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsIt
//////////////////////////////////////////////////////////////////////////
void EasyFPSGraphicsItem::clear()
void FpsGraphicsItem::clear()
{
m_frames.clear();
}
void EasyFPSGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
void FpsGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
{
m_frames.emplace_back(_maxFrameTime, _avgFrameTime);
if (static_cast<int>(m_frames.size()) > EASY_GLOBALS.max_fps_history)
@ -246,7 +246,7 @@ void EasyFPSGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTim
//////////////////////////////////////////////////////////////////////////
EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr)
FpsViewerWidget::FpsViewerWidget(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr)
{
setCacheMode(QGraphicsView::CacheNone);
//setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
@ -260,7 +260,7 @@ EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_
setScene(new QGraphicsScene(this));
scene()->setSceneRect(0, 0, 50, 50);
m_fpsItem = new EasyFPSGraphicsItem();
m_fpsItem = new FpsGraphicsItem();
m_fpsItem->setPos(0, 0);
m_fpsItem->setBoundingRect(0, 0, 50, 50);
scene()->addItem(m_fpsItem);
@ -277,24 +277,24 @@ EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_
});
}
EasyFrameRateViewer::~EasyFrameRateViewer()
FpsViewerWidget::~FpsViewerWidget()
{
}
void EasyFrameRateViewer::clear()
void FpsViewerWidget::clear()
{
m_fpsItem->clear();
scene()->update();
}
void EasyFrameRateViewer::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
void FpsViewerWidget::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
{
m_fpsItem->addPoint(_maxFrameTime, _avgFrameTime);
scene()->update();
}
void EasyFrameRateViewer::resizeEvent(QResizeEvent* _event)
void FpsViewerWidget::resizeEvent(QResizeEvent* _event)
{
Parent::resizeEvent(_event);
@ -305,21 +305,21 @@ void EasyFrameRateViewer::resizeEvent(QResizeEvent* _event)
scene()->update();
}
void EasyFrameRateViewer::hideEvent(QHideEvent* _event)
void FpsViewerWidget::hideEvent(QHideEvent* _event)
{
Parent::hideEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible();
clear();
}
void EasyFrameRateViewer::showEvent(QShowEvent* _event)
void FpsViewerWidget::showEvent(QShowEvent* _event)
{
Parent::showEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible();
clear();
}
void EasyFrameRateViewer::contextMenuEvent(QContextMenuEvent* _event)
void FpsViewerWidget::contextMenuEvent(QContextMenuEvent* _event)
{
QMenu menu;
QAction* action = nullptr;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : This file contains declaration of EasyFrameRateViewer widget.
* description : This file contains declaration of FpsViewerWidget widget.
* ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* :
@ -65,10 +65,10 @@
//////////////////////////////////////////////////////////////////////////
class EasyFPSGraphicsItem : public QGraphicsItem
class FpsGraphicsItem : public QGraphicsItem
{
using Parent = QGraphicsItem;
using This = EasyFPSGraphicsItem;
using This = FpsGraphicsItem;
using FrameTimes = std::deque<std::pair<uint32_t, uint32_t> >;
std::vector<QPointF> m_points1, m_points2;
@ -77,8 +77,8 @@ class EasyFPSGraphicsItem : public QGraphicsItem
public:
explicit EasyFPSGraphicsItem();
~EasyFPSGraphicsItem() override;
explicit FpsGraphicsItem();
~FpsGraphicsItem() override;
QRectF boundingRect() const override;
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget) override;
@ -89,25 +89,25 @@ public:
void clear();
void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime);
}; // END of class EasyFPSGraphicsItem.
}; // END of class FpsGraphicsItem.
//////////////////////////////////////////////////////////////////////////
class EasyFrameRateViewer : public QGraphicsView
class FpsViewerWidget : public QGraphicsView
{
Q_OBJECT
private:
using Parent = QGraphicsView;
using This = EasyFrameRateViewer;
using This = FpsViewerWidget;
EasyFPSGraphicsItem* m_fpsItem;
FpsGraphicsItem* m_fpsItem;
public:
explicit EasyFrameRateViewer(QWidget* _parent = nullptr);
~EasyFrameRateViewer() override;
explicit FpsViewerWidget(QWidget* _parent = nullptr);
~FpsViewerWidget() override;
void resizeEvent(QResizeEvent* _event) override;
void hideEvent(QHideEvent* _event) override;
@ -120,7 +120,7 @@ public slots:
void clear();
void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime);
}; // END of class EasyFrameRateViewer.
}; // END of class FpsViewerWidget.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyGraphicsItem.
* description : The file contains implementation of BlocksGraphicsItem.
* ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: Moved sources from blocks_graphics_view.cpp
* :
@ -93,7 +93,7 @@ const QPen HIGHLIGHTER_PEN = ([]() -> QPen { QPen p(::profiler::colors::Black);
//////////////////////////////////////////////////////////////////////////
EasyGraphicsItem::EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root)
BlocksGraphicsItem::BlocksGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root)
: QGraphicsItem(nullptr)
, m_threadName(::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, _root, EASY_GLOBALS.hex_thread_id))
, m_pRoot(&_root)
@ -101,23 +101,23 @@ EasyGraphicsItem::EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRo
{
}
EasyGraphicsItem::~EasyGraphicsItem()
BlocksGraphicsItem::~BlocksGraphicsItem()
{
}
void EasyGraphicsItem::validateName()
void BlocksGraphicsItem::validateName()
{
m_threadName = ::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, *m_pRoot, EASY_GLOBALS.hex_thread_id);
}
const EasyGraphicsView* EasyGraphicsItem::view() const
const BlocksGraphicsView* BlocksGraphicsItem::view() const
{
return static_cast<const EasyGraphicsView*>(scene()->parent());
return static_cast<const BlocksGraphicsView*>(scene()->parent());
}
//////////////////////////////////////////////////////////////////////////
QRectF EasyGraphicsItem::boundingRect() const
QRectF BlocksGraphicsItem::boundingRect() const
{
return m_boundingRect;
}
@ -141,7 +141,7 @@ struct EasyPainterInformation EASY_FINAL
bool is_light;
bool selectedItemsWasPainted;
explicit EasyPainterInformation(const EasyGraphicsView* sceneView)
explicit EasyPainterInformation(const BlocksGraphicsView* sceneView)
: visibleSceneRect(sceneView->visibleSceneRect())
, visibleBottom(visibleSceneRect.bottom() - 1)
, currentScale(sceneView->scale())
@ -162,7 +162,7 @@ struct EasyPainterInformation EASY_FINAL
};
#ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT
void EasyGraphicsItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode)
void BlocksGraphicsItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode)
{
if (_level >= _levelsNumber || _itemBlock.tree.children.empty())
return;
@ -436,7 +436,7 @@ void EasyGraphicsItem::paintChildren(const float _minWidth, const int _narrowSiz
}
#endif
void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
void BlocksGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{
const bool gotItems = !m_levels.empty() && !m_levels.front().empty();
const bool gotSync = !m_pRoot->sync.empty();
@ -1100,26 +1100,26 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
//////////////////////////////////////////////////////////////////////////
const ::profiler::BlocksTreeRoot* EasyGraphicsItem::root() const
const ::profiler::BlocksTreeRoot* BlocksGraphicsItem::root() const
{
return m_pRoot;
}
const QString& EasyGraphicsItem::threadName() const
const QString& BlocksGraphicsItem::threadName() const
{
return m_threadName;
}
//////////////////////////////////////////////////////////////////////////
QRect EasyGraphicsItem::getRect() const
QRect BlocksGraphicsItem::getRect() const
{
return view()->mapFromScene(m_boundingRect).boundingRect();
}
//////////////////////////////////////////////////////////////////////////
void EasyGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const
void BlocksGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const
{
// Search for first visible top-level item
auto& level0 = m_levels.front();
@ -1164,7 +1164,7 @@ void EasyGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::Tree
//////////////////////////////////////////////////////////////////////////
const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersect(const QPointF& _pos, ::profiler::block_index_t& _blockIndex) const
const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersect(const QPointF& _pos, ::profiler::block_index_t& _blockIndex) const
{
if (m_levels.empty() || m_levels.front().empty())
{
@ -1337,7 +1337,7 @@ const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersect(const QPointF& _pos
return nullptr;
}
const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersectEvent(const QPointF& _pos) const
const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersectEvent(const QPointF& _pos) const
{
if (m_pRoot->sync.empty())
{
@ -1388,36 +1388,36 @@ const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersectEvent(const QPointF&
//////////////////////////////////////////////////////////////////////////
void EasyGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
void BlocksGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{
m_boundingRect.setRect(x, y, w, h);
}
void EasyGraphicsItem::setBoundingRect(const QRectF& _rect)
void BlocksGraphicsItem::setBoundingRect(const QRectF& _rect)
{
m_boundingRect = _rect;
}
//////////////////////////////////////////////////////////////////////////
::profiler::thread_id_t EasyGraphicsItem::threadId() const
::profiler::thread_id_t BlocksGraphicsItem::threadId() const
{
return m_pRoot->thread_id;
}
//////////////////////////////////////////////////////////////////////////
uint8_t EasyGraphicsItem::levels() const
uint8_t BlocksGraphicsItem::levels() const
{
return static_cast<uint8_t>(m_levels.size());
}
float EasyGraphicsItem::levelY(uint8_t _level) const
float BlocksGraphicsItem::levelY(uint8_t _level) const
{
return y() + static_cast<int>(_level) * static_cast<int>(::profiler_gui::GRAPHICS_ROW_SIZE_FULL);
}
void EasyGraphicsItem::setLevels(uint8_t _levels)
void BlocksGraphicsItem::setLevels(uint8_t _levels)
{
typedef decltype(m_levelsIndexes) IndexesT;
static const auto MAX_CHILD_INDEX = ::profiler_gui::numeric_max<IndexesT::value_type>();
@ -1427,29 +1427,29 @@ void EasyGraphicsItem::setLevels(uint8_t _levels)
m_rightBounds.resize(_levels, -1e100);
}
void EasyGraphicsItem::reserve(uint8_t _level, unsigned int _items)
void BlocksGraphicsItem::reserve(uint8_t _level, unsigned int _items)
{
m_levels[_level].reserve(_items);
}
//////////////////////////////////////////////////////////////////////////
const EasyGraphicsItem::Children& EasyGraphicsItem::items(uint8_t _level) const
const BlocksGraphicsItem::Children& BlocksGraphicsItem::items(uint8_t _level) const
{
return m_levels[_level];
}
const ::profiler_gui::EasyBlockItem& EasyGraphicsItem::getItem(uint8_t _level, unsigned int _index) const
const ::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index) const
{
return m_levels[_level][_index];
}
::profiler_gui::EasyBlockItem& EasyGraphicsItem::getItem(uint8_t _level, unsigned int _index)
::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index)
{
return m_levels[_level][_index];
}
unsigned int EasyGraphicsItem::addItem(uint8_t _level)
unsigned int BlocksGraphicsItem::addItem(uint8_t _level)
{
m_levels[_level].emplace_back();
return static_cast<unsigned int>(m_levels[_level].size() - 1);

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyGraphicsItem - an item
* description : The file contains declaration of BlocksGraphicsItem - an item
* : used to draw profiler blocks on graphics scene.
* ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h/.cpp
@ -69,9 +69,9 @@
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class EasyGraphicsView;
class BlocksGraphicsView;
class EasyGraphicsItem : public QGraphicsItem
class BlocksGraphicsItem : public QGraphicsItem
{
typedef ::profiler_gui::EasyItems Children;
typedef ::std::vector<uint32_t> DrawIndexes;
@ -85,12 +85,12 @@ class EasyGraphicsItem : public QGraphicsItem
QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem)
QString m_threadName; ///<
const ::profiler::BlocksTreeRoot* m_pRoot; ///< Pointer to the root profiler block (thread block). Used by ProfTreeWidget to restore hierarchy.
uint8_t m_index; ///< This item's index in the list of items of EasyGraphicsView
uint8_t m_index; ///< This item's index in the list of items of BlocksGraphicsView
public:
explicit EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root);
virtual ~EasyGraphicsItem();
explicit BlocksGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root);
virtual ~BlocksGraphicsItem();
// Public virtual methods
@ -170,8 +170,8 @@ public:
private:
///< Returns pointer to the EasyGraphicsView widget.
const EasyGraphicsView* view() const;
///< Returns pointer to the BlocksGraphicsView widget.
const BlocksGraphicsView* view() const;
#ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT
void paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode);
@ -181,13 +181,12 @@ public:
// Public inline methods
///< Returns this item's index in the list of graphics items of EasyGraphicsView
inline uint8_t index() const
{
///< Returns this item's index in the list of graphics items of BlocksGraphicsView
uint8_t index() const {
return m_index;
}
}; // END of class EasyGraphicsItem.
}; // END of class BlocksGraphicsItem.
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

View File

@ -148,7 +148,7 @@ void GraphicsHistogramItem::paintMouseIndicator(QPainter* _painter, qreal _top,
void GraphicsHistogramItem::paintByPtr(QPainter* _painter)
{
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent());
const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
const bool bindMode = widget->bindMode();
const auto currentScale = widget->getWindowScale();
const auto bottom = m_boundingRect.bottom();
@ -239,7 +239,7 @@ void GraphicsHistogramItem::paintByPtr(QPainter* _painter)
void GraphicsHistogramItem::paintById(QPainter* _painter)
{
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent());
const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
const bool bindMode = widget->bindMode();
const auto currentScale = widget->getWindowScale();
const auto bottom = m_boundingRect.bottom();
@ -410,13 +410,15 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, const pr
m_timeUnits = EASY_GLOBALS.time_units;
setReady(false);
m_workerThread = std::thread([this](const profiler_gui::EasyItems* _source)
auto source = m_pSource;
m_worker.enqueue([this, source]
{
m_maxValue = 0;
m_minValue = 1e30;
bool empty = true;
for (const auto& item : *_source)
for (const auto& item : *source)
{
if (isReady())
return;
@ -464,7 +466,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, const pr
setReady(true);
}, m_pSource);
}, m_bReady);
startTimer();
show();
@ -536,10 +538,16 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
m_threadWaitTime = root.wait_time;
setReady(false);
m_workerThread = std::thread([this](decltype(root) profiler_thread, profiler::block_index_t selected_block, bool _showOnlyTopLevelBlocks)
const auto selected_thread = std::ref(root);
const auto selected_block = EASY_GLOBALS.selected_block;
const bool showOnlyTopLevelBlocks = EASY_GLOBALS.display_only_frames_on_histogram;
m_worker.enqueue([this, selected_thread, selected_block, showOnlyTopLevelBlocks]
{
using Stack = std::vector<std::pair<profiler::block_index_t, profiler::block_index_t> >;
const auto& profiler_thread = selected_thread.get();
m_maxValue = 0;
m_minValue = 1e30;
//const auto& profiler_thread = EASY_GLOBALS.profiler_blocks[m_threadId];
@ -565,7 +573,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
m_blockTotalDuraion += w;
}
if (_showOnlyTopLevelBlocks)
if (showOnlyTopLevelBlocks)
continue;
stack.emplace_back(frame, 0U);
@ -652,7 +660,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
setReady(true);
}, std::ref(root), EASY_GLOBALS.selected_block, EASY_GLOBALS.display_only_frames_on_histogram);
}, m_bReady);
startTimer();
}
@ -777,7 +785,7 @@ void GraphicsHistogramItem::onModeChanged()
if (!isImageUpdatePermitted())
return;
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent());
const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
if (!widget->bindMode() && EASY_GLOBALS.auto_adjust_histogram_height)
{
m_topValue = m_maxValue;
@ -800,10 +808,25 @@ bool GraphicsHistogramItem::updateImage()
m_imageScaleUpdate = widget->range() / widget->sliderWidth();
m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum();
m_workerThread = std::thread(&This::updateImageAsync, this, m_boundingRect, m_regime, widget->getWindowScale(),
widget->minimum(), widget->maximum(), widget->range(), widget->value(), widget->sliderWidth(),
m_topValue, m_bottomValue, widget->bindMode(), EASY_GLOBALS.frame_time, EASY_GLOBALS.begin_time,
EASY_GLOBALS.auto_adjust_histogram_height);
// Ugly, but doesn't use exceeded count of threads
const auto rect = m_boundingRect;
const auto regime = m_regime;
const auto scale = widget->getWindowScale();
const auto left = widget->minimum();
const auto right = widget->maximum();
const auto value = widget->value();
const auto window = widget->sliderWidth();
const auto top = m_topValue;
const auto bottom = m_bottomValue;
const auto bindMode = widget->bindMode();
const auto frameTime = EASY_GLOBALS.frame_time;
const auto beginTime = EASY_GLOBALS.begin_time;
const auto autoHeight = EASY_GLOBALS.auto_adjust_histogram_height;
m_worker.enqueue([this, rect, regime, scale, left, right, value, window, top, bottom, bindMode, frameTime, beginTime, autoHeight]
{
updateImageAsync(rect, regime, scale, left, right, right - left, value, window, top, bottom, bindMode,
frameTime, beginTime, autoHeight);
}, m_bReady);
return true;
}
@ -1119,7 +1142,7 @@ void GraphicsHistogramItem::updateImageAsync(QRectF _boundingRect, HistRegime _r
//////////////////////////////////////////////////////////////////////////
EasyGraphicsScrollbar::EasyGraphicsScrollbar(int _initialHeight, QWidget* _parent)
BlocksGraphicsScrollbar::BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent)
: Parent(_parent)
, m_histogramItem(nullptr)
{
@ -1134,27 +1157,27 @@ EasyGraphicsScrollbar::EasyGraphicsScrollbar(int _initialHeight, QWidget* _paren
m_histogramItem->setBoundingRect(0, scene()->sceneRect().top() + margin(), scene()->width(), sceneHeight - margins() - 1);
m_histogramItem->hide();
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::expectedFrameTimeChanged,
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::expectedFrameTimeChanged,
this, &This::onExpectedFrameTimeChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::autoAdjustHistogramChanged,
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::autoAdjustHistogramChanged,
this, &This::onAutoAdjustHistogramChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::displayOnlyFramesOnHistogramChanged,
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::displayOnlyFramesOnHistogramChanged,
this, &This::onDisplayOnlyFramesOnHistogramChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::threadNameDecorationChanged, this, &This::onThreadViewChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::hexThreadIdChanged, this, &This::onThreadViewChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::threadNameDecorationChanged, this, &This::onThreadViewChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::hexThreadIdChanged, this, &This::onThreadViewChanged);
}
EasyGraphicsScrollbar::~EasyGraphicsScrollbar()
BlocksGraphicsScrollbar::~BlocksGraphicsScrollbar()
{
}
//////////////////////////////////////////////////////////////////////////
void EasyGraphicsScrollbar::onThreadViewChanged()
void BlocksGraphicsScrollbar::onThreadViewChanged()
{
if (m_histogramItem->isVisible())
{
@ -1163,7 +1186,7 @@ void EasyGraphicsScrollbar::onThreadViewChanged()
}
}
void EasyGraphicsScrollbar::onExpectedFrameTimeChanged()
void BlocksGraphicsScrollbar::onExpectedFrameTimeChanged()
{
if (m_histogramItem->isVisible())
{
@ -1172,13 +1195,13 @@ void EasyGraphicsScrollbar::onExpectedFrameTimeChanged()
}
}
void EasyGraphicsScrollbar::onAutoAdjustHistogramChanged()
void BlocksGraphicsScrollbar::onAutoAdjustHistogramChanged()
{
if (m_histogramItem->isVisible())
m_histogramItem->onModeChanged();
}
void EasyGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
void BlocksGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
{
if (m_histogramItem->isVisible())
m_histogramItem->rebuildSource(GraphicsHistogramItem::Hist_Id);
@ -1186,18 +1209,18 @@ void EasyGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
//////////////////////////////////////////////////////////////////////////
void EasyGraphicsScrollbar::clear()
void BlocksGraphicsScrollbar::clear()
{
setHistogramSource(0, nullptr);
Parent::clear();
}
profiler::thread_id_t EasyGraphicsScrollbar::hystThread() const
profiler::thread_id_t BlocksGraphicsScrollbar::hystThread() const
{
return m_histogramItem->threadId();
}
void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items)
void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items)
{
if (m_bLocked)
return;
@ -1206,7 +1229,7 @@ void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id,
scene()->update();
}
void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id)
void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id)
{
if (m_bLocked)
return;
@ -1215,7 +1238,7 @@ void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id,
scene()->update();
}
void EasyGraphicsScrollbar::mousePressEvent(QMouseEvent* _event)
void BlocksGraphicsScrollbar::mousePressEvent(QMouseEvent* _event)
{
Parent::mousePressEvent(_event);
if ((m_mouseButtons & Qt::RightButton) && _event->modifiers())

View File

@ -142,21 +142,21 @@ private:
//////////////////////////////////////////////////////////////////////////
class EasyGraphicsScrollbar : public GraphicsSliderArea
class BlocksGraphicsScrollbar : public GraphicsSliderArea
{
Q_OBJECT
private:
using Parent = GraphicsSliderArea;
using This = EasyGraphicsScrollbar;
using This = BlocksGraphicsScrollbar;
GraphicsHistogramItem* m_histogramItem = nullptr;
public:
explicit EasyGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr);
~EasyGraphicsScrollbar() override;
explicit BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr);
~BlocksGraphicsScrollbar() override;
void clear() override;
void mousePressEvent(QMouseEvent* _event) override;
@ -180,7 +180,7 @@ private slots:
void onAutoAdjustHistogramChanged();
void onDisplayOnlyFramesOnHistogramChanged();
}; // END of class EasyGraphicsScrollbar.
}; // END of class BlocksGraphicsScrollbar.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : This file contains implementation of EasyQTimer class used to
* description : This file contains implementation of Timer class used to
* : connect QTimer to non-QObject classes.
* ----------------- :
* change log : * 2016/12/05 Victor Zarubkin: Initial commit.
@ -57,69 +57,69 @@
//////////////////////////////////////////////////////////////////////////
EasyQTimer::EasyQTimer()
Timer::Timer()
: QObject()
{
connect(&m_timer, &QTimer::timeout, this, &EasyQTimer::onTimeout);
connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout);
}
EasyQTimer::EasyQTimer(::std::function<void()>&& handler, bool signleShot)
Timer::Timer(std::function<void()>&& handler, bool signleShot)
: QObject()
, m_handler(::std::forward<::std::function<void()>&&>(handler))
, m_handler(std::forward<std::function<void()>&&>(handler))
{
m_timer.setSingleShot(signleShot);
connect(&m_timer, &QTimer::timeout, this, &EasyQTimer::onTimeout);
connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout);
}
EasyQTimer::~EasyQTimer()
Timer::~Timer()
{
}
void EasyQTimer::onTimeout()
void Timer::onTimeout()
{
m_handler();
}
void EasyQTimer::setHandler(::std::function<void()>&& handler)
void Timer::setHandler(std::function<void()>&& handler)
{
m_handler = handler;
}
void EasyQTimer::setSignleShot(bool singleShot)
void Timer::setSignleShot(bool singleShot)
{
m_timer.setSingleShot(singleShot);
}
bool EasyQTimer::isSingleShot() const
bool Timer::isSingleShot() const
{
return m_timer.isSingleShot();
}
void EasyQTimer::setInterval(int msec)
void Timer::setInterval(int msec)
{
m_timer.setInterval(msec);
}
void EasyQTimer::start(int msec)
void Timer::start(int msec)
{
stop();
m_timer.start(msec);
}
void EasyQTimer::start()
void Timer::start()
{
stop();
m_timer.start();
}
void EasyQTimer::stop()
void Timer::stop()
{
if (m_timer.isActive())
m_timer.stop();
}
bool EasyQTimer::isActive() const
bool Timer::isActive() const
{
return m_timer.isActive();
}

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : This file contains declaration of EasyQTimer class used to
* description : This file contains declaration of Timer class used to
* : connect QTimer to non-QObject classes.
* ----------------- :
* change log : * 2016/12/05 Victor Zarubkin: Initial commit.
@ -61,7 +61,7 @@
//////////////////////////////////////////////////////////////////////////
class EasyQTimer : public QObject
class Timer : public QObject
{
Q_OBJECT
@ -72,11 +72,11 @@ private:
public:
explicit EasyQTimer();
explicit EasyQTimer(::std::function<void()>&& handler, bool signleShot = false);
~EasyQTimer() override;
explicit Timer();
explicit Timer(std::function<void()>&& handler, bool signleShot = false);
~Timer() override;
void setHandler(::std::function<void()>&& _handler);
void setHandler(std::function<void()>&& handler);
void setSignleShot(bool singleShot);
bool isSingleShot() const;
@ -91,7 +91,7 @@ private slots:
void onTimeout();
}; // END of class EasyQTimer.
}; // END of class Timer.
//////////////////////////////////////////////////////////////////////////

View File

@ -61,15 +61,15 @@
namespace profiler_gui {
EasyGlobals& EasyGlobals::instance()
Globals& Globals::instance()
{
// It's okay even without C++11 "magic statics" feature because first call happens
// on application initialization - there is only one thread and no data races occur.
static EasyGlobals globals;
static Globals globals;
return globals;
}
EasyGlobals::EasyGlobals()
Globals::Globals()
: theme("default")
, bg_font(::profiler_gui::EFont("DejaVu Sans", 10, QFont::Bold))
, chronometer_font(::profiler_gui::EFont("DejaVu Sans", 16, QFont::Bold))

View File

@ -171,11 +171,11 @@ namespace profiler_gui {
bool empty = true;
};
struct EasyGlobals Q_DECL_FINAL
struct Globals Q_DECL_FINAL
{
static EasyGlobals& instance();
static Globals& instance();
EasyGlobalSignals events; ///< Global signals
GlobalSignals events; ///< Global signals
::profiler::thread_blocks_tree_t profiler_blocks; ///< Profiler blocks tree loaded from file
::profiler::descriptors_list_t descriptors; ///< Profiler block descriptors list
EasyBlocks gui_blocks; ///< Profiler graphics blocks builded by GUI
@ -226,16 +226,16 @@ namespace profiler_gui {
private:
EasyGlobals();
Globals();
}; // END of struct EasyGlobals.
}; // END of struct Globals.
//////////////////////////////////////////////////////////////////////////
} // END of namespace profiler_gui.
#ifndef IGNORE_GLOBALS_DECLARATION
#define EASY_GLOBALS ::profiler_gui::EasyGlobals::instance()
#define EASY_GLOBALS ::profiler_gui::Globals::instance()
inline ::profiler_gui::EasyBlock& easyBlock(::profiler::block_index_t i) {
return EASY_GLOBALS.gui_blocks[i];

View File

@ -5,7 +5,7 @@
* authors : Victor Zarubkin, Sergey Yagovtsev
* email : v.s.zarubkin@gmail.com, yse.sey@gmail.com
* ----------------- :
* description : The file contains implementation of EasyGlobalSignals QObject class.
* description : The file contains implementation of GlobalSignals QObject class.
* ----------------- :
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp
* :
@ -59,11 +59,11 @@
namespace profiler_gui {
EasyGlobalSignals::EasyGlobalSignals() : QObject()
GlobalSignals::GlobalSignals() : QObject()
{
}
EasyGlobalSignals::~EasyGlobalSignals()
GlobalSignals::~GlobalSignals()
{
}

View File

@ -5,7 +5,7 @@
* authors : Victor Zarubkin, Sergey Yagovtsev
* email : v.s.zarubkin@gmail.com, yse.sey@gmail.com
* ----------------- :
* description : The file contains declaration of EasyGlobalSignals QObject class.
* description : The file contains declaration of GlobalSignals QObject class.
* ----------------- :
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.h
* :
@ -60,14 +60,14 @@
namespace profiler_gui {
class EasyGlobalSignals Q_DECL_FINAL : public QObject
class GlobalSignals Q_DECL_FINAL : public QObject
{
Q_OBJECT
public:
EasyGlobalSignals();
~EasyGlobalSignals() Q_DECL_OVERRIDE;
GlobalSignals();
~GlobalSignals() Q_DECL_OVERRIDE;
signals:
@ -100,7 +100,7 @@ namespace profiler_gui {
void chartWheeled(qreal pos, int delta);
void chartSliderChanged(qreal pos);
}; // END of class EasyGlobalSignals.
}; // END of class GlobalSignals.
} // END of namespace profiler_gui.

View File

@ -258,9 +258,6 @@ void GraphicsImageItem::onTimeout()
{
// Image updated
if (m_workerThread.joinable())
m_workerThread.join();
m_workerImage->swap(m_image);
delete m_workerImage;
m_workerImage = nullptr;
@ -286,18 +283,15 @@ bool GraphicsImageItem::isImageUpdatePermitted() const
void GraphicsImageItem::cancelAnyJob()
{
setReady(true);
if (m_workerThread.joinable())
m_workerThread.join();
//setReady(false);
stopTimer();
m_worker.dequeue();
delete m_workerImage;
m_workerImage = nullptr;
m_imageOriginUpdate = m_imageOrigin;
m_imageScaleUpdate = m_imageScale;
stopTimer();
}
void GraphicsImageItem::resetTopBottomValues()

View File

@ -4,9 +4,9 @@
#define EASY_PROFILER_GRAPHICS_IMAGE_ITEM_H
#include <QGraphicsItem>
#include <thread>
#include <atomic>
#include "easy_qtimer.h"
#include "thread_pool_task.h"
class GraphicsImageItem : public QGraphicsItem
{
@ -17,8 +17,8 @@ protected:
QRectF m_boundingRect;
QImage m_image;
EasyQTimer m_boundaryTimer;
std::thread m_workerThread;
Timer m_boundaryTimer;
ThreadPoolTask m_worker;
QPointF m_mousePos;
QImage* m_workerImage;
qreal m_imageOrigin;
@ -31,11 +31,11 @@ protected:
qreal m_bottomValue;
qreal m_maxValue;
qreal m_minValue;
std::atomic_bool m_bReady;
private:
EasyQTimer m_timer;
std::atomic_bool m_bReady;
Timer m_timer;
bool m_bPermitImageUpdate; ///< Is false when m_workerThread is parsing input dataset (when setSource(_block_id) is called)
public:

View File

@ -218,13 +218,13 @@ GraphicsSliderArea::GraphicsSliderArea(QWidget* _parent)
centerOn(0, 0);
auto globalEvents = &EASY_GLOBALS.events;
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneCleared, this, &This::clear);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneVisibleRegionSizeChanged, this, &This::setSliderWidth);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneVisibleRegionPosChanged, this, &This::setValue);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::chartSliderChanged, this, &This::onExternalChartSliderChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneSizeChanged, this, &This::onSceneSizeChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::lockCharts, this, &This::lock);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::unlockCharts, this, &This::unlock);
connect(globalEvents, &profiler_gui::GlobalSignals::sceneCleared, this, &This::clear);
connect(globalEvents, &profiler_gui::GlobalSignals::sceneVisibleRegionSizeChanged, this, &This::setSliderWidth);
connect(globalEvents, &profiler_gui::GlobalSignals::sceneVisibleRegionPosChanged, this, &This::setValue);
connect(globalEvents, &profiler_gui::GlobalSignals::chartSliderChanged, this, &This::onExternalChartSliderChanged);
connect(globalEvents, &profiler_gui::GlobalSignals::sceneSizeChanged, this, &This::onSceneSizeChanged);
connect(globalEvents, &profiler_gui::GlobalSignals::lockCharts, this, &This::lock);
connect(globalEvents, &profiler_gui::GlobalSignals::unlockCharts, this, &This::unlock);
}
GraphicsSliderArea::~GraphicsSliderArea()

View File

@ -52,6 +52,7 @@
#include <QApplication>
#include "main_window.h"
#include "globals.h"
#include "thread_pool.h"
#if defined(_WIN32) && defined (_BUILD_RELEASE_)
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
@ -62,12 +63,15 @@ int main(int argc, char **argv)
auto now = ::std::chrono::duration_cast<std::chrono::seconds>(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1;
srand((unsigned int)now);
// Instanciate thread pool to avoid data races for compilers without C++11 thread-safe statics
ThreadPool::instance();
QApplication app(argc, argv);
// Instanciate easy globals after QApplication to allow creation of global fonts, and on the main thread to avoid data races
profiler_gui::EasyGlobals::instance();
profiler_gui::Globals::instance();
EasyMainWindow window;
MainWindow window;
window.show();
return app.exec();

File diff suppressed because it is too large Load Diff

View File

@ -83,28 +83,28 @@ namespace profiler { namespace net { struct EasyProfilerStatus; } }
//////////////////////////////////////////////////////////////////////////
class EasyFileReader Q_DECL_FINAL
class FileReader Q_DECL_FINAL
{
::profiler::SerializedData m_serializedBlocks; ///<
::profiler::SerializedData m_serializedDescriptors; ///<
::profiler::descriptors_list_t m_descriptors; ///<
::profiler::blocks_t m_blocks; ///<
::profiler::thread_blocks_tree_t m_blocksTree; ///<
::std::stringstream m_stream; ///<
::std::stringstream m_errorMessage; ///<
profiler::SerializedData m_serializedBlocks; ///<
profiler::SerializedData m_serializedDescriptors; ///<
profiler::descriptors_list_t m_descriptors; ///<
profiler::blocks_t m_blocks; ///<
profiler::thread_blocks_tree_t m_blocksTree; ///<
std::stringstream m_stream; ///<
std::stringstream m_errorMessage; ///<
QString m_filename; ///<
uint32_t m_descriptorsNumberInFile = 0; ///<
uint32_t m_version = 0; ///<
::std::thread m_thread; ///<
::std::atomic_bool m_bDone; ///<
::std::atomic<int> m_progress; ///<
::std::atomic<unsigned int> m_size; ///<
std::thread m_thread; ///<
std::atomic_bool m_bDone; ///<
std::atomic<int> m_progress; ///<
std::atomic<unsigned int> m_size; ///<
bool m_isFile = false; ///<
public:
EasyFileReader();
~EasyFileReader();
FileReader();
~FileReader();
const bool isFile() const;
bool done() const;
@ -113,44 +113,44 @@ public:
const QString& filename() const;
void load(const QString& _filename);
void load(::std::stringstream& _stream);
void load(std::stringstream& _stream);
void interrupt();
void get(::profiler::SerializedData& _serializedBlocks, ::profiler::SerializedData& _serializedDescriptors,
::profiler::descriptors_list_t& _descriptors, ::profiler::blocks_t& _blocks, ::profiler::thread_blocks_tree_t& _tree,
void get(profiler::SerializedData& _serializedBlocks, profiler::SerializedData& _serializedDescriptors,
profiler::descriptors_list_t& _descriptors, profiler::blocks_t& _blocks, profiler::thread_blocks_tree_t& _tree,
uint32_t& _descriptorsNumberInFile, uint32_t& _version, QString& _filename);
void join();
QString getError();
}; // END of class EasyFileReader.
}; // END of class FileReader.
//////////////////////////////////////////////////////////////////////////
enum EasyListenerRegime : uint8_t
enum class ListenerRegime : uint8_t
{
LISTENER_IDLE = 0,
LISTENER_CAPTURE,
LISTENER_CAPTURE_RECEIVE,
LISTENER_DESCRIBE
Idle = 0,
Capture,
Capture_Receive,
Descriptors
};
class EasySocketListener Q_DECL_FINAL
{
EasySocket m_easySocket; ///<
::std::string m_address; ///<
::std::stringstream m_receivedData; ///<
::std::thread m_thread; ///<
std::string m_address; ///<
std::stringstream m_receivedData; ///<
std::thread m_thread; ///<
uint64_t m_receivedSize; ///<
uint16_t m_port; ///<
::std::atomic<uint32_t> m_frameMax; ///<
::std::atomic<uint32_t> m_frameAvg; ///<
::std::atomic_bool m_bInterrupt; ///<
::std::atomic_bool m_bConnected; ///<
::std::atomic_bool m_bStopReceive; ///<
::std::atomic_bool m_bCaptureReady; ///<
::std::atomic_bool m_bFrameTimeReady; ///<
EasyListenerRegime m_regime; ///<
std::atomic<uint32_t> m_frameMax; ///<
std::atomic<uint32_t> m_frameAvg; ///<
std::atomic_bool m_bInterrupt; ///<
std::atomic_bool m_bConnected; ///<
std::atomic_bool m_bStopReceive; ///<
std::atomic_bool m_bCaptureReady; ///<
std::atomic_bool m_bFrameTimeReady; ///<
ListenerRegime m_regime; ///<
public:
@ -159,18 +159,18 @@ public:
bool connected() const;
bool captured() const;
EasyListenerRegime regime() const;
ListenerRegime regime() const;
uint64_t size() const;
const ::std::string& address() const;
const std::string& address() const;
uint16_t port() const;
::std::stringstream& data();
std::stringstream& data();
void clearData();
void disconnect();
void closeSocket();
bool connect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false);
bool reconnect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply);
bool connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false);
bool reconnect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply);
bool startCapture();
void stopCapture();
@ -181,8 +181,7 @@ public:
bool requestFrameTime();
template <class T>
inline void send(const T& _message)
{
void send(const T& _message) {
m_easySocket.send(&_message, sizeof(T));
}
@ -214,13 +213,13 @@ struct DialogWithGeometry EASY_FINAL
void restoreGeometry();
};
class EasyMainWindow : public QMainWindow
class MainWindow : public QMainWindow
{
Q_OBJECT
protected:
using This = EasyMainWindow;
using This = MainWindow;
using Parent = QMainWindow;
DialogWithGeometry m_descTreeDialog;
@ -237,14 +236,14 @@ protected:
#endif
class QProgressDialog* m_progress = nullptr;
class EasyDescWidget* m_dialogDescTree = nullptr;
class BlockDescriptorsWidget* m_dialogDescTree = nullptr;
class QMessageBox* m_listenerDialog = nullptr;
QTimer m_readerTimer;
QTimer m_listenerTimer;
QTimer m_fpsRequestTimer;
::profiler::SerializedData m_serializedBlocks;
::profiler::SerializedData m_serializedDescriptors;
EasyFileReader m_reader;
profiler::SerializedData m_serializedBlocks;
profiler::SerializedData m_serializedDescriptors;
FileReader m_reader;
EasySocketListener m_listener;
class QLineEdit* m_addressEdit = nullptr;
@ -267,8 +266,8 @@ protected:
public:
explicit EasyMainWindow();
~EasyMainWindow() override;
explicit MainWindow();
~MainWindow() override;
// Public virtual methods
@ -316,7 +315,7 @@ protected slots:
void onFrameTimeEditFinish();
void onFrameTimeChanged();
void onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status);
void onBlockStatusChange(profiler::block_id_t _id, profiler::EasyBlockStatus _status);
void checkFrameTimeReady();
@ -330,7 +329,7 @@ private:
void addFileToList(const QString& filename);
void loadFile(const QString& filename);
void readStream(::std::stringstream& data);
void readStream(std::stringstream& data);
void loadSettings();
void loadGeometry();
@ -341,7 +340,7 @@ private:
void destroyProgressDialog();
void createProgressDialog(const QString& text);
}; // END of class EasyMainWindow.
}; // END of class MainWindow.
//////////////////////////////////////////////////////////////////////////

View File

@ -20,7 +20,7 @@
*:disabled {
color: #a08888; }
EasyMainWindow, QToolBar, QDialog {
MainWindow, QToolBar, QDialog {
background-color: #f8f2f2; }
QToolTip {

View File

@ -42,7 +42,7 @@ $SpinBoxArrowSize: 8px;
color: $DisabledTextColor;
}
EasyMainWindow, QToolBar, QDialog {
MainWindow, QToolBar, QDialog {
background-color: #f8f2f2;
}

View File

@ -0,0 +1,77 @@
/*
* */
#include "thread_pool.h"
#include <algorithm>
ThreadPool& ThreadPool::instance()
{
static ThreadPool pool;
return pool;
}
ThreadPool::ThreadPool()
{
const auto threadsCount = std::max(std::thread::hardware_concurrency(), 2U);
m_threads.reserve(threadsCount);
std::generate_n(std::back_inserter(m_threads), threadsCount, [this] {
return std::thread(&ThreadPool::work, this);
});
}
ThreadPool::~ThreadPool()
{
m_interrupt.store(true, std::memory_order_release);
m_cv.notify_all();
for (auto& thread : m_threads)
thread.join();
}
void ThreadPool::enqueue(ThreadPoolTask& task)
{
m_mutex.lock();
m_tasks.emplace_back(task);
m_mutex.unlock();
m_cv.notify_one();
}
void ThreadPool::dequeue(ThreadPoolTask& task)
{
const std::lock_guard<std::mutex> lock(m_mutex);
if (task.status() != TaskStatus::Enqueued)
return;
for (auto it = m_tasks.begin(); it != m_tasks.end(); ++it)
{
if (&it->get() == &task)
{
m_tasks.erase(it);
break;
}
}
}
void ThreadPool::work()
{
while (true)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_cv.wait(lock, [this] { return !m_tasks.empty() || m_interrupt.load(std::memory_order_acquire); });
if (m_interrupt.load(std::memory_order_acquire))
break;
if (m_tasks.empty())
continue;
auto& task = m_tasks.front().get();
task.setStatus(TaskStatus::Processing);
m_tasks.pop_front();
lock.unlock();
task.execute();
}
}

View File

@ -0,0 +1,39 @@
/**
* */
#ifndef EASY_PROFILER_THREAD_POOL_H
#define EASY_PROFILER_THREAD_POOL_H
#include "thread_pool_task.h"
#include <vector>
#include <deque>
#include <condition_variable>
#include <thread>
class ThreadPool EASY_FINAL
{
friend ThreadPoolTask;
std::vector<std::thread> m_threads;
std::deque<std::reference_wrapper<ThreadPoolTask> > m_tasks;
std::mutex m_mutex;
std::condition_variable m_cv;
std::atomic_bool m_interrupt;
ThreadPool();
public:
~ThreadPool();
static ThreadPool& instance();
private:
void enqueue(ThreadPoolTask& task);
void dequeue(ThreadPoolTask& task);
void work();
}; // end of class ThreadPool.
#endif //EASY_PROFILER_THREAD_POOL_H

View File

@ -0,0 +1,65 @@
/**
* */
#include "thread_pool_task.h"
#include "thread_pool.h"
ThreadPoolTask::ThreadPoolTask() : m_func([]{}), m_interrupt(nullptr)
{
m_status = ATOMIC_VAR_INIT(static_cast<int8_t>(TaskStatus::Finished));
}
ThreadPoolTask::~ThreadPoolTask()
{
dequeue();
}
void ThreadPoolTask::enqueue(std::function<void()>&& func, std::atomic_bool& interruptFlag)
{
dequeue();
m_interrupt = & interruptFlag;
m_interrupt->store(false, std::memory_order_release);
m_func = std::move(func);
setStatus(TaskStatus::Enqueued);
ThreadPool::instance().enqueue(*this);
}
void ThreadPoolTask::dequeue()
{
if (m_interrupt == nullptr)
return;
m_interrupt->store(true, std::memory_order_release);
ThreadPool::instance().dequeue(*this);
// wait for finish
m_mutex.lock();
setStatus(TaskStatus::Finished);
m_mutex.unlock();
m_interrupt->store(false, std::memory_order_release);
}
TaskStatus ThreadPoolTask::status() const
{
return static_cast<TaskStatus>(m_status.load(std::memory_order_acquire));
}
void ThreadPoolTask::execute()
{
const std::lock_guard<std::mutex> guard(m_mutex);
if (status() == TaskStatus::Finished || m_interrupt->load(std::memory_order_acquire))
return;
m_func();
setStatus(TaskStatus::Finished);
}
void ThreadPoolTask::setStatus(TaskStatus status)
{
m_status.store(static_cast<int8_t>(status), std::memory_order_release);
}

View File

@ -0,0 +1,47 @@
/*
* */
#ifndef EASY_PROFILER_THREAD_POOL_TASK_H
#define EASY_PROFILER_THREAD_POOL_TASK_H
#include <easy/details/easy_compiler_support.h>
#include <functional>
#include <atomic>
#include <mutex>
enum class TaskStatus : int8_t
{
Enqueued,
Processing,
Finished,
};
class ThreadPoolTask EASY_FINAL
{
friend class ThreadPool;
std::function<void()> m_func;
std::mutex m_mutex;
std::atomic<int8_t> m_status;
std::atomic_bool* m_interrupt;
public:
ThreadPoolTask(const ThreadPoolTask&) = delete;
ThreadPoolTask(ThreadPoolTask&&) = delete;
ThreadPoolTask();
~ThreadPoolTask();
void enqueue(std::function<void()>&& func, std::atomic_bool& interruptFlag);
void dequeue();
private:
void execute();
TaskStatus status() const;
void setStatus(TaskStatus status);
};
#endif //EASY_PROFILER_THREAD_POOL_TASK_H

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyTreeWidgetItem.
* description : The file contains implementation of TreeWidgetItem.
* ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: Moved sources from blocks_tree_widget.cpp
* : and renamed classes from Prof* to Easy*.
@ -109,7 +109,7 @@ EASY_CONSTEXPR int ColumnBit[COL_COLUMNS_NUMBER] = {
//////////////////////////////////////////////////////////////////////////
EasyTreeWidgetItem::EasyTreeWidgetItem(const ::profiler::block_index_t _treeBlock, Parent* _parent)
TreeWidgetItem::TreeWidgetItem(const profiler::block_index_t _treeBlock, Parent* _parent)
: Parent(_parent, QTreeWidgetItem::UserType)
, m_block(_treeBlock)
, m_customBGColor(0)
@ -118,11 +118,11 @@ EasyTreeWidgetItem::EasyTreeWidgetItem(const ::profiler::block_index_t _treeBloc
}
EasyTreeWidgetItem::~EasyTreeWidgetItem()
TreeWidgetItem::~TreeWidgetItem()
{
}
bool EasyTreeWidgetItem::operator < (const Parent& _other) const
bool TreeWidgetItem::operator < (const Parent& _other) const
{
const auto col = treeWidget()->sortColumn();
@ -166,20 +166,20 @@ bool EasyTreeWidgetItem::operator < (const Parent& _other) const
}
}
bool EasyTreeWidgetItem::hasToolTip(int _column) const
bool TreeWidgetItem::hasToolTip(int _column) const
{
const int bit = ColumnBit[_column];
return bit < 0 ? false : m_bHasToolTip.test(static_cast<size_t>(bit));
}
void EasyTreeWidgetItem::setHasToolTip(int _column)
void TreeWidgetItem::setHasToolTip(int _column)
{
const int bit = ColumnBit[_column];
if (bit >= 0)
m_bHasToolTip.set(static_cast<size_t>(bit), true);
}
QVariant EasyTreeWidgetItem::data(int _column, int _role) const
QVariant TreeWidgetItem::data(int _column, int _role) const
{
if (_column == COL_NAME)
{
@ -207,7 +207,7 @@ QVariant EasyTreeWidgetItem::data(int _column, int _role) const
return m_font;
case Qt::ForegroundRole:
return m_bMain ? QVariant::fromValue(QColor::fromRgb(::profiler_gui::SELECTED_THREAD_FOREGROUND)) : QVariant();
return m_bMain ? QVariant::fromValue(QColor::fromRgb(profiler_gui::SELECTED_THREAD_FOREGROUND)) : QVariant();
case Qt::ToolTipRole:
return hasToolTip(_column) ?
@ -219,40 +219,40 @@ QVariant EasyTreeWidgetItem::data(int _column, int _role) const
}
}
::profiler::block_index_t EasyTreeWidgetItem::block_index() const
profiler::block_index_t TreeWidgetItem::block_index() const
{
return m_block;
}
::profiler_gui::EasyBlock& EasyTreeWidgetItem::guiBlock()
profiler_gui::EasyBlock& TreeWidgetItem::guiBlock()
{
return easyBlock(m_block);
}
const ::profiler::BlocksTree& EasyTreeWidgetItem::block() const
const profiler::BlocksTree& TreeWidgetItem::block() const
{
return easyBlocksTree(m_block);
}
::profiler::timestamp_t EasyTreeWidgetItem::duration() const
profiler::timestamp_t TreeWidgetItem::duration() const
{
if (parent() != nullptr)
return block().node->duration();
return data(COL_DURATION, Qt::UserRole).toULongLong();
}
::profiler::timestamp_t EasyTreeWidgetItem::selfDuration() const
profiler::timestamp_t TreeWidgetItem::selfDuration() const
{
return data(COL_SELF_DURATION, Qt::UserRole).toULongLong();
}
void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time, const QString& _prefix)
void TreeWidgetItem::setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time, const QString& _prefix)
{
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column);
setText(_column, QString("%1%2").arg(_prefix).arg(::profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3)));
setText(_column, QString("%1%2").arg(_prefix).arg(profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3)));
// if (_time < 1e3)
// {
@ -272,46 +272,46 @@ void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _un
// }
}
void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time)
void TreeWidgetItem::setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time)
{
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column);
setText(_column, ::profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3));
setText(_column, profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3));
}
void EasyTreeWidgetItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time)
void TreeWidgetItem::setTimeMs(int _column, const profiler::timestamp_t& _time)
{
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column);
setText(_column, QString::number(double(nanosecondsTime) * 1e-6, 'g', 9));
}
void EasyTreeWidgetItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time, const QString& _prefix)
void TreeWidgetItem::setTimeMs(int _column, const profiler::timestamp_t& _time, const QString& _prefix)
{
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column);
setText(_column, QString("%1%2").arg(_prefix).arg(double(nanosecondsTime) * 1e-6, 0, 'g', 9));
}
void EasyTreeWidgetItem::setBackgroundColor(QRgb _color)
void TreeWidgetItem::setBackgroundColor(QRgb _color)
{
m_customBGColor = _color;
}
void EasyTreeWidgetItem::setMain(bool _main)
void TreeWidgetItem::setMain(bool _main)
{
m_bMain = _main;
}
void EasyTreeWidgetItem::collapseAll()
void TreeWidgetItem::collapseAll()
{
for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i)
{
static_cast<EasyTreeWidgetItem*>(child(i))->collapseAll();
static_cast<TreeWidgetItem*>(child(i))->collapseAll();
}
setExpanded(false);
@ -319,11 +319,11 @@ void EasyTreeWidgetItem::collapseAll()
guiBlock().expanded = false;
}
void EasyTreeWidgetItem::expandAll()
void TreeWidgetItem::expandAll()
{
for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i)
{
static_cast<EasyTreeWidgetItem*>(child(i))->expandAll();
static_cast<TreeWidgetItem*>(child(i))->expandAll();
}
setExpanded(true);
@ -331,7 +331,7 @@ void EasyTreeWidgetItem::expandAll()
guiBlock().expanded = true;
}
void EasyTreeWidgetItem::setBold(bool _bold)
void TreeWidgetItem::setBold(bool _bold)
{
m_font.setBold(_bold);
}
@ -375,7 +375,7 @@ void EasyItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
{
painter->save();
painter->setBrush(Qt::NoBrush);
painter->setPen(::profiler_gui::SYSTEM_BORDER_COLOR);
painter->setPen(profiler_gui::SYSTEM_BORDER_COLOR);
painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft);
painter->restore();
}
@ -414,7 +414,7 @@ void EasyItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
// Draw color marker with block color
const auto brush = m_treeWidget->model()->data(index, Qt::UserRole + 1).value<QBrush>();
painter->setBrush(brush);
painter->setPen(::profiler_gui::SYSTEM_BORDER_COLOR);
painter->setPen(profiler_gui::SYSTEM_BORDER_COLOR);
painter->drawRect(QRect(option.rect.left(), option.rect.top() + 5, 16, option.rect.height() - 10));
// Draw line under tree indicator

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyTreeWidgetItem
* description : The file contains declaration of TreeWidgetItem
* : for displyaing EasyProfiler blocks tree.
* ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h
@ -113,10 +113,10 @@ enum EasyColumnsIndexes
//////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetItem : public QTreeWidgetItem
class TreeWidgetItem : public QTreeWidgetItem
{
using Parent = QTreeWidgetItem;
using This = EasyTreeWidgetItem;
using This = TreeWidgetItem;
QFont m_font;
const ::profiler::block_index_t m_block;
@ -126,8 +126,8 @@ class EasyTreeWidgetItem : public QTreeWidgetItem
public:
explicit EasyTreeWidgetItem(const ::profiler::block_index_t _treeBlock = ::profiler_gui::numeric_max<decltype(m_block)>(), Parent* _parent = nullptr);
virtual ~EasyTreeWidgetItem();
explicit TreeWidgetItem(const ::profiler::block_index_t _treeBlock = ::profiler_gui::numeric_max<decltype(m_block)>(), Parent* _parent = nullptr);
virtual ~TreeWidgetItem();
bool operator < (const Parent& _other) const override;
QVariant data(int _column, int _role) const override;
@ -162,7 +162,7 @@ private:
bool hasToolTip(int _column) const;
void setHasToolTip(int _column);
}; // END of class EasyTreeWidgetItem.
}; // END of class TreeWidgetItem.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains implementation of EasyTreeWidgetLoader which aim is
* description : The file contains implementation of TreeWidgetLoader which aim is
* : to load EasyProfiler blocks hierarchy in separate thread.
* ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp
@ -57,6 +57,7 @@
#include "tree_widget_loader.h"
#include "tree_widget_item.h"
#include "globals.h"
#include <thread>
#ifdef _WIN32
#include <Windows.h>
@ -77,46 +78,46 @@
//////////////////////////////////////////////////////////////////////////
EasyTreeWidgetLoader::EasyTreeWidgetLoader()
TreeWidgetLoader::TreeWidgetLoader()
: m_bDone(ATOMIC_VAR_INIT(false))
, m_bInterrupt(ATOMIC_VAR_INIT(false))
, m_progress(ATOMIC_VAR_INIT(0))
, m_mode(EasyTreeMode_Full)
, m_mode(TreeMode::Full)
{
}
EasyTreeWidgetLoader::~EasyTreeWidgetLoader()
TreeWidgetLoader::~TreeWidgetLoader()
{
interrupt(true);
}
bool EasyTreeWidgetLoader::done() const
bool TreeWidgetLoader::done() const
{
return m_bDone.load();
return m_bDone.load(std::memory_order_acquire);
}
void EasyTreeWidgetLoader::setDone()
void TreeWidgetLoader::setDone()
{
m_bDone.store(true);
m_bDone.store(true, std::memory_order_release);
//m_progress.store(100);
}
void EasyTreeWidgetLoader::setProgress(int _progress)
void TreeWidgetLoader::setProgress(int _progress)
{
m_progress.store(_progress);
m_progress.store(_progress, std::memory_order_release);
}
bool EasyTreeWidgetLoader::interrupted() const
bool TreeWidgetLoader::interrupted() const
{
return m_bInterrupt.load();
return m_bInterrupt.load(std::memory_order_acquire);
}
int EasyTreeWidgetLoader::progress() const
int TreeWidgetLoader::progress() const
{
return m_progress.load();
return m_progress.load(std::memory_order_acquire);
}
void EasyTreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output)
void TreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output)
{
if (done())
{
@ -125,7 +126,7 @@ void EasyTreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output)
}
}
void EasyTreeWidgetLoader::takeItems(Items& _output)
void TreeWidgetLoader::takeItems(Items& _output)
{
if (done())
{
@ -134,15 +135,11 @@ void EasyTreeWidgetLoader::takeItems(Items& _output)
}
}
void EasyTreeWidgetLoader::interrupt(bool _wait)
void TreeWidgetLoader::interrupt(bool _wait)
{
m_bInterrupt.store(true);
if (m_thread.joinable())
m_thread.join();
m_bInterrupt.store(false);
m_bDone.store(false);
m_progress.store(0);
m_worker.dequeue();
m_bDone.store(false, std::memory_order_release);
m_progress.store(0, std::memory_order_release);
if (!_wait)
{
@ -170,27 +167,39 @@ void EasyTreeWidgetLoader::interrupt(bool _wait)
m_iditems.clear();
}
void EasyTreeWidgetLoader::fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, EasyTreeMode _mode)
void TreeWidgetLoader::fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, TreeMode _mode)
{
interrupt();
m_mode = _mode;
m_thread = ::std::thread(&EasyTreeWidgetLoader::setTreeInternal1, this,
::std::ref(_beginTime), _blocksNumber, ::std::ref(_blocksTree), EASY_GLOBALS.add_zero_blocks_to_hierarchy,
EASY_GLOBALS.use_decorated_thread_name, EASY_GLOBALS.hex_thread_id, EASY_GLOBALS.time_units);
const auto zeroBlocks = EASY_GLOBALS.add_zero_blocks_to_hierarchy;
const auto decoratedNames = EASY_GLOBALS.use_decorated_thread_name;
const auto hexThreadIds = EASY_GLOBALS.hex_thread_id;
const auto timeUnits = EASY_GLOBALS.time_units;
m_worker.enqueue([this, &_beginTime, _blocksNumber, &_blocksTree, zeroBlocks, decoratedNames, hexThreadIds, timeUnits]
{
setTreeInternal1(_beginTime, _blocksNumber, _blocksTree, zeroBlocks, decoratedNames, hexThreadIds, timeUnits);
}, m_bInterrupt);
}
void EasyTreeWidgetLoader::fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, EasyTreeMode _mode)
void TreeWidgetLoader::fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, TreeMode _mode)
{
interrupt();
m_mode = _mode;
m_thread = ::std::thread(&EasyTreeWidgetLoader::setTreeInternal2, this,
_beginTime, ::std::ref(_blocks), _left, _right, _strict, EASY_GLOBALS.add_zero_blocks_to_hierarchy,
EASY_GLOBALS.use_decorated_thread_name, EASY_GLOBALS.hex_thread_id, EASY_GLOBALS.time_units);
const auto zeroBlocks = EASY_GLOBALS.add_zero_blocks_to_hierarchy;
const auto decoratedNames = EASY_GLOBALS.use_decorated_thread_name;
const auto hexThreadIds = EASY_GLOBALS.hex_thread_id;
const auto timeUnits = EASY_GLOBALS.time_units;
m_worker.enqueue([this, _beginTime, &_blocks, _left, _right, _strict, zeroBlocks, decoratedNames, hexThreadIds, timeUnits]
{
setTreeInternal2(_beginTime, _blocks, _left, _right, _strict, zeroBlocks, decoratedNames, hexThreadIds, timeUnits);
}, m_bInterrupt);
}
//////////////////////////////////////////////////////////////////////////
void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units)
void TreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units)
{
m_items.reserve(_blocksNumber + _blocksTree.size()); // _blocksNumber does not include Thread root blocks
@ -218,7 +227,7 @@ void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime,
break;
const auto& root = threadTree.second;
auto item = new EasyTreeWidgetItem();
auto item = new TreeWidgetItem();
item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, root, u_thread, _hexThreadId));
::profiler::timestamp_t duration = 0;
@ -270,7 +279,7 @@ void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime,
using BeginEndIndicesMap = ::std::unordered_map<::profiler::thread_id_t, ::profiler::block_index_t,
::estd::hash<::profiler::thread_id_t> >;
void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _beginTime,
void TreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _beginTime,
const ::profiler_gui::TreeBlocks& _blocks,
::profiler::timestamp_t _left,
::profiler::timestamp_t _right,
@ -289,7 +298,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
BeginEndIndicesMap beginEndMap;
RootsMap threadsMap;
auto const setTree = (m_mode == EasyTreeMode_Full) ? &EasyTreeWidgetLoader::setTreeInternal : &EasyTreeWidgetLoader::setTreeInternalPlain;
auto const setTree = (m_mode == TreeMode::Full) ? &TreeWidgetLoader::setTreeInternal : &TreeWidgetLoader::setTreeInternalPlain;
const auto u_thread = ::profiler_gui::toUnicode("thread");
int i = 0, total = static_cast<int>(_blocks.size());
@ -309,7 +318,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
}
::profiler::timestamp_t duration = 0;
EasyTreeWidgetItem* thread_item = nullptr;
TreeWidgetItem* thread_item = nullptr;
::profiler::block_index_t& firstCswitch = beginEndMap[block.root->thread_id];
auto thread_item_it = threadsMap.find(block.root->thread_id);
if (thread_item_it != threadsMap.end())
@ -318,7 +327,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
}
else
{
thread_item = new EasyTreeWidgetItem();
thread_item = new TreeWidgetItem();
thread_item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, *block.root, u_thread, _hexThreadId));
if (!block.root->children.empty())
@ -376,7 +385,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
}
}
auto item = new EasyTreeWidgetItem(block.tree, thread_item);
auto item = new TreeWidgetItem(block.tree, thread_item);
duration = endTime - startTime;
auto name = *gui_block.tree.node->name() != 0 ? gui_block.tree.node->name() : easyDescriptor(gui_block.tree.node->id()).name();
@ -538,12 +547,12 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
//////////////////////////////////////////////////////////////////////////
size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot,
size_t TreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot,
::profiler::block_index_t _firstCswitch,
const ::profiler::timestamp_t& _beginTime,
const ::profiler::BlocksTree::children_t& _children,
EasyTreeWidgetItem* _parent,
EasyTreeWidgetItem* _frame,
TreeWidgetItem* _parent,
TreeWidgetItem* _frame,
::profiler::timestamp_t _left,
::profiler::timestamp_t _right,
bool _strict,
@ -551,7 +560,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
bool _addZeroBlocks,
::profiler_gui::TimeUnits _units)
{
auto const setTree = m_mode == EasyTreeMode_Full ? &EasyTreeWidgetLoader::setTreeInternal : &EasyTreeWidgetLoader::setTreeInternalPlain;
auto const setTree = m_mode == TreeMode::Full ? &TreeWidgetLoader::setTreeInternal : &TreeWidgetLoader::setTreeInternalPlain;
size_t total_items = 0;
for (auto child_index : _children)
@ -599,7 +608,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
}
}
auto item = new EasyTreeWidgetItem(child_index, _parent);
auto item = new TreeWidgetItem(child_index, _parent);
auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name();
item->setText(COL_NAME, ::profiler_gui::toUnicode(name));
@ -771,7 +780,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
//////////////////////////////////////////////////////////////////////////
::profiler::timestamp_t EasyTreeWidgetLoader::calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id)
::profiler::timestamp_t TreeWidgetLoader::calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id)
{
::profiler::timestamp_t total_duration = 0;
@ -789,12 +798,12 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
return total_duration;
}
size_t EasyTreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot,
size_t TreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot,
::profiler::block_index_t _firstCswitch,
const ::profiler::timestamp_t& _beginTime,
const ::profiler::BlocksTree::children_t& _children,
EasyTreeWidgetItem*,
EasyTreeWidgetItem* _frame,
TreeWidgetItem*,
TreeWidgetItem* _frame,
::profiler::timestamp_t _left,
::profiler::timestamp_t _right,
bool _strict,
@ -915,7 +924,7 @@ size_t EasyTreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRo
}
}
auto item = new EasyTreeWidgetItem(child_index, _frame);
auto item = new TreeWidgetItem(child_index, _frame);
auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name();
item->setText(COL_NAME, ::profiler_gui::toUnicode(name));

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of EasyTreeWidgetLoader which aim is
* description : The file contains declaration of TreeWidgetLoader which aim is
* : to load EasyProfiler blocks hierarchy in separate thread.
* ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp
@ -59,50 +59,50 @@
#include <stdlib.h>
#include <vector>
#include <thread>
#include <atomic>
#include <easy/reader.h>
#include "common_types.h"
#include "thread_pool_task.h"
//////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetItem;
class TreeWidgetItem;
#ifndef EASY_TREE_WIDGET__USE_VECTOR
using Items = ::std::unordered_map<::profiler::block_index_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::block_index_t> >;
using Items = ::std::unordered_map<profiler::block_index_t, TreeWidgetItem*, ::estd::hash<profiler::block_index_t> >;
#else
using Items = ::std::vector<EasyTreeWidgetItem*>;
using Items = ::std::vector<TreeWidgetItem*>;
#endif
using ThreadedItems = ::std::vector<::std::pair<::profiler::thread_id_t, EasyTreeWidgetItem*> >;
using RootsMap = ::std::unordered_map<::profiler::thread_id_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::thread_id_t> >;
using IdItems = ::std::unordered_map<::profiler::block_id_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::block_index_t> >;
using ThreadedItems = ::std::vector<::std::pair<profiler::thread_id_t, TreeWidgetItem*> >;
using RootsMap = ::std::unordered_map<profiler::thread_id_t, TreeWidgetItem*, ::estd::hash<profiler::thread_id_t> >;
using IdItems = ::std::unordered_map<profiler::block_id_t, TreeWidgetItem*, ::estd::hash<profiler::block_index_t> >;
//////////////////////////////////////////////////////////////////////////
enum EasyTreeMode : uint8_t
enum class TreeMode : uint8_t
{
EasyTreeMode_Full,
EasyTreeMode_Plain
Full,
Plain
};
//////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetLoader Q_DECL_FINAL
class TreeWidgetLoader Q_DECL_FINAL
{
ThreadedItems m_topLevelItems; ///<
Items m_items; ///<
IdItems m_iditems; ///<
::std::thread m_thread; ///<
::std::atomic_bool m_bDone; ///<
::std::atomic_bool m_bInterrupt; ///<
::std::atomic<int> m_progress; ///<
EasyTreeMode m_mode; ///<
ThreadPoolTask m_worker; ///<
std::atomic_bool m_bDone; ///<
std::atomic_bool m_bInterrupt; ///<
std::atomic<int> m_progress; ///<
TreeMode m_mode; ///<
public:
EasyTreeWidgetLoader();
~EasyTreeWidgetLoader();
TreeWidgetLoader();
~TreeWidgetLoader();
int progress() const;
bool done() const;
@ -111,8 +111,8 @@ public:
void takeItems(Items& _output);
void interrupt(bool _wait = false);
void fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, EasyTreeMode _mode);
void fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, EasyTreeMode _mode);
void fillTree(profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree, TreeMode _mode);
void fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _beginTime, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, TreeMode _mode);
private:
@ -120,14 +120,14 @@ private:
void setDone();
void setProgress(int _progress);
void setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
void setTreeInternal2(const ::profiler::timestamp_t& _beginTime, const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
size_t setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot, ::profiler::block_index_t _firstCswitch, const ::profiler::timestamp_t& _beginTime, const ::profiler::BlocksTree::children_t& _children, EasyTreeWidgetItem* _parent, EasyTreeWidgetItem* _frame, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
size_t setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot, ::profiler::block_index_t _firstCswitch, const ::profiler::timestamp_t& _beginTime, const ::profiler::BlocksTree::children_t& _children, EasyTreeWidgetItem* _parent, EasyTreeWidgetItem* _frame, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
void setTreeInternal1(profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
void setTreeInternal2(const profiler::timestamp_t& _beginTime, const ::profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
size_t setTreeInternal(const profiler::BlocksTreeRoot& _threadRoot, profiler::block_index_t _firstCswitch, const profiler::timestamp_t& _beginTime, const profiler::BlocksTree::children_t& _children, TreeWidgetItem* _parent, TreeWidgetItem* _frame, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
size_t setTreeInternalPlain(const profiler::BlocksTreeRoot& _threadRoot, profiler::block_index_t _firstCswitch, const profiler::timestamp_t& _beginTime, const profiler::BlocksTree::children_t& _children, TreeWidgetItem* _parent, TreeWidgetItem* _frame, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
::profiler::timestamp_t calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id);
profiler::timestamp_t calculateChildrenDurationRecursive(const profiler::BlocksTree::children_t& _children, profiler::block_id_t _id);
}; // END of class EasyTreeWidgetLoader.
}; // END of class TreeWidgetLoader.
//////////////////////////////////////////////////////////////////////////

View File

@ -5,17 +5,17 @@
#include "treeview_first_column_delegate.h"
#include "globals.h"
EasyTreeViewFirstColumnItemDelegate::EasyTreeViewFirstColumnItemDelegate(QObject* parent) : QStyledItemDelegate(parent)
TreeViewFirstColumnItemDelegate::TreeViewFirstColumnItemDelegate(QObject* parent) : QStyledItemDelegate(parent)
{
}
EasyTreeViewFirstColumnItemDelegate::~EasyTreeViewFirstColumnItemDelegate()
TreeViewFirstColumnItemDelegate::~TreeViewFirstColumnItemDelegate()
{
}
void EasyTreeViewFirstColumnItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
void TreeViewFirstColumnItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
// Draw item as usual
QStyledItemDelegate::paint(painter, option, index);

View File

@ -8,16 +8,16 @@
#include <QStyledItemDelegate>
class EasyTreeViewFirstColumnItemDelegate : public QStyledItemDelegate
class TreeViewFirstColumnItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit EasyTreeViewFirstColumnItemDelegate(QObject* parent = nullptr);
~EasyTreeViewFirstColumnItemDelegate() override;
explicit TreeViewFirstColumnItemDelegate(QObject* parent = nullptr);
~TreeViewFirstColumnItemDelegate() override;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
}; // END of class EasyTreeViewFirstColumnItemDelegate.
}; // END of class TreeViewFirstColumnItemDelegate.
#endif // EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H

View File

@ -175,7 +175,7 @@ void modellingThread(){
localSleep(1200000);
++step;
EASY_VALUE("step", step, profiler::colors::Gold);
EASY_VALUE("step", sin((double)step), profiler::colors::Gold, EASY_VIN(step));
if (step > 10000000)
step = 0;