Fixed some network manager bug, refactoring of feed model.
This commit is contained in:
parent
f131be94b9
commit
39666e7bae
8 changed files with 27 additions and 28 deletions
|
@ -16,12 +16,12 @@
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
<ul>
|
<ul>
|
||||||
<li></li>
|
<li style="color: red;">Brand new "service plugin system" - HIGHLY EXPERIMENTAL and REWRITTEN from scratch. Some UI features (for example drag-drop) are temporarily unavailable. Expect bugs and misunderstandings now!</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
<ul>
|
<ul>
|
||||||
<li></li>
|
<li>When removing download item from download manager via DELETE key, then "Cleanup" button is correctly disabled.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
|
@ -231,30 +231,22 @@ bool FeedsModel::removeItem(const QModelIndex &index) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsModel::assignNodeToNewParent(RootItem *item, RootItem *new_parent) {
|
|
||||||
QModelIndex parent_index = indexForItem(new_parent);
|
|
||||||
int new_index_of_item = new_parent->childCount();
|
|
||||||
|
|
||||||
// TODO: sloučit do funkce reassignNodeToNewParent.
|
|
||||||
|
|
||||||
beginInsertRows(parent_index, new_index_of_item, new_index_of_item);
|
|
||||||
new_parent->appendChild(item);
|
|
||||||
endInsertRows();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FeedsModel::reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent) {
|
void FeedsModel::reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent) {
|
||||||
RootItem *original_parent = original_node->parent();
|
RootItem *original_parent = original_node->parent();
|
||||||
|
|
||||||
if (original_parent != new_parent) {
|
if (original_parent != new_parent) {
|
||||||
// User edited item and set it new parent item,
|
if (original_parent != NULL) {
|
||||||
// se we need to move the item in the model too.
|
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
||||||
int original_index_of_item = original_parent->childItems().indexOf(original_node);
|
|
||||||
int new_index_of_item = new_parent->childCount();
|
|
||||||
|
|
||||||
// Remove the original item from the model...
|
if (original_index_of_item >= 0) {
|
||||||
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
// Remove the original item from the model...
|
||||||
original_parent->removeChild(original_node);
|
beginRemoveRows(indexForItem(original_parent), original_index_of_item, original_index_of_item);
|
||||||
endRemoveRows();
|
original_parent->removeChild(original_node);
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int new_index_of_item = new_parent->childCount();
|
||||||
|
|
||||||
// ... and insert it under the new parent.
|
// ... and insert it under the new parent.
|
||||||
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
|
beginInsertRows(indexForItem(new_parent), new_index_of_item, new_index_of_item);
|
||||||
|
|
|
@ -63,9 +63,6 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
// NOTE: Also deletes item from memory.
|
// NOTE: Also deletes item from memory.
|
||||||
bool removeItem(const QModelIndex &index);
|
bool removeItem(const QModelIndex &index);
|
||||||
|
|
||||||
// Assigns item to the new parent.
|
|
||||||
void assignNodeToNewParent(RootItem *item, RootItem *new_parent);
|
|
||||||
|
|
||||||
// Checks if new parent node is different from one used by original node.
|
// Checks if new parent node is different from one used by original node.
|
||||||
// If it is, then it reassigns original_node to new parent.
|
// If it is, then it reassigns original_node to new parent.
|
||||||
void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent);
|
void reassignNodeToNewParent(RootItem *original_node, RootItem *new_parent);
|
||||||
|
|
|
@ -559,6 +559,10 @@ QNetworkAccessManager *DownloadManager::networkManager() const {
|
||||||
return m_networkManager;
|
return m_networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DownloadManager::totalDownloads() const {
|
||||||
|
return m_downloads.size();
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadManager::itemFinished() {
|
void DownloadManager::itemFinished() {
|
||||||
emit downloadFinished();
|
emit downloadFinished();
|
||||||
}
|
}
|
||||||
|
@ -789,6 +793,11 @@ bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_downloadManager->m_autoSaver->changeOccurred();
|
m_downloadManager->m_autoSaver->changeOccurred();
|
||||||
|
|
||||||
|
if (m_downloadManager->totalDownloads() == 0) {
|
||||||
|
m_downloadManager->m_ui->m_btnCleanup->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/network-web/downloadmanager.h
Normal file → Executable file
1
src/network-web/downloadmanager.h
Normal file → Executable file
|
@ -111,6 +111,7 @@ class DownloadManager : public TabContent {
|
||||||
WebBrowser *webBrowser();
|
WebBrowser *webBrowser();
|
||||||
QNetworkAccessManager *networkManager() const;
|
QNetworkAccessManager *networkManager() const;
|
||||||
|
|
||||||
|
int totalDownloads() const;
|
||||||
int activeDownloads() const;
|
int activeDownloads() const;
|
||||||
int downloadProgress() const;
|
int downloadProgress() const;
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ void FormStandardCategoryDetails::apply() {
|
||||||
if (m_editableCategory == NULL) {
|
if (m_editableCategory == NULL) {
|
||||||
// Add the category.
|
// Add the category.
|
||||||
if (new_category->addItself(parent)) {
|
if (new_category->addItself(parent)) {
|
||||||
m_serviceRoot->feedsModel()->assignNodeToNewParent(new_category, parent);
|
m_serviceRoot->feedsModel()->reassignNodeToNewParent(new_category, parent);
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -242,7 +242,7 @@ void FormStandardFeedDetails::apply() {
|
||||||
if (m_editableFeed == NULL) {
|
if (m_editableFeed == NULL) {
|
||||||
// Add the feed.
|
// Add the feed.
|
||||||
if (new_feed->addItself(parent)) {
|
if (new_feed->addItself(parent)) {
|
||||||
m_serviceRoot->feedsModel()->assignNodeToNewParent(new_feed, parent);
|
m_serviceRoot->feedsModel()->reassignNodeToNewParent(new_feed, parent);
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -256,7 +256,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model,
|
||||||
new_category->clearChildren();
|
new_category->clearChildren();
|
||||||
|
|
||||||
if (new_category->addItself(target_parent)) {
|
if (new_category->addItself(target_parent)) {
|
||||||
m_feedsModel->assignNodeToNewParent(new_category, target_parent);
|
m_feedsModel->reassignNodeToNewParent(new_category, target_parent);
|
||||||
|
|
||||||
// Process all children of this category.
|
// Process all children of this category.
|
||||||
original_parents.push(new_category);
|
original_parents.push(new_category);
|
||||||
|
@ -290,7 +290,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel *model,
|
||||||
|
|
||||||
// Append this feed and end this iteration.
|
// Append this feed and end this iteration.
|
||||||
if (new_feed->addItself(target_parent)) {
|
if (new_feed->addItself(target_parent)) {
|
||||||
m_feedsModel->assignNodeToNewParent(new_feed, target_parent);
|
m_feedsModel->reassignNodeToNewParent(new_feed, target_parent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delete new_feed;
|
delete new_feed;
|
||||||
|
|
Loading…
Add table
Reference in a new issue