major 'firzifikation'
This commit is contained in:
@@ -127,8 +127,8 @@ void XQChildModel::initContextMenu()
|
||||
// __fixme! add a menu title
|
||||
_contextMenu->clear();
|
||||
|
||||
const QModelIndex& curIdx = _treeView->currentIndex();
|
||||
bool hasSel = curIdx.isValid() && _treeView->selectionModel()->hasSelection();
|
||||
const QModelIndex& curIdx = _treeTable->currentIndex();
|
||||
bool hasSel = curIdx.isValid() && _treeTable->selectionModel()->hasSelection();
|
||||
bool canPaste = _clipBoard.canPaste( curIdx );
|
||||
|
||||
_contextMenu->addAction( "icn11Dummy", "Undo", XQCommand::cmdUndo, _undoStack->canUndo() );
|
||||
|
@@ -64,9 +64,9 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
|
||||
{
|
||||
XQItem* newTreeentry = _itemFactory.makeContentItem( contentNode, section.sheetRootNode );
|
||||
section.headerItem().appendRow( newTreeentry );
|
||||
_treeView->expand( section.modelIndex );
|
||||
_treeTable->expand( section.modelIndex );
|
||||
// ??
|
||||
_treeView->setCurrentIndex( section.modelIndex );
|
||||
_treeTable->setCurrentIndex( section.modelIndex );
|
||||
newTreeentry->setContentNode(contentNode);
|
||||
emit xqItemCreated( newTreeentry );
|
||||
return newTreeentry;
|
||||
|
@@ -70,7 +70,7 @@ void XQMainWindow::initMainWindow()
|
||||
_mainTreeView->setCurrentIndex( item->index() );
|
||||
// ... we set the current view to this node
|
||||
if( _documentStore.contains( pID ) )
|
||||
_tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeView() );
|
||||
_tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() );
|
||||
} );
|
||||
|
||||
try
|
||||
@@ -78,7 +78,7 @@ void XQMainWindow::initMainWindow()
|
||||
// hand over undostack
|
||||
_mainModelView.setUndoStack(&_undoStack);
|
||||
// hand over left side navigation tree
|
||||
_mainModelView.setTreeView(_mainTreeView);
|
||||
_mainModelView.setTreeTable(_mainTreeView);
|
||||
// #1. init the left side main tree view
|
||||
_mainModelView.initModel( c_MainModelName );
|
||||
|
||||
@@ -203,7 +203,7 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
||||
|
||||
QString key = entry.attribute(c_ProjectID);
|
||||
if( _documentStore.contains(key) )
|
||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeView() );
|
||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
||||
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
||||
// Den globalen undo-stack ...
|
||||
childModel->setUndoStack(&_undoStack);
|
||||
// und die TreeView übergeben
|
||||
childModel->setTreeView(childTreeView);
|
||||
childModel->setTreeTable(childTreeView);
|
||||
|
||||
// read the model data
|
||||
childModel->setContent( contentRoot->first_child() );
|
||||
|
@@ -144,7 +144,7 @@ XQItem::XQItem(XQItemType* itemType, const QString *content, const XQNodePtr& co
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
XQItem::XQItem(const XQItem& other)
|
||||
: QStandardItem( other )
|
||||
{
|
||||
@@ -152,17 +152,22 @@ XQItem::XQItem(const XQItem& other)
|
||||
// die data() struktur
|
||||
}
|
||||
|
||||
XQItem& XQItem::operator=(const XQItem& other)
|
||||
{
|
||||
if( this != &other)
|
||||
{
|
||||
// kopiert data()
|
||||
this->QStandardItem::operator=( other );
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
//! firz
|
||||
|
||||
XQItem::~XQItem()
|
||||
{
|
||||
// fixed choices lebt im item type, also
|
||||
// im parent
|
||||
|
||||
//QAbstractItemModel* model = fixedChoices();
|
||||
//if( model )
|
||||
// delete model;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,12 +183,13 @@ XQItem* XQItem::clone() const
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
//! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein
|
||||
//! mockup-itemtype gesetzt ist.
|
||||
|
||||
bool XQItem::isValid() const
|
||||
{
|
||||
// fragwürdig
|
||||
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != nullptr;
|
||||
XQItemType* dummyType = XQItemType::staticItemType();
|
||||
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != dummyType;
|
||||
}
|
||||
|
||||
|
||||
@@ -429,12 +435,14 @@ QString XQItem::fixedChoicesToString() const
|
||||
}
|
||||
|
||||
//! setzt das auswahl-model für read-only comboboxes
|
||||
|
||||
void XQItem::setfixedChoices( QStandardItemModel* newModel )
|
||||
{
|
||||
setData( QVariant::fromValue(newModel), XQItem::FixedChoicesRole);
|
||||
}
|
||||
|
||||
//! true, wenn 'ich' ein header item bin
|
||||
|
||||
bool XQItem::isHeaderStyle()
|
||||
{
|
||||
return renderStyle() == XQItem::HeaderStyle;
|
||||
@@ -442,6 +450,7 @@ bool XQItem::isHeaderStyle()
|
||||
|
||||
|
||||
//! gibt den namen der datarole zurück
|
||||
|
||||
QString XQItem::dataRoleName(int role)
|
||||
{
|
||||
if( role < XQItem::NoRole && model() )
|
||||
@@ -451,6 +460,7 @@ QString XQItem::dataRoleName(int role)
|
||||
|
||||
//! angespasste variante von qstandarditem::setData. geteilte attribute
|
||||
//! werden vom xqitemtype geholt
|
||||
|
||||
QVariant XQItem::data(int role ) const
|
||||
{
|
||||
//emitDataChanged()
|
||||
|
@@ -125,16 +125,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//XQItem(int rows, int columns = 1);
|
||||
XQItem();
|
||||
|
||||
XQItem( XQItemType* itemType );
|
||||
XQItem( XQItemType* itemType, const QString* content );
|
||||
XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode );
|
||||
|
||||
XQItem(const XQItem& other);
|
||||
XQItem(const QStandardItem& other);
|
||||
|
||||
virtual ~XQItem();
|
||||
|
||||
//! creates not a clone but a new default item, \see QStandardItemModel::setItemPrototype()
|
||||
@@ -184,7 +180,6 @@ public:
|
||||
QString renderStyleToString() const;
|
||||
void setRenderStyle(RenderStyle renderStyle );
|
||||
|
||||
//! fitze FATZE!
|
||||
EditorType editorType() const;
|
||||
QString editorTypeToString() const;
|
||||
void setEditorType(EditorType editorType);
|
||||
@@ -195,9 +190,11 @@ public:
|
||||
|
||||
QString contentFormat() const;
|
||||
void setContentFormat(const QString& contentFormat);
|
||||
|
||||
QStandardItemModel* fixedChoices() const;
|
||||
QString fixedChoicesToString() const;
|
||||
|
||||
QString fixedChoicesToString() const;
|
||||
|
||||
//! setzt das auswahl-model für read-only comboboxes
|
||||
void setfixedChoices( QStandardItemModel* newModel );
|
||||
|
||||
//
|
||||
@@ -205,20 +202,11 @@ public:
|
||||
//
|
||||
|
||||
bool isHeaderStyle();
|
||||
|
||||
//! gibt den namen der datarole zurück
|
||||
QString dataRoleName(int role);
|
||||
|
||||
//! angespasste variante von qstandarditem::data
|
||||
QVariant data(int role = Qt::DisplayRole ) const override;
|
||||
|
||||
//! angespasste variante von qstandarditem::setData
|
||||
void setData(const QVariant &value, int role ) override;
|
||||
|
||||
// Das sind die die items im tree links: icon,text, node pointer
|
||||
//XQItem( const QString& text, XQNodePtr contentNode );
|
||||
//XQItem( const QString& text, XQItemType::RenderStyle renderStyle );
|
||||
|
||||
/*
|
||||
template<class T>
|
||||
void setToVariant(T entry, QtExtUserRoles::NTDataRoles role)
|
||||
@@ -254,6 +242,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
XQItem(const XQItem& other) = default;
|
||||
XQItem& operator=(const XQItem& other) = default;
|
||||
|
||||
using XQItemFlagMap = QMap<QString,int>;
|
||||
using XQItemDataRoleMap = QMap<QString,int>;
|
||||
using XQRenderStyleMap = QMap<QString,RenderStyle>;
|
||||
@@ -268,6 +259,9 @@ protected:
|
||||
static XQUnitTypeMap s_UnitTypeMap;
|
||||
static XQPrefixExponentMap s_PrefixExponentMap;
|
||||
|
||||
//! leerer itemtype als mockup für den xqitem default constructor
|
||||
static XQItemType s_DummyItemType;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(XQItem::RenderStyle);
|
||||
|
@@ -69,9 +69,9 @@ XQItemDelegate::XQItemDelegate( XQViewModel& modelView)
|
||||
}
|
||||
|
||||
|
||||
XQTreeTable* XQItemDelegate::treeView() const
|
||||
XQTreeTable* XQItemDelegate::treeTable() const
|
||||
{
|
||||
return _modelView.treeView();
|
||||
return _modelView.treeTable();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ XQItem& XQItemDelegate::xqItemFromIndex( const QModelIndex& index ) const
|
||||
QWidget* XQItemDelegate::prepareHeaderOption(const QStyleOptionViewItem& option, const QModelIndex& index, QStyleOptionHeader& headerOption) const
|
||||
{
|
||||
// use the header as "parent" for style init
|
||||
QWidget* srcWidget = treeView()->header();
|
||||
QWidget* srcWidget = treeTable()->header();
|
||||
headerOption.initFrom(srcWidget);
|
||||
headerOption.text = index.data(Qt::DisplayRole).toString();
|
||||
headerOption.rect = option.rect;
|
||||
|
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
explicit XQItemDelegate(XQViewModel& modelView);
|
||||
|
||||
XQTreeTable* treeView() const;
|
||||
XQTreeTable* treeTable() const;
|
||||
XQItem& xqItemFromIndex( const QModelIndex& index ) const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
QApplication app(argc, argv);
|
||||
//qDebug() << " lebt";
|
||||
|
||||
//app.setStyle("fusion");
|
||||
XQMainWindow window;
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include <xqtreetable.h>
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQNodeStore::dumpList( const QString& title ) const
|
||||
{
|
||||
if( !title.isEmpty() )
|
||||
@@ -26,23 +28,34 @@ void XQNodeStore::dumpList( const QString& title ) const
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView )
|
||||
: _cmdType{ cmdType }, _model(modelView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQCommand::~XQCommand()
|
||||
{
|
||||
qDebug() << " --- command destructor: " << toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQCommand::CmdType XQCommand::commandType() const
|
||||
{
|
||||
return _cmdType;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQCommand::setCommandType( XQCommand::CmdType cmdType )
|
||||
{
|
||||
_cmdType = cmdType;
|
||||
@@ -105,6 +118,7 @@ void XQCommand::saveNodes( const QModelIndexList& list )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! erzeugt einen string aus dem command-type, fürs debuggen.
|
||||
|
||||
QString XQCommand::toString()
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <xqitem.h>
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode)
|
||||
: modelIndex{ aModelIndex }, sheetRootNode{ aSheetNode }
|
||||
{
|
||||
@@ -23,24 +25,32 @@ XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetN
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
bool XQModelSection::operator==(const XQModelSection& other) const
|
||||
{
|
||||
return modelIndex == other.modelIndex && sheetRootNode == other.sheetRootNode;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
bool XQModelSection::isValid() const
|
||||
{
|
||||
return modelIndex.isValid() && sheetRootNode;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
int XQModelSection::XQModelSection::row() const
|
||||
{
|
||||
return modelIndex.row();
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQItem& XQModelSection::XQModelSection::headerItem() const
|
||||
{
|
||||
return XQItem::xqItemFromIndex( modelIndex );
|
||||
|
@@ -17,6 +17,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void inspect( const XQNodePtr& node, int indent )
|
||||
{
|
||||
qDebug() << std::string(indent * 2, ' ').c_str() << node.use_count() << ": " << node->to_string();
|
||||
@@ -31,6 +34,10 @@ void inspect( const XQNodePtr& node, int indent )
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
// Overload the operator<< for MyClass and std::ostream
|
||||
std::ostream& operator<<(std::ostream& os, const QString& obj)
|
||||
{
|
||||
@@ -40,8 +47,7 @@ std::ostream& operator<<(std::ostream& os, const QString& obj)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
template<>
|
||||
bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString& sep, QString& key, QString& value )
|
||||
{
|
||||
@@ -53,12 +59,18 @@ bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
template<>
|
||||
QString znode::zpayload<QString>::xstr_sub_str( const QString& entry, int pos ) const
|
||||
{
|
||||
return entry.mid(pos);
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
template<>
|
||||
bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const
|
||||
{
|
||||
@@ -66,6 +78,8 @@ bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
template<>
|
||||
const QString znode::zpayload<QString>::cType = "Type";
|
||||
|
||||
|
@@ -20,6 +20,10 @@
|
||||
#include <xqnode.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const
|
||||
{
|
||||
QFile treeFile( fileName );
|
||||
@@ -36,6 +40,7 @@ void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const
|
||||
treeFile.close();
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
void XQNodeWriter::dumpNode( QXmlStreamWriter& writer, XQNodePtr node ) const
|
||||
{
|
||||
|
@@ -15,12 +15,19 @@
|
||||
#include <xqselectionmodel.h>
|
||||
#include <xqitem.h>
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQSelectionModel::XQSelectionModel(QAbstractItemModel* model)
|
||||
: QItemSelectionModel(model)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent)
|
||||
: QItemSelectionModel(model, parent)
|
||||
{
|
||||
@@ -28,6 +35,7 @@ XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent)
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command)
|
||||
{
|
||||
@@ -58,8 +66,5 @@ void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionMod
|
||||
}
|
||||
return QItemSelectionModel::select(newSelection, command);
|
||||
}
|
||||
|
||||
|
||||
QItemSelectionModel::select(selection, command);
|
||||
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
#include <xqviewmodel.h>
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
|
||||
{
|
||||
bool pasteOk = false;
|
||||
@@ -36,6 +38,8 @@ bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQSimpleClipBoard::saveNodes( const QModelIndexList& list )
|
||||
{
|
||||
clear();
|
||||
|
@@ -30,6 +30,8 @@
|
||||
//Q_GLOBAL_STATIC(XQItem,s_dummyItem)
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void showItemList( const XQItemList& list)
|
||||
{
|
||||
for(const auto& entry : list )
|
||||
@@ -38,11 +40,15 @@ void showItemList( const XQItemList& list)
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQViewModel::~XQViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQViewModel::XQViewModel( QObject* parent )
|
||||
: QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() }
|
||||
{
|
||||
@@ -51,6 +57,8 @@ XQViewModel::XQViewModel( QObject* parent )
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
const XQItem& XQViewModel::xqRootItem()
|
||||
{
|
||||
// das ist ein hack, denn 'invisibleRootItem()' ist und bleibt ein
|
||||
@@ -62,6 +70,8 @@ const XQItem& XQViewModel::xqRootItem()
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const
|
||||
{
|
||||
if( index.isValid() )
|
||||
@@ -73,17 +83,21 @@ XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const
|
||||
return XQItem::fallBackDummyItem();
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
XQItem& XQViewModel::xqFirstItem(int row) const
|
||||
{
|
||||
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::onActionTriggered(QAction* action)
|
||||
{
|
||||
qDebug() << " --- onActionTriggered: count:" << XQNode::s_Count;
|
||||
|
||||
// all selected indices
|
||||
QModelIndexList selectionList = treeView()->selectionModel()->selectedRows();
|
||||
QModelIndexList selectionList = treeTable()->selectionModel()->selectedRows();
|
||||
// extract command type
|
||||
XQCommand::CmdType cmdType = action->data().value<XQCommand::CmdType>();
|
||||
|
||||
@@ -115,7 +129,7 @@ void XQViewModel::onActionTriggered(QAction* action)
|
||||
XQCommand* command = new XQCommand( cmdType, this );
|
||||
// store the row positions of the selected indices
|
||||
command->saveNodes( selectionList );
|
||||
command->setOriginIndex( treeView()->currentIndex() );
|
||||
command->setOriginIndex( treeTable()->currentIndex() );
|
||||
|
||||
// execute command
|
||||
_undoStack->push( command );
|
||||
@@ -129,6 +143,8 @@ void XQViewModel::onActionTriggered(QAction* action)
|
||||
* @param command the current command
|
||||
*/
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::onCommandRedo( XQCommand& command )
|
||||
{
|
||||
try
|
||||
@@ -171,6 +187,8 @@ void XQViewModel::onCommandRedo( XQCommand& command )
|
||||
* @param command the command to be undone.
|
||||
*/
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::onCommandUndo( XQCommand& command )
|
||||
{
|
||||
qDebug() << " --- onCommandUndo: count: " << XQNode::s_Count;
|
||||
@@ -220,6 +238,7 @@ void XQViewModel::onCommandUndo( XQCommand& command )
|
||||
// undo-/redo-able stuff
|
||||
|
||||
//! markierte knoten entfernen, 'command' enthält die liste
|
||||
|
||||
void XQViewModel::cmdCut( XQCommand& command )
|
||||
{
|
||||
// wir gehen rückwärts über alle gemerkten knoten ...
|
||||
@@ -265,7 +284,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command )
|
||||
void XQViewModel::cmdPaste( XQCommand& command )
|
||||
{
|
||||
// selection holen ...
|
||||
QItemSelectionModel* selectionModel = treeView()->selectionModel();
|
||||
QItemSelectionModel* selectionModel = treeTable()->selectionModel();
|
||||
// ... und löschen
|
||||
selectionModel->clearSelection();
|
||||
|
||||
@@ -289,7 +308,7 @@ void XQViewModel::cmdPaste( XQCommand& command )
|
||||
insertRow( insRow, list );
|
||||
// die neue item-row selektieren
|
||||
const QModelIndex& selIdx = list[0]->index();
|
||||
_treeView->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
_treeTable->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
// zur nächsten zeile
|
||||
insRow++;
|
||||
nodePos++;
|
||||
@@ -322,6 +341,8 @@ void XQViewModel::cmdPasteUndo( XQCommand& command )
|
||||
|
||||
// don't clone into clipboard, remove items
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::cmdDelete( XQCommand& command )
|
||||
{
|
||||
// wir gehen rückwärts über alle markieren knoten ...
|
||||
@@ -337,6 +358,8 @@ void XQViewModel::cmdDelete( XQCommand& command )
|
||||
}
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::cmdDeleteUndo( XQCommand& command )
|
||||
{
|
||||
|
||||
@@ -348,6 +371,8 @@ void XQViewModel::cmdDeleteUndo( XQCommand& command )
|
||||
* @param command the command
|
||||
*/
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::cmdNew( XQCommand& command )
|
||||
{
|
||||
|
||||
@@ -376,17 +401,21 @@ void XQViewModel::cmdNew( XQCommand& command )
|
||||
insertRow( origin.row(), list );
|
||||
|
||||
// ... and make it ...
|
||||
treeView()->setCurrentIndex( list[0]->index() );
|
||||
treeTable()->setCurrentIndex( list[0]->index() );
|
||||
// ... editable
|
||||
treeView()->edit( list[0]->index() );
|
||||
treeTable()->edit( list[0]->index() );
|
||||
*/
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::cmdNewUndo( XQCommand& command )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::cmdToggleSection( const QModelIndex& index )
|
||||
{
|
||||
Q_ASSERT(index.isValid());
|
||||
@@ -394,31 +423,35 @@ void XQViewModel::cmdToggleSection( const QModelIndex& index )
|
||||
int fstRow = _sections.firstRow( index );
|
||||
int lstRow = _sections.lastRow( index );
|
||||
|
||||
bool hidden =_treeView->isRowHidden( fstRow, _treeView->rootIndex() );
|
||||
bool hidden =_treeTable->isRowHidden( fstRow, _treeTable->rootIndex() );
|
||||
for (int row = fstRow; row < lstRow; ++row )
|
||||
_treeView->setRowHidden( row, _treeView->rootIndex(), !hidden );
|
||||
_treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden );
|
||||
|
||||
}
|
||||
|
||||
|
||||
XQTreeTable* XQViewModel::treeView()
|
||||
//! firz
|
||||
|
||||
XQTreeTable* XQViewModel::treeTable()
|
||||
{
|
||||
return _treeView;
|
||||
return _treeTable;
|
||||
}
|
||||
|
||||
void XQViewModel::setTreeView(XQTreeTable* mainView )
|
||||
//! firz
|
||||
|
||||
void XQViewModel::setTreeTable(XQTreeTable* mainView )
|
||||
{
|
||||
// store view for direct access: the maintree
|
||||
_treeView = mainView;
|
||||
_treeTable = mainView;
|
||||
// connect myself as model to the mainview
|
||||
_treeView->setModel(this);
|
||||
_treeTable->setModel(this);
|
||||
XQItemDelegate* delegate = new XQItemDelegate( *this );
|
||||
_treeView->setItemDelegate( delegate );
|
||||
_treeTable->setItemDelegate( delegate );
|
||||
|
||||
_contextMenu = new XQContextMenu( mainView );
|
||||
|
||||
connect( _treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint)));
|
||||
//connect( _treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) );
|
||||
connect( _treeTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint)));
|
||||
//connect( _treeTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) );
|
||||
connect(_contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(onActionTriggered(QAction*)));
|
||||
|
||||
// __fixme, die view soll über das modelsheet konfiguriert werden!
|
||||
@@ -430,17 +463,21 @@ void XQViewModel::setTreeView(XQTreeTable* mainView )
|
||||
* edit triggers and so on.
|
||||
*/
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::setupViewProperties()
|
||||
{
|
||||
_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
_treeView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
|
||||
_treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
//_treeView->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||
_treeView->setSelectionModel( new XQSelectionModel(this) );
|
||||
_treeTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
_treeTable->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
|
||||
_treeTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
_treeTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
//_treeTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
|
||||
_treeTable->setSelectionModel( new XQSelectionModel(this) );
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode )
|
||||
{
|
||||
appendRow(list);
|
||||
@@ -448,25 +485,32 @@ void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
QUndoStack* XQViewModel::undoStack()
|
||||
{
|
||||
return _undoStack;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::setUndoStack( QUndoStack* undoStack )
|
||||
{
|
||||
_undoStack = undoStack;
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQViewModel::onShowContextMenu(const QPoint& point)
|
||||
{
|
||||
initContextMenu();
|
||||
_contextMenu->popup(_treeView->mapToGlobal(point));
|
||||
_contextMenu->popup(_treeTable->mapToGlobal(point));
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
QHash<int, QByteArray> XQViewModel::roleNames() const
|
||||
{
|
||||
|
@@ -52,8 +52,8 @@ public:
|
||||
XQViewModel(QObject* parent = nullptr);
|
||||
virtual ~XQViewModel();
|
||||
|
||||
XQTreeTable* treeView();
|
||||
virtual void setTreeView( XQTreeTable* mainView );
|
||||
XQTreeTable* treeTable();
|
||||
virtual void setTreeTable( XQTreeTable* mainView );
|
||||
|
||||
QUndoStack* undoStack();
|
||||
void setUndoStack( QUndoStack* undoStack );
|
||||
@@ -125,7 +125,7 @@ protected:
|
||||
XQSimpleClipBoard _clipBoard;
|
||||
XQModelSections _sections;
|
||||
|
||||
XQTreeTable* _treeView{};
|
||||
XQTreeTable* _treeTable{};
|
||||
QUndoStack* _undoStack{};
|
||||
XQContextMenu* _contextMenu{};
|
||||
|
||||
|
@@ -14,6 +14,9 @@
|
||||
|
||||
#include <znode.h>
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
namespace znode
|
||||
{
|
||||
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <xqexception.h>
|
||||
|
||||
//! firz
|
||||
|
||||
XQException::XQException(const QString& what, const QString& param )
|
||||
: std::runtime_error( param.isEmpty() ? what.toStdString() : QString( "%1: %2" ).arg(what,param).toStdString( ) )
|
||||
{}
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include <xqcontextmenu.h>
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQContextMenu::XQContextMenu(const QString& title, QWidget* parent )
|
||||
: QMenu( title, parent )
|
||||
{
|
||||
@@ -27,13 +29,15 @@ XQContextMenu::XQContextMenu(const QString& title, QWidget* parent )
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
XQContextMenu::XQContextMenu(QWidget* parent)
|
||||
: QMenu( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
@@ -45,12 +49,16 @@ void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandTyp
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled );
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
QAction* newAction = new QAction(icon, text, this);
|
||||
@@ -61,6 +69,8 @@ void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand:
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled)
|
||||
{
|
||||
if( _actionMap.contains(commandType) )
|
||||
|
@@ -20,6 +20,8 @@
|
||||
|
||||
#define DB_TIMESTAMP QTime::currentTime().toString(" -- HH:mm:ss.zzz")
|
||||
|
||||
//! firz
|
||||
|
||||
XQTreeTable::XQTreeTable(QWidget* parent)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
@@ -34,10 +36,7 @@ XQTreeTable::XQTreeTable(QWidget* parent)
|
||||
}
|
||||
|
||||
|
||||
XQTreeTable::~XQTreeTable()
|
||||
{
|
||||
}
|
||||
|
||||
//! firz
|
||||
|
||||
XQViewModel* XQTreeTable::modelView()
|
||||
{
|
||||
@@ -45,12 +44,16 @@ XQViewModel* XQTreeTable::modelView()
|
||||
}
|
||||
|
||||
// __fixme: necessary?
|
||||
//! firz
|
||||
|
||||
XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
|
||||
{
|
||||
return modelView()->xqItemFromIndex( index );
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
{
|
||||
|
||||
@@ -68,6 +71,8 @@ void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex&
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::mouseResizeHeaderEntry(int xpos)
|
||||
{
|
||||
// resize colummn: minimal vertical margin in pixels
|
||||
@@ -90,6 +95,9 @@ void XQTreeTable::mouseResizeHeaderEntry(int xpos)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
// pixel Grenzwert zur Anzeige des Splitcursors
|
||||
@@ -128,6 +136,9 @@ void XQTreeTable::mouseMoveEvent(QMouseEvent* event)
|
||||
QTreeView::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
/*
|
||||
@@ -144,6 +155,8 @@ void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
|
||||
@@ -161,6 +174,8 @@ void XQTreeTable::mousePressEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
// reset index for resize column
|
||||
@@ -170,6 +185,8 @@ void XQTreeTable::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQTreeTable::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
// Ctrl-key down?
|
||||
|
@@ -30,12 +30,13 @@ class XQViewModel;
|
||||
class XQTreeTable : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QTreeView)
|
||||
// wird hier lieber ncht benutzt
|
||||
//Q_DECLARE_PRIVATE(QTreeView)
|
||||
|
||||
public:
|
||||
|
||||
XQTreeTable(QWidget* parent = nullptr );
|
||||
virtual ~XQTreeTable();
|
||||
virtual ~XQTreeTable() = default;
|
||||
|
||||
XQViewModel* modelView();
|
||||
XQItem& xqItemFromIndex(const QModelIndex& index );
|
||||
@@ -45,14 +46,10 @@ protected:
|
||||
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
//! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view
|
||||
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
||||
//! Mouse release event.used to emulate the behavior of a QHeaderView in the first line of the view
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
//! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseResizeHeaderEntry(int xpos);
|
||||
//! Mouse wheel event.
|
||||
void wheelEvent(QWheelEvent* event) override;
|
||||
|
||||
//! used by the mouse events
|
||||
|
Reference in New Issue
Block a user