mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
Load DFN.
This commit is contained in:
parent
e44733dfa6
commit
23c27349c3
5 changed files with 187 additions and 3 deletions
|
@ -1,2 +1,74 @@
|
|||
#include "dfn_browser_ctrl.h"
|
||||
#include "3rdparty/qtpropertybrowser/qttreepropertybrowser.h"
|
||||
#include "3rdparty/qtpropertybrowser/qtvariantproperty.h"
|
||||
|
||||
#include "nel/georges/form_dfn.h"
|
||||
|
||||
DFNBrowserCtrl::DFNBrowserCtrl( QObject *parent ) :
|
||||
QObject( parent )
|
||||
{
|
||||
m_browser = NULL;
|
||||
m_dfn = NULL;
|
||||
|
||||
m_manager = new QtVariantPropertyManager();
|
||||
m_factory = new QtVariantEditorFactory();
|
||||
}
|
||||
|
||||
DFNBrowserCtrl::~DFNBrowserCtrl()
|
||||
{
|
||||
m_browser = NULL;
|
||||
m_dfn = NULL;
|
||||
|
||||
delete m_manager;
|
||||
m_manager = NULL;
|
||||
delete m_factory;
|
||||
m_factory = NULL;
|
||||
}
|
||||
|
||||
void DFNBrowserCtrl::onElementSelected( int idx )
|
||||
{
|
||||
NLGEORGES::CFormDfn::CEntry &entry = m_dfn->getEntry( idx );
|
||||
|
||||
m_browser->clear();
|
||||
m_browser->setFactoryForManager( m_manager, m_factory );
|
||||
|
||||
QtVariantProperty *p = NULL;
|
||||
|
||||
p = m_manager->addProperty( QVariant::String, "name" );
|
||||
p->setValue( entry.getName().c_str() );
|
||||
m_browser->addProperty( p );
|
||||
|
||||
|
||||
NLGEORGES::UFormDfn::TEntryType et = entry.getType();
|
||||
bool isArray = entry.getArrayFlag();
|
||||
QString type = "";
|
||||
|
||||
switch( et )
|
||||
{
|
||||
case NLGEORGES::UFormDfn::EntryType: type = "type"; break;
|
||||
case NLGEORGES::UFormDfn::EntryDfn: type = "DFN"; break;
|
||||
case NLGEORGES::UFormDfn::EntryVirtualDfn: type = "Virtual DFN"; break;
|
||||
}
|
||||
|
||||
if( isArray )
|
||||
type += " array";
|
||||
|
||||
p = m_manager->addProperty( QVariant::String, "type" );
|
||||
p->setValue( type );
|
||||
m_browser->addProperty( p );
|
||||
|
||||
p = m_manager->addProperty( QVariant::String, "value" );
|
||||
p->setValue( entry.getFilename().c_str() );
|
||||
m_browser->addProperty( p );
|
||||
|
||||
p = m_manager->addProperty( QVariant::String, "default" );
|
||||
p->setValue( entry.getDefault().c_str() );
|
||||
m_browser->addProperty( p );
|
||||
|
||||
p = m_manager->addProperty( QVariant::String, "extension" );
|
||||
p->setValue( entry.getFilenameExt().c_str() );
|
||||
m_browser->addProperty( p );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,38 @@
|
|||
#ifndef DFN_BROWSER_CTRL
|
||||
#define DFN_BROWSER_CTRL
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace NLGEORGES
|
||||
{
|
||||
class CFormDfn;
|
||||
}
|
||||
|
||||
class QtVariantPropertyManager;
|
||||
class QtVariantEditorFactory;
|
||||
class QtTreePropertyBrowser;
|
||||
class QVariant;
|
||||
class QtProperty;
|
||||
|
||||
class DFNBrowserCtrl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DFNBrowserCtrl( QObject *parent = NULL );
|
||||
~DFNBrowserCtrl();
|
||||
|
||||
void setBrowser( QtTreePropertyBrowser *browser ){ m_browser = browser; }
|
||||
void setDFN( NLGEORGES::CFormDfn *dfn ){ m_dfn = dfn; }
|
||||
|
||||
void onElementSelected( int idx );
|
||||
|
||||
private:
|
||||
QtTreePropertyBrowser *m_browser;
|
||||
NLGEORGES::CFormDfn *m_dfn;
|
||||
|
||||
QtVariantPropertyManager *m_manager;
|
||||
QtVariantEditorFactory *m_factory;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,6 +2,28 @@
|
|||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "georges.h"
|
||||
#include "dfn_browser_ctrl.h"
|
||||
|
||||
class GeorgesDFNDialogPvt
|
||||
{
|
||||
public:
|
||||
GeorgesDFNDialogPvt()
|
||||
{
|
||||
dfn = NULL;
|
||||
ctrl = new DFNBrowserCtrl();
|
||||
}
|
||||
|
||||
~GeorgesDFNDialogPvt()
|
||||
{
|
||||
delete ctrl;
|
||||
ctrl = NULL;
|
||||
}
|
||||
|
||||
NLGEORGES::CFormDfn *dfn;
|
||||
DFNBrowserCtrl *ctrl;
|
||||
};
|
||||
|
||||
GeorgesDFNDialog::GeorgesDFNDialog( QWidget *parent ) :
|
||||
GeorgesDockWidget( parent )
|
||||
{
|
||||
|
@ -10,10 +32,46 @@ GeorgesDockWidget( parent )
|
|||
|
||||
m_ui.addButton->setEnabled( false );
|
||||
m_ui.removeButton->setEnabled( false );
|
||||
|
||||
m_pvt = new GeorgesDFNDialogPvt();
|
||||
m_pvt->ctrl->setBrowser( m_ui.browser );
|
||||
}
|
||||
|
||||
GeorgesDFNDialog::~GeorgesDFNDialog()
|
||||
{
|
||||
delete m_pvt;
|
||||
m_pvt = NULL;
|
||||
}
|
||||
|
||||
bool GeorgesDFNDialog::load( const QString &fileName )
|
||||
{
|
||||
GeorgesQt::CGeorges georges;
|
||||
NLGEORGES::UFormDfn *udfn = georges.loadFormDfn( fileName.toUtf8().constData() );
|
||||
if( udfn == NULL )
|
||||
return false;
|
||||
|
||||
setWindowTitle( fileName );
|
||||
|
||||
NLGEORGES::CFormDfn *cdfn = static_cast< NLGEORGES::CFormDfn* >( udfn );
|
||||
m_pvt->dfn = cdfn;
|
||||
m_pvt->ctrl->setDFN( cdfn );
|
||||
|
||||
uint c = m_pvt->dfn->getNumEntry();
|
||||
for( uint i = 0; i < c; i++ )
|
||||
{
|
||||
NLGEORGES::CFormDfn::CEntry &entry = m_pvt->dfn->getEntry( i );
|
||||
m_ui.list->addItem( entry.getName().c_str() );
|
||||
}
|
||||
|
||||
if( c > 0 )
|
||||
{
|
||||
m_ui.list->setCurrentRow( 0 );
|
||||
}
|
||||
|
||||
m_ui.commentsEdit->setPlainText( cdfn->getComment().c_str() );
|
||||
m_ui.logEdit->setPlainText( cdfn->Header.Log.c_str() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::onAddClicked()
|
||||
|
@ -44,9 +102,18 @@ void GeorgesDFNDialog::onRemoveClicked()
|
|||
delete item;
|
||||
}
|
||||
|
||||
void GeorgesDFNDialog::onCurrentRowChanged( int row )
|
||||
{
|
||||
if( row < 0 )
|
||||
return;
|
||||
|
||||
m_pvt->ctrl->onElementSelected( row );
|
||||
}
|
||||
|
||||
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 ) ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "georges_dock_widget.h"
|
||||
#include "ui_georges_dfn_dialog.h"
|
||||
|
||||
class GeorgesDFNDialogPvt;
|
||||
|
||||
class GeorgesDFNDialog : public GeorgesDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -11,16 +13,19 @@ public:
|
|||
GeorgesDFNDialog( QWidget *parent = NULL );
|
||||
~GeorgesDFNDialog();
|
||||
|
||||
bool load( const QString &fileName );
|
||||
void write(){}
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
void onCurrentRowChanged( int row );
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
|
||||
Ui::GeorgesDFNDialog m_ui;
|
||||
GeorgesDFNDialogPvt *m_pvt;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -258,6 +258,8 @@ namespace GeorgesQt
|
|||
m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last());
|
||||
}
|
||||
|
||||
w->raise();
|
||||
|
||||
}
|
||||
|
||||
void GeorgesEditorForm::closingTreeView()
|
||||
|
@ -320,7 +322,12 @@ namespace GeorgesQt
|
|||
GeorgesDockWidget* GeorgesEditorForm::loadDfnDialog( const QString &fileName )
|
||||
{
|
||||
GeorgesDFNDialog *d = new GeorgesDFNDialog();
|
||||
m_mainDock->addDockWidget( Qt::RightDockWidgetArea, d );
|
||||
bool b = d->load( fileName );
|
||||
if( !b )
|
||||
{
|
||||
delete d;
|
||||
d = NULL;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
@ -329,7 +336,7 @@ namespace GeorgesQt
|
|||
{
|
||||
QFileInfo info( fileName );
|
||||
|
||||
CGeorgesTreeViewDialog *d = new CGeorgesTreeViewDialog(m_mainDock);
|
||||
CGeorgesTreeViewDialog *d = new CGeorgesTreeViewDialog();
|
||||
|
||||
// Retrieve the form and load the form.
|
||||
NLGEORGES::CForm *form;
|
||||
|
@ -350,7 +357,6 @@ namespace GeorgesQt
|
|||
QApplication::processEvents();
|
||||
connect(d, SIGNAL(modified()),
|
||||
this, SLOT(setModified()));
|
||||
d->raise();
|
||||
connect(d, SIGNAL(changeFile(QString)),
|
||||
m_georgesDirTreeDialog, SLOT(changeFile(QString)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue