File indexing completed on 2025-01-30 10:22:19
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_Browsable_RItem
0010 #define ROOT7_Browsable_RItem
0011
0012 #include <string>
0013 #include "RtypesCore.h"
0014
0015 namespace ROOT {
0016 namespace Browsable {
0017
0018
0019
0020
0021
0022
0023 class RItem {
0024 protected:
0025 std::string name;
0026 int nchilds{0};
0027 std::string icon;
0028 std::string title;
0029 std::string fsize;
0030 std::string mtime;
0031 bool checked{false};
0032 bool expanded{false};
0033 public:
0034
0035 RItem() = default;
0036 RItem(const std::string &_name, int _nchilds = 0, const std::string &_icon = "") : name(_name), nchilds(_nchilds), icon(_icon) {}
0037
0038 virtual ~RItem() = default;
0039
0040 const std::string &GetName() const { return name; }
0041 const std::string &GetIcon() const { return icon; }
0042 const std::string &GetTitle() const { return title; }
0043 const std::string &GetSize() const { return fsize; }
0044 const std::string &GetMTime() const { return mtime; }
0045
0046 virtual bool IsFolder() const { return nchilds != 0; }
0047 virtual bool IsHidden() const { return false; }
0048
0049 void SetChecked(bool on = true) { checked = on; }
0050 void SetExpanded(bool on = true) { expanded = on; }
0051
0052 void SetName(const std::string &_name) { name = _name; }
0053 void SetTitle(const std::string &_title) { title = _title; }
0054 void SetIcon(const std::string &_icon) { icon = _icon; }
0055 void SetSize(const std::string &_size) { fsize = _size; }
0056 void SetMTime(const std::string &_mtime) { mtime = _mtime; }
0057
0058 void SetSize(Long64_t _size)
0059 {
0060 if (_size > 4096) {
0061 Long64_t _ksize = _size / 1024;
0062 if (_ksize > 1024) {
0063
0064 fsize = std::to_string(_ksize/1024) + "." + std::to_string((_ksize%1024)/103) + "M";
0065 } else {
0066 fsize = std::to_string(_ksize) + "." + std::to_string((_size%1024)/103) + "K";
0067 }
0068 } else {
0069 fsize = std::to_string(_size);
0070 }
0071 }
0072
0073 virtual bool Compare(const RItem *b, const std::string &) const
0074 {
0075 if (IsFolder() != b->IsFolder())
0076 return IsFolder();
0077 return GetName() < b->GetName();
0078 }
0079 };
0080
0081 }
0082 }
0083
0084 #endif
0085
0086