--- fy
This commit is contained in:
@@ -63,7 +63,9 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
|||||||
|
|
||||||
// als Baum?
|
// als Baum?
|
||||||
//section.headerItem().appendRow( list );
|
//section.headerItem().appendRow( list );
|
||||||
insertRow( newRow, list);
|
|
||||||
|
// _hinter_ der letzen zeile einfügen
|
||||||
|
insertRow( newRow+1, list);
|
||||||
|
|
||||||
} // for
|
} // for
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ XQItem::XQRenderStyleMap XQItem::s_RenderStyleMap
|
|||||||
{ "CustomRenderStyle", CustomRenderStyle },
|
{ "CustomRenderStyle", CustomRenderStyle },
|
||||||
{ "PickerStyle", PickerStyle },
|
{ "PickerStyle", PickerStyle },
|
||||||
{ "SpinBoxStyle", SpinBoxStyle },
|
{ "SpinBoxStyle", SpinBoxStyle },
|
||||||
{ "ProgressBarStyle", ProgressBarStyle},
|
{ "ColorBarStyle", ColorBarStyle},
|
||||||
{ "FormattedStyle", FormattedStyle},
|
{ "FormattedStyle", FormattedStyle},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ XQItem::XQEditorTypeMap XQItem::s_EditorTypeMap
|
|||||||
{ "LineEditType", LineEditType },
|
{ "LineEditType", LineEditType },
|
||||||
{ "ComboBoxType", ComboBoxType },
|
{ "ComboBoxType", ComboBoxType },
|
||||||
{ "PickerType", PickerType },
|
{ "PickerType", PickerType },
|
||||||
{ "ProgressBarType", ProgressBarType },
|
{ "ColorBarType", ColorBarType },
|
||||||
{ "SpinBoxType", SpinBoxType},
|
{ "SpinBoxType", SpinBoxType},
|
||||||
{ "CustomEditorType", CustomEditorType}
|
{ "CustomEditorType", CustomEditorType}
|
||||||
};
|
};
|
||||||
@@ -501,7 +501,8 @@ QVariant XQItem::data(int role ) const
|
|||||||
case Qt::DisplayRole :
|
case Qt::DisplayRole :
|
||||||
{
|
{
|
||||||
QString plainText = contentFallBackText();
|
QString plainText = contentFallBackText();
|
||||||
if( renderStyle() == XQItem::FormattedStyle)
|
//if( renderStyle() == XQItem::FormattedStyle)
|
||||||
|
if( unitType() != XQItem::NoUnitType)
|
||||||
return XQItemType::formatToSI( plainText, unitType() );
|
return XQItemType::formatToSI( plainText, unitType() );
|
||||||
return plainText;
|
return plainText;
|
||||||
}
|
}
|
||||||
@@ -614,7 +615,9 @@ void XQItem::setData(const QVariant& value, int role )
|
|||||||
case XQItem::ContentRole:
|
case XQItem::ContentRole:
|
||||||
{
|
{
|
||||||
QVariant newValue;
|
QVariant newValue;
|
||||||
if( itemType().renderStyle() == XQItem::FormattedStyle)
|
|
||||||
|
//if( itemType().renderStyle() == XQItem::FormattedStyle)
|
||||||
|
if( unitType() != XQItem::NoUnitType)
|
||||||
newValue = XQItemType::unFormatFromSI( value.toString() );
|
newValue = XQItemType::unFormatFromSI( value.toString() );
|
||||||
else
|
else
|
||||||
newValue = value;
|
newValue = value;
|
||||||
|
@@ -84,7 +84,7 @@ public:
|
|||||||
ComboBoxStyle,
|
ComboBoxStyle,
|
||||||
PickerStyle,
|
PickerStyle,
|
||||||
SpinBoxStyle,
|
SpinBoxStyle,
|
||||||
ProgressBarStyle,
|
ColorBarStyle,
|
||||||
FormattedStyle,
|
FormattedStyle,
|
||||||
TreeHeaderStyle,
|
TreeHeaderStyle,
|
||||||
CustomRenderStyle,
|
CustomRenderStyle,
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
LineEditType,
|
LineEditType,
|
||||||
ComboBoxType,
|
ComboBoxType,
|
||||||
PickerType,
|
PickerType,
|
||||||
ProgressBarType,
|
ColorBarType,
|
||||||
SpinBoxType,
|
SpinBoxType,
|
||||||
CustomEditorType,
|
CustomEditorType,
|
||||||
EditorTypeEnd
|
EditorTypeEnd
|
||||||
|
@@ -28,6 +28,51 @@
|
|||||||
#include <xqitemtype.h>
|
#include <xqitemtype.h>
|
||||||
#include <xqviewmodel.h>
|
#include <xqviewmodel.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
class BarDelegate : public QStyledItemDelegate {
|
||||||
|
public:
|
||||||
|
BarDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const override {
|
||||||
|
// Standard-Zellenhintergrund zeichnen
|
||||||
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
|
||||||
|
// Wert aus dem Modell holen
|
||||||
|
bool ok;
|
||||||
|
int value = index.data().toInt(&ok);
|
||||||
|
if (!ok || value < 0 || value > 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Balkenbereich berechnen
|
||||||
|
QRect rect = option.rect.adjusted(4, 4, -4, -4); // etwas Padding
|
||||||
|
int barWidth = static_cast<int>(rect.width() * (value / 100.0));
|
||||||
|
|
||||||
|
// Balken zeichnen
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
QRect barRect(rect.left(), rect.top(), barWidth, rect.height());
|
||||||
|
QColor barColor = QColor(100, 180, 255); // z. B. hellblau
|
||||||
|
painter->setBrush(barColor);
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
|
painter->drawRect(barRect);
|
||||||
|
|
||||||
|
// Text (Zahl) zentriert zeichnen
|
||||||
|
painter->setPen(Qt::black);
|
||||||
|
painter->drawText(rect, Qt::AlignCenter, QString::number(value));
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! erzeugt eine editorfactory mit den hauseigenen editortypen.
|
//! erzeugt eine editorfactory mit den hauseigenen editortypen.
|
||||||
|
|
||||||
@@ -40,8 +85,8 @@ public:
|
|||||||
registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator<QLineEdit>());
|
registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator<QLineEdit>());
|
||||||
registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator<QComboBox>());
|
registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator<QComboBox>());
|
||||||
registerEditor(XQItem::PickerType, new QStandardItemEditorCreator<QLineEdit>());
|
registerEditor(XQItem::PickerType, new QStandardItemEditorCreator<QLineEdit>());
|
||||||
//registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QProgressBar>());
|
//registerEditor(XQItem::ColorBarType, new QStandardItemEditorCreator<QProgressBar>());
|
||||||
registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QSlider>());
|
registerEditor(XQItem::ColorBarType, new QStandardItemEditorCreator<QSlider>());
|
||||||
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QSpinBox>());
|
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QSpinBox>());
|
||||||
registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator<QLineEdit>());
|
registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator<QLineEdit>());
|
||||||
}
|
}
|
||||||
@@ -96,7 +141,7 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
case XQItem::SpinBoxStyle :
|
case XQItem::SpinBoxStyle :
|
||||||
return drawSpinBoxStyle( painter, option, index );
|
return drawSpinBoxStyle( painter, option, index );
|
||||||
|
|
||||||
case XQItem::ProgressBarStyle :
|
case XQItem::ColorBarStyle :
|
||||||
return drawProgressBarStyle( painter, option, index );
|
return drawProgressBarStyle( painter, option, index );
|
||||||
*/
|
*/
|
||||||
case XQItem::HiddenStyle :
|
case XQItem::HiddenStyle :
|
||||||
@@ -289,6 +334,7 @@ void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) co
|
|||||||
case XQItemType::ComboBoxType :
|
case XQItemType::ComboBoxType :
|
||||||
{
|
{
|
||||||
QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
|
QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
|
||||||
|
// wir erwarten hier ein gültiges model?
|
||||||
comboBox->setModel( item.fixedChoices());
|
comboBox->setModel( item.fixedChoices());
|
||||||
comboBox->setCurrentText( item.data().toString() );
|
comboBox->setCurrentText( item.data().toString() );
|
||||||
comboBox->showPopup();
|
comboBox->showPopup();
|
||||||
|
@@ -26,6 +26,9 @@
|
|||||||
#include <xqmainwindow.h>
|
#include <xqmainwindow.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
@@ -128,17 +128,13 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
|
|||||||
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if( _sections.size() > 0)
|
|
||||||
{
|
|
||||||
// wir gehen rückwärts, weil wir da nur einen vergleich brauchen
|
|
||||||
// und uns den test mit lastRow() sparen können.
|
|
||||||
|
|
||||||
int i = _sections.size() - 1;
|
for (const auto& section : _sections)
|
||||||
for (; i >= 0; --i)
|
{
|
||||||
{
|
qDebug() << " ---- SEC: " << itemRow << " -> " << section.firstRow() << " : " << lastRow( section );
|
||||||
if ( _sections.at(i).startIndex().row() < itemRow )
|
XQSectionRange range = sectionRange(section);
|
||||||
return _sections.at(i);
|
if( itemRow >= range.firstRow && itemRow <= range.lastRow)
|
||||||
}
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw XQException( "No section for item row: ", QString::number(itemRow));
|
throw XQException( "No section for item row: ", QString::number(itemRow));
|
||||||
@@ -169,9 +165,9 @@ int XQSectionManager::lastRow(const XQModelSection& section ) const
|
|||||||
{
|
{
|
||||||
// last section? return last row of model
|
// last section? return last row of model
|
||||||
if (index == _sections.size() - 1)
|
if (index == _sections.size() - 1)
|
||||||
return section.startIndex().model()->rowCount();// - 1;
|
return section.startIndex().model()->rowCount() - 1;
|
||||||
// return row above the row of the next section -> last row of given section
|
// return row above the row of the next section -> last row of given section
|
||||||
return _sections.at(index+1).firstRow();// - 1;
|
return _sections.at(index+1).firstRow() - 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -61,8 +61,7 @@ XQViewModel::XQViewModel( QObject* parent )
|
|||||||
XQItem* xqItem = static_cast<XQItem*>(item);
|
XQItem* xqItem = static_cast<XQItem*>(item);
|
||||||
emit xqItemChanged( *xqItem );
|
emit xqItemChanged( *xqItem );
|
||||||
});
|
});
|
||||||
|
// not needed
|
||||||
|
|
||||||
//qRegisterMetaType<XQItem>("XQItem");
|
//qRegisterMetaType<XQItem>("XQItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +193,8 @@ void XQViewModel::toggleSection( const XQModelSection& section )
|
|||||||
if( section.isValid() && _treeTable )
|
if( section.isValid() && _treeTable )
|
||||||
{
|
{
|
||||||
XQSectionRange pos = _sections.sectionRange(section);
|
XQSectionRange pos = _sections.sectionRange(section);
|
||||||
|
qDebug() << " --- Section RANGE: " << pos.firstRow << " -> " << pos.lastRow;
|
||||||
|
|
||||||
_treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow );
|
_treeTable->toggleRowsHidden(pos.firstRow, pos.lastRow );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -521,8 +522,15 @@ void XQViewModel::cmdToggleSection( const XQCommand& command )
|
|||||||
const QModelIndex& index = command.originIndex();
|
const QModelIndex& index = command.originIndex();
|
||||||
Q_ASSERT(index.isValid());
|
Q_ASSERT(index.isValid());
|
||||||
const XQModelSection& section = _sections.sectionByRow(index.row());
|
const XQModelSection& section = _sections.sectionByRow(index.row());
|
||||||
|
|
||||||
|
// Obacht! Das ist hier etwas unsauber, 'toogleSection'' ändert den check-State
|
||||||
|
// im document-tree, was wiederum die 'toggleSection' auslöst, das gibt also
|
||||||
|
// einen doppelten Aufruf und wir sind dann wieder im Anfangszustand.
|
||||||
|
|
||||||
//toggleSection( section );
|
//toggleSection( section );
|
||||||
|
|
||||||
emit sectionToggled(section);
|
emit sectionToggled(section);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,13 +51,18 @@ XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
|
|||||||
return viewModel()->xqItemFromIndex( index );
|
return viewModel()->xqItemFromIndex( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! rows sichtbar/unsichtbar schalten, von 'fstRow' bis _einschliesslich_
|
||||||
|
//! 'lstRow'
|
||||||
|
|
||||||
void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow )
|
void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow )
|
||||||
{
|
{
|
||||||
bool hidden = isRowHidden( fstRow, rootIndex() );
|
bool hidden = isRowHidden( fstRow, rootIndex() );
|
||||||
for (int row = fstRow; row < lstRow; ++row )
|
for (int row = fstRow; row <= lstRow; ++row )
|
||||||
setRowHidden( row, rootIndex(), !hidden );
|
setRowHidden( row, rootIndex(), !hidden );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! override von 'currentChanged' (noch nicht implementiert)
|
//! override von 'currentChanged' (noch nicht implementiert)
|
||||||
|
|
||||||
void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
<StaticType RenderStyle="PlainStyle"/>
|
<StaticType RenderStyle="PlainStyle"/>
|
||||||
<PlainType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
<PlainType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||||
<ValueType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="Coulomb"/>
|
<ValueType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="Coulomb"/>
|
||||||
<CheckableType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="###"/>
|
<CheckableType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" />
|
||||||
<PercentageType RenderStyle="ProgressBarStyle" EditorType="ProgressBarType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
<PercentageType RenderStyle="ColorBarStyle" EditorType="ColorBarType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||||
<ChoiceType RenderStyle="ComboBoxStyle" EditorType="ComboBoxType" ItemFlags="IsEnabled|IsEditable|IsSelectable" FixedChoices="1|2|3|4"/>
|
<ChoiceType RenderStyle="ComboBoxStyle" EditorType="ComboBoxType" ItemFlags="IsEnabled|IsEditable|IsSelectable" FixedChoices="2000|4000|6000|8000" UnitType="W"/>
|
||||||
<IntValueType RenderStyle="SpinBoxStyle" EditorType="SpinBoxType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
<IntValueType RenderStyle="SpinBoxStyle" EditorType="SpinBoxType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||||
</ItemTypes>
|
</ItemTypes>
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
<Manufacturer ItemType="PlainType"/>
|
<Manufacturer ItemType="PlainType"/>
|
||||||
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
||||||
<Width ItemType="CheckableType" Icon="VistaShield" UnitType="m"/>
|
<Width ItemType="ValueType" Icon="VistaShield" UnitType="m"/>
|
||||||
<Height ItemType="ValueType" UnitType="m"/>
|
<Height ItemType="ValueType" UnitType="m"/>
|
||||||
<Weight ItemType="ValueType" UnitType="kg"/>
|
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||||
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||||
@@ -98,13 +98,13 @@
|
|||||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<ModelSheet>
|
<ModelSheet>
|
||||||
<InverterID Caption="Inverter" ItemType="PlainType" />
|
<InverterID ItemType="PlainType" />
|
||||||
<InverterName Caption="Name" ItemType="PlainType" />
|
<InverterName ItemType="PlainType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
<Manufacturer ItemType="PlainType" />
|
||||||
<MaxPowerInput Caption="max. Input" ItemType="ChoiceType" FixedChoices="2000|4000|6000|8000" UnitType="W"/>
|
<MaxPowerInput ItemType="ChoiceType" FixedChoices="2000|4000|6000|8000" UnitType="W"/>
|
||||||
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
|
<MaxPowerOutput ItemType="ValueType" UnitType="W"/>
|
||||||
<NumStrings Caption="Strings" ItemType="IntValueType" />
|
<NumStrings ItemType="IntValueType" />
|
||||||
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||||
</ModelSheet>
|
</ModelSheet>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
@@ -119,13 +119,13 @@
|
|||||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<ModelSheet>
|
<ModelSheet>
|
||||||
<BatteryID Caption="Battery" ItemType="PlainType" />
|
<BatteryID ItemType="PlainType" />
|
||||||
<BatteryName Caption="Name" ItemType="PlainType" />
|
<BatteryName ItemType="PlainType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
<Manufacturer ItemType="PlainType" />
|
||||||
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
<Capacity ItemType="ValueType" UnitType="Wh"/>
|
||||||
<Yield Caption="Yield" ItemType="PercentageType" UnitType="%"/>
|
<Yield ItemType="PercentageType" UnitType="%"/>
|
||||||
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
<MaxCurrent ItemType="ValueType" UnitType="A"/>
|
||||||
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
|
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||||
</ModelSheet>
|
</ModelSheet>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user