attributedialog.cpp
author anng888
Thu, 06 Dec 2007 18:30:29 +0000
changeset 632 f4282e4db9f7
parent 626 96c8e6860e0c
child 637 0ff5fc89dc5c
permissions -rw-r--r--
- Fixed Win32 start up crash as a result of "showing" the main window to
early when its previous state was maximized.
     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 	updateTable();
    62 }
    63 
    64 void AttributeDialog::setBranch (BranchObj *bo)
    65 {
    66 	branch=bo;
    67 	updateTable();
    68 }
    69 
    70 void AttributeDialog::addKey()
    71 {
    72 	AttributeWidget *aw1=new AttributeWidget (this);
    73 	aw1->show();
    74 	tableLayout->addWidget (aw1);
    75 
    76 }
    77 
    78 void AttributeDialog::closeEvent( QCloseEvent* ce )
    79 {
    80     ce->accept();	// can be reopened with show()
    81 	hide();
    82 	emit (windowClosed() );
    83     return;
    84 }
    85 
    86 void AttributeDialog::updateTable()
    87 {
    88 	if (table)
    89 	{
    90 		// Update list of keys and values
    91 		QStringList keyList=table->getKeys();
    92 		AttributeWidget *aw;
    93 		int i;
    94 		for (i=0; i<keyList.count();i++)
    95 		{
    96 			aw=new AttributeWidget (this);
    97 			aw->setKey (keyList.at(i) );
    98 			aw->setValues (table->getValues (keyList.at(i) ));
    99 			aw->show();
   100 			tableLayout->addWidget (aw);
   101 		}
   102 
   103 		// Update attributes in dialog from data in selected branch
   104 
   105 		// TODO
   106 	}
   107 
   108 }
   109