My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
markerdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  markerdialog.cpp - description
3  -------------------
4  begin : Wed April 21 2004
5  copyright : (C) 2003 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "markerdialog.h"
19 
20 #include <qlayout.h>
21 #include <qlabel.h>
22 #include <qhbox.h>
23 #include <qpushbutton.h>
24 #include <qvalidator.h>
25 
26 
27 MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent)
28  : QDialog(parent, 0, FALSE, Qt::WDestructiveClose)
29 {
30  setCaption(tr("Edit Marker Properties"));
31  pMarker = pm_;
32 
33  QGridLayout *g = new QGridLayout(this, 5,2,5,5);
34 
35  g->addWidget(new QLabel(tr("Precision: "), this), 0,0);
36  Precision = new QLineEdit(this);
37  Precision->setText(QString::number(pMarker->Precision));
38  Precision->setValidator(new QIntValidator(0, 12, this));
39  g->addWidget(Precision, 0, 1);
40 
41  g->addWidget(new QLabel(tr("Number Notation: "), this), 1,0);
42  NumberBox = new QComboBox(this);
43  NumberBox->insertItem(tr("real/imaginary"));
44  NumberBox->insertItem(tr("magnitude/angle (degree)"));
45  NumberBox->insertItem(tr("magnitude/angle (radian)"));
46  NumberBox->setCurrentItem(pMarker->numMode);
47  g->addWidget(NumberBox, 1, 1);
48 
49  TransBox = new QCheckBox(tr("transparent"), this);
50  TransBox->setChecked(pMarker->transparent);
51  g->addMultiCellWidget(TransBox,3,3,0,1);
52 
53  QHBox *b = new QHBox(this);
54  b->setSpacing(5);
55  g->addMultiCellWidget(b,4,4,0,1);
56 
57  // first => activated by pressing RETURN
58  QPushButton *ButtOK = new QPushButton(tr("OK"),b);
59  connect(ButtOK, SIGNAL(clicked()), SLOT(slotAcceptValues()));
60 
61  QPushButton *ButtCancel = new QPushButton(tr("Cancel"),b);
62  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
63 }
64 
66 {
67 }
68 
69 // ----------------------------------------------------------
70 void MarkerDialog::slotAcceptValues()
71 {
72  bool changed = false;
73  int tmp = Precision->text().toInt();
74  if(tmp != pMarker->Precision) {
75  pMarker->Precision = tmp;
76  changed = true;
77  }
78  if(NumberBox->currentItem() != pMarker->numMode) {
79  pMarker->numMode = NumberBox->currentItem();
80  changed = true;
81  }
82  if(TransBox->isChecked() != pMarker->transparent) {
83  pMarker->transparent = TransBox->isChecked();
84  changed = true;
85  }
86 
87  if(changed) {
89  done(2);
90  }
91  else done(1);
92 }