Commit 31818caf authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Refactor class DialogBase to make property dialogs embeddable into parent widgets.

CCBUG:97291
parent 0481912e
......@@ -41,12 +41,8 @@ ActivityDialog::ActivityDialog(QWidget * parent, ActivityWidget * pWidget)
m_bChangesMade(false)
{
setCaption(i18n("Properties"));
setButtons(Ok | Apply | Cancel | Help);
setDefaultButton(Ok);
setModal(true);
setFaceType(KPageDialog::List);
showButtonSeparator(true);
setupPages();
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
}
......
......@@ -52,12 +52,6 @@ AssocPropDlg::AssocPropDlg (QWidget *parent, AssociationWidget * assocWidget, in
{
Q_UNUSED(pageNum)
setCaption(i18n("Association Properties"));
setButtons(Ok | Apply | Cancel | Help);
setDefaultButton(Ok);
setModal(true);
setFaceType(KPageDialog::List);
showButtonSeparator(true);
setupPages();
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
......@@ -74,7 +68,7 @@ AssocPropDlg::~AssocPropDlg()
void AssocPropDlg::slotOk()
{
slotApply();
KDialog::accept();
accept();
}
void AssocPropDlg::slotApply()
......
......@@ -126,11 +126,6 @@ ClassPropDlg::ClassPropDlg(QWidget *parent, UMLWidget *w)
void ClassPropDlg::init()
{
setCaption(i18n("Properties"));
setButtons(Ok | Apply | Cancel | Help);
setDefaultButton(Ok);
setModal(true);
showButtonSeparator(true);
setFaceType(KPageDialog::List);
m_pGenPage = 0;
m_pAttPage = 0;
m_pOpsPage = 0;
......@@ -156,7 +151,7 @@ ClassPropDlg::~ClassPropDlg()
void ClassPropDlg::slotOk()
{
slotApply();
KDialog::accept();
accept();
}
/**
......
......@@ -13,21 +13,49 @@
// local includes
#include "icon_utils.h"
#include "uml.h"
#include "umlwidget.h"
#include "umlwidgetstylepage.h"
#include "klocale.h"
#include <KFontChooser>
#include "umlwidget.h"
#include <KLocale>
#include <KPageDialog>
#include <KPageWidget>
// qt includes
#include <QApplication>
#include <QDockWidget>
#include <QFrame>
#include <QHBoxLayout>
/**
* Constructor
*/
DialogBase::DialogBase(QWidget *parent)
: KPageDialog(parent)
DialogBase::DialogBase(QWidget *parent, bool asWidget)
: QWidget(parent),
m_pageDialog(0),
m_pageWidget(0),
m_useDialog(!asWidget)
{
if (m_useDialog) {
m_pageDialog = new KPageDialog(parent);
m_pageDialog->setButtons(KDialog::Ok | KDialog::Apply | KDialog::Cancel | KDialog::Help);
m_pageDialog->setDefaultButton(KDialog::Ok);
m_pageDialog->showButtonSeparator(true);
m_pageDialog->setFaceType(KPageDialog::List);
m_pageDialog->setModal(true);
connect(m_pageDialog, SIGNAL(okClicked()), this, SLOT(slotOkClicked()));
connect(m_pageDialog, SIGNAL(applyClicked()), this, SLOT(slotApplyClicked()));
} else {
m_pageWidget = new KPageWidget(this);
m_pageWidget->setFaceType(KPageView::Tabbed);
}
}
DialogBase::~DialogBase()
{
delete m_pageDialog;
delete m_pageWidget;
}
/**
......@@ -93,3 +121,61 @@ void DialogBase::saveStylePageData(UMLWidget *widget)
Q_UNUSED(widget);
m_pStylePage->updateUMLWidget();
}
void DialogBase::setCaption(const QString &caption)
{
if (m_pageDialog)
m_pageDialog->setCaption(caption);
}
void DialogBase::accept()
{
if (m_pageDialog)
m_pageDialog->accept();
}
void DialogBase::reject()
{
if (m_pageDialog)
m_pageDialog->reject();
}
KPageWidgetItem *DialogBase::currentPage()
{
if (m_pageDialog)
return m_pageDialog->currentPage();
else
return m_pageWidget->currentPage();
}
void DialogBase::addPage(KPageWidgetItem *page)
{
if (m_pageDialog)
m_pageDialog->addPage(page);
else
m_pageWidget->addPage(page);
}
int DialogBase::spacingHint()
{
return KDialog::spacingHint();
}
int DialogBase::exec()
{
if (m_pageDialog)
return m_pageDialog->exec();
else {
return 0;
}
}
void DialogBase::slotOkClicked()
{
emit okClicked();
}
void DialogBase::slotApplyClicked()
{
emit applyClicked();
}
......@@ -13,14 +13,16 @@
#include "icon_utils.h"
// kde class includes
#include <kpagedialog.h>
#include <kpagewidget.h>
// qt class includes
#include <QWidget>
//forward declarations
class KFontChooser;
class KPageDialog;
class QFrame;
class UMLWidget;
class KFontChooser;
class KPageWidgetItem;
class UMLWidgetStylePage;
/**
......@@ -34,12 +36,13 @@ class UMLWidgetStylePage;
*
* Bugs and comments to umbrello-devel@kde.org or http://bugs.kde.org
*/
class DialogBase : public KPageDialog
class DialogBase : public QWidget
{
Q_OBJECT
public:
explicit DialogBase(QWidget *parent);
explicit DialogBase(QWidget *parent, bool asWidget=false);
virtual ~DialogBase();
QFrame* createPage(const QString& name, const QString& header, Icon_Utils::IconType icon);
KPageWidgetItem *setupFontPage(UMLWidget *widget);
void saveFontPageData(UMLWidget *widget);
......@@ -47,11 +50,29 @@ public:
KPageWidgetItem *setupStylePage(UMLWidget *widget);
void saveStylePageData(UMLWidget *widget);
void setCaption(const QString &caption);
void accept();
void reject();
KPageWidgetItem *currentPage();
void addPage(KPageWidgetItem *page);
static int spacingHint();
int exec();
signals:
void okClicked();
void applyClicked();
private slots:
void slotOkClicked();
void slotApplyClicked();
protected:
KFontChooser *m_fontChooser;
UMLWidgetStylePage *m_pStylePage;
KPageWidgetItem *m_pageItem;
KPageDialog *m_pageDialog;
KPageWidget *m_pageWidget;
bool m_useDialog;
};
#endif
......@@ -43,11 +43,6 @@ ObjectNodeDialog::ObjectNodeDialog(UMLView * pView, ObjectNodeWidget * pWidget)
m_bChangesMade(false)
{
setCaption(i18n("Properties"));
setButtons(Ok | Apply | Cancel | Help);
setDefaultButton(Ok);
setModal(true);
setFaceType(KPageDialog::List);
showButtonSeparator(true);
setupPages();
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
......
......@@ -43,11 +43,6 @@ StateDialog::StateDialog(UMLView * pView, StateWidget * pWidget)
m_bChangesMade(false)
{
setCaption(i18n("Properties"));
setButtons(Help | Default | Apply | Ok | Cancel);
setDefaultButton(Ok);
setModal(true);
showButtonSeparator(true);
setFaceType(KPageDialog::List);
setupPages();
connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply()));
......
......@@ -330,7 +330,11 @@ void RefactoringAssistant::editProperties(UMLObject *obj)
KDialog *dia(0);
UMLObject::ObjectType t = obj->baseType();
if (t == UMLObject::ot_Class || t == UMLObject::ot_Interface) {
dia = new ClassPropDlg(this, obj, true);
ClassPropDlg *dialog = new ClassPropDlg(this, obj, true);
if (dialog && dialog->exec()) {
// need to update something?
}
delete dialog;
}
else if (t == UMLObject::ot_Operation) {
dia = new UMLOperationDialog(this, static_cast<UMLOperation*>(obj));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment