mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 20:30:54 +00:00
Enable saving when modified, disable saving after saving.
--HG-- branch : dfighter-tools
This commit is contained in:
parent
f1a6a8d9cd
commit
e2cb637a13
5 changed files with 58 additions and 4 deletions
|
@ -19,6 +19,22 @@ namespace
|
|||
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 entry = NLGEORGES::UFormDfn::EntryType;
|
||||
|
@ -192,6 +208,10 @@ void DFNBrowserCtrl::onVariantValueChanged( QtProperty *p, const QVariant &v )
|
|||
{
|
||||
entry.setFilenameExt( value.c_str() );
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
Q_EMIT valueChanged( key, v.toString() );
|
||||
}
|
||||
|
||||
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 );
|
||||
entry.setArrayFlag( isArray );
|
||||
entry.setType( tentry );
|
||||
|
||||
QString value = enumToString( v );
|
||||
Q_EMIT valueChanged( p->propertyName(), value );
|
||||
}
|
||||
|
||||
void DFNBrowserCtrl::onFileValueChanged( QtProperty *p, const QString &v )
|
||||
{
|
||||
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( m_idx );
|
||||
entry.setFilename( v.toUtf8().constData() );
|
||||
|
||||
Q_EMIT valueChanged( p->propertyName(), v );
|
||||
}
|
||||
|
||||
void DFNBrowserCtrl::connectManagers()
|
||||
|
|
|
@ -31,6 +31,9 @@ public:
|
|||
|
||||
void onElementSelected( int idx );
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged( const QString &key, const QString &value );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFileValueChanged( QtProperty *p, const QString &v );
|
||||
void onVariantValueChanged( QtProperty *p, const QVariant &v );
|
||||
|
|
|
@ -28,13 +28,14 @@ GeorgesDFNDialog::GeorgesDFNDialog( QWidget *parent ) :
|
|||
GeorgesDockWidget( parent )
|
||||
{
|
||||
m_ui.setupUi( this );
|
||||
setupConnections();
|
||||
|
||||
m_ui.addButton->setEnabled( false );
|
||||
m_ui.removeButton->setEnabled( false );
|
||||
|
||||
m_pvt = new GeorgesDFNDialogPvt();
|
||||
m_pvt->ctrl->setBrowser( m_ui.browser );
|
||||
|
||||
setupConnections();
|
||||
}
|
||||
|
||||
GeorgesDFNDialog::~GeorgesDFNDialog()
|
||||
|
@ -74,6 +75,12 @@ bool GeorgesDFNDialog::load( const QString &fileName )
|
|||
return true;
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::write()
|
||||
{
|
||||
setModified( false );
|
||||
setWindowTitle( windowTitle().remove( "*" ) );
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::onAddClicked()
|
||||
{
|
||||
QString name = QInputDialog::getText( this,
|
||||
|
@ -110,10 +117,22 @@ void GeorgesDFNDialog::onCurrentRowChanged( int 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()
|
||||
{
|
||||
connect( m_ui.addButton, SIGNAL( clicked( bool ) ), this, SLOT( onAddClicked() ) );
|
||||
connect( m_ui.removeButton, SIGNAL( clicked( bool ) ), this, SLOT( onRemoveClicked() ) );
|
||||
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();
|
||||
|
||||
bool load( const QString &fileName );
|
||||
void write(){}
|
||||
void write();
|
||||
|
||||
Q_SIGNALS:
|
||||
void modified();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onCurrentRowChanged( int row );
|
||||
|
||||
void onValueChanged( const QString& key, const QString &value );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
|
|
|
@ -326,9 +326,11 @@ namespace GeorgesQt
|
|||
if( !b )
|
||||
{
|
||||
delete d;
|
||||
d = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
connect( d, SIGNAL( modified() ), this, SLOT( setModified() ) );
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue