9#include "AbstractTreeItem.h"
14#include <QFontMetrics>
18#include "IException.h"
20#include "SpecialPixel.h"
22#include "TableColumn.h"
26 AbstractTreeItem::AbstractTreeItem(AbstractTreeItem *parent) : m_parentItem(
32 m_nextVisibleItem = NULL;
37 AbstractTreeItem::~AbstractTreeItem() {
38 m_nextVisibleItem = NULL;
43 AbstractTreeItem *AbstractTreeItem::parent()
const {
48 void AbstractTreeItem::setParent(AbstractTreeItem *newParent) {
49 m_parentItem = newParent;
53 int AbstractTreeItem::row()
const {
57 rowIndex = m_parentItem->indexOf(
const_cast< AbstractTreeItem *
>(
this));
63 QString AbstractTreeItem::getFormattedData()
const {
64 return catchNull(getData());
68 QString AbstractTreeItem::getFormattedData(QString columnTitle)
const {
69 return catchNull(getData(columnTitle));
73 AbstractTreeItem *AbstractTreeItem::getNextVisiblePeer()
const {
74 return m_nextVisibleItem;
78 void AbstractTreeItem::setNextVisiblePeer(AbstractTreeItem *next) {
79 m_nextVisibleItem = next;
83 bool AbstractTreeItem::hasPoint(ControlPoint *point)
const {
86 for (
int i = 0; !found && i < childCount(); i++)
87 found = childAt(i)->hasPoint(point);
93 bool AbstractTreeItem::hasMeasure(ControlMeasure *measure)
const {
96 for (
int i = 0; !found && i < childCount(); i++)
97 found = childAt(i)->hasMeasure(measure);
103 bool AbstractTreeItem::hasImage(QString imageSerial)
const {
106 for (
int i = 0; !found && i < childCount(); i++) {
107 found = childAt(i)->hasImage(imageSerial);
114 void AbstractTreeItem::setExpanded(
bool newState) {
115 m_expanded = newState;
118 bool AbstractTreeItem::isExpanded()
const {
123 void AbstractTreeItem::setSelected(
bool newState) {
124 m_selected = newState;
128 void AbstractTreeItem::setSelectable(
bool newSelectable) {
129 m_selectable = newSelectable;
133 bool AbstractTreeItem::isSelected()
const {
138 bool AbstractTreeItem::isSelectable()
const {
143 void AbstractTreeItem::setVisible(
bool newState) {
144 m_visible = newState;
148 bool AbstractTreeItem::isVisible()
const {
153 int AbstractTreeItem::getDataWidth()
const {
154 if (m_dataWidth == 0) {
155 IString msg =
"Children of AbstractTreeItem must call setDataWidth "
156 "with a non-zero width";
157 throw IException(IException::Programmer, msg, _FILEINFO_);
164 int AbstractTreeItem::getDepth()
const {
167 AbstractTreeItem *item = parent();
171 item = item->parent();
178 void AbstractTreeItem::setLastVisibleFilteredItem(AbstractTreeItem *item) {
179 IString msg =
"This tree item does not keep track of visible filtered "
181 throw IException(IException::Programmer, msg, _FILEINFO_);
185 const AbstractTreeItem *
186 AbstractTreeItem::getLastVisibleFilteredItem()
const {
191 void AbstractTreeItem::calcDataWidth(
int avgCharWidth) {
192 if (avgCharWidth <= 0) {
193 IString msg =
"calcDataWidth() expects a positive non-zero value.";
194 throw IException(IException::Programmer, msg, _FILEINFO_);
197 m_dataWidth = (avgCharWidth + 1) * getFormattedData().size();
201 QString AbstractTreeItem::catchNull(QVariant data) {
204 if (data.type() == QVariant::Double) {
205 double dblData = data.toDouble();
208 if (dblData != Null) {
210 result = locale.toString(dblData,
'f');
214 result = data.toString();
221 double AbstractTreeItem::catchNull(QString str) {
223 if (str.toLower() !=
"null") {
225 d = locale.toDouble(str);
This is free and unencumbered software released into the public domain.
const double Null
Value for an Isis Null pixel.