~vbursian/research-assistant/trunk

« back to all changes in this revision

Viewing changes to RAGUI/DBLinkingDialogs.cpp

  • Committer: Viktor Bursian
  • Date: 2020-07-16 22:38:41 UTC
  • mfrom: (9.25.2 DIST) (9.16.21 VB)
  • Revision ID: vik@pryanik-20200716223841-0gp0sf6m5imdjtb3
Tags: version_1.5.0
releasing version 1.5.0, closing v.1.4 development

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/*! @file DBLinkingDialogs.cpp Classes sEditDBInfoDialog and sEditDBLinkDialog.
3
3
- Part of RAGUI - Research Assistant Graphical User Interface.
4
4
- Uses  RANet - Research Assistant Net Library (based on ANSI C++).
5
 
- Uses  Qt v.5.0  -  http://qt-project.org/
6
 
- Copyright(C) 2013, Viktor E. Bursian, St.Petersburg, Russia.
7
 
                     VBursian@gmail.com
 
5
- Uses  Qt v.5  - http://qt.io/
 
6
- Copyright(C) 2013-2017, Viktor E. Bursian, St.Petersburg, Russia.
 
7
                          VBursian@gmail.com
8
8
*///////////////////////////////////////////////////////////////////////////////
9
9
#include "DBLinkingDialogs.h"
10
10
#include "StringsAndQStrings.h"
11
11
#include <QMessageBox>
12
12
#include <QDialogButtonBox>
 
13
#include <QVBoxLayout>
 
14
#include <QHBoxLayout>
 
15
#include <QDir>
 
16
#include <QFileDialog>
 
17
#include <QIcon>
 
18
#include <QDebug>
13
19
namespace RA {
14
20
//------------------------------------------------------------------------------
15
21
 
 
22
const QRegExp      sEditDBInfoDialog::PrefixRegExpr("[a-z][_a-z0-9]+");
 
23
const QRegExp      sEditDBInfoDialog::SchemaRegExpr("[a-z][_a-z0-9]+");
 
24
const QRegExp      sEditDBInfoDialog::DBNameRegExpr("[a-z][_a-z0-9]+");
 
25
 
16
26
const sEditDBInfoDialog::sLinker      sEditDBInfoDialog::Linker;
17
27
 
18
28
//----------------------------------------------- sEditDBInfoDialog::sLinker ---
26
36
 
27
37
bool  sEditDBInfoDialog::Modify (psDB_Info  info)
28
38
{
29
 
  sEditDBInfoDialog *             D = new sEditDBInfoDialog(info);
 
39
  sEditDBInfoDialog *             D = new sEditDBInfoDialog(info
 
40
                                            ,tr("Select database"));
30
41
  D->setAttribute(Qt::WA_DeleteOnClose);
31
42
  return  D->exec() == QDialog::Accepted;
32
43
}
33
44
 
34
45
 
35
46
sEditDBInfoDialog::sEditDBInfoDialog (psDB_Info  info
 
47
                                     ,QString    title
36
48
                                     ,QWidget *  parent)
37
49
    :QDialog(parent)
38
50
    ,Info(info)
39
51
{
40
 
  setWindowTitle(tr("Select database"));
 
52
  setWindowTitle(title);
41
53
  resize(600, 100);
42
 
  Layout = new QVBoxLayout();
43
 
  setLayout(Layout);
44
 
 
45
 
  FLayout = new QFormLayout();
46
 
//  FLayout->setLabelAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
47
 
  Layout->addLayout(FLayout);
48
 
 
49
 
  FLayout->setWidget(20,QFormLayout::LabelRole,new QLabel(tr("Type")));
 
54
  setLayout(new QVBoxLayout());
 
55
 
 
56
  URLLabel = new QLabel(tr("URL:   "),this);
 
57
  URLField = new QLabel(this);
 
58
 
50
59
  TypeField = new QComboBox(this);
51
 
  FLayout->setWidget(20,QFormLayout::FieldRole,TypeField);
52
60
 
53
61
  HostLabel = new QLabel(tr("Host"),this);
54
 
  FLayout->setWidget(21,QFormLayout::LabelRole,HostLabel);
55
62
  HostField = new QLineEdit(this);
56
 
  FLayout->setWidget(21,QFormLayout::FieldRole,HostField);
57
63
 
58
64
  PortLabel = new QLabel(tr("Port"),this);
59
 
  FLayout->setWidget(22,QFormLayout::LabelRole,PortLabel);
60
65
  PortField = new QSpinBox(this);
61
 
  FLayout->setWidget(22,QFormLayout::FieldRole,PortField);
62
 
 
63
 
  NameLabel = new QLabel(tr("Name"),this);
64
 
  FLayout->setWidget(23,QFormLayout::LabelRole,NameLabel);
65
 
  NameField = new QLineEdit(this);
66
 
  FLayout->setWidget(23,QFormLayout::FieldRole,NameField);
67
 
 
68
 
  FLayout->setWidget(24,QFormLayout::LabelRole,new QLabel(tr("Login")));
 
66
  PortField->setRange(-1,0xffff);
 
67
  PortField->setSpecialValueText(tr("auto"));
 
68
 
 
69
  LoginLabel = new QLabel(tr("Login"),this);
69
70
  LoginField = new QLineEdit(this);
70
 
  FLayout->setWidget(24,QFormLayout::FieldRole,LoginField);
71
71
 
72
 
  FLayout->setWidget(25,QFormLayout::LabelRole,new QLabel(tr("Password")));
 
72
  PasswordLabel = new QLabel(tr("Password"),this);
73
73
  PasswordField = new QLineEdit(this);
74
 
  PasswordField->setEchoMode(QLineEdit::PasswordEchoOnEdit);
75
 
  FLayout->setWidget(25,QFormLayout::FieldRole,PasswordField);
 
74
  PasswordField->setEchoMode(QLineEdit::Password);
 
75
 
 
76
  ShowPasswordButton = new QToolButton(this);
 
77
  ShowPasswordButton->setIcon(QIcon(":/RAGUI/icons/eye.png"));
 
78
 
 
79
  DBNameLabel = new QLabel("",this);
 
80
  DBNameField = new QLineEdit(this);
 
81
  BrowseButton = new QPushButton(tr("Browse"),this);
 
82
  RelativeCheckBox = new QCheckBox(tr("relative to the current folder:"),this);
 
83
  CurrentDirField = new QLabel(QDir::currentPath(),this);
 
84
  DBNameValidator = new QRegExpValidator(DBNameRegExpr,this);
 
85
 
 
86
  SchemaLabel = new QLabel(tr("Schema name"),this);
 
87
  SchemaField = new QLineEdit(this);
 
88
 
 
89
  PrefixLabel = new QLabel(tr("Table naming prefix"),this);
 
90
  PrefixField = new QLineEdit(this);
 
91
 
 
92
  OptionsLabel = new QLabel(tr("Connection options"),this);
 
93
  OptionsField = new QLineEdit(this);
76
94
 
77
95
  QDialogButtonBox *  ButtonBox = new QDialogButtonBox(this);
78
96
  ButtonBox->setOrientation(Qt::Horizontal);
79
97
  ButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
80
 
//  ButtonBox->setStandardButtons(QDialogButtonBox::Cancel
81
 
//                               |QDialogButtonBox::Ok
82
 
//                               |QDialogButtonBox::Help);
83
 
  Layout->addWidget(ButtonBox);
84
 
 
85
 
//  QStringList drivers = QSqlDatabase::drivers();
86
 
//  // remove compat names
87
 
//  drivers.removeAll("QMYSQL3");
88
 
//  drivers.removeAll("QOCI8");
89
 
//  drivers.removeAll("QODBC3");
90
 
//  drivers.removeAll("QPSQL7");
91
 
//  drivers.removeAll("QTDS7");
92
 
//  TypeField->addItems(drivers);
 
98
  //layout
 
99
  {
 
100
    QHBoxLayout *             L;
 
101
 
 
102
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
103
    ((QVBoxLayout*)layout())->addItem(L);
 
104
    L->addWidget(URLLabel);
 
105
    L->addWidget(URLField);
 
106
 
 
107
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
108
    ((QVBoxLayout*)layout())->addItem(L);
 
109
    L->addWidget(new QLabel(tr("Type"),this));
 
110
    L->addWidget(TypeField);
 
111
 
 
112
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
113
    ((QVBoxLayout*)layout())->addItem(L);
 
114
    L->addWidget(HostLabel);
 
115
    L->addWidget(HostField);
 
116
    L->addWidget(PortLabel);
 
117
    L->addWidget(PortField);
 
118
 
 
119
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
120
    ((QVBoxLayout*)layout())->addItem(L);
 
121
    L->addWidget(LoginLabel);
 
122
    L->addWidget(LoginField);
 
123
    L->addWidget(PasswordLabel);
 
124
    L->addWidget(PasswordField);
 
125
    L->addWidget(ShowPasswordButton);
 
126
 
 
127
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
128
    ((QVBoxLayout*)layout())->addItem(L);
 
129
    L->addWidget(DBNameLabel);
 
130
    L->addWidget(DBNameField);
 
131
    L->addWidget(BrowseButton);
 
132
 
 
133
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
134
    ((QVBoxLayout*)layout())->addItem(L);
 
135
    L->addWidget(RelativeCheckBox);
 
136
 
 
137
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
138
    ((QVBoxLayout*)layout())->addItem(L);
 
139
    L->addWidget(CurrentDirField);
 
140
 
 
141
    (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
142
    ((QVBoxLayout*)layout())->addItem(L);
 
143
    L->addWidget(SchemaLabel);
 
144
    L->addWidget(SchemaField);
 
145
    L->addWidget(PrefixLabel);
 
146
    L->addWidget(PrefixField);
 
147
 
 
148
    layout()->addWidget(OptionsLabel);
 
149
    layout()->addWidget(OptionsField);
 
150
 
 
151
    ((QVBoxLayout*)layout())->addStretch(1);
 
152
    layout()->addWidget(ButtonBox);
 
153
  }
 
154
 
 
155
  PrefixField->setValidator(new QRegExpValidator(PrefixRegExpr));
 
156
  SchemaField->setValidator(new QRegExpValidator(SchemaRegExpr));
93
157
 
94
158
  TypeField->addItem(ToQString( sDB_Info::TypeName[sDB_Info::cSQLite] ));
95
159
  TypeField->addItem(ToQString( sDB_Info::TypeName[sDB_Info::cMySQL ] ));
96
 
 
97
 
  NameField->setText(ToQString( Info->Name ));
98
 
  HostField->setText(ToQString( Info->Host ));
99
 
  PortField->setValue(Info->Port);
100
 
  LoginField->setText(ToQString( Info->Login ));
101
 
  PasswordField->setText(ToQString( Info->Password ));
 
160
  TypeField->addItem(ToQString( sDB_Info::TypeName[sDB_Info::cPostgreSQL ] ));
 
161
  TypeField->setCurrentIndex( Info->Type );
 
162
  RelativeCheckBox->setChecked(true);
102
163
 
103
164
  OnTypeChanged(TypeField->currentIndex());
104
165
 
105
166
  connect(TypeField ,SIGNAL(currentIndexChanged(int))
106
167
         ,this      ,SLOT(OnTypeChanged(int)));
 
168
  connect(RelativeCheckBox ,SIGNAL(clicked())
 
169
         ,this      ,SLOT(OnRelativeCheckBoxChange()));
 
170
  connect(BrowseButton ,SIGNAL(clicked())
 
171
         ,this         ,SLOT(Browse()));
 
172
  connect(HostField ,SIGNAL(textChanged(QString))
 
173
         ,this      ,SLOT(ShowURL()));
 
174
  connect(PortField ,SIGNAL(valueChanged(int))
 
175
         ,this      ,SLOT(ShowURL()));
 
176
  connect(LoginField ,SIGNAL(textChanged(QString))
 
177
         ,this      ,SLOT(ShowURL()));
 
178
  connect(PasswordField ,SIGNAL(textChanged(QString))
 
179
         ,this      ,SLOT(ShowURL()));
 
180
  connect(ShowPasswordButton ,SIGNAL(pressed())
 
181
         ,this      ,SLOT(ShowPassword()) );
 
182
  connect(ShowPasswordButton ,SIGNAL(released())
 
183
         ,this      ,SLOT(MaskPassword()) );
 
184
  connect(DBNameField ,SIGNAL(textChanged(QString))
 
185
         ,this      ,SLOT(ShowURL()));
 
186
  connect(SchemaField ,SIGNAL(textChanged(QString))
 
187
         ,this      ,SLOT(ShowURL()));
 
188
  connect(PrefixField ,SIGNAL(textChanged(QString))
 
189
         ,this      ,SLOT(ShowURL()));
 
190
  connect(OptionsField ,SIGNAL(textChanged(QString))
 
191
         ,this         ,SLOT(ShowURL()));
107
192
  connect(ButtonBox ,SIGNAL(accepted()) ,this ,SLOT(OnOK()));
108
193
  connect(ButtonBox ,SIGNAL(rejected()) ,this ,SLOT(reject()));
109
194
//  connect(ButtonBox,SIGNAL(helpRequested()),this,SLOT(ShowHelp()));
118
203
 
119
204
void  sEditDBInfoDialog::OnTypeChanged (int  type)
120
205
{
 
206
 
121
207
  switch( sDB_Info::eType(type) ){
122
208
    case sDB_Info::cSQLite:
 
209
          HostLabel->setVisible( false );
123
210
          HostField->setVisible( false );
 
211
          PortLabel->setVisible( false );
124
212
          PortField->setVisible( false );
125
 
          NameLabel->setText(tr("File name"));
 
213
          LoginLabel->setVisible( false );
 
214
          LoginField->setVisible( false );
 
215
          PasswordLabel->setVisible( false );
 
216
          PasswordField->setVisible( false );
 
217
          ShowPasswordButton->setVisible( false );
 
218
          RelativeCheckBox->setVisible( true );
 
219
          CurrentDirField->setVisible( true );
 
220
          DBNameLabel->setText(tr("SQLite file"));
 
221
          DBNameField->setValidator(NULL);
 
222
          BrowseButton->setVisible( true );
 
223
          SchemaLabel->setVisible( false );
 
224
          SchemaField->setVisible( false );
126
225
          break;
127
 
    case sDB_Info::cMySQL:
 
226
    default:
 
227
          HostLabel->setVisible( true );
128
228
          HostField->setVisible( true );
 
229
          PortLabel->setVisible( true );
129
230
          PortField->setVisible( true );
130
 
          NameLabel->setText(tr("Database name"));
 
231
          LoginLabel->setVisible( true );
 
232
          LoginField->setVisible( true );
 
233
          PasswordLabel->setVisible( true );
 
234
          PasswordField->setVisible( true );
 
235
          ShowPasswordButton->setVisible( true );
 
236
          RelativeCheckBox->setVisible( false );
 
237
          CurrentDirField->setVisible( false );
 
238
          DBNameLabel->setText(tr("Database name"));
 
239
          DBNameField->setValidator(DBNameValidator);
 
240
          BrowseButton->setVisible( false );
 
241
          SchemaLabel->setVisible( true );
 
242
          SchemaField->setVisible( true );
131
243
          break;
132
244
  }
133
 
  HostLabel->setVisible( HostField->isVisible() );
134
 
  PortLabel->setVisible( PortLabel->isVisible() );
 
245
  if( sDB_Info::eType(type) == Info->Type ){
 
246
    HostField->setText(ToQString( Info->Host ));
 
247
    PortField->setValue(Info->Port);
 
248
    LoginField->setText(ToQString( Info->Login ));
 
249
    PasswordField->setText(ToQString( Info->Password ));
 
250
    DBNameField->setText(ToQString( Info->DBName ));
 
251
    SchemaField->setText(ToQString( Info->SchemaName ));
 
252
    PrefixField->setText(ToQString( Info->TableNamePrefix ));
 
253
    OptionsField->setText(ToQString( Info->ConnectOptions ));
 
254
  }else{
 
255
    sDB_Info          I( (sDB_Info::eType) type );
 
256
    HostField->setText(ToQString( I.Host ));
 
257
    PortField->setValue(I.Port);
 
258
    LoginField->setText(ToQString( I.Login ));
 
259
    PasswordField->setText(ToQString( I.Password ));
 
260
    DBNameField->setText(ToQString( I.DBName ));
 
261
    SchemaField->setText(ToQString( I.SchemaName ));
 
262
    PrefixField->setText(ToQString( I.TableNamePrefix ));
 
263
    OptionsField->setText(ToQString( I.ConnectOptions ));
 
264
  }
 
265
  ShowURL();
 
266
}
 
267
 
 
268
 
 
269
void  sEditDBInfoDialog::OnRelativeCheckBoxChange ()
 
270
{
 
271
  if( RelativeCheckBox->isChecked() ){
 
272
    DBNameField->setText( QDir::current().relativeFilePath(DBNameField->text()) );
 
273
  }else{
 
274
    DBNameField->setText( QFileInfo(DBNameField->text()).absoluteFilePath() );
 
275
  }
 
276
}
 
277
 
 
278
 
 
279
void  sEditDBInfoDialog::ShowURL ()
 
280
{
 
281
  TempInfo.Type = sDB_Info::eType( TypeField->currentIndex() );
 
282
  TempInfo.DBName = FromQString( DBNameField->text() );
 
283
  TempInfo.SchemaName = FromQString( SchemaField->text() );
 
284
  TempInfo.TableNamePrefix = FromQString( PrefixField->text() );
 
285
  TempInfo.Host = FromQString( HostField->text() );
 
286
  TempInfo.Port = PortField->value();
 
287
  TempInfo.Login = FromQString( LoginField->text() );
 
288
  TempInfo.Password = FromQString( PasswordField->text() );
 
289
  TempInfo.ConnectOptions = FromQString( OptionsField->text() );
 
290
  URLField->setText(ToQString(sString("<b>")+TempInfo.URL())+"</b>");
 
291
 
 
292
  //back translation
 
293
  {
 
294
//    TempInfo.SetByURL(TempInfo.URL());
 
295
//    URLField->setText(URLField->text()
 
296
//        +"<br/><small>"
 
297
//        +"<br/>&nbsp;&nbsp;type="+ToQString(sDB_Info::TypeName[TempInfo.Type])
 
298
//        +"<br/>&nbsp;&nbsp;login="+ToQString(TempInfo.Login)
 
299
//        +"<br/>&nbsp;&nbsp;password="+ToQString(TempInfo.Password)
 
300
//        +"<br/>&nbsp;&nbsp;host="+ToQString(TempInfo.Host)
 
301
//        +"<br/>&nbsp;&nbsp;port="+QString().setNum(TempInfo.Port)
 
302
//        +"<br/>&nbsp;&nbsp;dbname="+ToQString(TempInfo.DBName)
 
303
//        +"<br/>&nbsp;&nbsp;schema="+ToQString(TempInfo.SchemaName)
 
304
//        +"<br/>&nbsp;&nbsp;prefix="+ToQString(TempInfo.TableNamePrefix)
 
305
//        +"<br/>&nbsp;&nbsp;options="+ToQString(TempInfo.ConnectOptions)
 
306
//        +"</small>"
 
307
//        );
 
308
  }
 
309
}
 
310
 
 
311
 
 
312
void  sEditDBInfoDialog::Browse ()
 
313
{
 
314
  QString                     Name = DBNameField->text();
 
315
 
 
316
  Name = QFileDialog::getOpenFileName(DBNameField
 
317
      ,""
 
318
      ,QFileInfo(Name).path()
 
319
      ,"RANet sqlite files (*.RANet.sqlite);;All files (*)"
 
320
      ,0
 
321
      ,QFileDialog::DontUseCustomDirectoryIcons
 
322
      );
 
323
 
 
324
  //!@todo{UI} There should be different dialog styles:
 
325
  //!  - when setting a link to related part
 
326
  //!    - as is, but the file must exist;
 
327
  //!  - when selecting a root part to open
 
328
  //!    - RelativeCheckBox is senseless,
 
329
  //!    - file must exist;
 
330
  //!  - when creating new root part
 
331
  //!    - RelativeCheckBox is senseless,
 
332
  //!    - file should not exist,
 
333
  //!    - and it should be possible to create a folder.
 
334
 
 
335
//  Dir = QFileDialog::getExistingDirectory(NameField
 
336
//      ,""
 
337
//      ,QFileInfo(Name).path()
 
338
//      );
 
339
 
 
340
//  Name = QFileDialog::getSaveFileName(NameField
 
341
//      ,""
 
342
//      ,Name
 
343
//      ,"RANet sqlite files (*.RANet.sqlite);;All files (*)"
 
344
//      ,0
 
345
//      ,QFileDialog::DontUseCustomDirectoryIcons
 
346
//      );
 
347
 
 
348
  if( ! Name.isEmpty() ){
 
349
    if( RelativeCheckBox->isChecked() ){
 
350
      Name = QDir::current().relativeFilePath(Name);
 
351
    }
 
352
    DBNameField->setText(Name);
 
353
  }
 
354
}
 
355
 
 
356
 
 
357
void  sEditDBInfoDialog::ShowPassword ()
 
358
{
 
359
  PasswordField->setEchoMode(QLineEdit::Normal);
 
360
}
 
361
 
 
362
 
 
363
void  sEditDBInfoDialog::MaskPassword ()
 
364
{
 
365
  PasswordField->setEchoMode(QLineEdit::Password);
135
366
}
136
367
 
137
368
 
146
377
 
147
378
bool  sEditDBInfoDialog::Validate ()
148
379
{
149
 
  QString                     Name = NameField->text();
150
 
  //... analyse and transform Name
151
 
  if( Name.isEmpty() ){
 
380
  //... analyse and transform DBName, etc.
 
381
  /*! @todo{SQL} temporary allow all values for DBName, etc.
 
382
  QString                     DBName = DBNameField->text();
 
383
  if( DBName.isEmpty() ){
152
384
    QMessageBox::information(this, tr("No database name given")
153
385
                            ,tr("Please fill up the name field"));
154
 
    NameField->setFocus();
 
386
    DBNameField->setFocus();
155
387
    return false;
156
388
  }
 
389
  */
157
390
  return true;
158
391
}
159
392
 
161
394
void  sEditDBInfoDialog::AcceptChanges ()
162
395
{
163
396
  Info->Type = sDB_Info::eType( TypeField->currentIndex() );
164
 
  Info->Name = FromQString( NameField->text() );
 
397
  Info->DBName = FromQString( DBNameField->text() );
 
398
  Info->SchemaName = FromQString( SchemaField->text() );
 
399
  Info->TableNamePrefix = FromQString( PrefixField->text() );
165
400
  Info->Host = FromQString( HostField->text() );
166
401
  Info->Port = PortField->value();
167
402
  Info->Login = FromQString( LoginField->text() );
168
403
  Info->Password = FromQString( PasswordField->text() );
 
404
  Info->ConnectOptions = FromQString( OptionsField->text() );
169
405
}
170
406
 
171
407
//-------------------------------------------------------- sEditDBLinkDialog ---
172
408
 
173
409
sEditDBLinkDialog::sEditDBLinkDialog (psDB_Link  link
 
410
                                     ,QString    title
174
411
                                     ,QWidget *  parent)
175
 
    :sEditDBInfoDialog(link,parent)
 
412
    :sEditDBInfoDialog(link,title,parent)
176
413
    ,Link(link)
 
414
    ,IdDisplay(NULL)
177
415
{
178
 
  setWindowTitle(tr("Edit link to a database"));
179
 
 
180
416
  if( ! Link->Id.Undefined() ){
181
 
    IdDisplay = new QLabel(ToQString(Link->Id.ToString()),this);
182
 
    FLayout->setWidget(10,QFormLayout::LabelRole,new QLabel(tr("DB Id")));
183
 
    FLayout->setWidget(10,QFormLayout::FieldRole,IdDisplay);
184
 
  }
185
 
 
186
 
  NicknameField = new QLineEdit(ToQString( Link->Nickname ),this);
187
 
  FLayout->setWidget(11,QFormLayout::LabelRole,new QLabel(tr("Link nickname")));
188
 
  FLayout->setWidget(11,QFormLayout::FieldRole,NicknameField);
189
 
 
190
 
  CommentField = new QLineEdit(ToQString( Link->Comment ),this);
191
 
  FLayout->setWidget(12,QFormLayout::LabelRole,new QLabel(tr("Link comment")));
192
 
  FLayout->setWidget(12,QFormLayout::FieldRole,CommentField);
193
 
}
194
 
 
195
 
 
196
 
bool  sEditDBLinkDialog::Validate ()
197
 
{
198
 
  if( ! sEditDBInfoDialog::Validate() ){
199
 
    return false;
200
 
  }
201
 
  QString                     Nickname = NicknameField->text();
202
 
  //... analyse and transform Nickname
203
 
  if( Nickname.isEmpty() ){
204
 
    QMessageBox::information(this, tr("No database link nickname given")
205
 
                            ,tr("Please fill up the nickname field"));
206
 
    NicknameField->setFocus();
207
 
    return false;
208
 
  }
209
 
  return true;
210
 
}
211
 
 
212
 
 
213
 
void sEditDBLinkDialog::AcceptChanges ()
214
 
{
215
 
  sEditDBInfoDialog::AcceptChanges();
216
 
  Link->Nickname = FromQString( NicknameField->text() );
217
 
  Link->Comment = FromQString( CommentField->text() );
 
417
    IdDisplay = new QLabel(ToQString(Link->Id.ToString()
 
418
                                    +"    v."+Link->Version.Text()
 
419
                                    )
 
420
                          ,this);
 
421
  }
 
422
 
 
423
  //layout
 
424
  {
 
425
    int                       I = 0;
 
426
    QHBoxLayout *             L;
 
427
 
 
428
    if( IdDisplay ){
 
429
      (L = new QHBoxLayout())->setAlignment(Qt::AlignLeft);
 
430
      ((QVBoxLayout*)layout())->insertItem(I++,L);
 
431
      L->addWidget(new QLabel(tr("DB Id   "),this));
 
432
      L->addWidget(IdDisplay);
 
433
    }
 
434
  }
218
435
}
219
436
 
220
437
//------------------------------------------------------------------------------