Completed cmdNew implementation.
This commit is contained in:
@@ -404,7 +404,6 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
|
|
||||||
connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) );
|
connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) );
|
||||||
connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
|
connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
|
||||||
//connect( childModel, &QStandardItemModel::itemChanged, this, &XQMainWindow::onTreeItemChanged);
|
|
||||||
|
|
||||||
// Den globalen undo-stack ...
|
// Den globalen undo-stack ...
|
||||||
childModel->setUndoStack(&_undoStack);
|
childModel->setUndoStack(&_undoStack);
|
||||||
@@ -432,7 +431,9 @@ void XQMainWindow::saveDocument( const QString& fileName )
|
|||||||
{
|
{
|
||||||
XQNodeWriter nodeWriter;
|
XQNodeWriter nodeWriter;
|
||||||
int curIdx = _tabWidget->currentIndex();
|
int curIdx = _tabWidget->currentIndex();
|
||||||
XQNodePtr rootNode = _documentStore[curIdx].treeItem->contentNode();
|
//XQNodePtr rootNode = _documentStore[curIdx].treeItem->contentNode();
|
||||||
|
XQNodePtr rootNode = _documentStore[curIdx].modelView->contentRootNode();
|
||||||
|
Q_ASSERT(rootNode);
|
||||||
nodeWriter.dumpTree( rootNode, fileName );
|
nodeWriter.dumpTree( rootNode, fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,7 +69,14 @@ const XQItem& XQViewModel::xqRootItem()
|
|||||||
// dynamisch über den ItemData Mechanismus wie in QStandardItem
|
// dynamisch über den ItemData Mechanismus wie in QStandardItem
|
||||||
|
|
||||||
return *static_cast<XQItem*>(invisibleRootItem());
|
return *static_cast<XQItem*>(invisibleRootItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Gibt den daten root node des models zurück.
|
||||||
|
|
||||||
|
XQNodePtr XQViewModel::contentRootNode()
|
||||||
|
{
|
||||||
|
return _contentRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -431,20 +438,18 @@ void XQViewModel::cmdDeleteUndo( const XQCommand& command )
|
|||||||
|
|
||||||
void XQViewModel::cmdNew( const XQCommand& command )
|
void XQViewModel::cmdNew( const XQCommand& command )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const QModelIndex& origin = command.originIndex();
|
const QModelIndex& origin = command.originIndex();
|
||||||
|
|
||||||
|
|
||||||
XQItem& target = xqItemFromIndex( origin );
|
XQItem& target = xqItemFromIndex( origin );
|
||||||
// current data node
|
// current data node
|
||||||
XQNodePtr node = target.contentNode();
|
XQNodePtr node = target.contentNode();
|
||||||
|
|
||||||
|
qDebug() << " --- node own pos: " << node->own_pos();
|
||||||
|
|
||||||
// we create a new data node
|
// we create a new data node
|
||||||
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value(), node->parent() );
|
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value(), node->parent() );
|
||||||
// store node in node->parent()
|
// store node in node->parent()
|
||||||
//node->add_before_me( newNode );
|
newNode->add_me_at( node->own_pos(), node->parent() );
|
||||||
// store node also in 'command' to enable undo
|
// store node also in 'command' to enable undo
|
||||||
const XQModelSection& section = _sections.sectionFromIndex( origin );
|
const XQModelSection& section = _sections.sectionFromIndex( origin );
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
//little helpers
|
//little helpers
|
||||||
const XQItem& xqRootItem();
|
const XQItem& xqRootItem();
|
||||||
|
XQNodePtr contentRootNode();
|
||||||
|
|
||||||
XQItem& xqItemFromIndex(const QModelIndex& index) const;
|
XQItem& xqItemFromIndex(const QModelIndex& index) const;
|
||||||
XQItem& xqFirstItem(int row) const;
|
XQItem& xqFirstItem(int row) const;
|
||||||
|
@@ -180,16 +180,14 @@ namespace znode
|
|||||||
|
|
||||||
zshared_node sibling()
|
zshared_node sibling()
|
||||||
{
|
{
|
||||||
if( !parent() )
|
if( parent() )
|
||||||
//return zshared_node( make_node("WTF1") );
|
{
|
||||||
return zshared_node();
|
|
||||||
|
|
||||||
znode_list& childs = _parent->_children;
|
znode_list& childs = _parent->_children;
|
||||||
auto it = std::find( childs.begin(), childs.end(), this->shared_from_this() );
|
auto it = std::find( childs.begin(), childs.end(), this->shared_from_this() );
|
||||||
if( ++it != childs.end())
|
if( ++it != childs.end())
|
||||||
return *(it);
|
return *(it);
|
||||||
|
}
|
||||||
|
|
||||||
//return zshared_node( make_node("WTF?") );
|
|
||||||
return zshared_node();
|
return zshared_node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Project Established="2006" FriendlyName="@ProjectName" ProjectID="HA01" ProjectName="Wiebelbach West" State="runnning" WattPeak="84000">
|
<Components>
|
||||||
<Components>
|
|
||||||
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 1 XX" MaxAmpere="11" MaxVolt="67" PanelID="#1 JA 01" PanelName="JA 01 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
|
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 1 XX" MaxAmpere="11" MaxVolt="67" PanelID="#1 JA 01" PanelName="JA 01 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
|
||||||
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 2" MaxAmpere="11" MaxVolt="42" PanelID="#2 JA 02" PanelName="JA 02 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 2" MaxAmpere="11" MaxVolt="42" PanelID="#2 JA 02" PanelName="JA 02 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
||||||
|
<Panel/>
|
||||||
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 3" MaxAmpere="11" MaxVolt="67" PanelID="#3 JA 03" PanelName="JA 03 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
|
<Panel FriendlyName="@PanelName" Height="2,70" Manufacturer="JA Solar 3" MaxAmpere="11" MaxVolt="67" PanelID="#3 JA 03" PanelName="JA 03 Solar T62B" WattPeak="620" Weight="12" Width="1,10"/>
|
||||||
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 4" MaxAmpere="11" MaxVolt="42" PanelID="#4 JA 04" PanelName="JA 04 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 4" MaxAmpere="11" MaxVolt="42" PanelID="#4 JA 04" PanelName="JA 04 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
||||||
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 5" MaxAmpere="11" MaxVolt="42" PanelID="#5 JA 05" PanelName="JA 05 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
<Panel FriendlyName="@PanelName" Height="1,70" Manufacturer="JA Solar 5" MaxAmpere="11" MaxVolt="42" PanelID="#5 JA 05" PanelName="JA 05 Solar X58C" WattPeak="440" Weight="12" Width="1,10"/>
|
||||||
@@ -22,6 +22,4 @@
|
|||||||
<Battery BatteryID="#5 GroWatt 05 G2K" BatteryName="05 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="94"/>
|
<Battery BatteryID="#5 GroWatt 05 G2K" BatteryName="05 BYD T01 Stackable" Capacity="4500" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="94"/>
|
||||||
<Battery BatteryID="#6 GroWatt 06 G4K" BatteryName="06 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="49"/>
|
<Battery BatteryID="#6 GroWatt 06 G4K" BatteryName="06 BYD T02 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="GroWatt" MaxCurrent="120" MaxVolt="48" Yield="49"/>
|
||||||
<Battery BatteryID="#7 Pyne 07 G4K" BatteryName="07 Pyne K7 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="PyNe" MaxCurrent="120" MaxVolt="48" Yield="49"/>
|
<Battery BatteryID="#7 Pyne 07 G4K" BatteryName="07 Pyne K7 Stackable" Capacity="9000" FriendlyName="@BatteryName" Manufacturer="PyNe" MaxCurrent="120" MaxVolt="48" Yield="49"/>
|
||||||
</Components>
|
</Components>
|
||||||
<IrgendWasAnderes/>
|
|
||||||
</Project>
|
|
||||||
|
Reference in New Issue
Block a user