]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Move `enabled` above `disabled` in the domain settings spinners. https://redmine...
authorSoren Stoutner <soren@stoutner.com>
Wed, 14 Jun 2023 22:58:47 +0000 (15:58 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 14 Jun 2023 22:58:47 +0000 (15:58 -0700)
doc/index.docbook
src/databases/CookiesDatabase.cpp
src/databases/CookiesDatabase.h
src/databases/DomainsDatabase.cpp
src/databases/DomainsDatabase.h
src/dialogs/DomainSettingsDialog.cpp
src/dialogs/DurableCookiesDialog.cpp
src/uis/DomainSettingsDialog.ui
src/widgets/PrivacyWebEngineView.cpp

index f9b5f6196dd4845688ef2c893629a172f12e2b4d..fbad58acd7079e1985191a5da70fdda89fcd9451 100644 (file)
 
     <!-- Version 0.4. -->
     <sect1 id="version_0.4">
-      <title>0.4 -
-        13 June 2023</title>
+      <title><ulink url="https://www.stoutner.com/privacy-browser-pc-0-4/">0.4</ulink> -
+        <ulink url="https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff;h=b4c8c8d02113d14c2a07751eb3b0c1bdeec7abb4">13 June 2023</ulink></title>
 
       <itemizedlist>
         <listitem><para>Add a setting to <ulink url="https://redmine.stoutner.com/issues/1002">control spatial navigation</ulink>.</para></listitem>
index 207f45b89795c3ead31d00313cb78654890056c7..dcb6f0b13cf95797b51c67f9a0e756736c42b707 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
 // Define the private static schema constants.
 const int CookiesDatabase::SCHEMA_VERSION = 0;
 
-// Define the public static database constants.
+// Define the public static constants.
 const QString CookiesDatabase::CONNECTION_NAME = "cookies_database";
 const QString CookiesDatabase::COOKIES_TABLE = "cookies";
-
-// Define the public static database field names.
-const QString CookiesDatabase::_ID = "_id";
 const QString CookiesDatabase::DOMAIN = "domain";
-const QString CookiesDatabase::NAME = "name";
-const QString CookiesDatabase::PATH = "path";
 const QString CookiesDatabase::EXPIRATION_DATE = "expiration_date";
 const QString CookiesDatabase::HTTP_ONLY = "http_only";
+const QString CookiesDatabase::ID = "_id";
+const QString CookiesDatabase::NAME = "name";
+const QString CookiesDatabase::PATH = "path";
 const QString CookiesDatabase::SECURE = "secure";
 const QString CookiesDatabase::VALUE = "value";
 
@@ -83,15 +81,14 @@ void CookiesDatabase::addDatabase()
 
             // Prepare the create table query.
             createTableQuery.prepare("CREATE TABLE " + COOKIES_TABLE + "(" +
-                _ID + " INTEGER PRIMARY KEY, " +
-                DOMAIN + " TEXT NOT NULL, " +
-                NAME + " TEXT NOT NULL, " +
-                PATH + " TEXT NOT NULL, " +
-                EXPIRATION_DATE + " TEXT, " +
-                HTTP_ONLY + " INTEGER NOT NULL DEFAULT 0, " +
-                SECURE + " INTEGER NOT NULL DEFAULT 0, " +
-                VALUE + " TEXT NOT NULL)"
-            );
+                                     ID + " INTEGER PRIMARY KEY, " +
+                                     DOMAIN + " TEXT NOT NULL, " +
+                                     NAME + " TEXT NOT NULL, " +
+                                     PATH + " TEXT NOT NULL, " +
+                                     EXPIRATION_DATE + " TEXT, " +
+                                     HTTP_ONLY + " INTEGER NOT NULL DEFAULT 0, " +
+                                     SECURE + " INTEGER NOT NULL DEFAULT 0, " +
+                                     VALUE + " TEXT NOT NULL)");
 
             // Execute the query.
             if (!createTableQuery.exec())
@@ -128,8 +125,15 @@ void CookiesDatabase::addCookie(const QNetworkCookie &cookie)
         QSqlQuery addCookieQuery(cookiesDatabase);
 
         // Prepare the add cookie query.
-        addCookieQuery.prepare("INSERT INTO " + COOKIES_TABLE + " (" + DOMAIN + ", " + NAME + ", " + PATH + ", " + EXPIRATION_DATE + ", " + HTTP_ONLY + ", " + SECURE + ", " + VALUE + ") "
-                            "VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"
+        addCookieQuery.prepare("INSERT INTO " + COOKIES_TABLE + " (" +
+                                DOMAIN + ", " +
+                                NAME + ", " +
+                                PATH + ", " +
+                                EXPIRATION_DATE + ", " +
+                                HTTP_ONLY + ", " +
+                                SECURE + ", " +
+                                VALUE + ") "
+                                "VALUES (:domain, :name, :path, :expiration_date, :http_only, :secure, :value)"
         );
 
         // Bind the values.
@@ -158,7 +162,7 @@ int CookiesDatabase::cookieCount()
     countCookiesQuery.setForwardOnly(true);
 
     // Prepare the query.
-    countCookiesQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE);
+    countCookiesQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE);
 
     // Execute the query.
     countCookiesQuery.exec();
@@ -204,7 +208,10 @@ void CookiesDatabase::deleteCookie(const QNetworkCookie &cookie)
     QSqlQuery deleteCookieQuery(cookiesDatabase);
 
     // Prepare the delete cookie query.
-    deleteCookieQuery.prepare("DELETE FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+    deleteCookieQuery.prepare("DELETE FROM " + COOKIES_TABLE + " WHERE " +
+                              DOMAIN + " = :domain AND " +
+                              NAME + " = :name AND " +
+                              PATH + " = :path");
 
     // Bind the values.
     deleteCookieQuery.bindValue(":domain", cookie.domain());
@@ -270,7 +277,7 @@ QNetworkCookie* CookiesDatabase::getCookieById(const int &id)
     cookieQuery.setForwardOnly(true);
 
     // Prepare the cookies query.
-    cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + _ID + " = :id");
+    cookieQuery.prepare("SELECT * FROM " + COOKIES_TABLE + " WHERE " + ID + " = :id");
 
     // Bind the values.
     cookieQuery.bindValue(":id", id);
@@ -309,7 +316,10 @@ bool CookiesDatabase::isDurable(const QNetworkCookie &cookie)
     isDurableQuery.setForwardOnly(true);
 
     // Prepare the is durable query.
-    isDurableQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+    isDurableQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE + " WHERE " +
+                            DOMAIN + " = :domain AND " +
+                            NAME + " = :name AND " +
+                            PATH + " = :path");
 
     // Bind the values.
     isDurableQuery.bindValue(":domain", cookie.domain());
@@ -335,8 +345,14 @@ bool CookiesDatabase::isUpdate(const QNetworkCookie &cookie)
     QSqlQuery isUpdateQuery(cookiesDatabase);
 
     // Prepare the is update query.
-    isUpdateQuery.prepare("SELECT " + EXPIRATION_DATE + " , " + HTTP_ONLY + " , " + SECURE + " , " + VALUE + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " +
-                          NAME + " = :name AND " + PATH + " = :path");
+    isUpdateQuery.prepare("SELECT " + EXPIRATION_DATE + " , " +
+                          HTTP_ONLY + " , " +
+                          SECURE + " , " +
+                          VALUE +
+                          " FROM " + COOKIES_TABLE +
+                          " WHERE " + DOMAIN + " = :domain AND " +
+                          NAME + " = :name AND " +
+                          PATH + " = :path");
 
     // Bind the values.
     isUpdateQuery.bindValue(":domain", cookie.domain());
@@ -353,10 +369,10 @@ bool CookiesDatabase::isUpdate(const QNetworkCookie &cookie)
     if (isUpdateQuery.isValid())  // The cookie exists in the database.
     {
         // Check to see if the cookie data has changed.
-        if ((QDateTime::fromString(isUpdateQuery.value(0).toString(), Qt::ISODate) != cookie.expirationDate()) ||
-            (isUpdateQuery.value(1).toBool() != cookie.isHttpOnly()) ||
-            (isUpdateQuery.value(2).toBool() != cookie.isSecure()) ||
-            (isUpdateQuery.value(3).toString().toUtf8() != cookie.value()))  // The cookies data has changed.
+        if ((QDateTime::fromString(isUpdateQuery.value(EXPIRATION_DATE).toString(), Qt::ISODate) != cookie.expirationDate()) ||
+            (isUpdateQuery.value(HTTP_ONLY).toBool() != cookie.isHttpOnly()) ||
+            (isUpdateQuery.value(SECURE).toBool() != cookie.isSecure()) ||
+            (isUpdateQuery.value(VALUE).toString().toUtf8() != cookie.value()))  // The cookies data has changed.
         {
             //qDebug() << "The durable cookie data has changed.";
 
@@ -387,8 +403,14 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &cookie)
     QSqlQuery updateCookieQuery(cookiesDatabase);
 
     // Prepare the edit cookie query.
-    updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE + " SET " + EXPIRATION_DATE + " = :expiration_date , " + HTTP_ONLY + " = :http_only , " + SECURE + " = :secure , " +
-                              VALUE + " = :value WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+    updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
+                              " SET " + EXPIRATION_DATE + " = :expiration_date , " +
+                              HTTP_ONLY + " = :http_only , " +
+                              SECURE + " = :secure , " +
+                              VALUE + " = :value " +
+                              "WHERE " + DOMAIN + " = :domain AND " +
+                              NAME + " = :name AND " +
+                              PATH + " = :path");
 
     // Bind the values.
     updateCookieQuery.bindValue(":domain", cookie.domain());
@@ -415,7 +437,10 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &oldCookie, const QNetwo
     oldCookieQuery.setForwardOnly(true);
 
     // Prepare the old cookie query.
-    oldCookieQuery.prepare("SELECT " + _ID + " FROM " + COOKIES_TABLE + " WHERE " + DOMAIN + " = :domain AND " + NAME + " = :name AND " + PATH + " = :path");
+    oldCookieQuery.prepare("SELECT " + ID + " FROM " + COOKIES_TABLE +
+                           " WHERE " + DOMAIN + " = :domain AND " +
+                           NAME + " = :name AND " +
+                           PATH + " = :path");
 
     // Bind the values.
     oldCookieQuery.bindValue(":domain", oldCookie.domain());
@@ -432,8 +457,15 @@ void CookiesDatabase::updateCookie(const QNetworkCookie &oldCookie, const QNetwo
     QSqlQuery updateCookieQuery(cookiesDatabase);
 
     // Prepare the update cookie query.
-    updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE + " SET " + DOMAIN + " = :domain , " + NAME + " = :name , " + PATH + " = :path , " + EXPIRATION_DATE + " = :expiration_date , " +
-                              HTTP_ONLY + " = :http_only , " + SECURE + " = :secure , " + VALUE + " = :value WHERE " + _ID + " = :id");
+    updateCookieQuery.prepare("UPDATE " + COOKIES_TABLE +
+                              " SET " + DOMAIN + " = :domain , " +
+                              NAME + " = :name , " +
+                              PATH + " = :path , " +
+                              EXPIRATION_DATE + " = :expiration_date , " +
+                              HTTP_ONLY + " = :http_only , " +
+                              SECURE + " = :secure , " +
+                              VALUE + " = :value " +
+                              "WHERE " + ID + " = :id");
 
     // Bind the values.
     updateCookieQuery.bindValue(":id", oldCookieQuery.value(0).toLongLong());
index 76e788ca63572bc8dadb721ba12826666b46b944..b81557b7e46b540841bddf9be1132b6187e20f97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -44,12 +44,12 @@ public:
     static void updateCookie(const QNetworkCookie &oldCookie, const QNetworkCookie &newCookie);
 
     // The public constants.
-    static const QString _ID;
     static const QString CONNECTION_NAME;
     static const QString COOKIES_TABLE;
     static const QString DOMAIN;
     static const QString EXPIRATION_DATE;
     static const QString HTTP_ONLY;
+    static const QString ID;
     static const QString NAME;
     static const QString PATH;
     static const QString SECURE;
index 6dfc1bd69e7daad13563454dfedca826f6285f65..05535436efa2a418e435748db9ff5e30bf4a244a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
 #include "helpers/UserAgentHelper.h"
 
 // Define the private static schema constants.
-const int DomainsDatabase::SCHEMA_VERSION = 5;
+const int DomainsDatabase::SCHEMA_VERSION = 6;
 
-// Define the public static database constants.
+// Define the public static constants.
 const QString DomainsDatabase::CONNECTION_NAME = "domains_database";
-const QString DomainsDatabase::DOMAINS_TABLE = "domains";
-
-// Define the public static database field names.
-const QString DomainsDatabase::_ID = "_id";
+const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
+const QString DomainsDatabase::DOM_STORAGE = "dom_storage";
 const QString DomainsDatabase::DOMAIN_NAME = "domain_name";
+const QString DomainsDatabase::DOMAINS_TABLE = "domains";
+const QString DomainsDatabase::ID = "_id";
 const QString DomainsDatabase::JAVASCRIPT = "javascript";
 const QString DomainsDatabase::LOCAL_STORAGE = "local_storage";
-const QString DomainsDatabase::DOM_STORAGE = "dom_storage";
 const QString DomainsDatabase::USER_AGENT = "user_agent";
 const QString DomainsDatabase::ZOOM_FACTOR = "zoom_factor";
-const QString DomainsDatabase::CUSTOM_ZOOM_FACTOR = "custom_zoom_factor";
 
 // Construct the class.
 DomainsDatabase::DomainsDatabase() {}
@@ -76,7 +74,7 @@ void DomainsDatabase::addDatabase()
                         // Add the JavaScript column.
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + JAVASCRIPT + " INTEGER DEFAULT 0");
 
-                        // Fallthrough to the next case.
+                        // Fall through to the next case.
                         [[fallthrough]];
                     }
 
@@ -86,7 +84,7 @@ void DomainsDatabase::addDatabase()
                         // Add the User Agent column.
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "'");
 
-                        // Fallthrough to the next case.
+                        // Fall through to the next case.
                         [[fallthrough]];
                     }
 
@@ -97,7 +95,7 @@ void DomainsDatabase::addDatabase()
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ZOOM_FACTOR + " INTEGER DEFAULT 0");
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0");
 
-                        // Fallthrough to the next case.
+                        // Fall through to the next case.
                         [[fallthrough]];
                     }
 
@@ -107,7 +105,7 @@ void DomainsDatabase::addDatabase()
                         // Add the DOM Storage column.
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + DOM_STORAGE + " INTEGER DEFAULT 0");
 
-                        // Fallthrough to the next case.
+                        // Fall through to the next case.
                         [[fallthrough]];
                     }
 
@@ -117,7 +115,120 @@ void DomainsDatabase::addDatabase()
                         // Add the Local Storage column.
                         domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + LOCAL_STORAGE + " INTEGER DEFAULT 0");
 
-                        // Fallthrough to the next case.
+                        // Fall through to the next case.
+                        [[fallthrough]];
+                    }
+
+                    // Upgrade from schema version 5 to schema version 6.
+                    case 5:
+                    {
+                        // Instantiate a spinner query.
+                        QSqlQuery spinnerQuery(domainsDatabase);
+
+                        // Set the query to be forward only (increases performance while iterating over the query).
+                        spinnerQuery.setForwardOnly(true);
+
+                        // Prepare the query.
+                        spinnerQuery.prepare("SELECT " + ID + "," + JAVASCRIPT + "," + LOCAL_STORAGE + "," + DOM_STORAGE + " FROM " + DOMAINS_TABLE);
+
+                        // Execute the query.
+                        spinnerQuery.exec();
+
+                        // Update the spinner values so that enabled is 1 and disabled is 2.
+                        while (spinnerQuery.next())
+                        {
+                            // Initialize the new spinner values.
+                            int newJavaScriptValue = SYSTEM_DEFAULT;
+                            int newLocalStorageValue = SYSTEM_DEFAULT;
+                            int newDomStorageValue = SYSTEM_DEFAULT;
+
+                            // Update the new JavaScript value if needed.
+                            switch (spinnerQuery.value(JAVASCRIPT).toInt())
+                            {
+                                // Disabled used to be 1.
+                                case 1:
+                                {
+                                    // Update the value to be 2.
+                                    newJavaScriptValue = DISABLED;
+
+                                    break;
+                                }
+
+                                // Enabled used to be 2.
+                                case 2:
+                                {
+                                    // Update the new value to be 1.
+                                    newJavaScriptValue = ENABLED;
+
+                                    break;
+                                }
+                            }
+
+                            // Update the new local storage value if needed.
+                            switch (spinnerQuery.value(LOCAL_STORAGE).toInt())
+                            {
+                                // Disabled used to be 1.
+                                case 1:
+                                {
+                                    // Update the new value to be 2.
+                                    newLocalStorageValue = DISABLED;
+
+                                    break;
+                                }
+
+                                // Enabled used to be 2.
+                                case 2:
+                                {
+                                    // Update the new value to be 1.
+                                    newLocalStorageValue = ENABLED;
+
+                                    break;
+                                }
+                            }
+
+                            // Update the new DOM storage value if needed.
+                            switch (spinnerQuery.value(DOM_STORAGE).toInt())
+                            {
+                                // Disabled used to be 1.
+                                case 1:
+                                {
+                                    // Update the new value to be 2.
+                                    newDomStorageValue = DISABLED;
+
+                                    break;
+                                }
+
+                                // Enabled used to be 2.
+                                case 2:
+                                {
+                                    // Update the new value to be 1.
+                                    newDomStorageValue = ENABLED;
+
+                                    break;
+                                }
+                            }
+
+                            // Create an update spinner query.
+                            QSqlQuery updateSpinnerQuery(domainsDatabase);
+
+                            // Prepare the update spinner query.
+                            updateSpinnerQuery.prepare("UPDATE " + DOMAINS_TABLE + " SET " +
+                                                 JAVASCRIPT + " = :javascript , " +
+                                                 LOCAL_STORAGE + " = :local_storage , " +
+                                                 DOM_STORAGE + " = :dom_storage " +
+                                                 " WHERE " + ID + " = :id");
+
+                            // Bind the values.
+                            updateSpinnerQuery.bindValue(":javascript", newJavaScriptValue);
+                            updateSpinnerQuery.bindValue(":local_storage", newLocalStorageValue);
+                            updateSpinnerQuery.bindValue(":dom_storage", newDomStorageValue);
+                            updateSpinnerQuery.bindValue(":id", spinnerQuery.value(ID));
+
+                            // Execute the query.
+                            updateSpinnerQuery.exec();
+                        }
+
+                        // Fall through to the next case.
                         // [[fallthrough]];
                     }
                 }
@@ -133,15 +244,14 @@ void DomainsDatabase::addDatabase()
 
             // Prepare the create table query.
             createTableQuery.prepare("CREATE TABLE " + DOMAINS_TABLE + "(" +
-                _ID + " INTEGER PRIMARY KEY, " +
-                DOMAIN_NAME + " TEXT, " +
-                JAVASCRIPT + " INTEGER DEFAULT 0, " +
-                LOCAL_STORAGE + " INTEGER DEFAULT 0, " +
-                DOM_STORAGE + " INTEGER DEFAULT 0, " +
-                USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
-                ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
-                CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)"
-            );
+                                     ID + " INTEGER PRIMARY KEY, " +
+                                     DOMAIN_NAME + " TEXT, " +
+                                     JAVASCRIPT + " INTEGER DEFAULT 0, " +
+                                     LOCAL_STORAGE + " INTEGER DEFAULT 0, " +
+                                     DOM_STORAGE + " INTEGER DEFAULT 0, " +
+                                     USER_AGENT + " TEXT DEFAULT '" + UserAgentHelper::SYSTEM_DEFAULT_DATABASE + "', " +
+                                     ZOOM_FACTOR + " INTEGER DEFAULT 0, " +
+                                     CUSTOM_ZOOM_FACTOR + " REAL DEFAULT 1.0)");
 
             // Execute the query.
             if (!createTableQuery.exec())
@@ -173,7 +283,7 @@ QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname)
     allDomainNamesQuery.setForwardOnly(true);
 
     // Prepare the query.
-    allDomainNamesQuery.prepare("SELECT " + _ID + "," + DOMAIN_NAME + " FROM " + DOMAINS_TABLE);
+    allDomainNamesQuery.prepare("SELECT " + ID + "," + DOMAIN_NAME + " FROM " + DOMAINS_TABLE);
 
     // Execute the query.
     allDomainNamesQuery.exec();
@@ -185,7 +295,7 @@ QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname)
     while (allDomainNamesQuery.next())
     {
         // Add the domain name and database ID to the map.
-        domainSettingsMap.insert(allDomainNamesQuery.record().field(DOMAIN_NAME).value().toString(), allDomainNamesQuery.record().field(_ID).value().toInt());
+        domainSettingsMap.insert(allDomainNamesQuery.value(DOMAIN_NAME).toString(), allDomainNamesQuery.value(ID).toInt());
     }
 
     // Initialize the database ID tracker.
@@ -218,7 +328,7 @@ QSqlQuery DomainsDatabase::getDomainQuery(const QString &hostname)
     QSqlQuery domainLookupQuery(domainsDatabase);
 
     // Prepare the domain lookup query.
-    domainLookupQuery.prepare("SELECT * FROM " + DOMAINS_TABLE + " WHERE " + _ID + " = " + QString::number(databaseId));
+    domainLookupQuery.prepare("SELECT * FROM " + DOMAINS_TABLE + " WHERE " + ID + " = " + QString::number(databaseId));
 
     // Execute the query.
     domainLookupQuery.exec();
index a75b831761f8b650dceb5020552b5629c896cf69..cb7e09d4fac139dec11fc6b39fc40a796cd79dba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -35,17 +35,17 @@ public:
 
     // The public int constants.
     static const int SYSTEM_DEFAULT = 0;
-    static const int DISABLED = 1;
-    static const int ENABLED = 2;
+    static const int ENABLED = 1;
+    static const int DISABLED = 2;
     static const int CUSTOM = 1;
 
     // The public constants.
-    static const QString _ID;
     static const QString CONNECTION_NAME;
     static const QString CUSTOM_ZOOM_FACTOR;
     static const QString DOM_STORAGE;
     static const QString DOMAIN_NAME;
     static const QString DOMAINS_TABLE;
+    static const QString ID;
     static const QString JAVASCRIPT;
     static const QString LOCAL_STORAGE;
     static const QString USER_AGENT;
index ea5558c1fd267491dd8bfd3617bff89642611b86..6964d37532209b39871968b5cdaaba863d788598 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -219,13 +219,13 @@ void DomainSettingsDialog::apply() const
     QModelIndex currentIndex = domainsListViewPointer->currentIndex();
 
     // Get the ID of the current index row.
-    QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)).data();
+    QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)).data();
 
     // Submit all pending changes.
     domainsTableModelPointer->submitAll();
 
     // Find the new index for the selected id.  The `1` keeps searching after the first match.
-    QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)), Qt::DisplayRole, currentId,
+    QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)), Qt::DisplayRole, currentId,
                                                                    1, Qt::MatchWrap);
 
     // Select the new index.
@@ -389,10 +389,10 @@ void DomainSettingsDialog::populateDomStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
+            // Set the enabled text in bold.
+            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
 
             // Set the palette.
             domStorageWidgetPointer->setPalette(highlightedPalette);
@@ -400,10 +400,10 @@ void DomainSettingsDialog::populateDomStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
+            // Set the disabled text in bold.
+            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
 
             // Set the palette.
             domStorageWidgetPointer->setPalette(highlightedPalette);
@@ -432,10 +432,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
+            // Set the enabled text in bold.
+            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
 
             // Set the palette.
             javaScriptWidgetPointer->setPalette(highlightedPalette);
@@ -443,10 +443,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
+            // Set the disabled text in bold.
+            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
 
             // Set the palette.
             javaScriptWidgetPointer->setPalette(highlightedPalette);
@@ -475,10 +475,10 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>"));
+            // Set the enabled text in bold.
+            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
 
             // Set the palette.
             localStorageWidgetPointer->setPalette(highlightedPalette);
@@ -486,10 +486,10 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
+            // Set the disabled text in bold.
+            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>"));
 
             // Set the palette.
             localStorageWidgetPointer->setPalette(highlightedPalette);
index d998c20ab840cae96de877f57dde2371caba5912..abc21e98e4573dc10a5ed0ab1add3e34f2e20c6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -150,7 +150,7 @@ void DurableCookiesDialog::beforeUpdate(int row, QSqlRecord &sqlRecord) const
     if (sqlRecord.isGenerated(CookiesDatabase::DOMAIN) || sqlRecord.isGenerated(CookiesDatabase::NAME) || sqlRecord.isGenerated(CookiesDatabase::PATH))
     {
         // Get the ID of the cookie
-        int id = sqlRecord.value(CookiesDatabase::_ID).toInt();
+        int id = sqlRecord.value(CookiesDatabase::ID).toInt();
 
         // Get the cookie.
         QNetworkCookie *cookiePointer = CookiesDatabase::getCookieById(id);
index d498a106e786c8202ea78d26a25b80a20b92bf9f..c432b7c240f95ed725aeef65543ce4e25ac34e32 100644 (file)
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>JavaScript disabled</string>
+                                                            <string>JavaScript enabled</string>
                                                         </property>
                                                     </item>
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>JavaScript enabled</string>
+                                                            <string>JavaScript disabled</string>
                                                         </property>
                                                     </item>
                                                 </widget>
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>Local storage disabled</string>
+                                                            <string>Local storage enabled</string>
                                                         </property>
                                                     </item>
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>Local storage enabled</string>
+                                                            <string>Local storage disabled</string>
                                                         </property>
                                                     </item>
                                                 </widget>
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>DOM storage disabled</string>
+                                                            <string>DOM storage enabled</string>
                                                         </property>
                                                     </item>
 
                                                     <item>
                                                         <property name="text">
-                                                            <string>DOM storage enabled</string>
+                                                            <string>DOM storage disabled</string>
                                                         </property>
                                                     </item>
                                                 </widget>
index 96a0da5d67735743225293e0ca6a8db1990e5922..37c26bfef12f8b918a1d251baf691b54d66da638 100644 (file)
@@ -86,14 +86,11 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo
     // Check if the hostname has domain settings.
     if (domainQuery.isValid())  // The hostname has domain settings.
     {
-        // Get the domain record.
-        QSqlRecord domainRecord = domainQuery.record();
-
         // Store the domain settings name.
-        domainSettingsName = domainRecord.field(DomainsDatabase::DOMAIN_NAME).value().toString();
+        domainSettingsName = domainQuery.value(DomainsDatabase::DOMAIN_NAME).toString();
 
         // Set the JavaScript status.
-        switch (domainRecord.field(DomainsDatabase::JAVASCRIPT).value().toInt())
+        switch (domainQuery.value(DomainsDatabase::JAVASCRIPT).toInt())
         {
             // Set the default JavaScript status.
             case (DomainsDatabase::SYSTEM_DEFAULT):
@@ -103,25 +100,25 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo
                 break;
             }
 
-            // Disable JavaScript.
-            case (DomainsDatabase::DISABLED):
+            // Enable JavaScript.
+            case (DomainsDatabase::ENABLED):
             {
-                webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
+                webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
 
                 break;
             }
 
-            // Enable JavaScript.
-            case (DomainsDatabase::ENABLED):
+            // Disable JavaScript.
+            case (DomainsDatabase::DISABLED):
             {
-                webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
+                webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
 
                 break;
             }
         }
 
         // Set the local storage status.
-        switch (domainRecord.field(DomainsDatabase::LOCAL_STORAGE).value().toInt())
+        switch (domainQuery.value(DomainsDatabase::LOCAL_STORAGE).toInt())
         {
             // Set the default local storage status.
             case (DomainsDatabase::SYSTEM_DEFAULT):
@@ -131,25 +128,25 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo
                 break;
             }
 
-            // Disable local storage.
-            case (DomainsDatabase::DISABLED):
+            // Enable local storage.
+            case (DomainsDatabase::ENABLED):
             {
-                localStorageEnabled = false;
+                localStorageEnabled = true;
 
                 break;
             }
 
-            // Enable local storage.
-            case (DomainsDatabase::ENABLED):
+            // Disable local storage.
+            case (DomainsDatabase::DISABLED):
             {
-                localStorageEnabled = true;
+                localStorageEnabled = false;
 
                 break;
             }
         }
 
         // Set the DOM storage status.
-        switch (domainRecord.field(DomainsDatabase::DOM_STORAGE).value().toInt())
+        switch (domainQuery.value(DomainsDatabase::DOM_STORAGE).toInt())
         {
             // Set the default DOM storage status.  QWebEngineSettings confusingly calls this local storage.
             case (DomainsDatabase::SYSTEM_DEFAULT):
@@ -159,31 +156,31 @@ void PrivacyWebEngineView::applyDomainSettings(const QString &hostname, const bo
                 break;
             }
 
-            // Disable DOM storage.  QWebEngineSettings confusingly calls this local storage.
-            case (DomainsDatabase::DISABLED):
+            // Enable DOM storage.  QWebEngineSettings confusingly calls this local storage.
+            case (DomainsDatabase::ENABLED):
             {
-                webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
+                webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
 
                 break;
             }
 
-            // Enable DOM storage.  QWebEngineSettings confusingly calls this local storage.
-            case (DomainsDatabase::ENABLED):
+            // Disable DOM storage.  QWebEngineSettings confusingly calls this local storage.
+            case (DomainsDatabase::DISABLED):
             {
-                webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
+                webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
 
                 break;
             }
         }
 
         // Set the user agent.
-        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabase::USER_AGENT).value().toString()));
+        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainQuery.value(DomainsDatabase::USER_AGENT).toString()));
 
         // Check if a custom zoom factor is set.
-        if (domainRecord.field(DomainsDatabase::ZOOM_FACTOR).value().toInt())
+        if (domainQuery.value(DomainsDatabase::ZOOM_FACTOR).toInt())
         {
             // Store the current zoom factor.
-            setZoomFactor(domainRecord.field(DomainsDatabase::CUSTOM_ZOOM_FACTOR).value().toDouble());
+            setZoomFactor(domainQuery.value(DomainsDatabase::CUSTOM_ZOOM_FACTOR).toDouble());
         }
         else
         {