summaryrefslogtreecommitdiffstats
path: root/kbugbuster/gui/serverconfigdialog.cpp
blob: 32c5e241f10aedee06ff9a3e73816d2954ed4ae8 (plain)
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
#include "serverconfigdialog.h"

#include "bugserverconfig.h"

#include <kpassdlg.h>
#include <kdebug.h>
#include <klocale.h>

#include <qlayout.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qvbox.h>
#include <qcombobox.h>

ServerConfigDialog::ServerConfigDialog( QWidget *parent, const char *name ) :
  KDialogBase( parent, name, true, i18n("Edit Bugzilla Server"), Ok|Cancel )
{
  QWidget *topFrame = makeMainWidget();

  QGridLayout *topLayout = new QGridLayout( topFrame );
  topLayout->setSpacing( spacingHint() );

  QLabel *label;

  mServerName = new QLineEdit( topFrame );
  label = new QLabel( mServerName, i18n("Name:"), topFrame );
  topLayout->addWidget( label, 0, 0 );
  topLayout->addWidget( mServerName, 0, 1 );
  mServerName->setFocus();

  mServerUrl = new QLineEdit( topFrame );
  label = new QLabel( mServerUrl, i18n("URL:"), topFrame );
  topLayout->addWidget( label, 1, 0 );
  topLayout->addWidget( mServerUrl, 1, 1 );

  mUser = new QLineEdit( topFrame );
  label = new QLabel( mUser, i18n("User:"), topFrame );
  topLayout->addWidget( label, 2, 0 );
  topLayout->addWidget( mUser, 2, 1 );

  mPassword = new KPasswordEdit( topFrame );
  label = new QLabel( mPassword, i18n("Password:"), topFrame );
  topLayout->addWidget( label, 3, 0 );
  topLayout->addWidget( mPassword, 3, 1 );

  mVersion = new QComboBox( topFrame );
  label = new QLabel( mVersion, i18n("Bugzilla version:"), topFrame );
  topLayout->addWidget( label, 4, 0 );
  topLayout->addWidget( mVersion, 4, 1 );
  mVersion->insertStringList( BugServerConfig::bugzillaVersions() );
}

void ServerConfigDialog::setServerConfig( const BugServerConfig &cfg )
{
  mServerName->setText( cfg.name() );
  mServerUrl->setText( cfg.baseUrl().url() );
  mUser->setText( cfg.user() );
  mPassword->setText( cfg.password() );

  int i;
  for( i = 0; i < mVersion->count(); ++i ) {
    if ( mVersion->text( i ) == cfg.bugzillaVersion() ) {
      mVersion->setCurrentItem( i );
      break;
    }
  }
}

BugServerConfig ServerConfigDialog::serverConfig()
{
  BugServerConfig cfg;

  cfg.setName( mServerName->text() );
  cfg.setBaseUrl( KURL( mServerUrl->text() ) );
  cfg.setUser( mUser->text() );
  cfg.setPassword( mPassword->text() );
  cfg.setBugzillaVersion( mVersion->currentText() );

  return cfg;
}

#include "serverconfigdialog.moc"