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