20#include "kptrelationdialog.h"
21#include "kptrelation.h"
24#include "kptcommand.h"
25#include "kptdurationwidget.h"
26#include "relationpanel.h"
31#include <tqbuttongroup.h>
32#include <tqradiobutton.h>
34#include <tdemessagebox.h>
42AddRelationDialog::AddRelationDialog(
Relation *rel, TQWidget *p, TQString caption,
int buttons,
const char *n)
43 : KDialogBase(Swallow, caption, buttons, Ok, p, n, true, true)
45 if (caption.isEmpty())
46 setCaption(i18n(
"Add Relationship"));
48 m_panel =
new RelationPanel(
this);
49 setMainWidget(m_panel);
50 m_panel->setActiveWindow();
52 m_panel->fromName->setText(rel->parent()->name());
53 m_panel->toName->setText(rel->child()->name());
54 m_panel->relationType->setButton(rel->type());
56 m_panel->lag->setVisibleFields(DurationWidget::Days|DurationWidget::Hours|DurationWidget::Minutes);
57 m_panel->lag->setFieldUnit(0, i18n(
"days",
"d"));
58 m_panel->lag->setFieldUnit(1, i18n(
"hours",
"h"));
59 m_panel->lag->setFieldUnit(2, i18n(
"minutes",
"m"));
60 m_panel->lag->setValue(rel->lag());
62 m_panel->relationType->setFocus();
64 connect(m_panel->relationType, TQ_SIGNAL(clicked(
int)), TQ_SLOT(typeClicked(
int)));
65 connect(m_panel->lag, TQ_SIGNAL(valueChanged()), TQ_SLOT(lagChanged()));
68KCommand *AddRelationDialog::buildCommand(Part *part) {
69 return new AddRelationCmd(part, m_relation, i18n(
"Add Relation"));
72void AddRelationDialog::slotOk() {
73 if ( m_panel->relationType->selected() == 0 ) {
74 KMessageBox::sorry(
this, i18n(
"You must select a relationship type"));
80void AddRelationDialog::lagChanged() {
84void AddRelationDialog::typeClicked(
int id) {
85 if (
id != m_relation->type())
91ModifyRelationDialog::ModifyRelationDialog(Relation *rel, TQWidget *p,
const char *n)
92 : AddRelationDialog(rel, p, i18n(
"Edit Relationship"), Ok|Cancel|User1, n)
94 setButtonText( KDialogBase::User1, i18n(
"Delete") );
96 enableButtonOK(
false);
100void ModifyRelationDialog::slotUser1() {
105KCommand *ModifyRelationDialog::buildCommand(Part *part) {
106 KMacroCommand *cmd=0;
107 if (m_panel->relationType->selectedId() != m_relation->type()) {
109 cmd =
new KMacroCommand(i18n(
"Modify Relation"));
110 cmd->addCommand(
new ModifyRelationTypeCmd(part, m_relation, (Relation::Type)m_panel->relationType->selectedId()));
112 if (m_relation->lag() != m_panel->lag->value()) {
114 cmd =
new KMacroCommand(i18n(
"Modify Relation"));
115 cmd->addCommand(
new ModifyRelationLagCmd(part, m_relation, m_panel->lag->value()));
122#include "kptrelationdialog.moc"
The relation class couples a 2 nodes together which are dependent on each other.