--- fy
This commit is contained in:
@@ -63,7 +63,9 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
||||
|
||||
// als Baum?
|
||||
//section.headerItem().appendRow( list );
|
||||
insertRow( newRow, list);
|
||||
|
||||
// _hinter_ der letzen zeile einfügen
|
||||
insertRow( newRow+1, list);
|
||||
|
||||
} // for
|
||||
|
||||
|
@@ -64,7 +64,7 @@ XQItem::XQRenderStyleMap XQItem::s_RenderStyleMap
|
||||
{ "CustomRenderStyle", CustomRenderStyle },
|
||||
{ "PickerStyle", PickerStyle },
|
||||
{ "SpinBoxStyle", SpinBoxStyle },
|
||||
{ "ProgressBarStyle", ProgressBarStyle},
|
||||
{ "ColorBarStyle", ColorBarStyle},
|
||||
{ "FormattedStyle", FormattedStyle},
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ XQItem::XQEditorTypeMap XQItem::s_EditorTypeMap
|
||||
{ "LineEditType", LineEditType },
|
||||
{ "ComboBoxType", ComboBoxType },
|
||||
{ "PickerType", PickerType },
|
||||
{ "ProgressBarType", ProgressBarType },
|
||||
{ "ColorBarType", ColorBarType },
|
||||
{ "SpinBoxType", SpinBoxType},
|
||||
{ "CustomEditorType", CustomEditorType}
|
||||
};
|
||||
@@ -501,7 +501,8 @@ QVariant XQItem::data(int role ) const
|
||||
case Qt::DisplayRole :
|
||||
{
|
||||
QString plainText = contentFallBackText();
|
||||
if( renderStyle() == XQItem::FormattedStyle)
|
||||
//if( renderStyle() == XQItem::FormattedStyle)
|
||||
if( unitType() != XQItem::NoUnitType)
|
||||
return XQItemType::formatToSI( plainText, unitType() );
|
||||
return plainText;
|
||||
}
|
||||
@@ -614,7 +615,9 @@ void XQItem::setData(const QVariant& value, int role )
|
||||
case XQItem::ContentRole:
|
||||
{
|
||||
QVariant newValue;
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)
|
||||
|
||||
//if( itemType().renderStyle() == XQItem::FormattedStyle)
|
||||
if( unitType() != XQItem::NoUnitType)
|
||||
newValue = XQItemType::unFormatFromSI( value.toString() );
|
||||
else
|
||||
newValue = value;
|
||||
|
@@ -84,7 +84,7 @@ public:
|
||||
ComboBoxStyle,
|
||||
PickerStyle,
|
||||
SpinBoxStyle,
|
||||
ProgressBarStyle,
|
||||
ColorBarStyle,
|
||||
FormattedStyle,
|
||||
TreeHeaderStyle,
|
||||
CustomRenderStyle,
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
LineEditType,
|
||||
ComboBoxType,
|
||||
PickerType,
|
||||
ProgressBarType,
|
||||
ColorBarType,
|
||||
SpinBoxType,
|
||||
CustomEditorType,
|
||||
EditorTypeEnd
|
||||
|
@@ -28,6 +28,51 @@
|
||||
#include <xqitemtype.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.
|
||||
|
||||
@@ -40,8 +85,8 @@ public:
|
||||
registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator<QLineEdit>());
|
||||
registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator<QComboBox>());
|
||||
registerEditor(XQItem::PickerType, new QStandardItemEditorCreator<QLineEdit>());
|
||||
//registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QProgressBar>());
|
||||
registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QSlider>());
|
||||
//registerEditor(XQItem::ColorBarType, new QStandardItemEditorCreator<QProgressBar>());
|
||||
registerEditor(XQItem::ColorBarType, new QStandardItemEditorCreator<QSlider>());
|
||||
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QSpinBox>());
|
||||
registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator<QLineEdit>());
|
||||
}
|
||||
@@ -96,7 +141,7 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option
|
||||
case XQItem::SpinBoxStyle :
|
||||
return drawSpinBoxStyle( painter, option, index );
|
||||
|
||||
case XQItem::ProgressBarStyle :
|
||||
case XQItem::ColorBarStyle :
|
||||
return drawProgressBarStyle( painter, option, index );
|
||||
*/
|
||||
case XQItem::HiddenStyle :
|
||||
@@ -289,6 +334,7 @@ void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) co
|
||||
case XQItemType::ComboBoxType :
|
||||
{
|
||||
QComboBox* comboBox = qobject_cast<QComboBox*>(editor);
|
||||
// wir erwarten hier ein gültiges model?
|
||||
comboBox->setModel( item.fixedChoices());
|
||||
comboBox->setCurrentText( item.data().toString() );
|
||||
comboBox->showPopup();
|
||||
|
@@ -26,6 +26,9 @@
|
||||
#include <xqmainwindow.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
@@ -128,17 +128,13 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
|
||||
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 (; i >= 0; --i)
|
||||
{
|
||||
if ( _sections.at(i).startIndex().row() < itemRow )
|
||||
return _sections.at(i);
|
||||
}
|
||||
for (const auto& section : _sections)
|
||||
{
|
||||
qDebug() << " ---- SEC: " << itemRow << " -> " << section.firstRow() << " : " << lastRow( section );
|
||||
XQSectionRange range = sectionRange(section);
|
||||
if( itemRow >= range.firstRow && itemRow <= range.lastRow)
|
||||
return section;
|
||||
}
|
||||
|
||||
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
|
||||
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 _sections.at(index+1).firstRow();// - 1;
|
||||
return _sections.at(index+1).firstRow() - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@@ -61,8 +61,7 @@ XQViewModel::XQViewModel( QObject* parent )
|
||||
XQItem* xqItem = static_cast<XQItem*>(item);
|
||||
emit xqItemChanged( *xqItem );
|
||||
});
|
||||
|
||||
|
||||
// not needed
|
||||
//qRegisterMetaType<XQItem>("XQItem");
|
||||
}
|
||||
|
||||
@@ -192,8 +191,10 @@ void XQViewModel::onToggleSection(const QString& sectionKey )
|
||||
void XQViewModel::toggleSection( const XQModelSection& section )
|
||||
{
|
||||
if( section.isValid() && _treeTable )
|
||||
{
|
||||
{
|
||||
XQSectionRange pos = _sections.sectionRange(section);
|
||||
qDebug() << " --- Section RANGE: " << 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();
|
||||
Q_ASSERT(index.isValid());
|
||||
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 );
|
||||
|
||||
emit sectionToggled(section);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -51,13 +51,18 @@ XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
|
||||
return viewModel()->xqItemFromIndex( index );
|
||||
}
|
||||
|
||||
|
||||
//! rows sichtbar/unsichtbar schalten, von 'fstRow' bis _einschliesslich_
|
||||
//! 'lstRow'
|
||||
|
||||
void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow )
|
||||
{
|
||||
bool hidden = isRowHidden( fstRow, rootIndex() );
|
||||
for (int row = fstRow; row < lstRow; ++row )
|
||||
for (int row = fstRow; row <= lstRow; ++row )
|
||||
setRowHidden( row, rootIndex(), !hidden );
|
||||
}
|
||||
|
||||
|
||||
//! override von 'currentChanged' (noch nicht implementiert)
|
||||
|
||||
void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
|
@@ -17,9 +17,9 @@
|
||||
<StaticType RenderStyle="PlainStyle"/>
|
||||
<PlainType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||
<ValueType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="Coulomb"/>
|
||||
<CheckableType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" UnitType="###"/>
|
||||
<PercentageType RenderStyle="ProgressBarStyle" EditorType="ProgressBarType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||
<ChoiceType RenderStyle="ComboBoxStyle" EditorType="ComboBoxType" ItemFlags="IsEnabled|IsEditable|IsSelectable" FixedChoices="1|2|3|4"/>
|
||||
<CheckableType RenderStyle="FormattedStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsEditable|IsSelectable" />
|
||||
<PercentageType RenderStyle="ColorBarStyle" EditorType="ColorBarType" ItemFlags="IsEnabled|IsEditable|IsSelectable"/>
|
||||
<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"/>
|
||||
</ItemTypes>
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<Manufacturer ItemType="PlainType"/>
|
||||
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
||||
<Width ItemType="CheckableType" Icon="VistaShield" UnitType="m"/>
|
||||
<Width ItemType="ValueType" Icon="VistaShield" UnitType="m"/>
|
||||
<Height ItemType="ValueType" UnitType="m"/>
|
||||
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||
@@ -98,13 +98,13 @@
|
||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<ModelSheet>
|
||||
<InverterID Caption="Inverter" ItemType="PlainType" />
|
||||
<InverterName Caption="Name" ItemType="PlainType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||
<MaxPowerInput Caption="max. Input" ItemType="ChoiceType" FixedChoices="2000|4000|6000|8000" UnitType="W"/>
|
||||
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
|
||||
<NumStrings Caption="Strings" ItemType="IntValueType" />
|
||||
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
||||
<InverterID ItemType="PlainType" />
|
||||
<InverterName ItemType="PlainType" />
|
||||
<Manufacturer ItemType="PlainType" />
|
||||
<MaxPowerInput ItemType="ChoiceType" FixedChoices="2000|4000|6000|8000" UnitType="W"/>
|
||||
<MaxPowerOutput ItemType="ValueType" UnitType="W"/>
|
||||
<NumStrings ItemType="IntValueType" />
|
||||
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
|
||||
@@ -119,13 +119,13 @@
|
||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<ModelSheet>
|
||||
<BatteryID Caption="Battery" ItemType="PlainType" />
|
||||
<BatteryName Caption="Name" ItemType="PlainType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
||||
<Yield Caption="Yield" ItemType="PercentageType" UnitType="%"/>
|
||||
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
||||
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
|
||||
<BatteryID ItemType="PlainType" />
|
||||
<BatteryName ItemType="PlainType" />
|
||||
<Manufacturer ItemType="PlainType" />
|
||||
<Capacity ItemType="ValueType" UnitType="Wh"/>
|
||||
<Yield ItemType="PercentageType" UnitType="%"/>
|
||||
<MaxCurrent ItemType="ValueType" UnitType="A"/>
|
||||
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
|
||||
|
Reference in New Issue
Block a user