insilmaril@623: #include "attributedialog.h" insilmaril@623: insilmaril@626: #include "attributewidget.h" insilmaril@626: insilmaril@626: #include insilmaril@626: #include insilmaril@623: insilmaril@623: AttributeDialog::AttributeDialog (QWidget *parent):QDialog (parent) insilmaril@623: { insilmaril@626: if (this->objectName().isEmpty()) insilmaril@626: this->setObjectName(QString::fromUtf8("AttributeDialog")); insilmaril@626: QSize size(468, 75); insilmaril@626: size = size.expandedTo(this->minimumSizeHint()); insilmaril@626: this->resize(size); insilmaril@626: QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); insilmaril@626: sizePolicy.setHorizontalStretch(0); insilmaril@626: sizePolicy.setVerticalStretch(0); insilmaril@626: sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); insilmaril@626: this->setSizePolicy(sizePolicy); insilmaril@626: insilmaril@626: vboxLayout = new QVBoxLayout(this); insilmaril@626: vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); insilmaril@626: insilmaril@626: tableLayout = new QVBoxLayout(); insilmaril@626: tableLayout->setObjectName(QString::fromUtf8("tableLayout")); insilmaril@626: insilmaril@626: hboxLayout = new QHBoxLayout(); insilmaril@626: hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); insilmaril@626: addButton = new QPushButton(this); insilmaril@626: addButton->setObjectName(QString::fromUtf8("addButton")); insilmaril@626: insilmaril@626: hboxLayout->addWidget(addButton); insilmaril@626: insilmaril@626: spacerItem = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); insilmaril@626: insilmaril@626: hboxLayout->addItem(spacerItem); insilmaril@626: insilmaril@626: closeButton = new QPushButton(this); insilmaril@626: closeButton->setObjectName(QString::fromUtf8("closeButton")); insilmaril@626: insilmaril@626: hboxLayout->addWidget(closeButton); insilmaril@626: insilmaril@626: vboxLayout->addLayout(tableLayout); insilmaril@626: vboxLayout->addLayout(hboxLayout); insilmaril@626: insilmaril@626: insilmaril@626: insilmaril@626: setWindowTitle(QApplication::translate("AttributeDialog", "Attributes", 0, QApplication::UnicodeUTF8)); insilmaril@626: addButton->setText(QApplication::translate("AttributeDialog", "Add key", 0, QApplication::UnicodeUTF8)); insilmaril@626: closeButton->setText(QApplication::translate("AttributeDialog", "Close", 0, QApplication::UnicodeUTF8)); insilmaril@626: insilmaril@626: connect (addButton, SIGNAL (clicked()), this, SLOT (addKey())); insilmaril@626: connect (closeButton, SIGNAL (clicked()), this, SLOT (accept())); insilmaril@626: insilmaril@626: table=NULL; insilmaril@623: } insilmaril@623: insilmaril@626: void AttributeDialog::setTable (AttributeTable *t) insilmaril@626: { insilmaril@626: table=t; insilmaril@626: } insilmaril@626: insilmaril@626: void AttributeDialog::setBranch (BranchObj *bo) insilmaril@626: { insilmaril@626: branch=bo; insilmaril@626: } insilmaril@626: insilmaril@637: void AttributeDialog::setMode (const AttributeDialogMode &m) insilmaril@637: { insilmaril@637: mode=m; insilmaril@637: insilmaril@637: QString title; insilmaril@637: if (mode==Definition) insilmaril@637: title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit definitions", 0, QApplication::UnicodeUTF8); insilmaril@637: else insilmaril@637: title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit %1", 0, QApplication::UnicodeUTF8).arg("objname"); insilmaril@637: setWindowTitle(title); insilmaril@637: } insilmaril@637: insilmaril@637: void AttributeDialog::updateTable() insilmaril@637: { insilmaril@637: if (table) insilmaril@637: { insilmaril@637: // Update list of keys and values insilmaril@637: QStringList keyList=table->getKeys(); insilmaril@637: AttributeWidget *aw; insilmaril@637: for (int i=0; isetKey (keyList.at(i) ); insilmaril@746: // FIXME-3 aw->setValues (table->getValues (keyList.at(i) )); insilmaril@637: aw->show(); insilmaril@637: tableLayout->addWidget (aw); insilmaril@637: } insilmaril@637: insilmaril@637: // Update attributes in dialog from data in selected branch insilmaril@637: insilmaril@637: // TODO insilmaril@637: } insilmaril@637: insilmaril@637: } insilmaril@626: void AttributeDialog::addKey() insilmaril@626: { insilmaril@626: AttributeWidget *aw1=new AttributeWidget (this); insilmaril@626: aw1->show(); insilmaril@626: tableLayout->addWidget (aw1); insilmaril@626: insilmaril@626: } insilmaril@623: insilmaril@623: void AttributeDialog::closeEvent( QCloseEvent* ce ) insilmaril@623: { insilmaril@623: ce->accept(); // can be reopened with show() insilmaril@623: hide(); insilmaril@623: emit (windowClosed() ); insilmaril@623: return; insilmaril@623: } insilmaril@623: insilmaril@623: