fixed cut undo.
This commit is contained in:
@@ -128,14 +128,21 @@ const XQModelSection& XQSectionManager::sectionByKey( const QString& sectionKey
|
|||||||
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
// wir gehen rückwärts, weil wir da nur einen vergleich brauchen
|
if( _sections.size() > 0)
|
||||||
// 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);
|
// shortcut für die erste position
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw XQException( "No section for item row: ", QString::number(itemRow));
|
throw XQException( "No section for item row: ", QString::number(itemRow));
|
||||||
|
@@ -259,8 +259,6 @@ void XQViewModel::onActionTriggered(QAction* action)
|
|||||||
QModelIndex currentIndex = treeTable()->currentIndex();
|
QModelIndex currentIndex = treeTable()->currentIndex();
|
||||||
command->setOriginIndex(currentIndex);
|
command->setOriginIndex(currentIndex);
|
||||||
// store the row positions of the selected indices
|
// store the row positions of the selected indices
|
||||||
|
|
||||||
qDebug() << " --- Before saveNode: " << selectionList.isEmpty();
|
|
||||||
showSelectionList(selectionList);
|
showSelectionList(selectionList);
|
||||||
command->saveNodes( selectionList );
|
command->saveNodes( selectionList );
|
||||||
|
|
||||||
@@ -336,9 +334,16 @@ void XQViewModel::onCommandUndo( const XQCommand& command )
|
|||||||
|
|
||||||
void XQViewModel::cmdCut( const XQCommand& command )
|
void XQViewModel::cmdCut( const XQCommand& command )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int itmPos = command.first().itemPos;
|
||||||
|
const XQModelSection& section = _sections.sectionByRow( itmPos );
|
||||||
|
qDebug() << " --- HEADSHOT I: " << itmPos << "->" << section.contentType();
|
||||||
|
|
||||||
// wir gehen rückwärts über alle gemerkten knoten ...
|
// wir gehen rückwärts über alle gemerkten knoten ...
|
||||||
for (auto it = command.rbegin(); it != command.rend(); ++it)
|
for (auto it = command.rbegin(); it != command.rend(); ++it)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// ... holen das erste item, das auch den content node enthält
|
// ... holen das erste item, das auch den content node enthält
|
||||||
//const XQNodeBackup& entry = *it;
|
//const XQNodeBackup& entry = *it;
|
||||||
// jetzt löschen, dabei wird die parent-verbindung entfernt
|
// jetzt löschen, dabei wird die parent-verbindung entfernt
|
||||||
@@ -364,7 +369,7 @@ void XQViewModel::cmdCutUndo( const XQCommand& command )
|
|||||||
// die 'zuständige' section rausfinden
|
// die 'zuständige' section rausfinden
|
||||||
const XQModelSection& section = _sections.sectionByRow( itmPos );
|
const XQModelSection& section = _sections.sectionByRow( itmPos );
|
||||||
|
|
||||||
qDebug() << " --- HEADSHOT: " << itmPos << "->" << section.contentType();
|
qDebug() << " --- HEADSHOT II: " << itmPos << "->" << section.contentType();
|
||||||
|
|
||||||
// über alle einträge ...
|
// über alle einträge ...
|
||||||
for (auto& entry : command )
|
for (auto& entry : command )
|
||||||
|
Reference in New Issue
Block a user