add signal prototypes
This commit is contained in:
@@ -76,6 +76,17 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! SLOT als weiterleitung vom SIGNAL itemchanged
|
||||||
|
|
||||||
|
void XQChildModel::onItemChanged(XQItem& item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- Child item changed: " << item.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Erzeugt eine model-section und fügt den zugehörigen header ein.
|
||||||
|
|
||||||
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
|
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
|
||||||
{
|
{
|
||||||
XQModelSection& section = _sections.at( key );
|
XQModelSection& section = _sections.at( key );
|
||||||
@@ -89,7 +100,8 @@ void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& content
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! erzeugt ein adhoc-contextmenu, je nachdem welche aktionen gerade möflich sind.
|
|
||||||
|
//! erzeugt ein adhoc-contextmenu, je nachdem welche aktionen gerade möglich sind.
|
||||||
|
|
||||||
void XQChildModel::initContextMenu()
|
void XQChildModel::initContextMenu()
|
||||||
{
|
{
|
||||||
|
@@ -32,6 +32,10 @@ public:
|
|||||||
void addModelData(const XQNodePtr& contentRoot );
|
void addModelData(const XQNodePtr& contentRoot );
|
||||||
void addSectionEntry(const QString& key, const XQNodePtr& contentEntry );
|
void addSectionEntry(const QString& key, const XQNodePtr& contentEntry );
|
||||||
|
|
||||||
|
//public slots:
|
||||||
|
|
||||||
|
void onItemChanged( XQItem& item ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//void setupViewProperties() override;
|
//void setupViewProperties() override;
|
||||||
|
@@ -77,3 +77,11 @@ void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* project
|
|||||||
projectItem->appendRow( newItem );
|
projectItem->appendRow( newItem );
|
||||||
expandNewItem(projectItem->index() );
|
expandNewItem(projectItem->index() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void XQMainModel::onItemChanged( XQItem& item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- MAIN Model on itemChanged:" << item.text();
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -35,6 +35,12 @@ public:
|
|||||||
XQItem* addProjectItem( XQNodePtr contentNode );
|
XQItem* addProjectItem( XQNodePtr contentNode );
|
||||||
void addSectionItem( const XQModelSection& section, XQItem* projectItem );
|
void addSectionItem( const XQModelSection& section, XQItem* projectItem );
|
||||||
|
|
||||||
|
|
||||||
|
//public slots:
|
||||||
|
|
||||||
|
void onItemChanged(XQItem& item ) override;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void initContextMenu() override;
|
void initContextMenu() override;
|
||||||
|
@@ -88,18 +88,36 @@ void XQMainWindow::initMainWindow()
|
|||||||
connect( _actionExit, &QAction::triggered, this, &XQMainWindow::onExit );
|
connect( _actionExit, &QAction::triggered, this, &XQMainWindow::onExit );
|
||||||
connect( _actionAbout, &QAction::triggered, this, &XQMainWindow::onAbout );
|
connect( _actionAbout, &QAction::triggered, this, &XQMainWindow::onAbout );
|
||||||
|
|
||||||
//connect( _mainTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) );
|
|
||||||
connect( _mainTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onTreeItemClicked(QModelIndex)) );
|
|
||||||
connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) );
|
connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) );
|
||||||
|
|
||||||
|
//connect(&_mainModel, &QStandardItemModel::itemChanged, this, &XQMainWindow::onTreeItemChanged );
|
||||||
|
//connect( _mainTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) );
|
||||||
|
//connect( _mainTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onTreeItemClicked(QModelIndex)) );
|
||||||
|
/*
|
||||||
|
connect( _mainTreeView, &QTreeView::clicked, this, [&,this](const QModelIndex& index)
|
||||||
|
{
|
||||||
|
onTreeItemClicked( XQItem::xqItemFromIndex(index) );
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
connect( _mainTreeView, &QTreeView::clicked, this, [&,this](const QModelIndex& index)
|
||||||
|
{
|
||||||
|
onMyFirz( XQItem::xqItemFromIndex(index) );
|
||||||
|
});
|
||||||
|
|
||||||
|
connect( this, &XQMainWindow::doTheFirz, this, &XQMainWindow::onMyFirz );
|
||||||
|
|
||||||
|
XQItem* item = new XQItem();
|
||||||
|
item->setText("xxxFITZ!");
|
||||||
|
|
||||||
|
emit doTheFirz(*item);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
connect( &_mainModelView, &XQViewModel::itemCreated, this, [=, this](XQItem* item)
|
connect( &_mainModel, &XQViewModel::itemCreated, this, [=, this](XQItem* item)
|
||||||
{
|
{
|
||||||
// when a new main tree item has been created ...
|
// when a new main tree item has been created ...
|
||||||
QString pID = item->contentNode()->attribute(c_ProjectID);
|
QString pID = item.contentNode()->attribute(c_ProjectID);
|
||||||
_mainTreeView->setCurrentIndex( item->index() );
|
_mainTreeView->setCurrentIndex( item.index() );
|
||||||
// ... we set the current view to this node
|
// ... we set the current view to this node
|
||||||
if( _documentStore.contains( pID ) )
|
if( _documentStore.contains( pID ) )
|
||||||
_tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() );
|
_tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() );
|
||||||
@@ -109,11 +127,11 @@ void XQMainWindow::initMainWindow()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// hand over undostack
|
// hand over undostack
|
||||||
_mainModelView.setUndoStack(&_undoStack);
|
_mainModel.setUndoStack(&_undoStack);
|
||||||
// hand over left side navigation tree
|
// hand over left side navigation tree
|
||||||
_mainModelView.setTreeTable(_mainTreeView);
|
_mainModel.setTreeTable(_mainTreeView);
|
||||||
// #1. init the left side main tree view
|
// #1. init the left side main tree view
|
||||||
_mainModelView.initModel( c_MainModelName );
|
_mainModel.initModel( c_MainModelName );
|
||||||
|
|
||||||
// #2. load demo data
|
// #2. load demo data
|
||||||
loadDocument( c_DocumentFileName1 );
|
loadDocument( c_DocumentFileName1 );
|
||||||
@@ -245,20 +263,19 @@ void XQMainWindow::onAbout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! wenn ein item im navigations-baum geklickt wird, soll die document
|
//! wenn ein item im navigations-baum geklickt wird, soll die document
|
||||||
//! view rechts angepasst werden.
|
//! view rechts angepasst werden.
|
||||||
|
|
||||||
void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
void XQMainWindow::onTreeItemClicked( XQItem& item )
|
||||||
{
|
{
|
||||||
|
|
||||||
XQItem& entry = XQItem::xqItemFromIndex(index);
|
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << item.text();
|
||||||
|
_mainTreeView->selectionModel()->select(item.index(), QItemSelectionModel::Select);
|
||||||
|
|
||||||
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << entry.text();
|
if( XQNodePtr contentNode = item.contentNode() )
|
||||||
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
|
|
||||||
|
|
||||||
if( XQNodePtr contentNode = entry.contentNode() )
|
|
||||||
{
|
{
|
||||||
//XQNodePtr contentNode = entry.contentNode()
|
//XQNodePtr contentNode = item.contentNode()
|
||||||
QString key = contentNode->attribute(c_ProjectID);
|
QString key = contentNode->attribute(c_ProjectID);
|
||||||
qDebug() << " --- FIRZ: key: " << key;
|
qDebug() << " --- FIRZ: key: " << key;
|
||||||
|
|
||||||
@@ -266,8 +283,21 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
|||||||
if( isThere)
|
if( isThere)
|
||||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XQMainWindow::onTreeItemChanged(XQItem& item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- MAIN WINDOW on itemChanged:" << item.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void XQMainWindow::onChildViewItemClicked( XQItem& item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- MAIN WINDOW on CHILD item CLICK:" << item.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void XQMainWindow::onChildViewItemChanged( XQItem& item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- MAIN WINDOW on CHILD itemChanged:" << item.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -277,7 +307,7 @@ void XQMainWindow::onTabClicked( int index )
|
|||||||
{
|
{
|
||||||
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
||||||
//qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
//qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
||||||
//_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
//_mainTreeView->setCurrentIndex( _documentStore[index]->treeTtem.index() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
||||||
@@ -285,7 +315,7 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
|||||||
qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
||||||
if( _currentProjectItem )
|
if( _currentProjectItem )
|
||||||
{
|
{
|
||||||
_mainModelView.addSectionItem( section, _currentProjectItem );
|
_mainModel.addSectionItem( section, _currentProjectItem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,6 +413,7 @@ 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);
|
||||||
@@ -391,7 +422,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
childModel->setTreeTable(childTreeView);
|
childModel->setTreeTable(childTreeView);
|
||||||
|
|
||||||
// neuen eintrag im übsichts-baum erzeugen
|
// neuen eintrag im übsichts-baum erzeugen
|
||||||
_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
_currentProjectItem = _mainModel.addProjectItem( contentRoot );
|
||||||
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||||
|
|
||||||
// die Modelstruktur anlegen
|
// die Modelstruktur anlegen
|
||||||
|
@@ -33,8 +33,17 @@ public:
|
|||||||
|
|
||||||
void initMainWindow();
|
void initMainWindow();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void doTheFirz(XQItem& item);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
virtual void onMyFirz(XQItem& item)
|
||||||
|
{
|
||||||
|
qDebug() << " --- myFirz: " << item.text();
|
||||||
|
}
|
||||||
|
|
||||||
void onUndo();
|
void onUndo();
|
||||||
void onRedo();
|
void onRedo();
|
||||||
|
|
||||||
@@ -46,7 +55,10 @@ public slots:
|
|||||||
void onAbout();
|
void onAbout();
|
||||||
void onExit();
|
void onExit();
|
||||||
|
|
||||||
void onTreeItemClicked(const QModelIndex& index );
|
void onTreeItemClicked( XQItem& item );
|
||||||
|
void onTreeItemChanged( XQItem& item );
|
||||||
|
void onChildViewItemClicked( XQItem& item );
|
||||||
|
void onChildViewItemChanged( XQItem& item );
|
||||||
void onTabClicked( int index );
|
void onTabClicked( int index );
|
||||||
//void onItemCreated( XQItem* item );
|
//void onItemCreated( XQItem* item );
|
||||||
void onSectionCreated( const XQModelSection& section);
|
void onSectionCreated( const XQModelSection& section);
|
||||||
@@ -56,8 +68,6 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fixme implement
|
// fixme implement
|
||||||
void showDocumnet( const QString& key ){}
|
void showDocumnet( const QString& key ){}
|
||||||
void loadDocument( const QString& fileName );
|
void loadDocument( const QString& fileName );
|
||||||
@@ -68,7 +78,7 @@ protected:
|
|||||||
QUndoStack _undoStack;
|
QUndoStack _undoStack;
|
||||||
XQDocumentStore _documentStore;
|
XQDocumentStore _documentStore;
|
||||||
|
|
||||||
XQMainModel _mainModelView;
|
XQMainModel _mainModel;
|
||||||
XQItem* _currentProjectItem{};
|
XQItem* _currentProjectItem{};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -268,9 +268,7 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(XQItem);
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(XQItem::RenderStyle);
|
Q_DECLARE_METATYPE(XQItem::RenderStyle);
|
||||||
Q_DECLARE_METATYPE(XQItem::EditorType);
|
Q_DECLARE_METATYPE(XQItem::EditorType);
|
||||||
Q_DECLARE_METATYPE(XQItem::UnitType);
|
Q_DECLARE_METATYPE(XQItem::UnitType);
|
||||||
|
11
src/main.cpp
11
src/main.cpp
@@ -79,17 +79,6 @@ using namespace Qt::Literals::StringLiterals;
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
// Signal für einzelne QStandardItem-Änderungen
|
|
||||||
connect(model, &QStandardItemModel::itemChanged,
|
|
||||||
this, [](QStandardItem *changedItem){
|
|
||||||
QVariant state = changedItem->data(Qt::CheckStateRole);
|
|
||||||
qDebug() << "Neuer Check-State:" << state.toInt();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
//app.setStyle("fusion");
|
//app.setStyle("fusion");
|
||||||
XQMainWindow window;
|
XQMainWindow window;
|
||||||
|
@@ -40,19 +40,23 @@ void showItemList( const XQItemList& list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Konstruktur mit parent.
|
//! Konstruktor mit parent.
|
||||||
|
|
||||||
XQViewModel::XQViewModel( QObject* parent )
|
XQViewModel::XQViewModel( QObject* parent )
|
||||||
: QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() }
|
: QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() }
|
||||||
{
|
{
|
||||||
invisibleRootItem()->setData( "[rootItem]", Qt::DisplayRole );
|
invisibleRootItem()->setData( "[rootItem]", Qt::DisplayRole );
|
||||||
setItemPrototype( new XQItem );
|
setItemPrototype( new XQItem );
|
||||||
|
/*
|
||||||
connect(this, &QStandardItemModel::itemChanged, this, [](QStandardItem *item)
|
// auf änderungen kann in den unterklassen reagiert werden
|
||||||
|
connect(this, &QStandardItemModel::itemChanged, this, [this](QStandardItem *item)
|
||||||
{
|
{
|
||||||
qDebug() << " --- item changed: " << item->text();
|
XQItem* xqItem = static_cast<XQItem*>(item);
|
||||||
|
onItemChanged( *xqItem );
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
//qRegisterMetaType<XQItem>("XQItem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,6 +189,16 @@ void YourClass::onItemChanged(const QModelIndex &topLeft, const QModelIndex &bot
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//! SLOT als weiterleitung vom SIGNAL itemchanged
|
||||||
|
|
||||||
|
void XQViewModel::onItemChanged(XQItem* item )
|
||||||
|
{
|
||||||
|
qDebug() << " --- BASE item changed: " << item->text();
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//! SLOT, der aufgerufen wird, wenn eine edit-action getriggert wurde.
|
//! SLOT, der aufgerufen wird, wenn eine edit-action getriggert wurde.
|
||||||
|
|
||||||
void XQViewModel::onActionTriggered(QAction* action)
|
void XQViewModel::onActionTriggered(QAction* action)
|
||||||
@@ -518,7 +532,7 @@ void XQViewModel::setTreeTable(XQTreeTable* mainView )
|
|||||||
{
|
{
|
||||||
// store view for direct access: the maintree
|
// store view for direct access: the maintree
|
||||||
_treeTable = mainView;
|
_treeTable = mainView;
|
||||||
// connect myself as model to the mainview
|
// set myself as model to the mainview
|
||||||
_treeTable->setModel(this);
|
_treeTable->setModel(this);
|
||||||
XQItemDelegate* delegate = new XQItemDelegate( *this );
|
XQItemDelegate* delegate = new XQItemDelegate( *this );
|
||||||
_treeTable->setItemDelegate( delegate );
|
_treeTable->setItemDelegate( delegate );
|
||||||
|
@@ -95,12 +95,16 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
virtual void onItemChanged( XQItem& item ) = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
virtual void onShowContextMenu(const QPoint& point);
|
virtual void onShowContextMenu(const QPoint& point);
|
||||||
virtual void onActionTriggered(QAction* action);
|
virtual void onActionTriggered(QAction* action);
|
||||||
virtual void onToggleSection(const QString& sectionKey );
|
virtual void onToggleSection(const QString& sectionKey );
|
||||||
|
|
||||||
|
|
||||||
// handle XQCommands ( == UndoCommand )
|
// handle XQCommands ( == UndoCommand )
|
||||||
virtual void onCommandRedo( const XQCommand& command );
|
virtual void onCommandRedo( const XQCommand& command );
|
||||||
virtual void onCommandUndo( const XQCommand& command );
|
virtual void onCommandUndo( const XQCommand& command );
|
||||||
|
Reference in New Issue
Block a user