tree_widget_item.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /************************************************************************
  2. * file name : tree_widget_item.h
  3. * ----------------- :
  4. * creation time : 2016/08/18
  5. * author : Victor Zarubkin
  6. * email : [email protected]
  7. * ----------------- :
  8. * description : The file contains declaration of EasyTreeWidgetItem
  9. * : for displyaing EasyProfiler blocks tree.
  10. * ----------------- :
  11. * change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h
  12. * : and renamed classes from Prof* to Easy*.
  13. * :
  14. * : *
  15. * ----------------- :
  16. * license : Lightweight profiler library for c++
  17. * : Copyright(C) 2016-2017 Sergey Yagovtsev, Victor Zarubkin
  18. * :
  19. * : Licensed under either of
  20. * : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
  21. * : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  22. * : at your option.
  23. * :
  24. * : The MIT License
  25. * :
  26. * : Permission is hereby granted, free of charge, to any person obtaining a copy
  27. * : of this software and associated documentation files (the "Software"), to deal
  28. * : in the Software without restriction, including without limitation the rights
  29. * : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  30. * : of the Software, and to permit persons to whom the Software is furnished
  31. * : to do so, subject to the following conditions:
  32. * :
  33. * : The above copyright notice and this permission notice shall be included in all
  34. * : copies or substantial portions of the Software.
  35. * :
  36. * : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  37. * : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  38. * : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  39. * : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  40. * : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  41. * : USE OR OTHER DEALINGS IN THE SOFTWARE.
  42. * :
  43. * : The Apache License, Version 2.0 (the "License")
  44. * :
  45. * : You may not use this file except in compliance with the License.
  46. * : You may obtain a copy of the License at
  47. * :
  48. * : http://www.apache.org/licenses/LICENSE-2.0
  49. * :
  50. * : Unless required by applicable law or agreed to in writing, software
  51. * : distributed under the License is distributed on an "AS IS" BASIS,
  52. * : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  53. * : See the License for the specific language governing permissions and
  54. * : limitations under the License.
  55. ************************************************************************/
  56. #ifndef EASY_TREE_WIDGET_ITEM_H
  57. #define EASY_TREE_WIDGET_ITEM_H
  58. #include <stdlib.h>
  59. #include <QTreeWidget>
  60. #include <easy/reader.h>
  61. #include "common_types.h"
  62. //////////////////////////////////////////////////////////////////////////
  63. enum EasyColumnsIndexes
  64. {
  65. COL_UNKNOWN = -1,
  66. COL_NAME = 0,
  67. COL_BEGIN,
  68. COL_DURATION,
  69. COL_SELF_DURATION,
  70. COL_DURATION_SUM_PER_PARENT,
  71. COL_DURATION_SUM_PER_FRAME,
  72. COL_DURATION_SUM_PER_THREAD,
  73. COL_SELF_DURATION_PERCENT,
  74. COL_PERCENT_PER_PARENT,
  75. COL_PERCENT_PER_FRAME,
  76. COL_PERCENT_SUM_PER_PARENT,
  77. COL_PERCENT_SUM_PER_FRAME,
  78. COL_PERCENT_SUM_PER_THREAD,
  79. COL_END,
  80. COL_MIN_PER_FRAME,
  81. COL_MAX_PER_FRAME,
  82. COL_AVERAGE_PER_FRAME,
  83. COL_NCALLS_PER_FRAME,
  84. COL_MIN_PER_THREAD,
  85. COL_MAX_PER_THREAD,
  86. COL_AVERAGE_PER_THREAD,
  87. COL_NCALLS_PER_THREAD,
  88. COL_MIN_PER_PARENT,
  89. COL_MAX_PER_PARENT,
  90. COL_AVERAGE_PER_PARENT,
  91. COL_NCALLS_PER_PARENT,
  92. COL_ACTIVE_TIME,
  93. COL_ACTIVE_PERCENT,
  94. COL_COLUMNS_NUMBER
  95. };
  96. //////////////////////////////////////////////////////////////////////////
  97. class EasyTreeWidgetItem : public QTreeWidgetItem
  98. {
  99. typedef QTreeWidgetItem Parent;
  100. typedef EasyTreeWidgetItem This;
  101. const ::profiler::block_index_t m_block;
  102. QRgb m_customBGColor;
  103. QRgb m_customTextColor;
  104. public:
  105. using Parent::setBackgroundColor;
  106. using Parent::setTextColor;
  107. explicit EasyTreeWidgetItem(const ::profiler::block_index_t _treeBlock = ::profiler_gui::numeric_max<decltype(m_block)>(), Parent* _parent = nullptr);
  108. virtual ~EasyTreeWidgetItem();
  109. bool operator < (const Parent& _other) const override;
  110. public:
  111. ::profiler::block_index_t block_index() const;
  112. ::profiler_gui::EasyBlock& guiBlock();
  113. const ::profiler::BlocksTree& block() const;
  114. ::profiler::timestamp_t duration() const;
  115. ::profiler::timestamp_t selfDuration() const;
  116. void setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time, const QString& _prefix);
  117. void setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time);
  118. void setTimeMs(int _column, const ::profiler::timestamp_t& _time);
  119. void setTimeMs(int _column, const ::profiler::timestamp_t& _time, const QString& _prefix);
  120. void setBackgroundColor(QRgb _color);
  121. void setTextColor(QRgb _color);
  122. void colorize(bool _colorize);
  123. void collapseAll();
  124. void expandAll();
  125. }; // END of class EasyTreeWidgetItem.
  126. //////////////////////////////////////////////////////////////////////////
  127. #endif // EASY_TREE_WIDGET_ITEM_H