From 6cc882e95e532facbb00eb59300fd2c5e3ed44f9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 27 Aug 2014 19:22:10 +0200 Subject: [PATCH] Now logging changes. --- .../plugins/georges_editor/browser_ctrl.cpp | 6 +++ .../src/plugins/georges_editor/browser_ctrl.h | 2 + .../georges_editor/browser_ctrl_pvt.cpp | 3 ++ .../plugins/georges_editor/browser_ctrl_pvt.h | 1 + .../georges_treeview_dialog.cpp | 49 +++++++++++++++++++ .../georges_editor/georges_treeview_dialog.h | 3 ++ 6 files changed, 64 insertions(+) diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl.cpp b/code/studio/src/plugins/georges_editor/browser_ctrl.cpp index 17eb170c4..d4bd8daaa 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl.cpp +++ b/code/studio/src/plugins/georges_editor/browser_ctrl.cpp @@ -17,6 +17,7 @@ QObject( browser ) connect( m_pvt, SIGNAL( arrayResized( const QString&, int ) ), this, SLOT( onArrayResized( const QString&, int ) ) ); connect( m_pvt, SIGNAL( modified() ), this, SLOT( onModified() ) ); + connect( m_pvt, SIGNAL( valueChanged( const QString&, const QString& ) ), this, SLOT( onValueChanged( const QString&, const QString& ) ) ); } BrowserCtrl::~BrowserCtrl() @@ -43,6 +44,11 @@ void BrowserCtrl::onValueChanged( QtProperty *p, const QVariant &value ) m_pvt->onValueChanged( p, value ); } +void BrowserCtrl::onValueChanged( const QString &key, const QString &value ) +{ + Q_EMIT valueChanged( key, value ); +} + void BrowserCtrl::onArrayResized( const QString &name, int size ) { Q_EMIT arrayResized( name, size ); diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl.h b/code/studio/src/plugins/georges_editor/browser_ctrl.h index 9c70f51bb..daf77cc87 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl.h +++ b/code/studio/src/plugins/georges_editor/browser_ctrl.h @@ -29,9 +29,11 @@ public Q_SLOTS: Q_SIGNALS: void arrayResized( const QString &name, int size ); void modified(); + void valueChanged( const QString &key, const QString &value ); private Q_SLOTS: void onValueChanged( QtProperty *p, const QVariant &value ); + void onValueChanged( const QString &key, const QString &value ); void onArrayResized( const QString &name, int size ); void onModified(); diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp index df4168a78..0a62aa5a8 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp +++ b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.cpp @@ -158,7 +158,10 @@ void BrowserCtrlPvt::onStructValueChanged( QtProperty *p, const QVariant &value bool created = false; m_currentNode.p->setValueByName( v.c_str(), k.c_str(), &created ); + QString key = m_currentNode.name + "." + p->propertyName(); + Q_EMIT modified(); + Q_EMIT valueChanged( key, value.toString() ); } void BrowserCtrlPvt::createArray() diff --git a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h index 69924a308..2aabd5ecb 100644 --- a/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h +++ b/code/studio/src/plugins/georges_editor/browser_ctrl_pvt.h @@ -39,6 +39,7 @@ public: Q_SIGNALS: void arrayResized( const QString &name, int size ); void modified(); + void valueChanged( const QString &key, const QString &value ); private: void setupStruct( NLGEORGES::UFormElm *node ); diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp index 3222cab5f..6dbbe4899 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -90,6 +90,7 @@ namespace GeorgesQt connect(m_browserCtrl, SIGNAL(arrayResized(const QString&,int)), this, SLOT(onArrayResized(const QString&,int))); connect(m_browserCtrl, SIGNAL(modified()), this, SLOT(modifiedFile())); + connect(m_browserCtrl, SIGNAL(valueChanged(const QString&,const QString&)), this, SLOT(onValueChanged(const QString&,const QString&))); } CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog() @@ -470,12 +471,18 @@ namespace GeorgesQt if( !idx.isValid() ) return; m_ui.treeView->setCurrentIndex( idx ); + + log( name + " resized = " + QString::number( size ) ); } void CGeorgesTreeViewDialog::onAppendArray() { QModelIndex idx = m_ui.treeView->currentIndex(); + CFormItem *item = reinterpret_cast< CFormItem* >( idx.internalPointer() ); + QString formName = item->formName().c_str(); + int size = item->childCount(); + m_model->appendArray( idx ); m_ui.treeView->reset(); @@ -483,6 +490,8 @@ namespace GeorgesQt m_ui.treeView->setCurrentIndex( idx ); m_browserCtrl->clicked( idx ); + + log( formName + " resized = " + QString::number( size + 1 ) ); } void CGeorgesTreeViewDialog::onDeleteArrayEntry() @@ -490,11 +499,21 @@ namespace GeorgesQt QModelIndex current = m_ui.treeView->currentIndex(); QModelIndex parent = current.parent(); + CFormItem *item = reinterpret_cast< CFormItem* >( current.internalPointer() ); + QString formName = item->formName().c_str(); + m_model->deleteArrayEntry( current ); m_ui.treeView->expandAll(); m_ui.treeView->setCurrentIndex( parent ); m_browserCtrl->clicked( parent ); + + log( "deleted " + formName ); + } + + void CGeorgesTreeViewDialog::onValueChanged( const QString &key, const QString &value ) + { + log( key + " = " + value ); } void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) @@ -646,4 +665,34 @@ namespace GeorgesQt // delete structContext; } + void CGeorgesTreeViewDialog::log( const QString &msg ) + { + QString user = getenv( "USER" ); + if( user.isEmpty() ) + user = getenv( "USERNAME" ); + if( user.isEmpty() ) + user = "anonymous"; + + QTime time = QTime::currentTime(); + QDate date = QDate::currentDate(); + + QString dateString = date.toString( "ddd MMM dd" ); + QString timeString = time.toString( "HH:mm:ss" ); + + QString logMsg; + logMsg += dateString; + logMsg += ' '; + logMsg += timeString; + logMsg += ' '; + logMsg += QString::number( date.year() ); + logMsg += ' '; + logMsg += "("; + logMsg += user; + logMsg += ")"; + logMsg += ' '; + logMsg += msg; + + m_ui.logEdit->appendPlainText( logMsg ); + } + } /* namespace GeorgesQt */ diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h index 5e3e30ed8..17923e429 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h @@ -106,8 +106,11 @@ namespace GeorgesQt void onArrayResized( const QString &name, int size ); void onAppendArray(); void onDeleteArrayEntry(); + void onValueChanged( const QString &key, const QString &value ); private: + void log( const QString &msg ); + Ui::CGeorgesTreeViewDialog m_ui; ExpandableHeaderView *m_header; UForm *m_form;