Tested feed selectors.
This commit is contained in:
parent
26211cb229
commit
f78e2b77a7
@ -23,7 +23,7 @@ FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) {
|
||||
tr("Counts of unread/all meesages.");
|
||||
|
||||
loadFromDatabase();
|
||||
/*
|
||||
/*
|
||||
FeedsModelStandardCategory *cat1 = new FeedsModelStandardCategory();
|
||||
FeedsModelStandardCategory *cat2 = new FeedsModelStandardCategory();
|
||||
FeedsModelStandardFeed *feed1 = new FeedsModelStandardFeed();
|
||||
@ -164,8 +164,12 @@ int FeedsModel::columnCount(const QModelIndex &parent) const {
|
||||
}
|
||||
|
||||
FeedsModelRootItem *FeedsModel::itemForIndex(const QModelIndex &index) {
|
||||
FeedsModelRootItem *item = static_cast<FeedsModelRootItem*>(index.internalPointer());
|
||||
return item;
|
||||
if (index.isValid() && index.model() == this) {
|
||||
return static_cast<FeedsModelRootItem*>(index.internalPointer());
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsModel::loadFromDatabase() {
|
||||
@ -244,11 +248,12 @@ QList<FeedsModelFeed*> FeedsModel::feedsForIndex(const QModelIndex &index) {
|
||||
|
||||
switch (item->kind()) {
|
||||
case FeedsModelRootItem::Category:
|
||||
// This item is a category, add all its child feeds.
|
||||
feeds.append(static_cast<FeedsModelCategory*>(item)->feeds());
|
||||
break;
|
||||
|
||||
case FeedsModelRootItem::Feed:
|
||||
// This item is feed (it SURELY subclasses FeedsModelFeed),add it.
|
||||
// This item is feed (it SURELY subclasses FeedsModelFeed), add it.
|
||||
feeds.append(static_cast<FeedsModelFeed*>(item));
|
||||
break;
|
||||
|
||||
|
@ -45,15 +45,16 @@ class FeedsModel : public QAbstractItemModel {
|
||||
// Returns feeds contained within single index.
|
||||
QList<FeedsModelFeed*> feedsForIndex(const QModelIndex &index);
|
||||
|
||||
// Returns feed/category which lies at the specified index or
|
||||
// null if index is invalid.
|
||||
FeedsModelRootItem *itemForIndex(const QModelIndex &index);
|
||||
|
||||
protected:
|
||||
// Loads feed/categories from the database.
|
||||
void loadFromDatabase();
|
||||
|
||||
// TODO: Otestovat metody itemForIndex, feedsForIndex, feedsForIndexes.
|
||||
|
||||
// Returns feed/category which lies at the specified index.
|
||||
FeedsModelRootItem *itemForIndex(const QModelIndex &index);
|
||||
|
||||
// Takes lists of feeds/categories and assembles
|
||||
// them into the tree structure.
|
||||
void assembleCategories(CategoryAssignment categories);
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
FeedsModelCategory::FeedsModelCategory(FeedsModelRootItem *parent_item)
|
||||
: FeedsModelRootItem(parent_item) {
|
||||
m_kind = FeedsModelRootItem::Category;
|
||||
}
|
||||
|
||||
FeedsModelCategory::~FeedsModelCategory() {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
FeedsModelFeed::FeedsModelFeed(FeedsModelRootItem *parent_item)
|
||||
: FeedsModelRootItem(parent_item), m_totalCount(0), m_unreadCount(0) {
|
||||
m_kind = FeedsModelRootItem::Feed;
|
||||
}
|
||||
|
||||
FeedsModelFeed::~FeedsModelFeed() {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
FeedsModelStandardCategory::FeedsModelStandardCategory(FeedsModelRootItem *parent_item)
|
||||
: FeedsModelCategory(parent_item) {
|
||||
m_kind = FeedsModelRootItem::Category;
|
||||
m_type = Standard;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
FeedsModelStandardFeed::FeedsModelStandardFeed(FeedsModelRootItem *parent_item)
|
||||
: FeedsModelFeed(parent_item) {
|
||||
m_kind = FeedsModelRootItem::Category;
|
||||
}
|
||||
|
||||
FeedsModelStandardFeed::~FeedsModelStandardFeed() {
|
||||
|
@ -44,3 +44,14 @@ void FeedsView::setupAppearance() {
|
||||
setAllColumnsShowFocus(true);
|
||||
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
}
|
||||
|
||||
void FeedsView::selectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected) {
|
||||
QModelIndexList curr = selectionModel()->selectedRows();
|
||||
QModelIndexList mapped = m_proxyModel->mapListToSource(curr);
|
||||
|
||||
QList<FeedsModelFeed*> feeds = m_sourceModel->feedsForIndexes(mapped);
|
||||
|
||||
|
||||
int a = 5;
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ class FeedsView : public QTreeView {
|
||||
|
||||
protected:
|
||||
void setupAppearance();
|
||||
void selectionChanged(const QItemSelection &selected,
|
||||
const QItemSelection &deselected);
|
||||
|
||||
private:
|
||||
FeedsModel *m_sourceModel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user