00001 #include "constants.h"
00002
00003 #include "transitionDialogs.h"
00004 #include "editor.h"
00005 #include "transition.h"
00006 #include "transitionManager.h"
00007 #include "transforms.h"
00008 #include "label.h"
00009 #include "commands.h"
00010
00011 #include <QPushButton>
00012 #include <QLayout>
00013 #include <QGroupBox>
00014 #include <QLabel>
00015 #include <QLineEdit>
00016 #include <QCheckBox>
00017 #include <QComboBox>
00018 #include <QWidget>
00019 #include <QListWidget>
00020 #include <QSpinBox>
00021 #include <QRegExpValidator>
00022 #include <QRegExp>
00023 #include <QMessageBox>
00024
00025
00026
00027
00028 TransitionDialog::TransitionDialog(EMode mode, QWidget* parent)
00029 : NameAcceptDialog(parent), m_mode(mode)
00030 {
00031 TransitionManager *transitionManager = TransitionManager::getInstance();
00032
00033
00034 QLabel* labelName = new QLabel(QString("Label"), this);
00035 edtLabel = new QLineEdit(this);
00036
00037 QRegExp rx("^[\\-]{0,1}[0-9]{1,3}\\.[0-9]{1,3}$");
00038 QRegExp rx2("^[\\-]{0,1}[0-9]{1,3}$");
00039 QValidator *v = new QRegExpValidator(rx,this);
00040 QValidator *v2 = new QRegExpValidator(rx2,this);
00041
00042 QLabel* labelLabelPos = new QLabel(QString("pos"), this);
00043 lineLabelPos = new QLineEdit(this);
00044 lineLabelPos->setValidator(v);
00045 lineLabelPos->setMaximumWidth(40);
00046 lineLabelPos->setText(QString("%1").arg(DEF_EDGE_LAB_POS));
00047
00048 QWidget *labelWidget = new QWidget(this);
00049 QHBoxLayout *labelLayout = new QHBoxLayout(labelWidget);
00050 labelLayout->addWidget(labelName);
00051 labelLayout->addWidget(edtLabel);
00052 labelLayout->addWidget(labelLabelPos);
00053 labelLayout->addWidget(lineLabelPos);
00054
00055
00056 QLabel* labelOrientation = new QLabel(QString("Orientation"), this);
00057 comboOrientation = new QComboBox(this);
00058 comboOrientation->addItem("Left");
00059 comboOrientation->addItem("Right");
00060
00061
00062 QLabel* labelType = new QLabel(QString("Type"), this);
00063 comboType = new QComboBox(this);
00064 foreach(QString typeName, transitionManager->getTwoStatesTransitionTypeNameList())
00065 {
00066 comboType->addItem(typeName);
00067 }
00068
00069 QLabel *lblArcAngle = new QLabel(QString("ArcAngleA"), this);
00070 edtArcAngle = new QLineEdit(this);
00071 edtArcAngle->setEnabled(false);
00072 edtArcAngle->setValidator(v2);
00073
00074 QLabel *lblArcAngleB = new QLabel(QString("ArcAngleB"), this);
00075 edtArcAngleB = new QLineEdit(this);
00076 edtArcAngleB->setEnabled(false);
00077 edtArcAngleB->setValidator(v2);
00078
00079 QLabel *lblNCurv = new QLabel(QString("NCurv"), this);
00080 edtNCurv = new QLineEdit(this);
00081 edtNCurv->setEnabled(false);
00082 edtNCurv->setValidator(v);
00083
00084 connect(comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(showEdits(int)));
00085
00086 checkDimmed = new QCheckBox(QString("Dimmed"), this);
00087
00088 QWidget *hBox = new QWidget(this);
00089 QPushButton *buttonOk = new QPushButton("Ok");
00090 QPushButton *buttonCancel = new QPushButton("Cancel");
00091 QHBoxLayout *hBoxLayout = new QHBoxLayout;
00092 hBoxLayout->addWidget(buttonOk);
00093 hBoxLayout->addWidget(buttonCancel);
00094 hBox->setLayout(hBoxLayout);
00095 connect(buttonOk, SIGNAL(clicked()), this, SLOT(myAccept()));
00096 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00097
00098 QGridLayout* gridLayout = new QGridLayout(this);
00099 gridLayout->addWidget(labelWidget, 0, 0, 1, 2);
00100 gridLayout->addWidget(labelOrientation, 1, 0);
00101 gridLayout->addWidget(comboOrientation, 1, 1);
00102 gridLayout->addWidget(labelType, 2, 0);
00103 gridLayout->addWidget(comboType, 2, 1);
00104 gridLayout->addWidget(lblArcAngle, 3, 0);
00105 gridLayout->addWidget(edtArcAngle, 3, 1);
00106 gridLayout->addWidget(lblArcAngleB, 4, 0);
00107 gridLayout->addWidget(edtArcAngleB, 4, 1);
00108 gridLayout->addWidget(lblNCurv, 5, 0);
00109 gridLayout->addWidget(edtNCurv, 5, 1);
00110 gridLayout->addWidget(checkDimmed, 6, 1);
00111 gridLayout->addWidget(hBox, 7, 0, 1, 2);
00112
00113 QString s = "Transition dialog";
00114 if (mode == eAdd)
00115 s += " - add";
00116 else
00117 s += " - edit";
00118 setWindowTitle(s);
00119 setWindowIcon(QIcon(":images/transition.xpm"));
00120 }
00121
00122 QString TransitionDialog::getLabel() const
00123 {
00124 return edtLabel->text();
00125 }
00126
00127 float TransitionDialog::getLabelPos() const
00128 {
00129 return lineLabelPos->text().toFloat();
00130 }
00131
00132 int TransitionDialog::getType() const
00133 {
00134 return comboType->currentIndex();
00135 }
00136
00137 bool TransitionDialog::isLeftOriented() const
00138 {
00139 return ((comboOrientation->currentIndex() == 0));
00140 }
00141
00142 bool TransitionDialog::isDimmed() const
00143 {
00144 return checkDimmed->isChecked();
00145 }
00146
00147 int TransitionDialog::getArcAngle() const
00148 {
00149 return edtArcAngle->text().toInt();
00150 }
00151
00152 int TransitionDialog::getArcAngleB() const
00153 {
00154 return edtArcAngleB->text().toInt();
00155 }
00156
00157 float TransitionDialog::getNCurv() const
00158 {
00159 return edtNCurv->text().toFloat();
00160 }
00161
00162 void TransitionDialog::setName(const QString& name)
00163 {
00164 edtLabel->setText(name);
00165 }
00166
00167 void TransitionDialog::setLabelPos(float lp)
00168 {
00169 lineLabelPos->setText(QString("%1").arg(lp));
00170 }
00171
00172 void TransitionDialog::setType(int type)
00173 {
00174 comboType->setCurrentIndex(type);
00175 }
00176
00177 void TransitionDialog::setTrOrientation(bool leftOriented)
00178 {
00179 DBGLOG("idx=" << ((leftOriented) ? 0 : 1));
00180 comboOrientation->setCurrentIndex( ((leftOriented) ? 0 : 1) );
00181 }
00182
00183 void TransitionDialog::setDimmed(bool dimmed)
00184 {
00185 checkDimmed->setChecked(dimmed);
00186 }
00187
00188 void TransitionDialog::setArcAngle(int arcA)
00189 {
00190 edtArcAngle->setText(QString("%1").arg(arcA));
00191 }
00192
00193 void TransitionDialog::setArcAngleB(int arcAB)
00194 {
00195 edtArcAngleB->setText(QString("%1").arg(arcAB));
00196 }
00197
00198 void TransitionDialog::setNCurv(float ncurv)
00199 {
00200 edtNCurv->setText(QString("%1").arg(ncurv));
00201 }
00202
00203 void TransitionDialog::showEdits(int type)
00204 {
00205 TransitionManager *transitionManager = TransitionManager::getInstance();
00206
00207 const TwoStatesTransitionProperties trProps =
00208 transitionManager->getTwoStatesTransitionProperties(type);
00209
00210 edtLabel->setEnabled(trProps.hasLabel);
00211
00212 lineLabelPos->setEnabled(trProps.hasLabelPos);
00213 if (trProps.hasLabelPos && (m_mode == eAdd || lineLabelPos->text().isEmpty()))
00214 lineLabelPos->setText(QString("%1").arg(trProps.defLabelPos));
00215
00216 edtArcAngle->setEnabled(trProps.hasArcAngleA);
00217 if (trProps.hasArcAngleA && (m_mode == eAdd || edtArcAngle->text().isEmpty()))
00218 edtArcAngle->setText(QString("%1").arg(trProps.defArcAngleA));
00219
00220 edtArcAngleB->setEnabled(trProps.hasArcAngleB);
00221 if (trProps.hasArcAngleB && (m_mode == eAdd || edtArcAngleB->text().isEmpty()))
00222 edtArcAngleB->setText(QString("%1").arg(trProps.defArcAngleB));
00223
00224 edtNCurv->setEnabled(trProps.hasNCurve);
00225 if (trProps.hasNCurve && (m_mode == eAdd || edtNCurv->text().isEmpty()))
00226 edtNCurv->setText(QString("%1").arg(trProps.defNCurve));
00227 }
00228
00229
00230
00231
00232
00233
00234
00235 TransitionLoopSEDialog::TransitionLoopSEDialog(EMode mode, QWidget *parent)
00236 : NameAcceptDialog(parent), m_mode(mode)
00237 {
00238 TransitionManager *transitionManager = TransitionManager::getInstance();
00239 QLabel *labelName = new QLabel(QString("Label"), this);
00240 edtLabel = new QLineEdit(this);
00241
00242 QRegExp rx("^[\\-]{0,1}[0-9]{1,3}\\.[0-9]{1,3}$");
00243 QValidator *v = new QRegExpValidator(rx,this);
00244
00245 QLabel* labelLabelPos = new QLabel(QString("pos"), this);
00246 lineLabelPos = new QLineEdit(this);
00247 lineLabelPos->setValidator(v);
00248 lineLabelPos->setMaximumWidth(40);
00249 lineLabelPos->setText(QString("%1").arg(DEF_LOOP_LAB_POS));
00250
00251 QWidget *labelWidget = new QWidget(this);
00252 QHBoxLayout *labelLayout = new QHBoxLayout(labelWidget);
00253 labelLayout->addWidget(labelName);
00254 labelLayout->addWidget(edtLabel);
00255 labelLayout->addWidget(labelLabelPos);
00256 labelLayout->addWidget(lineLabelPos);
00257
00258 QLabel* labelType = new QLabel(QString("Type"), this);
00259 comboType = new QComboBox(this);
00260 foreach(QString typeName, transitionManager->getOneStateTransitionTypeNameList())
00261 {
00262 comboType->addItem(typeName);
00263 }
00264
00265 connect(comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(showEdits(int)));
00266
00267 QLabel *labelDirection = new QLabel(QString("Direction"),this);
00268
00269 QStringList sl;
00270 sl.append("North");
00271 sl.append("South");
00272 sl.append("East");
00273 sl.append("West");
00274 sl.append("North-East");
00275 sl.append("North-West");
00276 sl.append("South-East");
00277 sl.append("South-West");
00278 comboDirection = new QComboBox(this);
00279 comboDirection->addItems(sl);
00280 comboDirection->setCurrentIndex(0);
00281
00282 checkDimmed = new QCheckBox(QString("Dimmed"),this);
00283
00284 QWidget *hBox = new QWidget(this);
00285 QPushButton *buttonOk = new QPushButton("Ok");
00286 QPushButton *buttonCancel = new QPushButton("Cancel");
00287 QHBoxLayout *hBoxLayout = new QHBoxLayout;
00288 hBoxLayout->addWidget(buttonOk);
00289 hBoxLayout->addWidget(buttonCancel);
00290 hBox->setLayout(hBoxLayout);
00291 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
00292 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00293
00294 QGridLayout *gridLayout = new QGridLayout(this);
00295 gridLayout->addWidget(labelWidget, 0, 0, 1, 2);
00296 gridLayout->addWidget(labelType, 1, 0);
00297 gridLayout->addWidget(comboType, 1, 1);
00298 gridLayout->addWidget(labelDirection, 2, 0);
00299 gridLayout->addWidget(comboDirection, 2, 1);
00300 gridLayout->addWidget(checkDimmed, 3, 1);
00301 gridLayout->addWidget(hBox, 4, 0, 1, 2);
00302
00303 QString s = "Transition dialog";
00304 if (mode == eAdd)
00305 s += " - add";
00306 else
00307 s += " - edit";
00308 setWindowTitle(s);
00309 setWindowIcon(QIcon(":images/transition.xpm"));
00310 }
00311
00312 QString TransitionLoopSEDialog::getLabel() const
00313 {
00314 return edtLabel->text();
00315 }
00316
00317 float TransitionLoopSEDialog::getLabelPos() const
00318 {
00319 return lineLabelPos->text().toFloat();
00320 }
00321
00322 int TransitionLoopSEDialog::getDirection() const
00323 {
00324 return comboDirection->currentIndex();
00325 }
00326
00327 bool TransitionLoopSEDialog::isDimmed() const
00328 {
00329 return checkDimmed->isChecked();
00330 }
00331
00332 int TransitionLoopSEDialog::getType() const
00333 {
00334 return comboType->currentIndex();
00335 }
00336
00337 void TransitionLoopSEDialog::setDirection(int d){
00338 comboDirection->setCurrentIndex(d);
00339 }
00340
00341 void TransitionLoopSEDialog::setLabel(const QString &lab){
00342 edtLabel->setText(lab);
00343 }
00344
00345 void TransitionLoopSEDialog::setLabelPos(float lp){
00346 lineLabelPos->setText(QString("%1").arg(lp));
00347 }
00348
00349 void TransitionLoopSEDialog::setDimmed(bool d){
00350 checkDimmed->setChecked(d);
00351 }
00352
00353 void TransitionLoopSEDialog::setType(int type)
00354 {
00355 comboType->setCurrentIndex(type);
00356 }
00357
00358 void TransitionLoopSEDialog::showEdits(int type)
00359 {
00360 TransitionManager *transitionManager = TransitionManager::getInstance();
00361
00362 const OneStateTransitionProperties trProps =
00363 transitionManager->getOneStateTransitionProperties(type);
00364
00365 edtLabel->setEnabled(trProps.hasLabel);
00366 lineLabelPos->setEnabled(trProps.hasLabelPos);
00367
00368 if (trProps.hasLabelPos && (m_mode == eAdd || lineLabelPos->text().isEmpty()))
00369 lineLabelPos->setText(QString("%1").arg(trProps.defLabelPos));
00370 }
00371
00372
00373
00374
00375
00376
00377
00378 TransitionExtendedDialog::TransitionExtendedDialog(QWidget *parent)
00379 : QDialog(parent)
00380 {
00381 QStringList sls;
00382 sls.append("solid");
00383 sls.append("dashed");
00384 sls.append("dotted");
00385 sls.append("none");
00386
00387 QRegExp rx("^[\\-]{0,1}[0-9]{1,3}\\.[0-9]{1,3}$");
00388 QValidator *v = new QRegExpValidator(rx,this);
00389
00390
00391 QLabel *lineStyle = new QLabel(QString("EdgeLineStyle"),this);
00392 comboLineStyle = new QComboBox(this);
00393 comboLineStyle->addItems(sls);
00394 comboLineStyle->setCurrentIndex(0);
00395
00396 QLabel *lineWidth = new QLabel(QString("EdgeLineWidth"),this);
00397 edtLineWidth = new QLineEdit(this);
00398 edtLineWidth->setValidator(v);
00399
00400 QLabel *lineColor = new QLabel(QString("EdgeLineColor"),this);
00401 edtLineColor = new QLineEdit(this);
00402
00403 QLabel *labelColor = new QLabel(QString("EdgeLabelColor"),this);
00404 edtLabelColor = new QLineEdit(this);
00405
00406 QLabel *labelScale = new QLabel(QString("EdgeLabelScale"),this);
00407 edtLabelScale = new QLineEdit(this);
00408 edtLabelScale->setValidator(v);
00409
00410 QLabel *dblStatus = new QLabel(QString("EdgeLineDblStatus"),this);
00411 checkDblStatus = new QCheckBox(this);
00412 checkDblStatus->setChecked(false);
00413
00414
00415 QLabel *dimLineStyle = new QLabel(QString("DimEdgeLineStyle"),this);
00416 comboDimLineStyle = new QComboBox(this);
00417 comboDimLineStyle->addItems(sls);
00418 comboDimLineStyle->setCurrentIndex(0);
00419
00420 QLabel *dimLineColor = new QLabel(QString("DimEdgeLineColor"),this);
00421 edtDimLineColor = new QLineEdit(this);
00422
00423 QLabel *dimLineCoef = new QLabel(QString("DimEdgeLineCoef"),this);
00424 edtDimLineCoef = new QLineEdit(this);
00425 edtDimLineCoef->setValidator(v);
00426
00427 QLabel *dimLabelColor = new QLabel(QString("DimEdgeLabelColor"),this);
00428 edtDimLabelColor = new QLineEdit(this);
00429
00430
00431 QLabel *lineBorderCoef = new QLabel(QString("EdgeLineBorderCoef"),this);
00432 edtLineBorderCoef = new QLineEdit(this);
00433 edtLineBorderCoef->setValidator(v);
00434
00435 QLabel *lineBorderColor = new QLabel(QString("EdgeLineBorderColor"),this);
00436 edtLineBorderColor = new QLineEdit(this);
00437
00438
00439 QLabel *lineDblCoef = new QLabel(QString("EdgeLineDblCoef"),this);
00440 edtLineDblCoef = new QLineEdit(this);
00441 edtLineDblCoef->setValidator(v);
00442
00443 QLabel *lineDblSep = new QLabel(QString("EdgeLineDblSep"),this);
00444 edtLineDblSep= new QLineEdit(this);
00445 edtLineDblSep->setValidator(v);
00446
00447
00448 QWidget *hBox = new QWidget(this);
00449 QPushButton *buttonOk = new QPushButton("Ok");
00450 QPushButton *buttonCancel = new QPushButton("Cancel");
00451 QHBoxLayout *hBoxLayout = new QHBoxLayout;
00452 hBoxLayout->addWidget(buttonOk);
00453 hBoxLayout->addWidget(buttonCancel);
00454 hBox->setLayout(hBoxLayout);
00455 hBox->setMaximumWidth(300);
00456 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
00457 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00458
00459 QGroupBox *advancedGroup = new QGroupBox("Advanced parameters");
00460 QGridLayout *advancedLayout = new QGridLayout(advancedGroup);
00461 advancedLayout->addWidget(lineStyle,0,0);
00462 advancedLayout->addWidget(comboLineStyle,0,1);
00463 advancedLayout->addWidget(lineWidth,0,2);
00464 advancedLayout->addWidget(edtLineWidth,0,3);
00465 advancedLayout->addWidget(lineColor,1,0);
00466 advancedLayout->addWidget(edtLineColor,1,1);
00467 advancedLayout->addWidget(labelColor,1,2);
00468 advancedLayout->addWidget(edtLabelColor,1,3);
00469 advancedLayout->addWidget(labelScale,2,0);
00470 advancedLayout->addWidget(edtLabelScale,2,1);
00471 advancedLayout->addWidget(checkDblStatus,2,2,Qt::AlignRight);
00472 advancedLayout->addWidget(dblStatus,2,3,Qt::AlignLeft);
00473
00474 QGroupBox *presetGroup = new QGroupBox("Preset parameters (dim edge)");
00475 QGridLayout* presetLayout = new QGridLayout(presetGroup);
00476 presetLayout->addWidget(dimLineStyle, 0,0);
00477 presetLayout->addWidget(comboDimLineStyle, 0,1);
00478 presetLayout->addWidget(dimLineCoef, 0,2);
00479 presetLayout->addWidget(edtDimLineCoef, 0,3);
00480 presetLayout->addWidget(dimLineColor, 1,0);
00481 presetLayout->addWidget(edtDimLineColor, 1,1);
00482 presetLayout->addWidget(dimLabelColor, 1,2);
00483 presetLayout->addWidget(edtDimLabelColor, 1,3);
00484
00485 QGroupBox *borderGroup = new QGroupBox("Edge border parameters (edge line double) - unsupported in editor :+(");
00486 QHBoxLayout *borderLayout = new QHBoxLayout(borderGroup);
00487 borderLayout->addWidget(lineBorderCoef);
00488 borderLayout->addWidget(edtLineBorderCoef);
00489 borderLayout->addWidget(lineBorderColor);
00490 borderLayout->addWidget(edtLineBorderColor);
00491
00492 QGroupBox *doubleGroup = new QGroupBox("Line double parameters (final state) - unsupported in editor :+(");
00493 QHBoxLayout *doubleLayout = new QHBoxLayout(doubleGroup);
00494 doubleLayout->addWidget(lineDblCoef);
00495 doubleLayout->addWidget(edtLineDblCoef);
00496 doubleLayout->addWidget(lineDblSep);
00497 doubleLayout->addWidget(edtLineDblSep);
00498
00499 QVBoxLayout *dialogLayout = new QVBoxLayout(this);
00500 dialogLayout->addWidget(advancedGroup);
00501 dialogLayout->addWidget(presetGroup);
00502 dialogLayout->addWidget(borderGroup);
00503 dialogLayout->addWidget(doubleGroup);
00504 dialogLayout->addWidget(hBox, 0, Qt::AlignHCenter);
00505
00506 QString s = "Extended parameters";
00507 setWindowTitle(s);
00508 setWindowIcon(QIcon(":images/transition.xpm"));
00509 }
00510
00511 void TransitionExtendedDialog::setParams(Transition *tr){
00512 comboLineStyle->setCurrentIndex(trLineStyleI(tr->edgeLineStyle));
00513 edtLineWidth->setText(QString("%1").arg(tr->edgeLineWidth));
00514 edtLineColor->setText(tr->edgeLineColor);
00515 edtLabelColor->setText(tr->edgeLabelColor);
00516 edtLabelScale->setText(QString("%1").arg(tr->edgeLabelScale));
00517 checkDblStatus->setChecked(tr->edgeLineDblStatus);
00518
00519 comboDimLineStyle->setCurrentIndex(trLineStyleI(tr->dimEdgeLineStyle));
00520 edtDimLineColor->setText(tr->dimEdgeLineColor);
00521 edtDimLineCoef->setText(QString("%1").arg(tr->dimEdgeLineCoef));
00522 edtDimLabelColor->setText(tr->dimEdgeLabelColor);
00523
00524 edtLineBorderCoef->setText(QString("%1").arg(tr->edgeLineBorderCoef));
00525 edtLineBorderColor->setText(QString("%1").arg(tr->edgeLineBorderColor));
00526
00527 edtLineDblCoef->setText(QString("%1").arg(tr->edgeLineDblCoef));
00528 edtLineDblSep->setText(QString("%1").arg(tr->edgeLineDblSep));
00529 }
00530
00531 Qt::PenStyle TransitionExtendedDialog::getLineStyle(){
00532 return trLineStyle(comboLineStyle->currentIndex());
00533 }
00534
00535 float TransitionExtendedDialog::getLineWidth(){
00536 return edtLineWidth->text().toFloat();
00537 }
00538
00539 QString TransitionExtendedDialog::getLineColor(){
00540 return edtLineColor->text();
00541 }
00542
00543 QString TransitionExtendedDialog::getLabelColor(){
00544 return edtLabelColor->text();
00545 }
00546
00547 float TransitionExtendedDialog::getLabelScale(){
00548 return edtLabelScale->text().toFloat();
00549 }
00550
00551 bool TransitionExtendedDialog::getDblStatus(){
00552 return checkDblStatus->isChecked();
00553 }
00554
00555 Qt::PenStyle TransitionExtendedDialog::getDimLineStyle(){
00556 return trLineStyle(comboDimLineStyle->currentIndex());
00557 }
00558
00559 QString TransitionExtendedDialog::getDimLineColor(){
00560 return edtDimLineColor->text();
00561 }
00562
00563 float TransitionExtendedDialog::getDimLineCoef(){
00564 return edtDimLineCoef->text().toFloat();
00565 }
00566
00567 QString TransitionExtendedDialog::getDimLabelColor(){
00568 return edtDimLabelColor->text();
00569 }
00570
00571 float TransitionExtendedDialog::getLineBorderCoef(){
00572 return edtLineBorderCoef->text().toFloat();
00573 }
00574
00575 QString TransitionExtendedDialog::getLineBorderColor(){
00576 return edtLineBorderColor->text();
00577 }
00578
00579 float TransitionExtendedDialog::getLineDblCoef(){
00580 return edtLineDblCoef->text().toFloat();
00581 }
00582
00583 float TransitionExtendedDialog::getLineDblSep(){
00584 return edtLineDblSep->text().toFloat();
00585 }
00586
00587
00588
00589
00590
00591
00592
00593 NextLabelsDialog::NextLabelsDialog(Editor *editor, Transition *tr, QWidget *parent)
00594 : QDialog(parent), m_pEditor(editor), m_pTransition(tr)
00595 {
00596 QLabel *lblNextLabels = new QLabel(QString("Next labels:"),this);
00597
00598 labelList = new QListWidget(this);
00599 QStringList sl;
00600 for (Transition::TLabelXList::ConstIterator labelIt = m_pTransition->nextLabels.begin();
00601 labelIt != m_pTransition->nextLabels.end();
00602 ++labelIt)
00603 {
00604 sl << getListLine(*labelIt);
00605 }
00606 labelList->addItems(sl);
00607 connect(labelList, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
00608
00609 btnAdd = new QPushButton("Add", this);
00610 connect(btnAdd, SIGNAL(clicked()), this, SLOT(addLabel()));
00611
00612 btnEdit = new QPushButton("Edit", this);
00613 connect(btnEdit, SIGNAL(clicked()), this, SLOT(editLabel()));
00614
00615 btnDelete = new QPushButton("Delete", this);
00616 connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteLabel()));
00617
00618 QPushButton *buttonClose = new QPushButton("&Close");
00619 connect(buttonClose, SIGNAL(clicked()), this, SLOT(close()));
00620
00621 QGridLayout *dialogLayout = new QGridLayout(this);
00622 dialogLayout->addWidget(lblNextLabels, 0, 0, 1, 2);
00623 dialogLayout->addWidget(labelList, 1, 0, 5, 1);
00624 dialogLayout->addWidget(btnAdd, 1, 1);
00625 dialogLayout->addWidget(btnEdit, 2, 1);
00626 dialogLayout->addWidget(btnDelete, 3, 1);
00627 dialogLayout->addWidget(buttonClose, 5, 1);
00628
00629 QString s = "Next labels";
00630 setWindowTitle(s);
00631 setWindowIcon(QIcon(":images/transition.xpm"));
00632
00633 selectionChanged();
00634 }
00635
00636 void NextLabelsDialog::selectionChanged()
00637 {
00638 DBGLOG("selected row=" << labelList->currentRow());
00639
00640
00641 btnEdit->setEnabled(labelList->currentRow() != -1);
00642 btnDelete->setEnabled(labelList->currentRow() != -1);
00643 }
00644
00645 QString NextLabelsDialog::getListLine(LabelX *label)
00646 {
00647 return QString("%1, pos=%2, orientation=%3")
00648 .arg(label->text())
00649 .arg(label->posParam())
00650 .arg(label->left() ? "left" : "right");
00651 }
00652
00653 void NextLabelsDialog::addLabel()
00654 {
00655 NextLabelsEditDialog nled(eAdd, this);
00656 if (nled.exec() == QDialog::Rejected) return;
00657
00658 LabelX *label = new LabelX(m_pTransition, nled.edtLabel->text(), nled.checkLeft->isChecked(),
00659 m_pTransition->m_labelFontSize, m_pTransition->getLabelColor(), nled.edtPos->text().toFloat());
00660
00661 m_pEditor->addToUndoStack(new NextLabelAddCommand(m_pEditor,label));
00662
00663 labelList->insertItem(labelList->count(), getListLine(label));
00664 }
00665
00666 void NextLabelsDialog::editLabel()
00667 {
00668 LabelX *label = m_pTransition->nextLabels[labelList->currentRow()];
00669 NextLabelsEditDialog nled(eEdit, this, label->text(), label->posParam(), label->left());
00670 if (nled.exec() == QDialog::Rejected) return;
00671
00672 m_pEditor->addToUndoStack(
00673 new NextLabelEditCommand(label, nled.edtLabel->text(), nled.edtPos->text().toFloat(),
00674 nled.checkLeft->isChecked())
00675 );
00676
00677
00678 int row = labelList->currentRow();
00679 labelList->takeItem(row);
00680 labelList->insertItem(row, getListLine(label));
00681 }
00682
00683 void NextLabelsDialog::deleteLabel()
00684 {
00685 if (QMessageBox::question(this, QString("Realy delete?"), QString("Are you sure you want to delete selected label?"),
00686 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
00687 {
00688 LabelX *label = m_pTransition->nextLabels[labelList->currentRow()];
00689 m_pEditor->addToUndoStack(new NextLabelDeleteCommand(m_pEditor, label));
00690 labelList->takeItem(labelList->currentRow());
00691 }
00692 }
00693
00694
00695
00696
00697
00698
00699
00700 NextLabelsDialog::NextLabelsEditDialog::NextLabelsEditDialog
00701 (EActionType action, QWidget *parent)
00702 : QDialog(parent)
00703 {
00704 init(action, "", DEF_EDGE_LAB_POS, true);
00705 }
00706
00707 NextLabelsDialog::NextLabelsEditDialog::NextLabelsEditDialog
00708 (EActionType action, QWidget *parent, const QString& str, float pos, bool left)
00709 : QDialog(parent)
00710 {
00711 init(action, str, pos, left);
00712 }
00713
00714 void NextLabelsDialog::NextLabelsEditDialog::init(EActionType action, const QString &str, float pos, bool left)
00715 {
00716 QLabel *lblLabel = new QLabel(QString("label"), this);
00717 edtLabel = new QLineEdit(str, this);
00718
00719 QLabel *lblPos = new QLabel(QString("pos"), this);
00720 QRegExp rx("^[\\-]{0,1}[0-9]{1,3}\\.[0-9]{1,3}$");
00721 QValidator *v = new QRegExpValidator(rx,this);
00722 edtPos = new QLineEdit(QString("%1").arg(pos), this);
00723 edtPos->setValidator(v);
00724
00725 checkLeft = new QCheckBox(QString("isLeft"), this);
00726 checkLeft->setChecked(left);
00727
00728
00729 QWidget *buttonBox = new QWidget(this);
00730 QPushButton *buttonOk = new QPushButton("Ok");
00731 QPushButton *buttonCancel = new QPushButton("Cancel");
00732 QHBoxLayout *buttonBoxLayout = new QHBoxLayout;
00733 buttonBoxLayout->addWidget(buttonOk);
00734 buttonBoxLayout->addWidget(buttonCancel);
00735 buttonBox->setLayout(buttonBoxLayout);
00736 buttonBox->setMaximumWidth(300);
00737 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
00738 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
00739
00740 QGridLayout *dialogLayout = new QGridLayout(this);
00741 dialogLayout->addWidget(lblLabel, 0, 0);
00742 dialogLayout->addWidget(edtLabel, 0, 1);
00743 dialogLayout->addWidget(lblPos, 0, 2);
00744 dialogLayout->addWidget(edtPos, 0, 3);
00745 dialogLayout->addWidget(checkLeft, 0, 4);
00746 dialogLayout->addWidget(buttonBox, 1, 0, 1, 5, Qt::AlignHCenter);
00747
00748 QString s;
00749 switch (action)
00750 {
00751 case eAdd:
00752 s = QString("Add label");
00753 break;
00754 case eEdit:
00755 s = QString("Edit label");
00756 break;
00757 }
00758 setWindowTitle(s);
00759 setWindowIcon(QIcon(":images/transition.xpm"));
00760 }
00761
00762