Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RItem.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_Browsable_RItem
10#define ROOT7_Browsable_RItem
11
12#include <string>
13#include "RtypesCore.h"
14
15namespace ROOT {
16namespace Experimental {
17namespace Browsable {
18
19/** \class RItem
20\ingroup rbrowser
21\brief Representation of single item in the browser
22*/
23
24class RItem {
25protected:
26 std::string name; ///< item name
27 int nchilds{0}; ///< number of childs
28 std::string icon; ///< icon associated with item
29 std::string title; ///< item title
30 std::string fsize; ///< item size
31 bool checked{false}; ///< is checked, not yet used
32 bool expanded{false}; ///< is expanded
33public:
34
35 RItem() = default;
36 RItem(const std::string &_name, int _nchilds = 0, const std::string &_icon = "") : name(_name), nchilds(_nchilds), icon(_icon) {}
37 // must be here, one needs virtual table for correct streaming of sub-classes
38 virtual ~RItem() = default;
39
40 const std::string &GetName() const { return name; }
41 const std::string &GetIcon() const { return icon; }
42 const std::string &GetTitle() const { return title; }
43 const std::string &GetSize() const { return fsize; }
44 virtual bool IsFolder() const { return nchilds != 0; }
45 virtual bool IsHidden() const { return false; }
46
47 void SetChecked(bool on = true) { checked = on; }
48 void SetExpanded(bool on = true) { expanded = on; }
49
50 void SetName(const std::string &_name) { name = _name; }
51 void SetTitle(const std::string &_title) { title = _title; }
52 void SetIcon(const std::string &_icon) { icon = _icon; }
53 void SetSize(const std::string &_size) { fsize = _size; }
54
55 void SetSize(Long64_t _size)
56 {
57 if (_size > 1024) {
58 Long64_t _ksize = _size / 1024;
59 if (_ksize > 1024) {
60 // 3.7MB is more informative than just 3MB
61 fsize = std::to_string(_ksize/1024) + "." + std::to_string((_ksize%1024)/103) + "M";
62 } else {
63 fsize = std::to_string(_ksize) + "." + std::to_string((_size%1024)/103) + "K";
64 }
65 } else {
66 fsize = std::to_string(_size);
67 }
68 }
69
70 virtual bool Compare(const RItem *b, const std::string &) const
71 {
72 if (IsFolder() != b->IsFolder())
73 return IsFolder();
74 return GetName() < b->GetName();
75 }
76};
77
78
79} // namespace Browsable
80} // namespace Experimental
81} // namespace ROOT
82
83#endif
84
85
#define b(i)
Definition RSha256.hxx:100
long long Long64_t
Definition RtypesCore.h:80
Representation of single item in the browser.
Definition RItem.hxx:24
std::string name
item name
Definition RItem.hxx:26
virtual bool IsHidden() const
Definition RItem.hxx:45
const std::string & GetIcon() const
Definition RItem.hxx:41
int nchilds
number of childs
Definition RItem.hxx:27
void SetName(const std::string &_name)
Definition RItem.hxx:50
RItem(const std::string &_name, int _nchilds=0, const std::string &_icon="")
Definition RItem.hxx:36
bool checked
is checked, not yet used
Definition RItem.hxx:31
virtual bool Compare(const RItem *b, const std::string &) const
Definition RItem.hxx:70
std::string fsize
item size
Definition RItem.hxx:30
std::string icon
icon associated with item
Definition RItem.hxx:28
void SetSize(Long64_t _size)
Definition RItem.hxx:55
std::string title
item title
Definition RItem.hxx:29
void SetTitle(const std::string &_title)
Definition RItem.hxx:51
const std::string & GetName() const
Definition RItem.hxx:40
virtual bool IsFolder() const
Definition RItem.hxx:44
void SetSize(const std::string &_size)
Definition RItem.hxx:53
const std::string & GetSize() const
Definition RItem.hxx:43
void SetExpanded(bool on=true)
Definition RItem.hxx:48
const std::string & GetTitle() const
Definition RItem.hxx:42
void SetIcon(const std::string &_icon)
Definition RItem.hxx:52
void SetChecked(bool on=true)
Definition RItem.hxx:47
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...