# HG changeset patch # User insilmaril # Date 1196771576 0 # Node ID 96c8e6860e0c277c2a65427eeffc69f30bce05c9 # Parent 22955004d512f699740afad33d122412315027da Fixed HideExport bug, changed pre- and postscript in XHTML export dialog diff -r 22955004d512 -r 96c8e6860e0c attribute.cpp --- a/attribute.cpp Fri Nov 09 12:07:22 2007 +0000 +++ b/attribute.cpp Tue Dec 04 12:32:56 2007 +0000 @@ -26,6 +26,16 @@ return value; } +void Attribute::setTable (AttributeTable *at) +{ + table=at; +} + +AttributeTable* Attribute::getTable() +{ + return table; +} + QString Attribute::getDataXML() { return valueElement ("attribute",key,value); @@ -67,6 +77,11 @@ } } +int AttributeTable::countKeys() +{ + return keys.count(); +} + void AttributeTable::addValue (const QString &k, const QString &v) { int i=keys.indexOf (k); diff -r 22955004d512 -r 96c8e6860e0c attribute.h --- a/attribute.h Fri Nov 09 12:07:22 2007 +0000 +++ b/attribute.h Tue Dec 04 12:32:56 2007 +0000 @@ -5,21 +5,25 @@ #include "xmlobj.h" +class AttributeTable; -/*! \brief A key and a list of values +/*! \brief A key and a value */ class Attribute:public XMLObj { public: Attribute(); - virtual void setKey (const QString &k); - virtual QString getKey (); - virtual void setValue (const QString &v); - virtual QString getValue(); - virtual QString getDataXML(); + void setKey (const QString &k); + QString getKey (); + void setValue (const QString &v); + QString getValue(); + void setTable (AttributeTable *at); + AttributeTable* getTable(); + QString getDataXML(); protected: QString key; QString value; + AttributeTable *table; }; /*! \brief A table containing a list of keys and each of these keys has @@ -29,14 +33,15 @@ class AttributeTable:public XMLObj{ public: AttributeTable(); - virtual ~AttributeTable(); - virtual void clear(); - virtual void addKey (const QString &k); //!< Adds a key to the table - virtual void removeKey (const QString &k); //!< Removes key and its default values - virtual void addValue (const QString &k, const QString &v); //!< Adds key and value - virtual QStringList getKeys (); - virtual QStringList getValues(const QString &k); - virtual QString getDataXML(); + ~AttributeTable(); + void clear(); + void addKey (const QString &k); //!< Adds a key to the table + void removeKey (const QString &k); //!< Removes key and its default values + int countKeys(); //!< Return number of keys + void addValue (const QString &k, const QString &v); //!< Adds key and value + QStringList getKeys (); + QStringList getValues(const QString &k); + QString getDataXML(); protected: QStringList keys; diff -r 22955004d512 -r 96c8e6860e0c attributedialog.cpp --- a/attributedialog.cpp Fri Nov 09 12:07:22 2007 +0000 +++ b/attributedialog.cpp Tue Dec 04 12:32:56 2007 +0000 @@ -1,11 +1,79 @@ #include "attributedialog.h" +#include "attributewidget.h" + +#include +#include AttributeDialog::AttributeDialog (QWidget *parent):QDialog (parent) { - ui.setupUi (this); + if (this->objectName().isEmpty()) + this->setObjectName(QString::fromUtf8("AttributeDialog")); + QSize size(468, 75); + size = size.expandedTo(this->minimumSizeHint()); + this->resize(size); + QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); + this->setSizePolicy(sizePolicy); + + vboxLayout = new QVBoxLayout(this); + vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); + + tableLayout = new QVBoxLayout(); + tableLayout->setObjectName(QString::fromUtf8("tableLayout")); + + hboxLayout = new QHBoxLayout(); + hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); + addButton = new QPushButton(this); + addButton->setObjectName(QString::fromUtf8("addButton")); + + hboxLayout->addWidget(addButton); + + spacerItem = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + + hboxLayout->addItem(spacerItem); + + closeButton = new QPushButton(this); + closeButton->setObjectName(QString::fromUtf8("closeButton")); + + hboxLayout->addWidget(closeButton); + + vboxLayout->addLayout(tableLayout); + vboxLayout->addLayout(hboxLayout); + + + + setWindowTitle(QApplication::translate("AttributeDialog", "Attributes", 0, QApplication::UnicodeUTF8)); + addButton->setText(QApplication::translate("AttributeDialog", "Add key", 0, QApplication::UnicodeUTF8)); + closeButton->setText(QApplication::translate("AttributeDialog", "Close", 0, QApplication::UnicodeUTF8)); + + connect (addButton, SIGNAL (clicked()), this, SLOT (addKey())); + connect (closeButton, SIGNAL (clicked()), this, SLOT (accept())); + + table=NULL; } +void AttributeDialog::setTable (AttributeTable *t) +{ + table=t; + updateTable(); +} + +void AttributeDialog::setBranch (BranchObj *bo) +{ + branch=bo; + updateTable(); +} + +void AttributeDialog::addKey() +{ + AttributeWidget *aw1=new AttributeWidget (this); + aw1->show(); + tableLayout->addWidget (aw1); + +} void AttributeDialog::closeEvent( QCloseEvent* ce ) { @@ -15,5 +83,27 @@ return; } +void AttributeDialog::updateTable() +{ + if (table) + { + // Update list of keys and values + QStringList keyList=table->getKeys(); + AttributeWidget *aw; + int i; + for (i=0; isetKey (keyList.at(i) ); + aw->setValues (table->getValues (keyList.at(i) )); + aw->show(); + tableLayout->addWidget (aw); + } + // Update attributes in dialog from data in selected branch + // TODO + } + +} + diff -r 22955004d512 -r 96c8e6860e0c attributedialog.h --- a/attributedialog.h Fri Nov 09 12:07:22 2007 +0000 +++ b/attributedialog.h Tue Dec 04 12:32:56 2007 +0000 @@ -1,22 +1,41 @@ #ifndef ATTRIBUTEDIALOG_H #define ATTRIBUTEDIALOG_H -#include "ui_attributedialog.h" +#include "attribute.h" +#include "branchobj.h" #include #include +#include +#include +#include +#include + class AttributeDialog:public QDialog { Q_OBJECT public: AttributeDialog (QWidget *parent=0 ); + void setTable (AttributeTable *table=0); + void setBranch (BranchObj *bo); signals: void windowClosed(); +private slots: + void addKey(); protected: void closeEvent(QCloseEvent*); + void updateTable(); private: - Ui::AttributeDialog ui; + QVBoxLayout *vboxLayout; + QVBoxLayout *tableLayout; + QHBoxLayout *hboxLayout; + QPushButton *addButton; + QSpacerItem *spacerItem; + QPushButton *closeButton; + + AttributeTable *table; + BranchObj *branch; }; #endif