]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Rename Local Storage to DOM Storage. https://redmine.stoutner.com/issues/852
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index 32d61d09e4363401848c19eb39a1851d9cd7268f..eb43fb560ec7431b94dd1e1bbbf2721af5a604d0 100644 (file)
@@ -34,6 +34,7 @@ const int DomainSettingsDialog::SHOW_ALL_DOMAINS = 0;
 const int DomainSettingsDialog::ADD_DOMAIN = 1;
 const int DomainSettingsDialog::EDIT_DOMAIN = 2;
 
 const int DomainSettingsDialog::ADD_DOMAIN = 1;
 const int DomainSettingsDialog::EDIT_DOMAIN = 2;
 
+// Construct the class.
 DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
 {
     // Set the window title.
 DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
 {
     // Set the window title.
@@ -48,14 +49,14 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     // Setup the UI.
     domainSettingsDialogUi.setupUi(this);
 
     // Setup the UI.
     domainSettingsDialogUi.setupUi(this);
 
-    // Get handles for the views.
+    // Get handles for the widgets.
     domainsListViewPointer = domainSettingsDialogUi.domainsListView;
     domainSettingsWidgetPointer = domainSettingsDialogUi.domainSettingsWidget;
     domainNameLineEditPointer = domainSettingsDialogUi.domainNameLineEdit;
     javaScriptComboBoxPointer = domainSettingsDialogUi.javaScriptComboBox;
     javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel;
     domainsListViewPointer = domainSettingsDialogUi.domainsListView;
     domainSettingsWidgetPointer = domainSettingsDialogUi.domainSettingsWidget;
     domainNameLineEditPointer = domainSettingsDialogUi.domainNameLineEdit;
     javaScriptComboBoxPointer = domainSettingsDialogUi.javaScriptComboBox;
     javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel;
-    localStorageComboBoxPointer = domainSettingsDialogUi.localStorageComboBox;
-    localStorageLabelPointer = domainSettingsDialogUi.localStorageLabel;
+    domStorageComboBoxPointer = domainSettingsDialogUi.domStorageComboBox;
+    domStorageLabelPointer = domainSettingsDialogUi.domStorageLabel;
     userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox;
     userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel;
     zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox;
     userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox;
     userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel;
     zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox;
@@ -129,10 +130,10 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     // Handle clicks on the domains.
     connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
 
     // Handle clicks on the domains.
     connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
 
-    // Connect the domain settings.
+    // Process changes to the domain settings.
     connect(domainNameLineEditPointer, SIGNAL(textEdited(QString)), this, SLOT(domainNameChanged(QString)));
     connect(javaScriptComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(javaScriptChanged(int)));
     connect(domainNameLineEditPointer, SIGNAL(textEdited(QString)), this, SLOT(domainNameChanged(QString)));
     connect(javaScriptComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(javaScriptChanged(int)));
-    connect(localStorageComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(localStorageChanged(int)));
+    connect(domStorageComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(domStorageChanged(int)));
     connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(QString)), this, SLOT(userAgentChanged(QString)));
     connect(zoomFactorComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomFactorComboBoxChanged(int)));
     connect(customZoomFactorSpinBoxPointer, SIGNAL(valueChanged(double)), this, SLOT(customZoomFactorChanged(double)));
     connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(QString)), this, SLOT(userAgentChanged(QString)));
     connect(zoomFactorComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomFactorComboBoxChanged(int)));
     connect(customZoomFactorSpinBoxPointer, SIGNAL(valueChanged(double)), this, SLOT(customZoomFactorChanged(double)));
@@ -157,7 +158,7 @@ void DomainSettingsDialog::addDomain(const QString &domainName) const
     // Set the values for the new domain.
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), domainName);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), DomainsDatabaseHelper::SYSTEM_DEFAULT);
     // Set the values for the new domain.
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), domainName);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), DomainsDatabaseHelper::SYSTEM_DEFAULT);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE), DomainsDatabaseHelper::SYSTEM_DEFAULT);
+    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE), DomainsDatabaseHelper::SYSTEM_DEFAULT);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR), DomainsDatabaseHelper::SYSTEM_DEFAULT);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR), 1.0);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR), DomainsDatabaseHelper::SYSTEM_DEFAULT);
     newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR), 1.0);
@@ -244,8 +245,8 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
     // Populate the JavaScript combo box.
     javaScriptComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)).data().toInt());
 
     // Populate the JavaScript combo box.
     javaScriptComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)).data().toInt());
 
-    // Populate the local storage combo box.
-    localStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)).data().toInt());
+    // Populate the DOM storage combo box.
+    domStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)).data().toInt());
 
     // Get the user agent string.
     QString userAgent = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)).data().toString();
 
     // Get the user agent string.
     QString userAgent = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)).data().toString();
@@ -282,7 +283,7 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
 
     // Populate the labels.
     populateJavaScriptLabel();
 
     // Populate the labels.
     populateJavaScriptLabel();
-    populateLocalStorageLabel();
+    populateDomStorageLabel();
     populateUserAgentLabel(userAgentComboBoxPointer->currentText());
 
     // Update the UI.
     populateUserAgentLabel(userAgentComboBoxPointer->currentText());
 
     // Update the UI.
@@ -302,14 +303,14 @@ void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const
     updateUi();
 }
 
     updateUi();
 }
 
-void DomainSettingsDialog::localStorageChanged(const int &newIndex) const
+void DomainSettingsDialog::domStorageChanged(const int &newIndex) const
 {
     // Update the domains table model.
 {
     // Update the domains table model.
-    domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)),
+    domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)),
                                       newIndex);
 
                                       newIndex);
 
-    // Populate the local storage label.
-    populateLocalStorageLabel();
+    // Populate the DOM storage label.
+    populateDomStorageLabel();
 
     // Update the UI.
     updateUi();
 
     // Update the UI.
     updateUi();
@@ -335,8 +336,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
         case (DomainsDatabaseHelper::SYSTEM_DEFAULT):
         {
             // Set the text according to the system default.
         case (DomainsDatabaseHelper::SYSTEM_DEFAULT):
         {
             // Set the text according to the system default.
-            if (Settings::javaScript()) javaScriptLabelPointer->setText(i18nc("Domains settings label", "JavaScript enabled"));
-            else javaScriptLabelPointer->setText(i18nc("Domain settings label", "JavaScript disabled"));
+            if (Settings::javaScriptEnabled())
+                javaScriptLabelPointer->setText(i18nc("Domains settings label", "JavaScript enabled"));
+            else
+                javaScriptLabelPointer->setText(i18nc("Domain settings label", "JavaScript disabled"));
 
             break;
         }
 
             break;
         }
@@ -344,7 +347,7 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
         case (DomainsDatabaseHelper::DISABLED):
         {
             // Set the label text in bold.
         case (DomainsDatabaseHelper::DISABLED):
         {
             // Set the label text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domain settings label.  The <strong> tags should be retained.", "<strong>JavaScript disabled</strong>"));
+            javaScriptLabelPointer->setText(i18nc("Domain settings label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
 
             break;
         }
 
             break;
         }
@@ -352,23 +355,25 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
         case (DomainsDatabaseHelper::ENABLED):
         {
             // Set the label text in bold.
         case (DomainsDatabaseHelper::ENABLED):
         {
             // Set the label text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domains settings label.  The <strong> tags should be retained.", "<strong>JavaScript enabled</strong>"));
+            javaScriptLabelPointer->setText(i18nc("Domains settings label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
 
             break;
         }
     }
 }
 
 
             break;
         }
     }
 }
 
-void DomainSettingsDialog::populateLocalStorageLabel() const
+void DomainSettingsDialog::populateDomStorageLabel() const
 {
     // Populate the label according to the currently selected index.
 {
     // Populate the label according to the currently selected index.
-    switch (localStorageComboBoxPointer->currentIndex())
+    switch (domStorageComboBoxPointer->currentIndex())
     {
         case (DomainsDatabaseHelper::SYSTEM_DEFAULT):
         {
             // Set the text according to the system default.
     {
         case (DomainsDatabaseHelper::SYSTEM_DEFAULT):
         {
             // Set the text according to the system default.
-            if (Settings::localStorage()) localStorageLabelPointer->setText(i18nc("Local storage label", "Local storage enabled"));
-            else localStorageLabelPointer->setText(i18nc("Local storage label", "Local storage disabled"));
+            if (Settings::domStorageEnabled())
+                domStorageLabelPointer->setText(i18nc("DOM storage label", "DOM storage enabled"));
+            else
+                domStorageLabelPointer->setText(i18nc("DOM storage label", "DOM storage disabled"));
 
             break;
         }
 
             break;
         }
@@ -376,7 +381,7 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
         case (DomainsDatabaseHelper::DISABLED):
         {
             // Set the label text in bold.
         case (DomainsDatabaseHelper::DISABLED):
         {
             // Set the label text in bold.
-            localStorageLabelPointer->setText(i18nc("Local storage label.  The <string> tags should be retained.", "<strong>Local storage disabled</strong>"));
+            domStorageLabelPointer->setText(i18nc("DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
 
             break;
         }
 
             break;
         }
@@ -384,7 +389,7 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
         case (DomainsDatabaseHelper::ENABLED):
         {
             // Set the label text in bold.
         case (DomainsDatabaseHelper::ENABLED):
         {
             // Set the label text in bold.
-            localStorageLabelPointer->setText(i18nc("Local storage label.  The <strong> tags should be retained.", "<strong>Local storage enabled</strong>"));
+            domStorageLabelPointer->setText(i18nc("DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
 
             break;
         }
 
             break;
         }