Public Member Functions | Private Member Functions | Private Attributes | List of all members
dbutils::gui::NamedConfigDataModel Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-25/DatabaseUtils/cxx/include/GUI/NamedConfigDataModel.h"

Inheritance diagram for dbutils::gui::NamedConfigDataModel:

Public Member Functions

 NamedConfigDataModel (QObject *parent=0)
 
virtual ~NamedConfigDataModel ()
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
virtual QModelIndex parent (const QModelIndex &index) const
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
 
virtual void loadData (dbutils::daqconfig::NamedConfigUtils::GlobalNameSpecMap nameSpecMap)
 

Private Member Functions

TreeItem_getItem (const QModelIndex &index) const
 

Private Attributes

boost::shared_ptr< TreeItem_rootItem
 

Detailed Description

Author
Kurt Biery
Version
Revision
1.1.24.1
Date
2019/09/27 00:07:04

Definition at line 21 of file NamedConfigDataModel.h.

Constructor & Destructor Documentation

dbutils::gui::NamedConfigDataModel::NamedConfigDataModel ( QObject *  parent = 0)

Definition at line 9 of file NamedConfigDataModel.cpp.

References loadData().

9  : QAbstractItemModel(parent)
10 {
11 }
virtual QModelIndex parent(const QModelIndex &index) const
virtual dbutils::gui::NamedConfigDataModel::~NamedConfigDataModel ( )
inlinevirtual

Member Function Documentation

TreeItem * dbutils::gui::NamedConfigDataModel::_getItem ( const QModelIndex &  index) const
private

Definition at line 129 of file NamedConfigDataModel.cpp.

References _rootItem.

Referenced by data(), index(), parent(), rowCount(), and ~NamedConfigDataModel().

130 {
131  if (index.isValid()) {
132  TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
133  if (item) return item;
134  }
135  return _rootItem.get();
136 }
boost::shared_ptr< TreeItem > _rootItem
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
int dbutils::gui::NamedConfigDataModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 52 of file NamedConfigDataModel.cpp.

References _rootItem.

Referenced by dbutils::gui::NamedConfigTree::loadData(), and ~NamedConfigDataModel().

53 {
54  return _rootItem->columnCount();
55 }
boost::shared_ptr< TreeItem > _rootItem
QVariant dbutils::gui::NamedConfigDataModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 57 of file NamedConfigDataModel.cpp.

References _getItem(), and dbutils::gui::TreeItem::data().

Referenced by dbutils::gui::NamedConfigTree::getSelectedConfigName(), dbutils::gui::NamedConfigTree::getSelectedDCMOpMode(), dbutils::gui::NamedConfigTree::getSelectedTime(), and ~NamedConfigDataModel().

58 {
59  if (!index.isValid()) {return QVariant();}
60 
61  if (role != Qt::DisplayRole && role != Qt::EditRole)
62  return QVariant();
63 
64  TreeItem *item = _getItem(index);
65 
66  return item->data(index.column());
67 }
TreeItem * _getItem(const QModelIndex &index) const
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QVariant dbutils::gui::NamedConfigDataModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 106 of file NamedConfigDataModel.cpp.

References _rootItem.

Referenced by rowCount(), and ~NamedConfigDataModel().

107 {
108  if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
109  return _rootItem->data(section);
110 
111  return QVariant();
112 }
boost::shared_ptr< TreeItem > _rootItem
QModelIndex dbutils::gui::NamedConfigDataModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual

Definition at line 69 of file NamedConfigDataModel.cpp.

References _getItem(), and dbutils::gui::TreeItem::child().

Referenced by dbutils::gui::NamedConfigTree::loadData(), and ~NamedConfigDataModel().

71 {
72  if (parent.isValid() && parent.column() != 0) {
73  return QModelIndex();
74  }
75 
76  TreeItem *parentItem = _getItem(parent);
77 
78  TreeItem *childItem = parentItem->child(row);
79  if (childItem)
80  return createIndex(row, column, childItem);
81  else
82  return QModelIndex();
83 }
TreeItem * _getItem(const QModelIndex &index) const
virtual QModelIndex parent(const QModelIndex &index) const
void dbutils::gui::NamedConfigDataModel::loadData ( dbutils::daqconfig::NamedConfigUtils::GlobalNameSpecMap  nameSpecMap)
virtual

Definition at line 14 of file NamedConfigDataModel.cpp.

References _rootItem, dbutils::gui::TreeItem::child(), dbutils::gui::TreeItem::childCount(), dbutils::gui::TreeItem::columnCount(), compare_h5_caf::idx, dbutils::gui::TreeItem::insertChildren(), makeTrainCVSamples::int, and dbutils::gui::TreeItem::setData().

Referenced by dbutils::gui::NamedConfigTree::loadData(), NamedConfigDataModel(), and ~NamedConfigDataModel().

15 {
16  QVector<QVariant> rootData;
17  rootData << "Configuration Name";
18  rootData << "DCM Operating Mode";
19  rootData << "Time";
20 
21  if (_rootItem.get() != 0) {
22  QModelIndex dummyIndex;
23  this->removeRows(0, _rootItem->childCount(), dummyIndex);
24  }
25  _rootItem.reset(new TreeItem(rootData));
26 
27  NamedConfigUtils::GlobalNameSpecMap::const_iterator iter;
28  NamedConfigUtils::GlobalNameSpecMap::const_iterator iterEnd =
29  nameSpecMap.end();
30  for (iter = nameSpecMap.begin(); iter != iterEnd; ++iter) {
31  int newChildIndex = _rootItem->childCount();
32  _rootItem->insertChildren(newChildIndex, 1, _rootItem->columnCount());
33  TreeItem* thisItem = _rootItem->child(newChildIndex);
34 
35  thisItem->setData(0, QVariant((*iter).first.getConfigName().c_str()));
36  thisItem->setData(1, QVariant((*iter).first.getDCMOpMode().c_str()));
37  thisItem->setData(2, QVariant(NamedConfigUtils::LATEST_TIME_STRING.c_str()));
38 
39  std::vector<GlobalNameSpec> detailsList = (*iter).second;
40  for (int idx = 0; idx < (int) detailsList.size(); ++idx) {
41  newChildIndex = thisItem->childCount();
42  thisItem->insertChildren(newChildIndex,1,thisItem->columnCount());
43  TreeItem* childItem = thisItem->child(newChildIndex);
44 
45  childItem->setData(0, QVariant(detailsList[idx].getConfigName().c_str()));
46  childItem->setData(1, QVariant(detailsList[idx].getDCMOpMode().c_str()));
47  childItem->setData(2, QVariant(detailsList[idx].getTimestamp().c_str()));
48  }
49  }
50 }
boost::shared_ptr< TreeItem > _rootItem
QModelIndex dbutils::gui::NamedConfigDataModel::parent ( const QModelIndex &  index) const
virtual

Definition at line 85 of file NamedConfigDataModel.cpp.

References _getItem(), _rootItem, dbutils::gui::TreeItem::childNumber(), and dbutils::gui::TreeItem::parent().

Referenced by ~NamedConfigDataModel().

86 {
87  if (!index.isValid()) {return QModelIndex();}
88 
89  TreeItem *childItem = _getItem(index);
90  TreeItem *parentItem = childItem->parent();
91 
92  if (parentItem == _rootItem.get())
93  return QModelIndex();
94 
95  return createIndex(parentItem->childNumber(), 0, parentItem);
96 }
TreeItem * _getItem(const QModelIndex &index) const
boost::shared_ptr< TreeItem > _rootItem
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
int dbutils::gui::NamedConfigDataModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 98 of file NamedConfigDataModel.cpp.

References _getItem(), dbutils::gui::TreeItem::childCount(), and headerData().

Referenced by ~NamedConfigDataModel().

99 {
100  TreeItem *parentItem = _getItem(parent);
101 
102  return parentItem->childCount();
103 }
TreeItem * _getItem(const QModelIndex &index) const
virtual QModelIndex parent(const QModelIndex &index) const
bool dbutils::gui::NamedConfigDataModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant &  value,
int  role = Qt::EditRole 
)
virtual

Definition at line 114 of file NamedConfigDataModel.cpp.

References _rootItem, and fillBadChanDBTables::result.

Referenced by ~NamedConfigDataModel().

117 {
118  if (role != Qt::EditRole || orientation != Qt::Horizontal)
119  return false;
120 
121  bool result = _rootItem->setData(section, value);
122 
123  if (result)
124  emit headerDataChanged(orientation, section, section);
125 
126  return result;
127 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
boost::shared_ptr< TreeItem > _rootItem

Member Data Documentation

boost::shared_ptr<TreeItem> dbutils::gui::NamedConfigDataModel::_rootItem
private

The documentation for this class was generated from the following files: