mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
c6fb0bfeb9
@ -17,6 +17,7 @@ add_executable(${PROJECT_NAME}
|
||||
blocks_tree_widget.cpp
|
||||
globals.h
|
||||
globals.cpp
|
||||
globals_qobjects.cpp
|
||||
graphics_scrollbar.h
|
||||
graphics_scrollbar.cpp
|
||||
main_window.h
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <algorithm>
|
||||
#include "blocks_graphics_view.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
using namespace profiler_gui;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -310,7 +312,7 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
_painter->setPen(BORDERS_COLOR); // restore pen for rectangle painting
|
||||
}
|
||||
|
||||
if (next_level < levelsNumber && item.children_begin != -1)
|
||||
if (next_level < levelsNumber && item.children_begin != NEGATIVE_ONE)
|
||||
{
|
||||
// Mark that we would not paint children of current item
|
||||
m_levels[next_level][item.children_begin].state = -1;
|
||||
@ -319,9 +321,9 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
continue;
|
||||
}
|
||||
|
||||
if (next_level < levelsNumber && item.children_begin != -1)
|
||||
if (next_level < levelsNumber && item.children_begin != NEGATIVE_ONE)
|
||||
{
|
||||
if (m_levelsIndexes[next_level] == -1)
|
||||
if (m_levelsIndexes[next_level] == NEGATIVE_ONE)
|
||||
{
|
||||
// Mark first potentially visible child item on next sublevel
|
||||
m_levelsIndexes[next_level] = item.children_begin;
|
||||
@ -568,7 +570,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
||||
return &item;
|
||||
}
|
||||
|
||||
if (item.children_begin == -1)
|
||||
if (item.children_begin == NEGATIVE_ONE)
|
||||
{
|
||||
if (itemIndex != 0)
|
||||
{
|
||||
@ -578,7 +580,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
||||
|
||||
--j;
|
||||
const auto& item2 = level[j];
|
||||
if (item2.children_begin != -1)
|
||||
if (item2.children_begin != NEGATIVE_ONE)
|
||||
{
|
||||
firstItem = item2.children_begin;
|
||||
break;
|
||||
@ -600,7 +602,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
||||
for (auto j = itemIndex + 1; j < size; ++j)
|
||||
{
|
||||
const auto& item2 = level[j];
|
||||
if (item2.children_begin != -1)
|
||||
if (item2.children_begin != NEGATIVE_ONE)
|
||||
{
|
||||
lastItem = item2.children_begin;
|
||||
break;
|
||||
@ -1629,7 +1631,8 @@ void ProfGraphicsView::mouseMoveEvent(QMouseEvent* _event)
|
||||
auto vbar = verticalScrollBar();
|
||||
|
||||
m_bUpdatingRect = true; // Block scrollbars from updating scene rect to make it possible to do it only once
|
||||
vbar->setValue(vbar->value() - delta.y());
m_pScrollbar->setValue(m_pScrollbar->value() - delta.x() / m_scale);
|
||||
vbar->setValue(vbar->value() - delta.y());
|
||||
m_pScrollbar->setValue(m_pScrollbar->value() - delta.x() / m_scale);
|
||||
m_bUpdatingRect = false;
|
||||
// Seems like an ugly stub, but QSignalBlocker is also a bad decision
|
||||
// because if scrollbar does not emit valueChanged signal then viewport does not move
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "graphics_scrollbar.h"
|
||||
#include "profiler/reader.h"
|
||||
#include "common_types.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include "blocks_tree_widget.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -834,7 +835,7 @@ void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
case COL_MAX_PER_PARENT:
|
||||
case COL_MAX_PER_FRAME:
|
||||
{
|
||||
unsigned int i = -1;
|
||||
unsigned int i = NEGATIVE_ONE;
|
||||
switch (col)
|
||||
{
|
||||
case COL_MIN_PER_THREAD: i = item->block()->per_thread_stats->min_duration_block; break;
|
||||
@ -845,7 +846,7 @@ void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
||||
case COL_MAX_PER_FRAME: i = item->block()->per_frame_stats->max_duration_block; break;
|
||||
}
|
||||
|
||||
if (i != -1)
|
||||
if (i != NEGATIVE_ONE)
|
||||
{
|
||||
menu.addSeparator();
|
||||
itemAction = new ProfItemAction("Jump to such item", i);
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <vector>
|
||||
#include "profiler/reader.h"
|
||||
#include "common_types.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -15,21 +15,15 @@
|
||||
* license : TODO: add license text
|
||||
************************************************************************/
|
||||
|
||||
#define IGNORE_GLOBALS_DECLARATION
|
||||
#include "globals.h"
|
||||
#undef IGNORE_GLOBALS_DECLARATION
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace profiler_gui {
|
||||
|
||||
ProfGlobalSignals::ProfGlobalSignals() : QObject()
|
||||
{
|
||||
}
|
||||
|
||||
ProfGlobalSignals::~ProfGlobalSignals()
|
||||
{
|
||||
}
|
||||
|
||||
ProfGlobals& ProfGlobals::instance()
|
||||
{
|
||||
static ProfGlobals globals;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QObject>
|
||||
#include <QColor>
|
||||
#include "common_types.h"
|
||||
#include "globals_qobjects.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -29,6 +30,8 @@
|
||||
class ProfGraphicsItem;
|
||||
class ProfTreeWidgetItem;
|
||||
|
||||
const unsigned int NEGATIVE_ONE = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace profiler_gui {
|
||||
@ -43,23 +46,6 @@ namespace profiler_gui {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ProfGlobalSignals final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ProfGlobalSignals();
|
||||
virtual ~ProfGlobalSignals();
|
||||
|
||||
signals:
|
||||
|
||||
void selectedThreadChanged(::profiler::thread_id_t _id);
|
||||
void selectedBlockChanged(unsigned int _block_index);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct ProfBlock final
|
||||
{
|
||||
ProfGraphicsItem* graphics_item;
|
||||
@ -87,9 +73,9 @@ namespace profiler_gui {
|
||||
|
||||
ProfGlobals();
|
||||
};
|
||||
|
||||
#ifndef IGNORE_GLOBALS_DECLARATION
|
||||
static ProfGlobals& EASY_GLOBALS = ProfGlobals::instance();
|
||||
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // END of namespace profiler_gui.
|
||||
|
35
profiler_gui/globals_qobjects.cpp
Normal file
35
profiler_gui/globals_qobjects.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/************************************************************************
|
||||
* file name : globals_qobjects.cpp
|
||||
* ----------------- :
|
||||
* creation time : 2016/08/08
|
||||
* copyright : (c) 2016 Victor Zarubkin, Sergey Yagovtsev
|
||||
* author : Victor Zarubkin
|
||||
* email : v.s.zarubkin@gmail.com
|
||||
* ----------------- :
|
||||
* description : The file contains implementation of ProfGlobalSignals QObject class.
|
||||
* ----------------- :
|
||||
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp
|
||||
* :
|
||||
* : *
|
||||
* ----------------- :
|
||||
* license : TODO: add license text
|
||||
************************************************************************/
|
||||
|
||||
#include "globals_qobjects.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace profiler_gui {
|
||||
|
||||
ProfGlobalSignals::ProfGlobalSignals() : QObject()
|
||||
{
|
||||
}
|
||||
|
||||
ProfGlobalSignals::~ProfGlobalSignals()
|
||||
{
|
||||
}
|
||||
|
||||
} // END of namespace profiler_gui.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
25
profiler_gui/globals_qobjects.h
Normal file
25
profiler_gui/globals_qobjects.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef GLOBALS_QOBJECTS_H
|
||||
#define GLOBALS_QOBJECTS_H
|
||||
|
||||
#include <QObject>
|
||||
#include "profiler/profiler.h"
|
||||
|
||||
namespace profiler_gui {
|
||||
class ProfGlobalSignals final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ProfGlobalSignals();
|
||||
virtual ~ProfGlobalSignals();
|
||||
|
||||
signals:
|
||||
|
||||
void selectedThreadChanged(::profiler::thread_id_t _id);
|
||||
void selectedBlockChanged(unsigned int _block_index);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLOBALS_QOBJECTS_H
|
@ -22,6 +22,7 @@
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include "graphics_scrollbar.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QAction>
|
||||
#include "common_types.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "main_window.h"
|
||||
#include "blocks_tree_widget.h"
|
||||
#include "blocks_graphics_view.h"
|
||||
#include "globals.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user