mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-25 13:38:44 +01:00
Some optimizations for feedsmodel.
This commit is contained in:
parent
7f33dfdd2e
commit
e7a313fd77
@ -19,7 +19,6 @@ class BaseNetworkAccessManager : public QNetworkAccessManager {
|
||||
virtual void loadSettings();
|
||||
|
||||
protected:
|
||||
|
||||
QNetworkReply *createRequest(Operation op,
|
||||
const QNetworkRequest &request,
|
||||
QIODevice *outgoingData);
|
||||
|
@ -35,19 +35,13 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
||||
|
||||
FeedsModel::~FeedsModel() {
|
||||
qDebug("Destroying FeedsModel instance.");
|
||||
|
||||
delete m_rootItem;
|
||||
DatabaseFactory::getInstance()->removeConnection(objectName());
|
||||
}
|
||||
|
||||
QVariant FeedsModel::data(const QModelIndex &index, int role) const {
|
||||
FeedsModelRootItem *item = itemForIndex(index);
|
||||
|
||||
if (item != NULL) {
|
||||
return item->data(index.column(), role);
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
}
|
||||
return itemForIndex(index)->data(index.column(), role);
|
||||
}
|
||||
|
||||
QVariant FeedsModel::headerData(int section,
|
||||
@ -153,7 +147,7 @@ FeedsModelRootItem *FeedsModel::itemForIndex(const QModelIndex &index) const {
|
||||
return static_cast<FeedsModelRootItem*>(index.internalPointer());
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
return m_rootItem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,9 +162,9 @@ FeedsModelCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||
if (item->kind() == FeedsModelRootItem::RootItem) {
|
||||
if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) {
|
||||
// Root item lies on invalid index.
|
||||
return QModelIndex();
|
||||
}
|
||||
@ -212,8 +206,8 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||
if (item->kind() == FeedsModelRootItem::RootItem) {
|
||||
// Root item lies on invalid index.
|
||||
@ -255,7 +249,7 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
}*/
|
||||
|
||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||
while (!list.isEmpty()) {
|
||||
|
@ -64,7 +64,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||
FeedsModelCategory *categoryForIndex(const QModelIndex &index) const;
|
||||
|
||||
// Returns feed/category which lies at the specified index or
|
||||
// null if index is invalid.
|
||||
// root item if index is invalid.
|
||||
FeedsModelRootItem *itemForIndex(const QModelIndex &index) const;
|
||||
|
||||
// Returns QModelIndex on which lies given item.
|
||||
|
@ -205,8 +205,12 @@ void FeedsView::selectionChanged(const QItemSelection &selected,
|
||||
m_selectedFeeds.clear();
|
||||
|
||||
foreach (FeedsModelFeed *feed, selectedFeeds()) {
|
||||
QModelIndex id = m_sourceModel->indexForItem(feed);
|
||||
qDebug("INDEX %d, %d", id.row(), id.column());
|
||||
#if defined(DEBUG)
|
||||
QModelIndex index_for_feed = m_sourceModel->indexForItem(feed);
|
||||
|
||||
qDebug("Selecting feed '%s' (source index [%d, %d]).",
|
||||
qPrintable(feed->title()), index_for_feed.row(), index_for_feed.column());
|
||||
#endif
|
||||
|
||||
m_selectedFeeds << feed->id();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user