attributedialog.cpp
author insilmaril
Wed, 29 Apr 2009 18:46:31 +0000
changeset 760 59614eaf5fbb
parent 746 ee6b0f3a4c2f
permissions -rw-r--r--
started to save data like positions outside of MapObj & Co
     1 #include "attributedialog.h"
     2 
     3 #include "attributewidget.h"
     4 
     5 #include <QtGui/QApplication>
     6 #include <QtGui/QButtonGroup>
     7 
     8 AttributeDialog::AttributeDialog (QWidget *parent):QDialog (parent)
     9 {
    10     if (this->objectName().isEmpty())
    11         this->setObjectName(QString::fromUtf8("AttributeDialog"));
    12     QSize size(468, 75);
    13     size = size.expandedTo(this->minimumSizeHint());
    14     this->resize(size);
    15     QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    16     sizePolicy.setHorizontalStretch(0);
    17     sizePolicy.setVerticalStretch(0);
    18     sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
    19     this->setSizePolicy(sizePolicy);
    20 
    21     vboxLayout = new QVBoxLayout(this);
    22     vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
    23 
    24     tableLayout = new QVBoxLayout();
    25     tableLayout->setObjectName(QString::fromUtf8("tableLayout"));
    26 
    27     hboxLayout = new QHBoxLayout();
    28     hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
    29     addButton = new QPushButton(this);
    30     addButton->setObjectName(QString::fromUtf8("addButton"));
    31 
    32     hboxLayout->addWidget(addButton);
    33 
    34     spacerItem = new QSpacerItem(111, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    35 
    36     hboxLayout->addItem(spacerItem);
    37 
    38     closeButton = new QPushButton(this);
    39     closeButton->setObjectName(QString::fromUtf8("closeButton"));
    40 
    41     hboxLayout->addWidget(closeButton);
    42 
    43     vboxLayout->addLayout(tableLayout);
    44     vboxLayout->addLayout(hboxLayout);
    45 
    46 
    47 	
    48     setWindowTitle(QApplication::translate("AttributeDialog", "Attributes", 0, QApplication::UnicodeUTF8));
    49     addButton->setText(QApplication::translate("AttributeDialog", "Add key", 0, QApplication::UnicodeUTF8));
    50     closeButton->setText(QApplication::translate("AttributeDialog", "Close", 0, QApplication::UnicodeUTF8));
    51 
    52 	connect (addButton, SIGNAL (clicked()), this, SLOT (addKey()));
    53 	connect (closeButton, SIGNAL (clicked()), this, SLOT (accept()));
    54 
    55 	table=NULL;
    56 }
    57 
    58 void AttributeDialog::setTable (AttributeTable *t)
    59 {
    60 	table=t;
    61 }
    62 
    63 void AttributeDialog::setBranch (BranchObj *bo)
    64 {
    65 	branch=bo;
    66 }
    67 
    68 void AttributeDialog::setMode (const AttributeDialogMode &m)
    69 {
    70 	mode=m;
    71 
    72 	QString title;
    73 	if (mode==Definition)
    74 		title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit definitions", 0, QApplication::UnicodeUTF8);
    75 	else	
    76 		title= QApplication::translate("Attribute Dialog","AttributeDialog - Edit %1", 0, QApplication::UnicodeUTF8).arg("objname");
    77     setWindowTitle(title);
    78 }
    79 
    80 void AttributeDialog::updateTable()
    81 {
    82 	if (table)
    83 	{
    84 		// Update list of keys and values
    85 		QStringList keyList=table->getKeys();
    86 		AttributeWidget *aw;
    87 		for (int i=0; i<keyList.count();i++)
    88 		{
    89 			aw=new AttributeWidget (this);
    90 			aw->setKey (keyList.at(i) );
    91 			// FIXME-3 aw->setValues (table->getValues (keyList.at(i) ));
    92 			aw->show();
    93 			tableLayout->addWidget (aw);
    94 		}
    95 
    96 		// Update attributes in dialog from data in selected branch
    97 
    98 		// TODO
    99 	}
   100 
   101 }
   102 void AttributeDialog::addKey()
   103 {
   104 	AttributeWidget *aw1=new AttributeWidget (this);
   105 	aw1->show();
   106 	tableLayout->addWidget (aw1);
   107 
   108 }
   109 
   110 void AttributeDialog::closeEvent( QCloseEvent* ce )
   111 {
   112     ce->accept();	// can be reopened with show()
   113 	hide();
   114 	emit (windowClosed() );
   115     return;
   116 }
   117 
   118