diff --git a/src/network-web/webbrowser.cpp b/src/network-web/webbrowser.cpp index c1da07cae..7a41612f2 100755 --- a/src/network-web/webbrowser.cpp +++ b/src/network-web/webbrowser.cpp @@ -27,6 +27,7 @@ #include "gui/tabwidget.h" #include "gui/feedmessageviewer.h" #include "gui/feedsview.h" +#include "services/standard/standardserviceroot.h" #include #include @@ -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) { diff --git a/src/services/standard/gui/formstandardcategorydetails.cpp b/src/services/standard/gui/formstandardcategorydetails.cpp index 5c8d94b3d..5c78d9958 100755 --- a/src/services/standard/gui/formstandardcategorydetails.cpp +++ b/src/services/standard/gui/formstandardcategorydetails.cpp @@ -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) { diff --git a/src/services/standard/gui/formstandardfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp index e6a64cb5a..c6ccde65b 100755 --- a/src/services/standard/gui/formstandardfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -237,7 +237,6 @@ void FormStandardFeedDetails::apply() { new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text()); new_feed->setAutoUpdateType(static_cast(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); diff --git a/src/services/standard/standardserviceroot.cpp b/src/services/standard/standardserviceroot.cpp index cf71c528b..f475e3aab 100755 --- a/src/services/standard/standardserviceroot.cpp +++ b/src/services/standard/standardserviceroot.cpp @@ -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 #include #include #include #include +#include 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 form_pointer = new FormStandardCategoryDetails(this, qApp->mainForm()); + + form_pointer.data()->exec(NULL, NULL); + delete form_pointer.data(); +} + +void StandardServiceRoot::addNewFeed() { + QPointer form_pointer = new FormStandardFeedDetails(this, qApp->mainForm()); + + form_pointer.data()->exec(NULL, NULL); + delete form_pointer.data(); +} + QList 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 StandardServiceRoot::serviceMenu() { - return QList(); + return m_addItemMenu; } void StandardServiceRoot::assembleCategories(CategoryAssignment categories) { diff --git a/src/services/standard/standardserviceroot.h b/src/services/standard/standardserviceroot.h index 7af1838ab..77cfb15fb 100755 --- a/src/services/standard/standardserviceroot.h +++ b/src/services/standard/standardserviceroot.h @@ -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();