diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index ea257a5c0..a4ce90e63 100644 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -3,13 +3,14 @@ Fixed: Added: Changed: diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index c9ea16682..02bba2577 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -110,6 +110,17 @@ QList FeedsView::allFeeds() const { return m_sourceModel->allFeeds(); } +FeedsModelRootItem *FeedsView::selectedItem() const { + QModelIndexList selected_rows = selectionModel()->selectedRows(); + + if (selected_rows.isEmpty()) { + return NULL; + } + + FeedsModelRootItem *selected_item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(selected_rows.at(0))); + return selected_item == m_sourceModel->rootItem() ? NULL : selected_item; +} + FeedsModelCategory *FeedsView::selectedCategory() const { QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex()); return m_sourceModel->categoryForIndex(current_mapped); @@ -246,7 +257,7 @@ void FeedsView::addNewCategory() { QPointer form_pointer = new FormCategoryDetails(m_sourceModel, this); - form_pointer.data()->exec(NULL, NULL); + form_pointer.data()->exec(NULL, selectedItem()); delete form_pointer.data(); @@ -275,7 +286,7 @@ void FeedsView::addNewFeed() { QPointer form_pointer = new FormFeedDetails(m_sourceModel, this); - form_pointer.data()->exec(NULL); + form_pointer.data()->exec(NULL, selectedItem()); delete form_pointer.data(); @@ -286,7 +297,7 @@ void FeedsView::addNewFeed() { void FeedsView::editFeed(FeedsModelFeed *feed) { QPointer form_pointer = new FormFeedDetails(m_sourceModel, this); - form_pointer.data()->exec(feed); + form_pointer.data()->exec(feed, NULL); delete form_pointer.data(); } diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 29e44d02a..7a315e34a 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -61,6 +61,7 @@ class FeedsView : public QTreeView { // Returns pointers to selected feed/category if they are really // selected. + FeedsModelRootItem *selectedItem() const; FeedsModelCategory *selectedCategory() const; FeedsModelFeed *selectedFeed() const; FeedsModelRecycleBin *selectedRecycleBin() const; @@ -113,9 +114,7 @@ class FeedsView : public QTreeView { // Is called when counts of messages are changed externally, // typically from message view. - void receiveMessageCountsChange(MessagesModel::MessageMode mode, - bool total_msg_count_changed, - bool any_msg_restored); + void receiveMessageCountsChange(MessagesModel::MessageMode mode, bool total_msg_count_changed, bool any_msg_restored); // Reloads counts for selected feeds. void updateCountsOfSelectedFeeds(bool update_total_too); diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp index 7e78e8577..7aa9f7e05 100755 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -92,6 +92,20 @@ int FormCategoryDetails::exec(FeedsModelCategory *input_category, FeedsModelRoot // Make sure that "default" icon is used as the default option for new // categories. m_actionUseDefaultIcon->trigger(); + + // Load parent from suggested item. + if (parent_to_select != NULL) { + if (parent_to_select->kind() == FeedsModelRootItem::Category) { + m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); + } + else if (parent_to_select->kind() == FeedsModelRootItem::Feed) { + int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); + + if (target_item >= 0) { + m_ui->m_cmbParentCategory->setCurrentIndex(target_item); + } + } + } } else { // User is editing existing category. diff --git a/src/gui/formfeeddetails.cpp b/src/gui/formfeeddetails.cpp index 7f54bbaab..ea0a7af12 100755 --- a/src/gui/formfeeddetails.cpp +++ b/src/gui/formfeeddetails.cpp @@ -56,7 +56,7 @@ FormFeedDetails::~FormFeedDetails() { delete m_ui; } -int FormFeedDetails::exec(FeedsModelFeed *input_feed) { +int FormFeedDetails::exec(FeedsModelFeed *input_feed, FeedsModelRootItem *parent_to_select) { // Load categories. loadCategories(m_feedsModel->allCategories().values(), m_feedsModel->rootItem()); @@ -73,6 +73,19 @@ int FormFeedDetails::exec(FeedsModelFeed *input_feed) { if (default_encoding_index >= 0) { m_ui->m_cmbEncoding->setCurrentIndex(default_encoding_index); } + + if (parent_to_select != NULL) { + if (parent_to_select->kind() == FeedsModelRootItem::Category) { + m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select))); + } + else if (parent_to_select->kind() == FeedsModelRootItem::Feed) { + int target_item = m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) parent_to_select->parent())); + + if (target_item >= 0) { + m_ui->m_cmbParentCategory->setCurrentIndex(target_item); + } + } + } } else { // User is editing existing category. diff --git a/src/gui/formfeeddetails.h b/src/gui/formfeeddetails.h index 0574c59bb..7f62fd649 100644 --- a/src/gui/formfeeddetails.h +++ b/src/gui/formfeeddetails.h @@ -42,7 +42,7 @@ class FormFeedDetails : public QDialog { public slots: // Executes add/edit standard feed dialog. - int exec(FeedsModelFeed *input_feed); + int exec(FeedsModelFeed *input_feed, FeedsModelRootItem *parent_to_select); protected slots: // Applies changes. diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index b456edbdb..e11def2f5 100755 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -95,7 +95,6 @@ bool DatabaseFactory::initiateRestoration(const QString &database_backup_file_pa } void DatabaseFactory::finishRestoration() { - // TODO: Finish restoration. if (m_activeDatabaseDriver != SQLITE && m_activeDatabaseDriver != SQLITE_MEMORY) { return; }