Go to the documentation of this file.
26 LOG(VB_GENERAL, LOG_NOTICE,
27 "Inserting MythBrowser initial database information.");
31 "DROP TABLE IF EXISTS websites;",
32 "CREATE TABLE websites ("
33 "id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, "
34 "category VARCHAR(100) NOT NULL, "
35 "name VARCHAR(100) NOT NULL, "
36 "url VARCHAR(255) NOT NULL);"
39 updates,
"1000", dbver))
47 "UPDATE settings SET data = 'Internal' WHERE data LIKE '%mythbrowser' AND value = 'WebBrowserCommand';"
50 updates,
"1001", dbver))
58 "DELETE FROM keybindings "
59 " WHERE action = 'DELETETAB' AND context = 'Browser';"
62 updates,
"1002", dbver))
70 "ALTER TABLE `websites` ADD `homepage` BOOL NOT NULL;"
73 updates,
"1003", dbver))
80 bool FindInDB(
const QString &category,
const QString& name)
83 query.
prepare(
"SELECT name FROM websites "
84 "WHERE category = :CATEGORY AND name = :NAME ;");
93 return (query.
size() > 0);
99 query.
prepare(
"UPDATE `websites` SET `homepage` = '0' WHERE `homepage` = '1';");
107 query.
prepare(
"UPDATE `websites` SET `homepage` = '1' "
108 "WHERE `category` = :CATEGORY "
109 "AND `name` = :NAME;");
127 const bool isHomepage)
129 if (category.isEmpty() || name.isEmpty() || url.isEmpty())
135 QString _url = url.trimmed();
136 if (!_url.startsWith(
"http://") && !_url.startsWith(
"https://") &&
137 !_url.startsWith(
"file:/"))
138 _url.prepend(
"http://");
140 _url.replace(
"&",
"&");
143 query.
prepare(
"INSERT INTO websites (category, name, url, homepage) "
144 "VALUES(:CATEGORY, :NAME, :URL, :HOMEPAGE);");
148 query.
bindValue(
":HOMEPAGE", isHomepage);
169 query.
prepare(
"DELETE FROM websites "
170 "WHERE category = :CATEGORY AND name = :NAME;");
185 query.
prepare(
"SELECT DISTINCT category FROM websites "
186 "ORDER BY category;");
196 list << query.
value(0).toString();
204 while (!siteList.isEmpty())
205 delete siteList.takeFirst();
209 if (!query.
exec(
"SELECT category, name, url, homepage FROM websites "
210 "ORDER BY category, name"))
212 LOG(VB_GENERAL, LOG_ERR,
"BookmarkManager: Error in loading from DB");
220 site->m_category = query.
value(0).toString();
221 site->m_name = query.
value(1).toString();
222 site->m_sortName = sh->
doTitle(site->m_name);
223 site->m_url = query.
value(2).toString();
224 site->m_isHomepage = query.
value(3).toBool();
225 site->m_selected =
false;
226 siteList.append(site);
231 return siteList.size();
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool UpgradeBrowserDatabaseSchema(void)
bool InsertInDB(Bookmark *site)
std::shared_ptr< MythSortHelper > getMythSortHelper(void)
Get a pointer to the MythSortHelper singleton.
bool UpdateHomepageInDB(Bookmark *site)
QVariant value(int i) const
bool RemoveFromDB(Bookmark *site)
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QString doTitle(const QString &title) const
Create the sortable form of an title string.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
const QString currentDatabaseVersion
bool ResetHomepageFromDB()
bool FindInDB(const QString &category, const QString &name)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
bool performActualUpdate(const QString &component, const QString &versionkey, const DBUpdates &updates, const QString &version, QString &dbver)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
int numRowsAffected() const
int GetCategoryList(QStringList &list)
std::vector< std::string > DBUpdates
int GetSiteList(QList< Bookmark * > &siteList)
static bool sortByName(Bookmark *a, Bookmark *b)
QString GetSetting(const QString &key, const QString &defaultval="")
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
const QString MythBrowserVersionName