Fixed HideExport bug, changed pre- and postscript in XHTML export dialog
authorinsilmaril
Tue, 04 Dec 2007 12:32:56 +0000
changeset 62696c8e6860e0c
parent 625 22955004d512
child 627 513107d1ed59
Fixed HideExport bug, changed pre- and postscript in XHTML export dialog
attribute.cpp
attribute.h
attributedialog.cpp
attributedialog.h
     1.1 --- a/attribute.cpp	Fri Nov 09 12:07:22 2007 +0000
     1.2 +++ b/attribute.cpp	Tue Dec 04 12:32:56 2007 +0000
     1.3 @@ -26,6 +26,16 @@
     1.4  	return value;
     1.5  }
     1.6  
     1.7 +void Attribute::setTable (AttributeTable *at)
     1.8 +{
     1.9 +	table=at;
    1.10 +}
    1.11 +
    1.12 +AttributeTable* Attribute::getTable()
    1.13 +{
    1.14 +	return table;
    1.15 +}
    1.16 +
    1.17  QString Attribute::getDataXML()
    1.18  {
    1.19  	return valueElement ("attribute",key,value);
    1.20 @@ -67,6 +77,11 @@
    1.21  	}
    1.22  }
    1.23  
    1.24 +int AttributeTable::countKeys()
    1.25 +{
    1.26 +	return keys.count();
    1.27 +}
    1.28 +
    1.29  void AttributeTable::addValue (const QString &k, const QString &v)
    1.30  {
    1.31  	int i=keys.indexOf (k);
     2.1 --- a/attribute.h	Fri Nov 09 12:07:22 2007 +0000
     2.2 +++ b/attribute.h	Tue Dec 04 12:32:56 2007 +0000
     2.3 @@ -5,21 +5,25 @@
     2.4  
     2.5  #include "xmlobj.h"
     2.6  
     2.7 +class AttributeTable;
     2.8  
     2.9 -/*! \brief A key and a list of values
    2.10 +/*! \brief A key and a value
    2.11  */
    2.12  
    2.13  class Attribute:public XMLObj {
    2.14  public:
    2.15  	Attribute();
    2.16 -	virtual void setKey (const QString &k);
    2.17 -	virtual QString getKey ();
    2.18 -	virtual void setValue (const QString &v);
    2.19 -	virtual QString getValue();
    2.20 -	virtual QString getDataXML();
    2.21 +	void setKey (const QString &k);
    2.22 +	QString getKey ();
    2.23 +	void setValue (const QString &v);
    2.24 +	QString getValue();
    2.25 +	void setTable (AttributeTable *at);
    2.26 +	AttributeTable* getTable();
    2.27 +	QString getDataXML();
    2.28  protected:
    2.29  	QString key;
    2.30  	QString value;
    2.31 +	AttributeTable *table;
    2.32  };
    2.33  
    2.34  /*! \brief A table containing a list of keys and each of these keys has
    2.35 @@ -29,14 +33,15 @@
    2.36  class AttributeTable:public XMLObj{
    2.37  public:
    2.38  	AttributeTable();
    2.39 -	virtual ~AttributeTable();
    2.40 -	virtual void clear();
    2.41 -	virtual void addKey (const QString &k);		//!< Adds a key to the table
    2.42 -	virtual void removeKey (const QString &k);	//!< Removes key and its default values
    2.43 -	virtual void addValue (const QString &k, const QString &v);	//!< Adds key and value
    2.44 -	virtual QStringList getKeys ();
    2.45 -	virtual QStringList getValues(const QString &k);
    2.46 -	virtual QString getDataXML();
    2.47 +	~AttributeTable();
    2.48 +	void clear();
    2.49 +	void addKey (const QString &k);		//!< Adds a key to the table
    2.50 +	void removeKey (const QString &k);	//!< Removes key and its default values
    2.51 +	int countKeys();					//!< Return number of keys
    2.52 +	void addValue (const QString &k, const QString &v);	//!< Adds key and value
    2.53 +	QStringList getKeys ();
    2.54 +	QStringList getValues(const QString &k);
    2.55 +	QString getDataXML();
    2.56  
    2.57  protected:
    2.58  	QStringList keys;
     3.1 --- a/attributedialog.cpp	Fri Nov 09 12:07:22 2007 +0000
     3.2 +++ b/attributedialog.cpp	Tue Dec 04 12:32:56 2007 +0000
     3.3 @@ -1,11 +1,79 @@
     3.4  #include "attributedialog.h"
     3.5  
     3.6 +#include "attributewidget.h"
     3.7 +
     3.8 +#include <QtGui/QApplication>
     3.9 +#include <QtGui/QButtonGroup>
    3.10  
    3.11  AttributeDialog::AttributeDialog (QWidget *parent):QDialog (parent)
    3.12  {
    3.13 -	ui.setupUi (this);
    3.14 +    if (this->objectName().isEmpty())
    3.15 +        this->setObjectName(QString::fromUtf8("AttributeDialog"));
    3.16 +    QSize size(468, 75);
    3.17 +    size = size.expandedTo(this->minimumSizeHint());
    3.18 +    this->resize(size);
    3.19 +    QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    3.20 +    sizePolicy.setHorizontalStretch(0);
    3.21 +    sizePolicy.setVerticalStretch(0);
    3.22 +    sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
    3.23 +    this->setSizePolicy(sizePolicy);
    3.24 +
    3.25 +    vboxLayout = new QVBoxLayout(this);
    3.26 +    vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
    3.27 +
    3.28 +    tableLayout = new QVBoxLayout();
    3.29 +    tableLayout->setObjectName(QString::fromUtf8("tableLayout"));
    3.30 +
    3.31 +    hboxLayout = new QHBoxLayout();
    3.32 +    hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
    3.33 +    addButton = new QPushButton(this);
    3.34 +    addButton->setObjectName(QString::fromUtf8("addButton"));
    3.35 +
    3.36 +    hboxLayout->addWidget(addButton);
    3.37 +
    3.38 +    spacerItem = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    3.39 +
    3.40 +    hboxLayout->addItem(spacerItem);
    3.41 +
    3.42 +    closeButton = new QPushButton(this);
    3.43 +    closeButton->setObjectName(QString::fromUtf8("closeButton"));
    3.44 +
    3.45 +    hboxLayout->addWidget(closeButton);
    3.46 +
    3.47 +    vboxLayout->addLayout(tableLayout);
    3.48 +    vboxLayout->addLayout(hboxLayout);
    3.49 +
    3.50 +
    3.51 +	
    3.52 +    setWindowTitle(QApplication::translate("AttributeDialog", "Attributes", 0, QApplication::UnicodeUTF8));
    3.53 +    addButton->setText(QApplication::translate("AttributeDialog", "Add key", 0, QApplication::UnicodeUTF8));
    3.54 +    closeButton->setText(QApplication::translate("AttributeDialog", "Close", 0, QApplication::UnicodeUTF8));
    3.55 +
    3.56 +	connect (addButton, SIGNAL (clicked()), this, SLOT (addKey()));
    3.57 +	connect (closeButton, SIGNAL (clicked()), this, SLOT (accept()));
    3.58 +
    3.59 +	table=NULL;
    3.60  }
    3.61  
    3.62 +void AttributeDialog::setTable (AttributeTable *t)
    3.63 +{
    3.64 +	table=t;
    3.65 +	updateTable();
    3.66 +}
    3.67 +
    3.68 +void AttributeDialog::setBranch (BranchObj *bo)
    3.69 +{
    3.70 +	branch=bo;
    3.71 +	updateTable();
    3.72 +}
    3.73 +
    3.74 +void AttributeDialog::addKey()
    3.75 +{
    3.76 +	AttributeWidget *aw1=new AttributeWidget (this);
    3.77 +	aw1->show();
    3.78 +	tableLayout->addWidget (aw1);
    3.79 +
    3.80 +}
    3.81  
    3.82  void AttributeDialog::closeEvent( QCloseEvent* ce )
    3.83  {
    3.84 @@ -15,5 +83,27 @@
    3.85      return;
    3.86  }
    3.87  
    3.88 +void AttributeDialog::updateTable()
    3.89 +{
    3.90 +	if (table)
    3.91 +	{
    3.92 +		// Update list of keys and values
    3.93 +		QStringList keyList=table->getKeys();
    3.94 +		AttributeWidget *aw;
    3.95 +		int i;
    3.96 +		for (i=0; i<keyList.count();i++)
    3.97 +		{
    3.98 +			aw=new AttributeWidget (this);
    3.99 +			aw->setKey (keyList.at(i) );
   3.100 +			aw->setValues (table->getValues (keyList.at(i) ));
   3.101 +			aw->show();
   3.102 +			tableLayout->addWidget (aw);
   3.103 +		}
   3.104  
   3.105 +		// Update attributes in dialog from data in selected branch
   3.106  
   3.107 +		// TODO
   3.108 +	}
   3.109 +
   3.110 +}
   3.111 +
     4.1 --- a/attributedialog.h	Fri Nov 09 12:07:22 2007 +0000
     4.2 +++ b/attributedialog.h	Tue Dec 04 12:32:56 2007 +0000
     4.3 @@ -1,22 +1,41 @@
     4.4  #ifndef ATTRIBUTEDIALOG_H
     4.5  #define ATTRIBUTEDIALOG_H
     4.6  
     4.7 -#include "ui_attributedialog.h"
     4.8 +#include "attribute.h"
     4.9 +#include "branchobj.h"
    4.10  
    4.11  #include <QDialog>
    4.12  #include <QCloseEvent>
    4.13 +#include <QtGui/QHBoxLayout>
    4.14 +#include <QtGui/QPushButton>
    4.15 +#include <QtGui/QSpacerItem>
    4.16 +#include <QtGui/QVBoxLayout>
    4.17 +
    4.18  
    4.19  class AttributeDialog:public QDialog
    4.20  {
    4.21  	Q_OBJECT 
    4.22  public:
    4.23  	AttributeDialog (QWidget *parent=0 );
    4.24 +	void setTable (AttributeTable *table=0);
    4.25 +	void setBranch (BranchObj *bo);
    4.26  signals:
    4.27  	void windowClosed();
    4.28 +private slots:
    4.29 +	void addKey();
    4.30  protected:
    4.31  	void closeEvent(QCloseEvent*);
    4.32 +	void updateTable();
    4.33  private:
    4.34 -	Ui::AttributeDialog ui;
    4.35 +	QVBoxLayout *vboxLayout;
    4.36 +	QVBoxLayout *tableLayout;
    4.37 +    QHBoxLayout *hboxLayout;
    4.38 +    QPushButton *addButton;
    4.39 +    QSpacerItem *spacerItem;
    4.40 +    QPushButton *closeButton;
    4.41 +
    4.42 +	AttributeTable *table;
    4.43 +	BranchObj *branch;
    4.44  };
    4.45  
    4.46  #endif