Added ability to add feeds/categories to standard service.

This commit is contained in:
Martin Rotter 2015-11-10 13:47:24 +01:00
parent c3ea32cf3d
commit 5515c9c7c1
5 changed files with 36 additions and 8 deletions

View File

@ -27,6 +27,7 @@
#include "gui/tabwidget.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
#include "services/standard/standardserviceroot.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
@ -214,9 +215,7 @@ void WebBrowser::onIconChanged() {
void WebBrowser::addFeedFromWebsite(const QString &feed_link) {
qApp->clipboard()->setText(feed_link);
// TODO: dodělat
//qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->addNewFeed();
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot()->addNewFeed();
}
void WebBrowser::onTitleChanged(const QString &new_title) {

View File

@ -118,7 +118,6 @@ void FormStandardCategoryDetails::apply() {
new_category->setCreationDate(QDateTime::currentDateTime());
new_category->setDescription(m_ui->m_txtDescription->lineEdit()->text());
new_category->setIcon(m_ui->m_btnIcon->icon());
new_category->setParent(parent);
if (m_editableCategory == NULL) {
// Add the category.
@ -135,6 +134,8 @@ void FormStandardCategoryDetails::apply() {
}
}
else {
new_category->setParent(parent);
bool edited = m_editableCategory->editItself(new_category);
if (edited) {

View File

@ -237,7 +237,6 @@ void FormStandardFeedDetails::apply() {
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
new_feed->setAutoUpdateType(static_cast<StandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
new_feed->setParent(parent);
if (m_editableFeed == NULL) {
// Add the feed.
@ -253,6 +252,8 @@ void FormStandardFeedDetails::apply() {
}
}
else {
new_feed->setParent(parent);
// Edit the feed.
bool edited = m_editableFeed->editItself(new_feed);

View File

@ -30,12 +30,15 @@
#include "services/standard/standardfeed.h"
#include "services/standard/standardcategory.h"
#include "services/standard/standardfeedsimportexportmodel.h"
#include "services/standard/gui/formstandardcategorydetails.h"
#include "services/standard/gui/formstandardfeeddetails.h"
#include <QSqlQuery>
#include <QSqlError>
#include <QStack>
#include <QCoreApplication>
#include <QAction>
#include <QPointer>
StandardServiceRoot::StandardServiceRoot(bool load_from_db, FeedsModel *feeds_model, RootItem *parent)
@ -329,17 +332,37 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model,
return !some_feed_category_error;
}
void StandardServiceRoot::addNewCategory() {
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(this, qApp->mainForm());
form_pointer.data()->exec(NULL, NULL);
delete form_pointer.data();
}
void StandardServiceRoot::addNewFeed() {
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(this, qApp->mainForm());
form_pointer.data()->exec(NULL, NULL);
delete form_pointer.data();
}
QList<QAction*> StandardServiceRoot::addItemMenu() {
if (m_addItemMenu.isEmpty()) {
// TODO: Add items.
m_addItemMenu.append(new QAction("abc", this));
QAction *action_new_category = new QAction(qApp->icons()->fromTheme("folder-category"), tr("Add new category"), this);
connect(action_new_category, SIGNAL(triggered()), this, SLOT(addNewCategory()));
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_category);
m_addItemMenu.append(action_new_feed);
}
return m_addItemMenu;
}
QList<QAction*> StandardServiceRoot::serviceMenu() {
return QList<QAction*>();
return m_addItemMenu;
}
void StandardServiceRoot::assembleCategories(CategoryAssignment categories) {

View File

@ -74,6 +74,10 @@ class StandardServiceRoot : public ServiceRoot {
// NOTE: This is used for import/export of the model.
bool mergeImportExportModel(FeedsImportExportModel *model, QString &output_message);
public slots:
void addNewCategory();
void addNewFeed();
private:
void loadFromDatabase();