Some work on adding feeds to TT-RSS.
This commit is contained in:
parent
c0ac2d0ddb
commit
8f5dec672b
@ -32,6 +32,7 @@ FormEditFeed::FormEditFeed(TtRssServiceRoot *root, QWidget *parent)
|
|||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
|
connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onUrlChanged(QString)));
|
||||||
connect(m_ui->m_gbAuthentication, SIGNAL(toggled(bool)), this, SLOT(onAuthenticationSwitched()));
|
connect(m_ui->m_gbAuthentication, SIGNAL(toggled(bool)), this, SLOT(onAuthenticationSwitched()));
|
||||||
connect(m_ui->m_cmbAutoUpdateType, SIGNAL(currentIndexChanged(int)), this, SLOT(onAutoUpdateTypeChanged(int)));
|
connect(m_ui->m_cmbAutoUpdateType, SIGNAL(currentIndexChanged(int)), this, SLOT(onAutoUpdateTypeChanged(int)));
|
||||||
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(performAction()));
|
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(performAction()));
|
||||||
@ -44,6 +45,8 @@ FormEditFeed::~FormEditFeed() {
|
|||||||
int FormEditFeed::execForEdit(TtRssFeed *input_feed) {
|
int FormEditFeed::execForEdit(TtRssFeed *input_feed) {
|
||||||
loadCategories(m_root->getSubTreeCategories(), m_root);
|
loadCategories(m_root->getSubTreeCategories(), m_root);
|
||||||
loadFeed(input_feed);
|
loadFeed(input_feed);
|
||||||
|
m_ui->m_txtUrl->lineEdit()->setFocus();
|
||||||
|
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +55,10 @@ int FormEditFeed::execForAdd() {
|
|||||||
m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text());
|
m_ui->m_txtUrl->lineEdit()->setText(qApp->clipboard()->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: todo
|
loadCategories(m_root->getSubTreeCategories(), m_root);
|
||||||
|
loadFeed(NULL);
|
||||||
|
m_ui->m_txtUrl->lineEdit()->setFocus();
|
||||||
|
|
||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +88,7 @@ void FormEditFeed::performAction() {
|
|||||||
saveFeed();
|
saveFeed();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: Add new feed.
|
addNewFeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
@ -145,11 +151,14 @@ void FormEditFeed::initialize() {
|
|||||||
m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("Full feed url including scheme"));
|
m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("Full feed url including scheme"));
|
||||||
m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username"));
|
m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username"));
|
||||||
m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password"));
|
m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password"));
|
||||||
|
|
||||||
|
onAuthenticationSwitched();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditFeed::loadFeed(TtRssFeed *input_feed) {
|
void FormEditFeed::loadFeed(TtRssFeed *input_feed) {
|
||||||
m_loadedFeed = input_feed;
|
m_loadedFeed = input_feed;
|
||||||
|
|
||||||
|
if (input_feed != NULL) {
|
||||||
setWindowTitle(tr("Edit existing feed"));
|
setWindowTitle(tr("Edit existing feed"));
|
||||||
|
|
||||||
// Tiny Tiny RSS does not support editing of these features.
|
// Tiny Tiny RSS does not support editing of these features.
|
||||||
@ -163,6 +172,18 @@ void FormEditFeed::loadFeed(TtRssFeed *input_feed) {
|
|||||||
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) input_feed->parent())));
|
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) input_feed->parent())));
|
||||||
m_ui->m_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue((int) input_feed->autoUpdateType())));
|
m_ui->m_cmbAutoUpdateType->setCurrentIndex(m_ui->m_cmbAutoUpdateType->findData(QVariant::fromValue((int) input_feed->autoUpdateType())));
|
||||||
m_ui->m_spinAutoUpdateInterval->setValue(input_feed->autoUpdateInitialInterval());
|
m_ui->m_spinAutoUpdateInterval->setValue(input_feed->autoUpdateInitialInterval());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setWindowTitle(tr("Add new feed"));
|
||||||
|
|
||||||
|
// Tiny Tiny RSS does not support editing of these features.
|
||||||
|
// User can edit only individual auto-update statuses.
|
||||||
|
m_ui->m_gbAuthentication->setEnabled(true);
|
||||||
|
m_ui->m_txtUrl->setEnabled(true);
|
||||||
|
m_ui->m_lblUrl->setEnabled(true);
|
||||||
|
m_ui->m_lblParentCategory->setEnabled(true);
|
||||||
|
m_ui->m_cmbParentCategory->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormEditFeed::saveFeed() {
|
void FormEditFeed::saveFeed() {
|
||||||
@ -176,6 +197,12 @@ void FormEditFeed::saveFeed() {
|
|||||||
delete new_feed_data;
|
delete new_feed_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditFeed::addNewFeed() {
|
||||||
|
// Store feed online and if successfull, then store into DB/model.
|
||||||
|
|
||||||
|
// TODO: todo
|
||||||
|
}
|
||||||
|
|
||||||
void FormEditFeed::loadCategories(const QList<Category*> categories, RootItem *root_item) {
|
void FormEditFeed::loadCategories(const QList<Category*> categories, RootItem *root_item) {
|
||||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||||
root_item->title(),
|
root_item->title(),
|
||||||
|
@ -54,6 +54,7 @@ class FormEditFeed : public QDialog {
|
|||||||
void initialize();
|
void initialize();
|
||||||
void loadFeed(TtRssFeed *input_feed);
|
void loadFeed(TtRssFeed *input_feed);
|
||||||
void saveFeed();
|
void saveFeed();
|
||||||
|
void addNewFeed();
|
||||||
void loadCategories(const QList<Category*> categories, RootItem *root_item);
|
void loadCategories(const QList<Category*> categories, RootItem *root_item);
|
||||||
|
|
||||||
Ui::FormEditFeed *m_ui;
|
Ui::FormEditFeed *m_ui;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "services/tt-rss/definitions.h"
|
#include "services/tt-rss/definitions.h"
|
||||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||||
#include "services/tt-rss/gui/formeditaccount.h"
|
#include "services/tt-rss/gui/formeditaccount.h"
|
||||||
|
#include "services/tt-rss/gui/formeditfeed.h"
|
||||||
|
|
||||||
#include <QSqlTableModel>
|
#include <QSqlTableModel>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
@ -38,7 +39,9 @@
|
|||||||
|
|
||||||
|
|
||||||
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent)
|
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent)
|
||||||
: ServiceRoot(parent), m_recycleBin(new TtRssRecycleBin(this)), m_actionSyncIn(NULL), m_serviceMenu(QList<QAction*>()), m_network(new TtRssNetworkFactory) {
|
: ServiceRoot(parent), m_recycleBin(new TtRssRecycleBin(this)),
|
||||||
|
m_actionSyncIn(NULL), m_serviceMenu(QList<QAction*>()), m_addItemMenu(QList<QAction*>()),
|
||||||
|
m_network(new TtRssNetworkFactory) {
|
||||||
setIcon(TtRssServiceEntryPoint().icon());
|
setIcon(TtRssServiceEntryPoint().icon());
|
||||||
setCreationDate(QDateTime::currentDateTime());
|
setCreationDate(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
@ -136,7 +139,14 @@ QVariant TtRssServiceRoot::data(int column, int role) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> TtRssServiceRoot::addItemMenu() {
|
QList<QAction*> TtRssServiceRoot::addItemMenu() {
|
||||||
return QList<QAction*>();
|
if (m_addItemMenu.isEmpty()) {
|
||||||
|
QAction *action_new_feed = new QAction(qApp->icons()->fromTheme("folder-feed"), tr("Add new feed"), this);
|
||||||
|
connect(action_new_feed, SIGNAL(triggered()), this, SLOT(addNewFeed()));
|
||||||
|
|
||||||
|
m_addItemMenu.append(action_new_feed);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_addItemMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecycleBin *TtRssServiceRoot::recycleBin() {
|
RecycleBin *TtRssServiceRoot::recycleBin() {
|
||||||
@ -585,6 +595,13 @@ void TtRssServiceRoot::syncIn() {
|
|||||||
itemChanged(QList<RootItem*>() << this);
|
itemChanged(QList<RootItem*>() << this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TtRssServiceRoot::addNewFeed() {
|
||||||
|
QPointer<FormEditFeed> form_pointer = new FormEditFeed(this, qApp->mainForm());
|
||||||
|
|
||||||
|
form_pointer.data()->execForAdd();
|
||||||
|
delete form_pointer.data();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList TtRssServiceRoot::customIDsOfMessages(const QList<QPair<Message,RootItem::Importance> > &changes) {
|
QStringList TtRssServiceRoot::customIDsOfMessages(const QList<QPair<Message,RootItem::Importance> > &changes) {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
|
@ -85,6 +85,9 @@ class TtRssServiceRoot : public ServiceRoot {
|
|||||||
public slots:
|
public slots:
|
||||||
void syncIn();
|
void syncIn();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addNewFeed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList customIDsOfMessages(const QList<QPair<Message,Importance> > &changes);
|
QStringList customIDsOfMessages(const QList<QPair<Message,Importance> > &changes);
|
||||||
QStringList customIDsOfMessages(const QList<Message> &messages);
|
QStringList customIDsOfMessages(const QList<Message> &messages);
|
||||||
@ -102,6 +105,7 @@ class TtRssServiceRoot : public ServiceRoot {
|
|||||||
|
|
||||||
QAction *m_actionSyncIn;
|
QAction *m_actionSyncIn;
|
||||||
QList<QAction*> m_serviceMenu;
|
QList<QAction*> m_serviceMenu;
|
||||||
|
QList<QAction*> m_addItemMenu;
|
||||||
|
|
||||||
TtRssNetworkFactory *m_network;
|
TtRssNetworkFactory *m_network;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user