Enable saving when modified, disable saving after saving.
This commit is contained in:
parent
2292fc96c4
commit
8163f41473
5 changed files with 58 additions and 4 deletions
|
@ -19,6 +19,22 @@ namespace
|
||||||
ENTRY_DFN_ARRAY
|
ENTRY_DFN_ARRAY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString enumToString( int value )
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
|
||||||
|
switch( value )
|
||||||
|
{
|
||||||
|
case ENTRY_TYPE: s = "type"; break;
|
||||||
|
case ENTRY_DFN: s = "dfn"; break;
|
||||||
|
case ENTRY_VIRTUAL_DFN: s = "virtual dfn"; break;
|
||||||
|
case ENTRY_TYPE_ARRAY: s = "type array"; break;
|
||||||
|
case ENTRY_DFN_ARRAY: s = "dfn array"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
NLGEORGES::UFormDfn::TEntryType enumToEntry( int value )
|
NLGEORGES::UFormDfn::TEntryType enumToEntry( int value )
|
||||||
{
|
{
|
||||||
NLGEORGES::UFormDfn::TEntryType entry = NLGEORGES::UFormDfn::EntryType;
|
NLGEORGES::UFormDfn::TEntryType entry = NLGEORGES::UFormDfn::EntryType;
|
||||||
|
@ -192,6 +208,10 @@ void DFNBrowserCtrl::onVariantValueChanged( QtProperty *p, const QVariant &v )
|
||||||
{
|
{
|
||||||
entry.setFilenameExt( value.c_str() );
|
entry.setFilenameExt( value.c_str() );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
Q_EMIT valueChanged( key, v.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFNBrowserCtrl::onEnumValueChanged( QtProperty *p, int v )
|
void DFNBrowserCtrl::onEnumValueChanged( QtProperty *p, int v )
|
||||||
|
@ -202,12 +222,17 @@ void DFNBrowserCtrl::onEnumValueChanged( QtProperty *p, int v )
|
||||||
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( m_idx );
|
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( m_idx );
|
||||||
entry.setArrayFlag( isArray );
|
entry.setArrayFlag( isArray );
|
||||||
entry.setType( tentry );
|
entry.setType( tentry );
|
||||||
|
|
||||||
|
QString value = enumToString( v );
|
||||||
|
Q_EMIT valueChanged( p->propertyName(), value );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFNBrowserCtrl::onFileValueChanged( QtProperty *p, const QString &v )
|
void DFNBrowserCtrl::onFileValueChanged( QtProperty *p, const QString &v )
|
||||||
{
|
{
|
||||||
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( m_idx );
|
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( m_idx );
|
||||||
entry.setFilename( v.toUtf8().constData() );
|
entry.setFilename( v.toUtf8().constData() );
|
||||||
|
|
||||||
|
Q_EMIT valueChanged( p->propertyName(), v );
|
||||||
}
|
}
|
||||||
|
|
||||||
void DFNBrowserCtrl::connectManagers()
|
void DFNBrowserCtrl::connectManagers()
|
||||||
|
|
|
@ -31,6 +31,9 @@ public:
|
||||||
|
|
||||||
void onElementSelected( int idx );
|
void onElementSelected( int idx );
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void valueChanged( const QString &key, const QString &value );
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onFileValueChanged( QtProperty *p, const QString &v );
|
void onFileValueChanged( QtProperty *p, const QString &v );
|
||||||
void onVariantValueChanged( QtProperty *p, const QVariant &v );
|
void onVariantValueChanged( QtProperty *p, const QVariant &v );
|
||||||
|
|
|
@ -28,13 +28,14 @@ GeorgesDFNDialog::GeorgesDFNDialog( QWidget *parent ) :
|
||||||
GeorgesDockWidget( parent )
|
GeorgesDockWidget( parent )
|
||||||
{
|
{
|
||||||
m_ui.setupUi( this );
|
m_ui.setupUi( this );
|
||||||
setupConnections();
|
|
||||||
|
|
||||||
m_ui.addButton->setEnabled( false );
|
m_ui.addButton->setEnabled( false );
|
||||||
m_ui.removeButton->setEnabled( false );
|
m_ui.removeButton->setEnabled( false );
|
||||||
|
|
||||||
m_pvt = new GeorgesDFNDialogPvt();
|
m_pvt = new GeorgesDFNDialogPvt();
|
||||||
m_pvt->ctrl->setBrowser( m_ui.browser );
|
m_pvt->ctrl->setBrowser( m_ui.browser );
|
||||||
|
|
||||||
|
setupConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
GeorgesDFNDialog::~GeorgesDFNDialog()
|
GeorgesDFNDialog::~GeorgesDFNDialog()
|
||||||
|
@ -74,6 +75,12 @@ bool GeorgesDFNDialog::load( const QString &fileName )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeorgesDFNDialog::write()
|
||||||
|
{
|
||||||
|
setModified( false );
|
||||||
|
setWindowTitle( windowTitle().remove( "*" ) );
|
||||||
|
}
|
||||||
|
|
||||||
void GeorgesDFNDialog::onAddClicked()
|
void GeorgesDFNDialog::onAddClicked()
|
||||||
{
|
{
|
||||||
QString name = QInputDialog::getText( this,
|
QString name = QInputDialog::getText( this,
|
||||||
|
@ -110,10 +117,22 @@ void GeorgesDFNDialog::onCurrentRowChanged( int row )
|
||||||
m_pvt->ctrl->onElementSelected( row );
|
m_pvt->ctrl->onElementSelected( row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeorgesDFNDialog::onValueChanged( const QString &key, const QString &value )
|
||||||
|
{
|
||||||
|
if( !isModified() )
|
||||||
|
{
|
||||||
|
setModified( true );
|
||||||
|
setWindowTitle( windowTitle() + "*" );
|
||||||
|
|
||||||
|
Q_EMIT modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GeorgesDFNDialog::setupConnections()
|
void GeorgesDFNDialog::setupConnections()
|
||||||
{
|
{
|
||||||
connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||||
connect( m_ui.removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
connect( m_ui.removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||||
connect( m_ui.list, SIGNAL( currentRowChanged( int ) ), this, SLOT( onCurrentRowChanged( int ) ) );
|
connect( m_ui.list, SIGNAL( currentRowChanged( int ) ), this, SLOT( onCurrentRowChanged( int ) ) );
|
||||||
|
connect( m_pvt->ctrl, SIGNAL( valueChanged( const QString&, const QString& ) ), this, SLOT( onValueChanged( const QString&, const QString& ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,18 @@ public:
|
||||||
~GeorgesDFNDialog();
|
~GeorgesDFNDialog();
|
||||||
|
|
||||||
bool load( const QString &fileName );
|
bool load( const QString &fileName );
|
||||||
void write(){}
|
void write();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void modified();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onAddClicked();
|
void onAddClicked();
|
||||||
void onRemoveClicked();
|
void onRemoveClicked();
|
||||||
void onCurrentRowChanged( int row );
|
void onCurrentRowChanged( int row );
|
||||||
|
|
||||||
|
void onValueChanged( const QString& key, const QString &value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupConnections();
|
void setupConnections();
|
||||||
|
|
||||||
|
|
|
@ -326,9 +326,11 @@ namespace GeorgesQt
|
||||||
if( !b )
|
if( !b )
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
d = NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect( d, SIGNAL( modified() ), this, SLOT( setModified() ) );
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue