Pārlūkot izejas kodu

Allow non-default port numbers for database connections

Neal Wilson 9 gadus atpakaļ
vecāks
revīzija
9ee855f920
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9
    1
      src/typica.w

+ 9
- 1
src/typica.w Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt