File: Dialog.cpp

package info (click to toggle)
bouml 4.21-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 73,336 kB
  • ctags: 55,459
  • sloc: cpp: 290,644; makefile: 228; sh: 13
file content (175 lines) | stat: -rw-r--r-- 4,407 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

#include "Dialog.h"

#include <stdlib.h>

#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qfiledialog.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>

#include "SmallPushButton.h"

Dialog::Dialog(QCString & path, QCString & encoding, QCString & genview, int & taggedvalue, Language & lang)
  : QDialog(0, 0, TRUE), _path(path), _encoding(encoding), _genview(genview), _taggedvalue(taggedvalue), _lang(lang) {
  QVBoxLayout * vbox = new QVBoxLayout(this);
  QHBox * htab;
  
  vbox->setMargin(5);
  
  // get xmi pathname
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel("generated \nXMI file : ", htab);
  
  ed = new QLineEdit(htab);
  ed->setText(_path);
  
  new QLabel(" ", htab);
  
  SmallPushButton * br = new SmallPushButton("browse", htab);
  
  connect(br, SIGNAL(clicked ()), this, SLOT(browse()));

  // to choose encoding
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel("Encoding : ", htab);
  
  QString charset = getenv("BOUML_CHARSET");
  int index = 0;
  
  while ((index = charset.find('_')) != -1) {
    charset[index] = '-';
    index += 1;
  }

  encoding_cb = new QComboBox(TRUE, htab);
  encoding_cb->insertItem(QString(_encoding));
  if (!charset.isEmpty() && (_encoding != (const char *) charset))
    encoding_cb->insertItem(charset);
#ifdef WIN32
  if ((_encoding != "windows-1252") && (charset != "windows-1252"))
    encoding_cb->insertItem("windows-1252");
  if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1"))
    encoding_cb->insertItem("ISO-8859-1");
#else
  if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1"))
    encoding_cb->insertItem("ISO-8859-1");
  if ((_encoding != "windows-1252") && (charset != "windows-1252"))
    encoding_cb->insertItem("windows-1252");
#endif
  
  // generate view checkbox
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  gen_cb = new QCheckBox("Generate views as package", htab);
  if (_genview == "yes")
    gen_cb->setChecked(TRUE);
    
  // tagged value generation mode
    
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  QButtonGroup * bg =
    new QButtonGroup(3, Qt::Vertical, "Tagged values generation", htab);
  
  tg_0 = new QRadioButton("Not generated", bg);
  tg_1 = new QRadioButton("<UML:TaggedValue tag=\"..\" value=\"..\"/>", bg);
  tg_2 = new QRadioButton("<UML:TaggedValue>\n"
			  "    <Uml:TaggedValue.tag>..</Uml:TaggedValue.tag>\n"
			  "    <Uml:TaggedValue.value>..</Uml:TaggedValue.value>\n"
			  "</UML:TaggedValue>",
			  bg);
  switch (taggedvalue) {
  case 1: tg_1->setChecked(TRUE); break;
  case 2: tg_2->setChecked(TRUE); break;
  default: tg_0->setChecked(TRUE); break;
  }
  
  // uml , c++, java, cancel buttons
  
  htab = new QHBox(this);
  htab->setMargin(5);
  vbox->addWidget(htab);
  
  new QLabel(htab);
  QPushButton * uml = new QPushButton("&Uml", htab);
  new QLabel(htab);
  QPushButton * cpp = new QPushButton("&C++", htab);
  new QLabel(htab);
  QPushButton * java = new QPushButton("&Java", htab);
  new QLabel(htab);
  QPushButton * cancel = new QPushButton("&Cancel", htab);
  new QLabel(htab);
  QSize bs(cancel->sizeHint());
  
  uml->setFixedSize(bs);
  cpp->setFixedSize(bs);
  java->setFixedSize(bs);
  
  connect(uml, SIGNAL(clicked()), this, SLOT(accept_uml()));
  connect(cpp, SIGNAL(clicked()), this, SLOT(accept_cpp()));
  connect(java, SIGNAL(clicked()), this, SLOT(accept_java()));
  connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
}

void Dialog::browse() {
  QString s = QFileDialog::getSaveFileName(_path, "*.xmi", 0);
  
  if (! s.isEmpty()) {
    if (s.right(4).lower() != ".xmi")
      ed->setText(s + ".xmi");
    else
      ed->setText(s);
  }
}

void Dialog::accept_cpp() {
  _lang = Cpp;
  
  accept();
}

void Dialog::accept_uml() {
  _lang = Uml;
  accept();
}

void Dialog::accept_java() {
  _lang = Java;
  accept();
}

void Dialog::accept() {
  _path = ed->text();
  _encoding = encoding_cb->currentText();
  _genview = (gen_cb->isChecked()) ? "yes" : "no";
  if (tg_0->isChecked())
    _taggedvalue = 0;
  else if (tg_1->isChecked())
    _taggedvalue = 1;
  else if (tg_2->isChecked())
    _taggedvalue = 2;
  
  QDialog::accept();
}