Many refactoring stuff. Recycle bin now displays count of deleted items.
This commit is contained in:
parent
202d26cea5
commit
5581a5a92f
|
@ -3,16 +3,20 @@
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Overall code cleanups and refactoring primarily in area of feed/message models and recycle bin functionality.</li>
|
||||||
<li>Fixed bug #66, #67.</li>
|
<li>Fixed bug #66, #67.</li>
|
||||||
<li>Blau skin now has colored webkit scrollbars, fixed some button widths and enhanced menu popup tool buttons.</li>
|
<li>Blau skin now has colored webkit scrollbars, fixed some button widths and enhanced menu popup tool buttons.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Top-level recycle bin which displays count of deleted items properly.</li>
|
||||||
<li>MySQL backend now alows to defragment/optimize RSS Guard database.</li>
|
<li>MySQL backend now alows to defragment/optimize RSS Guard database.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Changed:
|
Changed:
|
||||||
|
<ul>
|
||||||
|
<li>Target message is now selected instead of highlighted when searching with keyboard.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
|
@ -66,13 +66,7 @@ FeedsModel::~FeedsModel() {
|
||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndexList FeedsModel::persistentIndexList() const {
|
QVariant FeedsModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||||
return QAbstractItemModel::persistentIndexList();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant FeedsModel::headerData(int section,
|
|
||||||
Qt::Orientation orientation,
|
|
||||||
int role) const {
|
|
||||||
if (orientation != Qt::Horizontal) {
|
if (orientation != Qt::Horizontal) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -900,6 +894,10 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeedsModelRecycleBin *FeedsModel::recycleBin() const {
|
||||||
|
return m_recycleBin;
|
||||||
|
}
|
||||||
|
|
||||||
void FeedsModel::assembleCategories(CategoryAssignment categories) {
|
void FeedsModel::assembleCategories(CategoryAssignment categories) {
|
||||||
QHash<int, FeedsModelRootItem*> assignments;
|
QHash<int, FeedsModelRootItem*> assignments;
|
||||||
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
|
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
|
||||||
|
|
|
@ -45,10 +45,6 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
explicit FeedsModel(QObject *parent = 0);
|
explicit FeedsModel(QObject *parent = 0);
|
||||||
virtual ~FeedsModel();
|
virtual ~FeedsModel();
|
||||||
|
|
||||||
// Returns list of all indexes available in the model.
|
|
||||||
// NOTE: Overriden because original method is protected.
|
|
||||||
QModelIndexList persistentIndexList() const;
|
|
||||||
|
|
||||||
// Model implementation.
|
// Model implementation.
|
||||||
inline QVariant data(const QModelIndex &index, int role) const {
|
inline QVariant data(const QModelIndex &index, int role) const {
|
||||||
// Return data according to item.
|
// Return data according to item.
|
||||||
|
@ -142,6 +138,9 @@ class FeedsModel : public QAbstractItemModel {
|
||||||
// it to active structure.
|
// it to active structure.
|
||||||
bool mergeModel(FeedsImportExportModel *model, QString &output_message);
|
bool mergeModel(FeedsImportExportModel *model, QString &output_message);
|
||||||
|
|
||||||
|
// Access to recycle bin.
|
||||||
|
FeedsModelRecycleBin *recycleBin() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Feeds operations.
|
// Feeds operations.
|
||||||
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
|
bool markFeedsRead(const QList<FeedsModelFeed*> &feeds, int read);
|
||||||
|
|
|
@ -94,6 +94,9 @@ QVariant FeedsModelRecycleBin::data(int column, int role) const {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
return tr("Recycle bin\n%1").arg(tr("%n deleted message(s).", 0, countOfUnreadMessages()));
|
||||||
|
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
if (column == FDS_MODEL_COUNTS_INDEX) {
|
if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
return Qt::AlignCenter;
|
return Qt::AlignCenter;
|
||||||
|
|
|
@ -68,7 +68,9 @@ int FeedsModelRootItem::countOfAllMessages() const {
|
||||||
int total_count = 0;
|
int total_count = 0;
|
||||||
|
|
||||||
foreach (FeedsModelRootItem *child_item, m_childItems) {
|
foreach (FeedsModelRootItem *child_item, m_childItems) {
|
||||||
total_count += child_item->countOfAllMessages();
|
if (child_item->kind() != FeedsModelRootItem::RecycleBin) {
|
||||||
|
total_count += child_item->countOfAllMessages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_count;
|
return total_count;
|
||||||
|
@ -95,7 +97,9 @@ int FeedsModelRootItem::countOfUnreadMessages() const {
|
||||||
int total_count = 0;
|
int total_count = 0;
|
||||||
|
|
||||||
foreach (FeedsModelRootItem *child_item, m_childItems) {
|
foreach (FeedsModelRootItem *child_item, m_childItems) {
|
||||||
total_count += child_item->countOfUnreadMessages();
|
if (child_item->kind() != FeedsModelRootItem::RecycleBin) {
|
||||||
|
total_count += child_item->countOfUnreadMessages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return total_count;
|
return total_count;
|
||||||
|
|
|
@ -274,7 +274,7 @@ bool MessagesModel::setMessageRead(int row_index, int read) {
|
||||||
// can reflect.
|
// can reflect.
|
||||||
emit dataChanged(index(row_index, 0),
|
emit dataChanged(index(row_index, 0),
|
||||||
index(row_index, columnCount() - 1));
|
index(row_index, columnCount() - 1));
|
||||||
emit feedCountsChanged();
|
emit feedCountsChanged(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -354,7 +354,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList &messages
|
||||||
select();
|
select();
|
||||||
fetchAll();
|
fetchAll();
|
||||||
|
|
||||||
emit feedCountsChanged();
|
//emit feedCountsChanged(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -381,7 +381,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList &messages,
|
||||||
select();
|
select();
|
||||||
fetchAll();
|
fetchAll();
|
||||||
|
|
||||||
emit feedCountsChanged();
|
emit feedCountsChanged(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -407,7 +407,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList &messages, int re
|
||||||
select();
|
select();
|
||||||
fetchAll();
|
fetchAll();
|
||||||
|
|
||||||
emit feedCountsChanged();
|
emit feedCountsChanged(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -109,7 +109,7 @@ class MessagesModel : public QSqlTableModel {
|
||||||
signals:
|
signals:
|
||||||
// Emitted if some persistent change is made which affects
|
// Emitted if some persistent change is made which affects
|
||||||
// count of "unread/all" messages.
|
// count of "unread/all" messages.
|
||||||
void feedCountsChanged();
|
void feedCountsChanged(bool total_message_number_changed = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Returns selected feed ids in concatenated textual form,
|
// Returns selected feed ids in concatenated textual form,
|
||||||
|
|
|
@ -206,7 +206,7 @@ void FeedMessageViewer::createConnections() {
|
||||||
connect(m_feedsView, SIGNAL(feedsSelected(QList<int>)), m_messagesView, SLOT(loadFeeds(QList<int>)));
|
connect(m_feedsView, SIGNAL(feedsSelected(QList<int>)), m_messagesView, SLOT(loadFeeds(QList<int>)));
|
||||||
|
|
||||||
// If user changes status of some messages, recalculate message counts.
|
// If user changes status of some messages, recalculate message counts.
|
||||||
connect(m_messagesView, SIGNAL(feedCountsChanged()), m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
|
connect(m_messagesView, SIGNAL(feedCountsChanged(bool)), m_feedsView, SLOT(updateCountsOfSelectedFeeds()));
|
||||||
|
|
||||||
// State of many messages is changed, then we need
|
// State of many messages is changed, then we need
|
||||||
// to reload selections.
|
// to reload selections.
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "core/feedsproxymodel.h"
|
#include "core/feedsproxymodel.h"
|
||||||
#include "core/feedsmodelrootitem.h"
|
#include "core/feedsmodelrootitem.h"
|
||||||
#include "core/feedsmodelcategory.h"
|
#include "core/feedsmodelcategory.h"
|
||||||
|
#include "core/feedsmodelrecyclebin.h"
|
||||||
#include "core/feedsmodelfeed.h"
|
#include "core/feedsmodelfeed.h"
|
||||||
#include "miscellaneous/systemfactory.h"
|
#include "miscellaneous/systemfactory.h"
|
||||||
#include "gui/formmain.h"
|
#include "gui/formmain.h"
|
||||||
|
@ -407,18 +408,24 @@ void FeedsView::openSelectedFeedsInNewspaperMode() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
||||||
QList<FeedsModelFeed*> selected_feeds = selectedFeeds();
|
foreach (FeedsModelFeed *feed, selectedFeeds()) {
|
||||||
|
feed->updateCounts(update_total_too);
|
||||||
if (!selected_feeds.isEmpty()) {
|
|
||||||
foreach (FeedsModelFeed *feed, selected_feeds) {
|
|
||||||
feed->updateCounts(update_total_too);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that selected view reloads changed indexes.
|
|
||||||
m_sourceModel->reloadChangedLayout(m_proxyModel->mapListToSource(selectionModel()->selectedRows()));
|
|
||||||
notifyWithCounts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QModelIndexList selected_indexes = m_proxyModel->mapListToSource(selectionModel()->selectedRows());
|
||||||
|
|
||||||
|
if (update_total_too) {
|
||||||
|
// Number of items in recycle bin has changed.
|
||||||
|
m_sourceModel->recycleBin()->updateCounts();
|
||||||
|
|
||||||
|
// We need to refresh data for recycle bin too.
|
||||||
|
selected_indexes.append(m_sourceModel->indexForItem(m_sourceModel->recycleBin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that selected view reloads changed indexes.
|
||||||
|
m_sourceModel->reloadChangedLayout(selected_indexes);
|
||||||
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||||
|
@ -426,9 +433,13 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||||
feed->updateCounts(update_total_too);
|
feed->updateCounts(update_total_too);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update_total_too) {
|
||||||
|
// Number of items in recycle bin has changed.
|
||||||
|
m_sourceModel->recycleBin()->updateCounts();
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure that all views reloads its data.
|
// Make sure that all views reloads its data.
|
||||||
m_sourceModel->reloadWholeLayout();
|
m_sourceModel->reloadWholeLayout();
|
||||||
|
|
||||||
notifyWithCounts();
|
notifyWithCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,17 +50,14 @@ MessagesView::~MessagesView() {
|
||||||
|
|
||||||
void MessagesView::createConnections() {
|
void MessagesView::createConnections() {
|
||||||
// Forward feed counts changes.
|
// Forward feed counts changes.
|
||||||
connect(m_sourceModel, SIGNAL(feedCountsChanged()),
|
connect(m_sourceModel, SIGNAL(feedCountsChanged(bool)), this, SIGNAL(feedCountsChanged(bool)));
|
||||||
this, SIGNAL(feedCountsChanged()));
|
|
||||||
|
|
||||||
// Make sure that source message is opened
|
// Make sure that source message is opened
|
||||||
// in new tab on double click.
|
// in new tab on double click.
|
||||||
connect(this, SIGNAL(doubleClicked(QModelIndex)),
|
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openSelectedSourceMessagesInternally()));
|
||||||
this, SLOT(openSelectedSourceMessagesInternally()));
|
|
||||||
|
|
||||||
// Adjust columns when layout gets changed.
|
// Adjust columns when layout gets changed.
|
||||||
connect(header(), SIGNAL(geometriesChanged()),
|
connect(header(), SIGNAL(geometriesChanged()), this, SLOT(adjustColumns()));
|
||||||
this, SLOT(adjustColumns()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::keyboardSearch(const QString &search) {
|
void MessagesView::keyboardSearch(const QString &search) {
|
||||||
|
@ -137,8 +134,7 @@ void MessagesView::contextMenuEvent(QContextMenuEvent *event) {
|
||||||
QModelIndex clicked_index = indexAt(event->pos());
|
QModelIndex clicked_index = indexAt(event->pos());
|
||||||
|
|
||||||
if (!clicked_index.isValid()) {
|
if (!clicked_index.isValid()) {
|
||||||
qDebug("Context menu for MessagesView will not be shown because "
|
qDebug("Context menu for MessagesView will not be shown because user clicked on invalid item.");
|
||||||
"user clicked on invalid item.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,7 @@ class MessagesView : public QTreeView {
|
||||||
void createConnections();
|
void createConnections();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void keyboardSearch(const QString &search) {
|
void keyboardSearch(const QString &search);
|
||||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
|
||||||
QTreeView::keyboardSearch(search);
|
|
||||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called after data got changed externally
|
// Called after data got changed externally
|
||||||
// and it needs to be reloaded to the view.
|
// and it needs to be reloaded to the view.
|
||||||
|
@ -118,7 +114,7 @@ class MessagesView : public QTreeView {
|
||||||
|
|
||||||
// Emitted if counts of unread/total messages has changed
|
// Emitted if counts of unread/total messages has changed
|
||||||
// because of user interaction with list of messages.
|
// because of user interaction with list of messages.
|
||||||
void feedCountsChanged();
|
void feedCountsChanged(bool total_message_number_changed = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMenu *m_contextMenu;
|
QMenu *m_contextMenu;
|
||||||
|
|
Loading…
Reference in New Issue