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 Browsable {
17
18/** \class RItem
19\ingroup rbrowser
20\brief Representation of single item in the browser
21*/
22
23class RItem {
24protected:
25 std::string name; ///< item name
26 int nchilds{0}; ///< number of childs
27 std::string icon; ///< icon associated with item
28 std::string title; ///< item title
29 std::string fsize; ///< item size
30 std::string mtime; ///< modification time
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 const std::string &GetMTime() const { return mtime; }
45
46 virtual bool IsFolder() const { return nchilds != 0; }
47 virtual bool IsHidden() const { return false; }
48
49 void SetChecked(bool on = true) { checked = on; }
50 void SetExpanded(bool on = true) { expanded = on; }
51
52 void SetName(const std::string &_name) { name = _name; }
53 void SetTitle(const std::string &_title) { title = _title; }
54 void SetIcon(const std::string &_icon) { icon = _icon; }
55 void SetSize(const std::string &_size) { fsize = _size; }
56 void SetMTime(const std::string &_mtime) { mtime = _mtime; }
57
58 void SetSize(Long64_t _size)
59 {
60 if (_size > 4096) {
61 Long64_t _ksize = _size / 1024;
62 if (_ksize > 1024) {
63 // 3.7MB is more informative than just 3MB
64 fsize = std::to_string(_ksize/1024) + "." + std::to_string((_ksize%1024)/103) + "M";
65 } else {
66 fsize = std::to_string(_ksize) + "." + std::to_string((_size%1024)/103) + "K";
67 }
68 } else {
69 fsize = std::to_string(_size);
70 }
71 }
72
73 virtual bool Compare(const RItem *b, const std::string &) const
74 {
75 if (IsFolder() != b->IsFolder())
76 return IsFolder();
77 return GetName() < b->GetName();
78 }
79};
80
81} // namespace Browsable
82} // namespace ROOT
83
84#endif
85
86
#define b(i)
Definition RSha256.hxx:100
long long Long64_t
Definition RtypesCore.h:69
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Representation of single item in the browser.
Definition RItem.hxx:23
const std::string & GetMTime() const
Definition RItem.hxx:44
int nchilds
number of childs
Definition RItem.hxx:26
const std::string & GetIcon() const
Definition RItem.hxx:41
virtual bool Compare(const RItem *b, const std::string &) const
Definition RItem.hxx:73
virtual bool IsHidden() const
Definition RItem.hxx:47
const std::string & GetSize() const
Definition RItem.hxx:43
bool expanded
is expanded
Definition RItem.hxx:32
void SetSize(Long64_t _size)
Definition RItem.hxx:58
virtual ~RItem()=default
RItem(const std::string &_name, int _nchilds=0, const std::string &_icon="")
Definition RItem.hxx:36
void SetMTime(const std::string &_mtime)
Definition RItem.hxx:56
void SetChecked(bool on=true)
Definition RItem.hxx:49
bool checked
is checked, not yet used
Definition RItem.hxx:31
void SetIcon(const std::string &_icon)
Definition RItem.hxx:54
void SetTitle(const std::string &_title)
Definition RItem.hxx:53
const std::string & GetTitle() const
Definition RItem.hxx:42
virtual bool IsFolder() const
Definition RItem.hxx:46
void SetName(const std::string &_name)
Definition RItem.hxx:52
const std::string & GetName() const
Definition RItem.hxx:40
std::string fsize
item size
Definition RItem.hxx:29
void SetSize(const std::string &_size)
Definition RItem.hxx:55
std::string mtime
modification time
Definition RItem.hxx:30
std::string icon
icon associated with item
Definition RItem.hxx:27
std::string name
item name
Definition RItem.hxx:25
std::string title
item title
Definition RItem.hxx:28
void SetExpanded(bool on=true)
Definition RItem.hxx:50
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...