11 #include "AbstractTreeItem.h"
16 #include <QFontMetrics>
20 #include "IException.h"
22 #include "SpecialPixel.h"
24 #include "AbstractTableModel.h"
25 #include "TableColumn.h"
29 AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent) : m_parentItem(
35 m_nextVisibleItem = NULL;
40 AbstractTreeItem::~AbstractTreeItem() {
41 m_nextVisibleItem = NULL;
46 AbstractTreeItem *AbstractTreeItem::parent()
const {
51 void AbstractTreeItem::setParent(AbstractTreeItem *newParent) {
52 m_parentItem = newParent;
56 int AbstractTreeItem::row()
const {
60 rowIndex = m_parentItem->indexOf(
const_cast< AbstractTreeItem *
>(
this));
66 QString AbstractTreeItem::getFormattedData()
const {
67 return catchNull(getData());
71 QString AbstractTreeItem::getFormattedData(QString columnTitle)
const {
72 return catchNull(getData(columnTitle));
76 AbstractTreeItem *AbstractTreeItem::getNextVisiblePeer()
const {
77 return m_nextVisibleItem;
81 void AbstractTreeItem::setNextVisiblePeer(AbstractTreeItem *next) {
82 m_nextVisibleItem = next;
86 bool AbstractTreeItem::hasPoint(ControlPoint *point)
const {
89 for (
int i = 0; !found && i < childCount(); i++)
90 found = childAt(i)->hasPoint(point);
96 bool AbstractTreeItem::hasMeasure(ControlMeasure *measure)
const {
99 for (
int i = 0; !found && i < childCount(); i++)
100 found = childAt(i)->hasMeasure(measure);
106 bool AbstractTreeItem::hasImage(QString imageSerial)
const {
109 for (
int i = 0; !found && i < childCount(); i++) {
110 found = childAt(i)->hasImage(imageSerial);
117 void AbstractTreeItem::setExpanded(
bool newState) {
118 m_expanded = newState;
121 bool AbstractTreeItem::isExpanded()
const {
126 void AbstractTreeItem::setSelected(
bool newState) {
127 m_selected = newState;
131 void AbstractTreeItem::setSelectable(
bool newSelectable) {
132 m_selectable = newSelectable;
136 bool AbstractTreeItem::isSelected()
const {
141 bool AbstractTreeItem::isSelectable()
const {
146 void AbstractTreeItem::setVisible(
bool newState) {
147 m_visible = newState;
151 bool AbstractTreeItem::isVisible()
const {
156 int AbstractTreeItem::getDataWidth()
const {
157 if (m_dataWidth == 0) {
158 IString msg =
"Children of AbstractTreeItem must call setDataWidth "
159 "with a non-zero width";
167 int AbstractTreeItem::getDepth()
const {
170 AbstractTreeItem *item = parent();
174 item = item->parent();
181 void AbstractTreeItem::setLastVisibleFilteredItem(AbstractTreeItem *item) {
182 IString msg =
"This tree item does not keep track of visible filtered "
188 const AbstractTreeItem *
189 AbstractTreeItem::getLastVisibleFilteredItem()
const {
194 void AbstractTreeItem::calcDataWidth(
int avgCharWidth) {
195 if (avgCharWidth <= 0) {
196 IString msg =
"calcDataWidth() expects a positive non-zero value.";
200 m_dataWidth = (avgCharWidth + 1) * getFormattedData().size();
204 QString AbstractTreeItem::catchNull(QVariant data) {
207 if (data.type() == QVariant::Double) {
208 double dblData = data.toDouble();
211 if (dblData !=
Null) {
213 result = locale.toString(dblData,
'f');
217 result = data.toString();
224 double AbstractTreeItem::catchNull(QString str) {
226 if (str.toLower() !=
"null") {
228 d = locale.toDouble(str);