Logging DFN changes.
This commit is contained in:
parent
0904c30803
commit
5fa370463b
5 changed files with 47 additions and 24 deletions
|
@ -83,6 +83,8 @@ void GeorgesDFNDialog::write()
|
|||
setModified( false );
|
||||
setWindowTitle( windowTitle().remove( "*" ) );
|
||||
|
||||
m_pvt->dfn->Header.Log = m_ui.logEdit->toPlainText().toUtf8().constData();
|
||||
|
||||
std::string path = NLMISC::CPath::lookup( m_fileName.toUtf8().constData(), false );
|
||||
if( path.empty() )
|
||||
return;
|
||||
|
@ -117,6 +119,8 @@ void GeorgesDFNDialog::onAddClicked()
|
|||
|
||||
m_ui.list->addItem( name );
|
||||
m_pvt->dfn->addEntry( name.toUtf8().constData() );
|
||||
|
||||
log( "Added " + name );
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::onRemoveClicked()
|
||||
|
@ -125,6 +129,8 @@ void GeorgesDFNDialog::onRemoveClicked()
|
|||
if( row < 0 )
|
||||
return;
|
||||
|
||||
log( "Removed " + m_ui.list->currentItem()->text() );
|
||||
|
||||
QListWidgetItem *item = m_ui.list->takeItem( row );
|
||||
delete item;
|
||||
|
||||
|
@ -149,12 +155,20 @@ void GeorgesDFNDialog::onValueChanged( const QString &key, const QString &value
|
|||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
log( m_ui.list->currentItem()->text() + "." + key + " = " + value );
|
||||
|
||||
if( key == "name" )
|
||||
{
|
||||
m_ui.list->currentItem()->setText( value );
|
||||
}
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::log( const QString &msg )
|
||||
{
|
||||
QString logMsg = buildLogMsg( msg );
|
||||
m_ui.logEdit->appendPlainText( logMsg );
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::setupConnections()
|
||||
{
|
||||
connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
|
|
|
@ -27,6 +27,7 @@ private Q_SLOTS:
|
|||
void onValueChanged( const QString& key, const QString &value );
|
||||
|
||||
private:
|
||||
void log( const QString &msg );
|
||||
void setupConnections();
|
||||
|
||||
Ui::GeorgesDFNDialog m_ui;
|
||||
|
|
|
@ -11,4 +11,32 @@ GeorgesDockWidget::~GeorgesDockWidget()
|
|||
{
|
||||
}
|
||||
|
||||
QString GeorgesDockWidget::buildLogMsg( 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;
|
||||
|
||||
return logMsg;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ public:
|
|||
virtual void write() = 0;
|
||||
|
||||
protected:
|
||||
QString buildLogMsg( const QString &msg );
|
||||
virtual void log( const QString &msg ) = 0;
|
||||
|
||||
QString m_fileName;
|
||||
bool m_modified;
|
||||
QUndoStack *m_undoStack;
|
||||
|
|
|
@ -698,30 +698,7 @@ namespace GeorgesQt
|
|||
|
||||
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;
|
||||
QString logMsg = buildLogMsg( msg );
|
||||
|
||||
m_ui.logEdit->appendPlainText( logMsg );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue