Browse Source

Allow non-default port numbers for database connections

Neal Wilson 9 years ago
parent
commit
9ee855f920
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/typica.w

+ 9
- 1
src/typica.w View File

1436
 @ The constructor is trivial.
1436
 @ The constructor is trivial.
1437
 
1437
 
1438
 @<Functions for scripting@>=
1438
 @<Functions for scripting@>=
1439
-QScriptValue constructQSvgWidget(QScriptContext *context,
1439
+QScriptValue constructQSvgWidget(QScriptContext *,
1440
                                  QScriptEngine *engine)
1440
                                  QScriptEngine *engine)
1441
 {
1441
 {
1442
     QScriptValue object = engine->newQObject(new QSvgWidget);
1442
     QScriptValue object = engine->newQObject(new QSvgWidget);
13473
         QFormLayout *formLayout;
13473
         QFormLayout *formLayout;
13474
         QComboBox *driver;
13474
         QComboBox *driver;
13475
         QLineEdit *hostname;
13475
         QLineEdit *hostname;
13476
+        QLineEdit *portnumber;
13476
         QLineEdit *dbname;
13477
         QLineEdit *dbname;
13477
         QLineEdit *user;
13478
         QLineEdit *user;
13478
         QLineEdit *password;
13479
         QLineEdit *password;
13487
 @<SqlConnectionSetup implementation@>=
13488
 @<SqlConnectionSetup implementation@>=
13488
 SqlConnectionSetup::SqlConnectionSetup() :
13489
 SqlConnectionSetup::SqlConnectionSetup() :
13489
     formLayout(new QFormLayout), driver(new QComboBox), hostname(new QLineEdit),
13490
     formLayout(new QFormLayout), driver(new QComboBox), hostname(new QLineEdit),
13491
+    portnumber(new QLineEdit),
13490
     dbname(new QLineEdit), user(new QLineEdit), password(new QLineEdit),
13492
     dbname(new QLineEdit), user(new QLineEdit), password(new QLineEdit),
13491
     layout(new QVBoxLayout), buttons(new QHBoxLayout),
13493
     layout(new QVBoxLayout), buttons(new QHBoxLayout),
13492
     cancelButton(new QPushButton(tr("Cancel"))),
13494
     cancelButton(new QPushButton(tr("Cancel"))),
13495
     driver->addItem("PostgreSQL", "QPSQL");
13497
     driver->addItem("PostgreSQL", "QPSQL");
13496
     formLayout->addRow(tr("Database driver:"), driver);
13498
     formLayout->addRow(tr("Database driver:"), driver);
13497
     formLayout->addRow(tr("Host name:"), hostname);
13499
     formLayout->addRow(tr("Host name:"), hostname);
13500
+    formLayout->addRow(tr("Port number:"), portnumber);
13501
+    portnumber->setText("5432");
13498
     formLayout->addRow(tr("Database name:"), dbname);
13502
     formLayout->addRow(tr("Database name:"), dbname);
13499
     formLayout->addRow(tr("User name:"), user);
13503
     formLayout->addRow(tr("User name:"), user);
13500
     password->setEchoMode(QLineEdit::Password);
13504
     password->setEchoMode(QLineEdit::Password);
13506
     buttons->addWidget(connectButton);
13510
     buttons->addWidget(connectButton);
13507
     layout->addLayout(buttons);
13511
     layout->addLayout(buttons);
13508
     connect(connectButton, SIGNAL(clicked(bool)), this, SLOT(testConnection()));
13512
     connect(connectButton, SIGNAL(clicked(bool)), this, SLOT(testConnection()));
13513
+    connectButton->setDefault(true);
13509
     setLayout(layout);
13514
     setLayout(layout);
13510
     setModal(true);
13515
     setModal(true);
13511
 }
13516
 }
13526
                                   toString());
13531
                                   toString());
13527
     database.setConnectOptions("application_name=Typica");
13532
     database.setConnectOptions("application_name=Typica");
13528
     database.setHostName(hostname->text());
13533
     database.setHostName(hostname->text());
13534
+    database.setPort(portnumber->text().toInt());
13529
     database.setDatabaseName(dbname->text());
13535
     database.setDatabaseName(dbname->text());
13530
     database.setUserName(user->text());
13536
     database.setUserName(user->text());
13531
     database.setPassword(password->text());
13537
     database.setPassword(password->text());
13536
         settings.setValue("database/driver",
13542
         settings.setValue("database/driver",
13537
                           driver->itemData(driver->currentIndex()).toString());
13543
                           driver->itemData(driver->currentIndex()).toString());
13538
         settings.setValue("database/hostname", hostname->text());
13544
         settings.setValue("database/hostname", hostname->text());
13545
+        settings.setValue("database/portnumber", portnumber->text());
13539
         settings.setValue("database/dbname", dbname->text());
13546
         settings.setValue("database/dbname", dbname->text());
13540
         settings.setValue("database/user", user->text());
13547
         settings.setValue("database/user", user->text());
13541
         settings.setValue("database/password", password->text());
13548
         settings.setValue("database/password", password->text());
13568
     QSqlDatabase::addDatabase(settings.value("database/driver").toString());
13575
     QSqlDatabase::addDatabase(settings.value("database/driver").toString());
13569
 database.setConnectOptions("application_name=Typica");
13576
 database.setConnectOptions("application_name=Typica");
13570
 database.setHostName(settings.value("database/hostname").toString());
13577
 database.setHostName(settings.value("database/hostname").toString());
13578
+database.setPort(settings.value("database/portnumber", 5432).toInt());
13571
 database.setDatabaseName(settings.value("database/dbname").toString());
13579
 database.setDatabaseName(settings.value("database/dbname").toString());
13572
 database.setUserName(settings.value("database/user").toString());
13580
 database.setUserName(settings.value("database/user").toString());
13573
 database.setPassword(settings.value("database/password").toString());
13581
 database.setPassword(settings.value("database/password").toString());

Loading…
Cancel
Save