+void DomainSettingsDialog::addDomain(const QString &domainName) const
+{
+ // Create a new domain record.
+ QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME).record(DomainsDatabase::DOMAINS_TABLE);
+
+ // Set the values for the new domain.
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME), domainName);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT), DomainsDatabase::SYSTEM_DEFAULT);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE), DomainsDatabase::SYSTEM_DEFAULT);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR), DomainsDatabase::SYSTEM_DEFAULT);
+ newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR), 1.0);
+
+ // Insert the new domain. `-1` appends it to the end.
+ domainsTableModelPointer->insertRecord(-1, newDomainRecord);
+
+ // Submit all pending changes.
+ domainsTableModelPointer->submitAll();
+
+ // Find the index for the new domain. `-1` allows for multiple entries to be returned.
+ QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)),
+ Qt::DisplayRole, domainName, -1, Qt::MatchWrap);
+
+ // Move to the new domain. If there are multiple domains with the same name, the new one should be the last in the list.
+ domainsListViewPointer->setCurrentIndex(newDomainIndex[newDomainIndex.size() - 1]);
+
+ // Populate the domain settings.
+ domainSelected(domainsSelectionModelPointer->currentIndex());
+
+ // Update the UI.
+ updateUi();
+}
+