TT-RSS accounts now store its additions/edits to DB/model.
This commit is contained in:
parent
d5c7e3b8f4
commit
441e0e8632
3 changed files with 17 additions and 10 deletions
|
@ -136,7 +136,7 @@ void FormEditAccount::onClickedOk() {
|
||||||
if (m_editableRoot == NULL) {
|
if (m_editableRoot == NULL) {
|
||||||
// We want to confirm newly created account.
|
// We want to confirm newly created account.
|
||||||
// So save new account into DB, setup its properties.
|
// So save new account into DB, setup its properties.
|
||||||
m_editableRoot = new TtRssServiceRoot(false);
|
m_editableRoot = new TtRssServiceRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editableRoot->network()->setUrl(m_ui->m_txtUrl->lineEdit()->text());
|
m_editableRoot->network()->setUrl(m_ui->m_txtUrl->lineEdit()->text());
|
||||||
|
|
|
@ -26,14 +26,10 @@
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
|
||||||
|
|
||||||
TtRssServiceRoot::TtRssServiceRoot(bool load_from_db, RootItem *parent)
|
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent)
|
||||||
: ServiceRoot(parent), m_network(new TtRssNetworkFactory) {
|
: ServiceRoot(parent), m_network(new TtRssNetworkFactory) {
|
||||||
setIcon(TtRssServiceEntryPoint().icon());
|
setIcon(TtRssServiceEntryPoint().icon());
|
||||||
setCreationDate(QDateTime::currentDateTime());
|
setCreationDate(QDateTime::currentDateTime());
|
||||||
|
|
||||||
if (load_from_db) {
|
|
||||||
loadFromDatabase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TtRssServiceRoot::~TtRssServiceRoot() {
|
TtRssServiceRoot::~TtRssServiceRoot() {
|
||||||
|
@ -145,10 +141,21 @@ TtRssNetworkFactory *TtRssServiceRoot::network() const {
|
||||||
void TtRssServiceRoot::saveToDatabase() {
|
void TtRssServiceRoot::saveToDatabase() {
|
||||||
if (accountId() != NO_PARENT_CATEGORY) {
|
if (accountId() != NO_PARENT_CATEGORY) {
|
||||||
// We are overwritting previously saved data.
|
// We are overwritting previously saved data.
|
||||||
// TODO: todo
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
|
QSqlQuery query(database);
|
||||||
|
|
||||||
updateTitle();
|
query.prepare("UPDATE TtRssAccounts "
|
||||||
itemChanged(QList<RootItem*>() << this);
|
"SET username = :username, password = :password, url = :url "
|
||||||
|
"WHERE id = :id;");
|
||||||
|
query.bindValue(":username", m_network->username());
|
||||||
|
query.bindValue(":password", m_network->password());
|
||||||
|
query.bindValue(":url", m_network->url());
|
||||||
|
query.bindValue(":id", accountId());
|
||||||
|
|
||||||
|
if (query.exec()) {
|
||||||
|
updateTitle();
|
||||||
|
itemChanged(QList<RootItem*>() << this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We are probably saving newly added account.
|
// We are probably saving newly added account.
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TtRssServiceRoot : public ServiceRoot {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TtRssServiceRoot(bool load_from_db, RootItem *parent = NULL);
|
explicit TtRssServiceRoot(RootItem *parent = NULL);
|
||||||
virtual ~TtRssServiceRoot();
|
virtual ~TtRssServiceRoot();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
Loading…
Add table
Reference in a new issue