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(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
|
||||
//connect( childModel, &QStandardItemModel::itemChanged, this, &XQMainWindow::onTreeItemChanged);
|
||||
|
||||
// Den globalen undo-stack ...
|
||||
childModel->setUndoStack(&_undoStack);
|
||||
@@ -432,7 +431,9 @@ void XQMainWindow::saveDocument( const QString& fileName )
|
||||
{
|
||||
XQNodeWriter nodeWriter;
|
||||
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 );
|
||||
}
|
||||
|
||||
|
@@ -69,7 +69,14 @@ const XQItem& XQViewModel::xqRootItem()
|
||||
// dynamisch über den ItemData Mechanismus wie in QStandardItem
|
||||
|
||||
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 )
|
||||
{
|
||||
|
||||
|
||||
|
||||
const QModelIndex& origin = command.originIndex();
|
||||
|
||||
|
||||
XQItem& target = xqItemFromIndex( origin );
|
||||
// current data node
|
||||
XQNodePtr node = target.contentNode();
|
||||
|
||||
qDebug() << " --- node own pos: " << node->own_pos();
|
||||
|
||||
// we create a new data node
|
||||
XQNodePtr newNode = XQNode::make_node( node->tag_name(), node->tag_value(), 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
|
||||
const XQModelSection& section = _sections.sectionFromIndex( origin );
|
||||
|
||||
|
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
//little helpers
|
||||
const XQItem& xqRootItem();
|
||||
XQNodePtr contentRootNode();
|
||||
|
||||
XQItem& xqItemFromIndex(const QModelIndex& index) const;
|
||||
XQItem& xqFirstItem(int row) const;
|
||||
|
@@ -180,16 +180,14 @@ namespace znode
|
||||
|
||||
zshared_node sibling()
|
||||
{
|
||||
if( !parent() )
|
||||
//return zshared_node( make_node("WTF1") );
|
||||
return zshared_node();
|
||||
|
||||
if( parent() )
|
||||
{
|
||||
znode_list& childs = _parent->_children;
|
||||
auto it = std::find( childs.begin(), childs.end(), this->shared_from_this() );
|
||||
if( ++it != childs.end())
|
||||
return *(it);
|
||||
}
|
||||
|
||||
//return zshared_node( make_node("WTF?") );
|
||||
return zshared_node();
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project Established="2006" FriendlyName="@ProjectName" ProjectID="HA01" ProjectName="Wiebelbach West" State="runnning" WattPeak="84000">
|
||||
<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="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="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"/>
|
||||
@@ -23,5 +23,3 @@
|
||||
<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"/>
|
||||
</Components>
|
||||
<IrgendWasAnderes/>
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user