[Kde-pim] Using EntityTreeModel

Anders Lund anders at alweb.dk
Sat Nov 3 09:23:51 GMT 2012


Hi,

I am trying to revive a project of mine, creating a dedicated journal 
application.

I use EntityTreeModel to show the journal items, or rather to not show them, 
since my list is always empty, although journal items exist in my calendars. 
This worked when I originally wrote the application, approxymately a year ago, 
using the by then stable KDE.

Can you spot a mistake?

    // The journal list
    ChangeRecorder *changeRecorder = new ChangeRecorder(this);
    changeRecorder->setCollectionMonitored(Collection::root());
    changeRecorder-
>setMimeTypeMonitored(KCalCore::Journal::journalMimeType());
//     changeRecorder-
>itemFetchScope().fetchAttribute<Akonadi::EntityDisplayAttribute>();
    changeRecorder->itemFetchScope().fetchFullPayload(true);
//     changeRecorder->setAllMonitored();

    m_model = new JournalModel(changeRecorder, this);
//     m_model-
>setCollectionFetchStrategy(EntityTreeModel::InvisibleCollectionFetch);
//     m_model-
>setCollectionFetchStrategy(EntityTreeModel::FetchNoCollections);

    // only show journal items
    EntityMimeTypeFilterModel *journalproxy = new EntityMimeTypeFilterModel();
    journalproxy-
>addMimeTypeInclusionFilter(KCalCore::Journal::journalMimeType());
    journalproxy->setHeaderGroup(EntityTreeModel::ItemListHeaders);// i do not 
use them!
    journalproxy->setSourceModel(m_model);

    // sort items by date, newest first
    m_sortfilterproxy = new QSortFilterProxyModel(this);
    m_sortfilterproxy->setSourceModel(journalproxy);
    m_sortfilterproxy->setSortRole(Qt::EditRole);

    // search filter
    m_searchbar->setProxy(m_sortfilterproxy);
    m_sortfilterproxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
    m_sortfilterproxy->setFilterKeyColumn(-1);

    // category filter
    m_categoryfilter = new QSortFilterProxyModel(this);
    m_categoryfilter->setSourceModel(journalproxy);
    m_categoryfilter->setFilterKeyColumn(2);
    // FIXME use a model for the combo, and just connect those.
    connect(m_categoryChooser, SIGNAL(activated(int)),
            this, SLOT(categoryChooserActivated(int)));

    m_journallist = new EntityListView(this);
    m_journallist->setModel(m_categoryfilter);


-- 
Anders
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list