2016-08-18 23:26:41 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : tree_widget_item.h
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/08/18
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
2018-01-28 20:52:17 +03:00
|
|
|
* description : The file contains declaration of TreeWidgetItem
|
2016-08-18 23:26:41 +03:00
|
|
|
* : for displyaing EasyProfiler blocks tree.
|
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h
|
|
|
|
* : and renamed classes from Prof* to Easy*.
|
|
|
|
* :
|
|
|
|
* : *
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* license : Lightweight profiler library for c++
|
2019-10-20 16:12:37 +03:00
|
|
|
* : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin
|
2016-09-06 21:49:32 +03:00
|
|
|
* :
|
2017-03-30 06:14:23 +03:00
|
|
|
* : Licensed under either of
|
|
|
|
* : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
|
|
|
|
* : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
* : at your option.
|
2016-11-13 16:39:59 +03:00
|
|
|
* :
|
2017-03-30 06:14:23 +03:00
|
|
|
* : The MIT License
|
|
|
|
* :
|
|
|
|
* : Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* : of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* : in the Software without restriction, including without limitation the rights
|
|
|
|
* : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* : of the Software, and to permit persons to whom the Software is furnished
|
|
|
|
* : to do so, subject to the following conditions:
|
|
|
|
* :
|
|
|
|
* : The above copyright notice and this permission notice shall be included in all
|
|
|
|
* : copies or substantial portions of the Software.
|
|
|
|
* :
|
|
|
|
* : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
|
|
* : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
|
|
* : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
* : USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
* :
|
|
|
|
* : The Apache License, Version 2.0 (the "License")
|
|
|
|
* :
|
|
|
|
* : You may not use this file except in compliance with the License.
|
2016-11-13 16:39:59 +03:00
|
|
|
* : You may obtain a copy of the License at
|
|
|
|
* :
|
|
|
|
* : http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* :
|
|
|
|
* : Unless required by applicable law or agreed to in writing, software
|
|
|
|
* : distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* : See the License for the specific language governing permissions and
|
|
|
|
* : limitations under the License.
|
2016-08-18 23:26:41 +03:00
|
|
|
************************************************************************/
|
|
|
|
|
2017-03-05 22:59:03 +03:00
|
|
|
#ifndef EASY_TREE_WIDGET_ITEM_H
|
|
|
|
#define EASY_TREE_WIDGET_ITEM_H
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QTreeWidget>
|
2017-11-27 22:02:15 +03:00
|
|
|
#include <QStyledItemDelegate>
|
2017-03-05 23:50:38 +03:00
|
|
|
#include <easy/reader.h>
|
|
|
|
|
2017-12-07 22:36:53 +03:00
|
|
|
#include "common_functions.h"
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
class BlocksTreeWidget;
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-10-24 19:21:31 +03:00
|
|
|
EASY_CONSTEXPR int COLUMNS_VERSION = 3;
|
|
|
|
EASY_CONSTEXPR int BlockColorRole = Qt::UserRole + 1;
|
|
|
|
EASY_CONSTEXPR int MinMaxBlockIndexRole = Qt::UserRole + 2;
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
enum EasyColumnsIndexes
|
|
|
|
{
|
|
|
|
COL_UNKNOWN = -1,
|
|
|
|
|
|
|
|
COL_NAME = 0,
|
|
|
|
|
|
|
|
COL_BEGIN,
|
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_TIME,
|
|
|
|
COL_SELF_TIME,
|
|
|
|
COL_SELF_TIME_PERCENT,
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
COL_END,
|
|
|
|
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_PERCENT_PER_FRAME,
|
|
|
|
COL_TOTAL_TIME_PER_FRAME,
|
|
|
|
COL_PERCENT_SUM_PER_FRAME,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_MIN_PER_FRAME,
|
|
|
|
COL_MAX_PER_FRAME,
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_AVG_PER_FRAME,
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_MEDIAN_PER_FRAME,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_NCALLS_PER_FRAME,
|
|
|
|
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_TOTAL_TIME_PER_THREAD,
|
|
|
|
COL_PERCENT_SUM_PER_THREAD,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_MIN_PER_THREAD,
|
|
|
|
COL_MAX_PER_THREAD,
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_AVG_PER_THREAD,
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_MEDIAN_PER_THREAD,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_NCALLS_PER_THREAD,
|
|
|
|
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_PERCENT_PER_PARENT,
|
|
|
|
COL_TOTAL_TIME_PER_PARENT,
|
|
|
|
COL_PERCENT_SUM_PER_PARENT,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_MIN_PER_PARENT,
|
|
|
|
COL_MAX_PER_PARENT,
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_AVG_PER_PARENT,
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_MEDIAN_PER_PARENT,
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_NCALLS_PER_PARENT,
|
|
|
|
|
2016-12-18 17:59:41 +03:00
|
|
|
COL_ACTIVE_TIME,
|
|
|
|
COL_ACTIVE_PERCENT,
|
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_PERCENT_PER_AREA,
|
|
|
|
COL_TOTAL_TIME_PER_AREA,
|
|
|
|
COL_PERCENT_SUM_PER_AREA,
|
|
|
|
COL_MIN_PER_AREA,
|
|
|
|
COL_MAX_PER_AREA,
|
|
|
|
COL_AVG_PER_AREA,
|
2019-10-24 19:21:31 +03:00
|
|
|
COL_MEDIAN_PER_AREA,
|
2019-10-20 16:12:37 +03:00
|
|
|
COL_NCALLS_PER_AREA,
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
COL_COLUMNS_NUMBER
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-01-28 20:52:17 +03:00
|
|
|
class TreeWidgetItem : public QTreeWidgetItem
|
2016-08-18 23:26:41 +03:00
|
|
|
{
|
2017-12-04 20:29:22 +03:00
|
|
|
using Parent = QTreeWidgetItem;
|
2018-01-28 20:52:17 +03:00
|
|
|
using This = TreeWidgetItem;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2018-03-26 21:38:41 +03:00
|
|
|
const profiler::block_index_t m_block;
|
2016-08-18 23:26:41 +03:00
|
|
|
QRgb m_customBGColor;
|
2017-11-27 22:02:15 +03:00
|
|
|
bool m_bMain;
|
2019-10-20 16:12:37 +03:00
|
|
|
bool m_partial;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
explicit TreeWidgetItem(profiler::block_index_t _treeBlock = profiler_gui::numeric_max<decltype(m_block)>()
|
2018-05-19 23:41:01 +03:00
|
|
|
, Parent* _parent = nullptr);
|
|
|
|
|
2018-02-01 23:17:01 +03:00
|
|
|
~TreeWidgetItem() override;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
bool operator < (const Parent& _other) const override;
|
2017-11-27 22:02:15 +03:00
|
|
|
QVariant data(int _column, int _role) const override;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
bool isPartial() const;
|
2018-02-01 23:17:01 +03:00
|
|
|
profiler::block_index_t block_index() const;
|
|
|
|
profiler_gui::EasyBlock& guiBlock();
|
|
|
|
const profiler::BlocksTree& block() const;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
profiler::thread_id_t threadId() const;
|
|
|
|
|
2018-02-01 23:17:01 +03:00
|
|
|
void setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time, const QString& _prefix);
|
|
|
|
void setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time);
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2018-02-01 23:17:01 +03:00
|
|
|
void setTimeMs(int _column, const profiler::timestamp_t& _time);
|
|
|
|
void setTimeMs(int _column, const profiler::timestamp_t& _time, const QString& _prefix);
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
void setBackgroundColor(QRgb _color);
|
|
|
|
|
2017-11-27 22:02:15 +03:00
|
|
|
void setMain(bool _main);
|
2019-10-20 16:12:37 +03:00
|
|
|
void setPartial(bool partial);
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
void collapseAll();
|
|
|
|
|
|
|
|
void expandAll();
|
|
|
|
|
2017-11-27 22:02:15 +03:00
|
|
|
private:
|
|
|
|
|
2019-10-24 19:21:31 +03:00
|
|
|
//void setHasToolTip(int _column);
|
2019-10-20 16:12:37 +03:00
|
|
|
QVariant relevantData(int _column, int _role) const;
|
|
|
|
QVariant partialForeground() const;
|
2017-11-27 22:02:15 +03:00
|
|
|
|
2018-01-28 20:52:17 +03:00
|
|
|
}; // END of class TreeWidgetItem.
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-02-01 23:17:01 +03:00
|
|
|
class TreeWidgetItemDelegate : public QStyledItemDelegate
|
2017-11-27 22:02:15 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-10-20 16:12:37 +03:00
|
|
|
BlocksTreeWidget* m_treeWidget;
|
2017-11-27 22:02:15 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-10-20 16:12:37 +03:00
|
|
|
explicit TreeWidgetItemDelegate(BlocksTreeWidget* parent = nullptr);
|
2018-02-01 23:17:01 +03:00
|
|
|
~TreeWidgetItemDelegate() override;
|
2017-11-27 22:02:15 +03:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
2019-10-20 16:12:37 +03:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void highlightMatchingText(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
|
|
|
|
|
|
|
void highlightMatchingText(
|
|
|
|
QPainter* painter,
|
|
|
|
const QStyleOptionViewItem& option,
|
|
|
|
const QString& text,
|
|
|
|
const QString& pattern,
|
|
|
|
Qt::CaseSensitivity caseSensitivity,
|
|
|
|
bool current
|
|
|
|
) const;
|
2017-11-27 22:02:15 +03:00
|
|
|
|
2018-02-01 23:17:01 +03:00
|
|
|
}; // END of class TreeWidgetItemDelegate.
|
2017-11-27 22:02:15 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-03-05 22:59:03 +03:00
|
|
|
#endif // EASY_TREE_WIDGET_ITEM_H
|