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 std::string mtime; ///< modification time
32 bool checked{false}; ///< is checked, not yet used
33 bool expanded{false}; ///< is expanded
34public:
35
36 RItem() = default;
37 RItem(const std::string &_name, int _nchilds = 0, const std::string &_icon = "") : name(_name), nchilds(_nchilds), icon(_icon) {}
38 // must be here, one needs virtual table for correct streaming of sub-classes
39 virtual ~RItem() = default;
40
41 const std::string &GetName() const { return name; }
42 const std::string &GetIcon() const { return icon; }
43 const std::string &GetTitle() const { return title; }
44 const std::string &GetSize() const { return fsize; }
45 const std::string &GetMTime() const { return mtime; }
46
47 virtual bool IsFolder() const { return nchilds != 0; }
48 virtual bool IsHidden() const { return false; }
49
50 void SetChecked(bool on = true) { checked = on; }
51 void SetExpanded(bool on = true) { expanded = on; }
52
53 void SetName(const std::string &_name) { name = _name; }
54 void SetTitle(const std::string &_title) { title = _title; }
55 void SetIcon(const std::string &_icon) { icon = _icon; }
56 void SetSize(const std::string &_size) { fsize = _size; }
57 void SetMTime(const std::string &_mtime) { mtime = _mtime; }
58
59 void SetSize(Long64_t _size)
60 {
61 if (_size > 4096) {
62 Long64_t _ksize = _size / 1024;
63 if (_ksize > 1024) {
64 // 3.7MB is more informative than just 3MB
65 fsize = std::to_string(_ksize/1024) + "." + std::to_string((_ksize%1024)/103) + "M";
66 } else {
67 fsize = std::to_string(_ksize) + "." + std::to_string((_size%1024)/103) + "K";
68 }
69 } else {
70 fsize = std::to_string(_size);
71 }
72 }
73
74 virtual bool Compare(const RItem *b, const std::string &) const
75 {
76 if (IsFolder() != b->IsFolder())
77 return IsFolder();
78 return GetName() < b->GetName();
79 }
80};
81
82} // namespace Browsable
83} // namespace Experimental
84} // namespace ROOT
85
86#endif
87
88
#define b(i)
Definition RSha256.hxx:100
long long Long64_t
Definition RtypesCore.h:80
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:24
std::string name
item name
Definition RItem.hxx:26
virtual bool IsHidden() const
Definition RItem.hxx:48
const std::string & GetIcon() const
Definition RItem.hxx:42
int nchilds
number of childs
Definition RItem.hxx:27
void SetName(const std::string &_name)
Definition RItem.hxx:53
RItem(const std::string &_name, int _nchilds=0, const std::string &_icon="")
Definition RItem.hxx:37
bool checked
is checked, not yet used
Definition RItem.hxx:32
virtual bool Compare(const RItem *b, const std::string &) const
Definition RItem.hxx:74
std::string fsize
item size
Definition RItem.hxx:30
std::string icon
icon associated with item
Definition RItem.hxx:28
void SetMTime(const std::string &_mtime)
Definition RItem.hxx:57
void SetSize(Long64_t _size)
Definition RItem.hxx:59
std::string title
item title
Definition RItem.hxx:29
std::string mtime
modification time
Definition RItem.hxx:31
void SetTitle(const std::string &_title)
Definition RItem.hxx:54
const std::string & GetName() const
Definition RItem.hxx:41
virtual bool IsFolder() const
Definition RItem.hxx:47
void SetSize(const std::string &_size)
Definition RItem.hxx:56
const std::string & GetMTime() const
Definition RItem.hxx:45
const std::string & GetSize() const
Definition RItem.hxx:44
void SetExpanded(bool on=true)
Definition RItem.hxx:51
const std::string & GetTitle() const
Definition RItem.hxx:43
void SetIcon(const std::string &_icon)
Definition RItem.hxx:55
void SetChecked(bool on=true)
Definition RItem.hxx:50
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.