Added common base class for Typ, Dfn, and From dialogs: GeorgesDockWidget.
This commit is contained in:
parent
ff88a345a8
commit
e44733dfa6
8 changed files with 128 additions and 58 deletions
|
@ -3,7 +3,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
GeorgesDFNDialog::GeorgesDFNDialog( QWidget *parent ) :
|
||||
QDockWidget( parent )
|
||||
GeorgesDockWidget( parent )
|
||||
{
|
||||
m_ui.setupUi( this );
|
||||
setupConnections();
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#ifndef GEORGES_DFN_DIALOG
|
||||
#define GEORGES_DFN_DIALOG
|
||||
|
||||
#include "georges_dock_widget.h"
|
||||
#include "ui_georges_dfn_dialog.h"
|
||||
|
||||
class GeorgesDFNDialog : public QDockWidget
|
||||
class GeorgesDFNDialog : public GeorgesDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GeorgesDFNDialog( QWidget *parent = NULL );
|
||||
~GeorgesDFNDialog();
|
||||
|
||||
void write(){}
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onRemoveClicked();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "georges_dock_widget.h"
|
||||
|
||||
GeorgesDockWidget::GeorgesDockWidget( QWidget *parent ) :
|
||||
QDockWidget( parent )
|
||||
{
|
||||
m_modified = false;
|
||||
m_undoStack = NULL;
|
||||
}
|
||||
|
||||
GeorgesDockWidget::~GeorgesDockWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
29
code/studio/src/plugins/georges_editor/georges_dock_widget.h
Normal file
29
code/studio/src/plugins/georges_editor/georges_dock_widget.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef GEORGES_DOCK_WIDGET
|
||||
#define GEORGES_DOCK_WIDGET
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class QUndoStack;
|
||||
|
||||
class GeorgesDockWidget : public QDockWidget
|
||||
{
|
||||
public:
|
||||
GeorgesDockWidget( QWidget *parent = NULL );
|
||||
~GeorgesDockWidget();
|
||||
|
||||
void setUndoStack( QUndoStack *stack ){ m_undoStack = stack; }
|
||||
|
||||
bool isModified() const{ return m_modified; }
|
||||
void setModified( bool b ){ m_modified = b; }
|
||||
|
||||
QString fileName() const{ return m_fileName; }
|
||||
|
||||
virtual void write() = 0;
|
||||
|
||||
protected:
|
||||
QString m_fileName;
|
||||
bool m_modified;
|
||||
QUndoStack *m_undoStack;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -207,9 +207,9 @@ namespace GeorgesQt
|
|||
// Check to see if the form is already loaded, if it is just raise it.
|
||||
if (m_dockedWidgets.size())
|
||||
{
|
||||
Q_FOREACH(CGeorgesTreeViewDialog *wgt, m_dockedWidgets)
|
||||
Q_FOREACH(GeorgesDockWidget *wgt, m_dockedWidgets)
|
||||
{
|
||||
if (info.fileName() == wgt->loadedForm)
|
||||
if (info.fileName() == wgt->fileName())
|
||||
{
|
||||
wgt->raise();
|
||||
return;
|
||||
|
@ -217,16 +217,33 @@ namespace GeorgesQt
|
|||
}
|
||||
}
|
||||
|
||||
GeorgesDockWidget *w = NULL;
|
||||
|
||||
if( info.suffix() == "dfn" )
|
||||
{
|
||||
loadDfnDialog( fileName );
|
||||
w = loadDfnDialog( fileName );
|
||||
}
|
||||
else
|
||||
if( info.suffix() == "typ" )
|
||||
{
|
||||
w = loadTypDialog( fileName );
|
||||
}
|
||||
else
|
||||
{
|
||||
w = loadFormDialog( fileName, loadFromDfn );
|
||||
}
|
||||
|
||||
if( w == NULL )
|
||||
{
|
||||
QMessageBox::information( this,
|
||||
tr( "Failed to load file..." ),
|
||||
tr( "Failed to load file '%1'" ).arg( info.fileName() ) );
|
||||
return;
|
||||
}
|
||||
|
||||
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
|
||||
dock->setUndoStack(UndoStack);
|
||||
m_lastActiveDock = dock;
|
||||
m_dockedWidgets.append(dock);
|
||||
w->setUndoStack(UndoStack);
|
||||
m_lastActiveDock = w;
|
||||
m_dockedWidgets.append(w);
|
||||
|
||||
connect(m_dockedWidgets.last(), SIGNAL(closing()), this, SLOT(closingTreeView()));
|
||||
connect(m_dockedWidgets.last(), SIGNAL(visibilityChanged(bool)), m_dockedWidgets.last(), SLOT(checkVisibility(bool)));
|
||||
|
@ -241,38 +258,6 @@ namespace GeorgesQt
|
|||
m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last());
|
||||
}
|
||||
|
||||
// Retrieve the form and load the form.
|
||||
NLGEORGES::CForm *form;
|
||||
if(loadFromDfn)
|
||||
{
|
||||
// Get the form by DFN name.
|
||||
form = m_dockedWidgets.last()->getFormByDfnName(info.fileName());
|
||||
}
|
||||
else
|
||||
{
|
||||
form = m_dockedWidgets.last()->getFormByName(info.fileName());
|
||||
}
|
||||
|
||||
if (form)
|
||||
{
|
||||
m_dockedWidgets.last()->setForm(form);
|
||||
m_dockedWidgets.last()->loadFormIntoDialog(form);
|
||||
QApplication::processEvents();
|
||||
connect(m_dockedWidgets.last(), SIGNAL(modified()),
|
||||
this, SLOT(setModified()));
|
||||
m_dockedWidgets.last()->raise();
|
||||
connect(m_dockedWidgets.last(), SIGNAL(changeFile(QString)),
|
||||
m_georgesDirTreeDialog, SLOT(changeFile(QString)));
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Failed to load form: %s", info.fileName().toUtf8().constData());
|
||||
m_dockedWidgets.last()->close();
|
||||
|
||||
QMessageBox::information( this,
|
||||
tr( "Failed to load form..." ),
|
||||
tr( "Failed to load form '%1'" ).arg( info.fileName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void GeorgesEditorForm::closingTreeView()
|
||||
|
@ -327,11 +312,55 @@ namespace GeorgesQt
|
|||
}
|
||||
}
|
||||
|
||||
GeorgesDockWidget* GeorgesEditorForm::loadTypDialog( const QString &fileName )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GeorgesEditorForm::loadDfnDialog( const QString &fileName )
|
||||
GeorgesDockWidget* GeorgesEditorForm::loadDfnDialog( const QString &fileName )
|
||||
{
|
||||
GeorgesDFNDialog *d = new GeorgesDFNDialog();
|
||||
m_mainDock->addDockWidget( Qt::RightDockWidgetArea, d );
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
GeorgesDockWidget* GeorgesEditorForm::loadFormDialog( const QString &fileName, bool loadFromDFN )
|
||||
{
|
||||
QFileInfo info( fileName );
|
||||
|
||||
CGeorgesTreeViewDialog *d = new CGeorgesTreeViewDialog(m_mainDock);
|
||||
|
||||
// Retrieve the form and load the form.
|
||||
NLGEORGES::CForm *form;
|
||||
if(loadFromDFN)
|
||||
{
|
||||
// Get the form by DFN name.
|
||||
form = d->getFormByDfnName(info.fileName());
|
||||
}
|
||||
else
|
||||
{
|
||||
form = d->getFormByName(info.fileName());
|
||||
}
|
||||
|
||||
if (form)
|
||||
{
|
||||
d->setForm(form);
|
||||
d->loadFormIntoDialog(form);
|
||||
QApplication::processEvents();
|
||||
connect(d, SIGNAL(modified()),
|
||||
this, SLOT(setModified()));
|
||||
d->raise();
|
||||
connect(d, SIGNAL(changeFile(QString)),
|
||||
m_georgesDirTreeDialog, SLOT(changeFile(QString)));
|
||||
}
|
||||
else
|
||||
{
|
||||
delete d;
|
||||
d = NULL;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
} /* namespace GeorgesQt */
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
// Qt includes
|
||||
#include <QtGui/QUndoStack>
|
||||
|
||||
class GeorgesDockWidget;
|
||||
|
||||
namespace GeorgesQt
|
||||
{
|
||||
|
||||
|
@ -56,7 +58,9 @@ private:
|
|||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
void loadDfnDialog(const QString &fileName);
|
||||
GeorgesDockWidget* loadTypDialog(const QString &fileName);
|
||||
GeorgesDockWidget* loadDfnDialog(const QString &fileName);
|
||||
GeorgesDockWidget* loadFormDialog(const QString &fileName, bool loadFromDFN );
|
||||
|
||||
Ui::GeorgesEditorForm m_ui;
|
||||
|
||||
|
@ -71,10 +75,10 @@ private:
|
|||
QMainWindow *m_mainDock;
|
||||
|
||||
/// Contains a list of all of the open forms.
|
||||
QList<CGeorgesTreeViewDialog*> m_dockedWidgets;
|
||||
QList<GeorgesDockWidget*> m_dockedWidgets;
|
||||
|
||||
/// Contains a pointer to the last known focal change for active documents.
|
||||
CGeorgesTreeViewDialog *m_lastActiveDock;
|
||||
GeorgesDockWidget *m_lastActiveDock;
|
||||
|
||||
/// Contains a record of the last directory a sheet file dialog was opened for.
|
||||
QString m_lastSheetDir;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace GeorgesQt
|
|||
{
|
||||
|
||||
CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/)
|
||||
: QDockWidget(parent),
|
||||
: GeorgesDockWidget(parent),
|
||||
m_header(0),
|
||||
m_modified(false)
|
||||
{
|
||||
|
@ -263,6 +263,7 @@ namespace GeorgesQt
|
|||
if (root)
|
||||
{
|
||||
loadedForm = m_form->getFilename().c_str();
|
||||
m_fileName = m_form->getFilename().c_str();
|
||||
|
||||
CGeorgesFormModel *model = new CGeorgesFormModel(m_form,deps,comments,parents,m_header->expanded());
|
||||
m_ui.treeView->setModel(model);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#define GEORGES_TREEVIEWER_DIALOG_H
|
||||
|
||||
#include "ui_georges_treeview_form.h"
|
||||
#include "georges_dock_widget.h"
|
||||
#include "expandable_headerview.h"
|
||||
|
||||
// Qt includes
|
||||
|
@ -49,7 +50,7 @@ namespace GeorgesQt
|
|||
class CGeorges;
|
||||
class CGeorgesFormModel;
|
||||
|
||||
class CGeorgesTreeViewDialog: public QDockWidget
|
||||
class CGeorgesTreeViewDialog: public GeorgesDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -57,9 +58,6 @@ namespace GeorgesQt
|
|||
CGeorgesTreeViewDialog(QWidget *parent = 0);
|
||||
~CGeorgesTreeViewDialog();
|
||||
|
||||
bool isModified() {return m_modified;}
|
||||
void setModified(bool m) {m_modified = m;}
|
||||
|
||||
NLGEORGES::CForm* getFormByName(const QString formName);
|
||||
NLGEORGES::CForm* getFormByDfnName(const QString dfnName);
|
||||
|
||||
|
@ -75,12 +73,6 @@ namespace GeorgesQt
|
|||
|
||||
QTabWidget* tabWidget() { return m_ui.treeViewTabWidget; }
|
||||
|
||||
void setUndoStack(QUndoStack *stack) {
|
||||
m_undoStack = stack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString loadedForm;
|
||||
|
||||
protected:
|
||||
|
@ -117,8 +109,6 @@ namespace GeorgesQt
|
|||
UForm *m_form;
|
||||
CGeorges *m_georges;
|
||||
|
||||
QUndoStack *m_undoStack;
|
||||
|
||||
/// Contains a record of the last directory a sheet file dialog was opened for.
|
||||
QString m_lastSheetDir;
|
||||
|
||||
|
|
Loading…
Reference in a new issue