ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #00193
[Branch ~agateau/plasma-indicatordisplay/trunk] Rev 85: Fixed FilterModelTest
------------------------------------------------------------
revno: 85
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-indicatordisplay
timestamp: Tue 2009-09-15 16:42:06 +0200
message:
Fixed FilterModelTest
removed:
src/filtermodel.cpp
src/filtermodel.h
modified:
src/CMakeLists.txt
src/indicatordisplay.cpp
src/indicatordisplay.h
tests/CMakeLists.txt
tests/filtermodeltest.cpp
tests/filtermodeltest.h
--
lp:plasma-indicatordisplay
https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk
Your team ayatana-commits is subscribed to branch lp:plasma-indicatordisplay.
To unsubscribe from this branch go to https://code.launchpad.net/~agateau/plasma-indicatordisplay/trunk/+edit-subscription.
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2009-09-11 10:18:06 +0000
+++ src/CMakeLists.txt 2009-09-15 14:42:06 +0000
@@ -6,7 +6,6 @@
set(indicatordisplay_SRCS
delegate.cpp
indicatordisplay.cpp
- filtermodel.cpp
listenermodel.cpp
modeldump.cpp
timeutils.cpp
=== removed file 'src/filtermodel.cpp'
--- src/filtermodel.cpp 2009-09-15 12:19:29 +0000
+++ src/filtermodel.cpp 1970-01-01 00:00:00 +0000
@@ -1,75 +0,0 @@
-/*
- * Plasma applet to display indicators from libindicate
- *
- * Copyright 2009 Canonical Ltd.
- *
- * Authors:
- * - Aurélien Gâteau <aurelien.gateau@xxxxxxxxxxxxx>
- *
- * License: GPL v3
- */
-// Self
-#include "filtermodel.h"
-
-// Qt
-
-// KDE
-#include <KDebug>
-
-// Local
-#include <listenermodel.h>
-
-struct FilterModelPrivate
-{
- FilterModel* q;
- QString mAcceptedServerType;
-};
-
-FilterModel::FilterModel(QObject* parent)
-: QSortFilterProxyModel(parent)
-, d(new FilterModelPrivate)
-{
- d->q = this;
- setDynamicSortFilter(true);
-}
-
-FilterModel::~FilterModel()
-{
- delete d;
-}
-
-void FilterModel::setAcceptedServerType(const QString& type)
-{
- d->mAcceptedServerType = type;
- invalidateFilter();
-}
-
-QString FilterModel::acceptedServerType() const
-{
- return d->mAcceptedServerType;
-}
-
-bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
-{
- QModelIndex serverIndex;
- if (sourceParent.isValid()) {
- // Row is an indicator, parent is the server
- serverIndex = sourceParent;
- } else {
- // Row is a server
- serverIndex = sourceModel()->index(sourceRow, 0);
- if (!serverIndex.isValid()) {
- kWarning() << "Invalid index!";
- return false;
- }
- }
-
- QVariant serverType = serverIndex.data(ListenerModel::ServerTypeRole);
- if (!serverType.isValid()) {
- // We don't know the server type for now, wait
- return false;
- }
- return serverType.toString() == d->mAcceptedServerType;
-}
-
-#include "filtermodel.moc"
=== removed file 'src/filtermodel.h'
--- src/filtermodel.h 2009-09-15 12:16:56 +0000
+++ src/filtermodel.h 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
-/*
- * Plasma applet to display indicators from libindicate
- *
- * Copyright 2009 Canonical Ltd.
- *
- * Authors:
- * - Aurélien Gâteau <aurelien.gateau@xxxxxxxxxxxxx>
- *
- * License: GPL v3
- */
-#ifndef FILTERMODEL_H
-#define FILTERMODEL_H
-
-// Qt
-#include <QSortFilterProxyModel>
-
-// Local
-#include <qindicatelistener.h>
-
-struct FilterModelPrivate;
-class FilterModel : public QSortFilterProxyModel
-{
-Q_OBJECT
-public:
- FilterModel(QObject* parent=0);
- ~FilterModel();
-
- void setAcceptedServerType(const QString& type);
- QString acceptedServerType() const;
-
-protected:
- virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
-
-private:
- FilterModelPrivate* const d;
-};
-
-#endif /* FILTERMODEL_H */
=== modified file 'src/indicatordisplay.cpp'
--- src/indicatordisplay.cpp 2009-09-15 13:56:48 +0000
+++ src/indicatordisplay.cpp 2009-09-15 14:42:06 +0000
@@ -27,7 +27,6 @@
#include "view.h"
//#define DUMP_MODELS
-//#define USE_FILTER
static const char* NO_NEW_STUFF_ICON = "mail-unread";
static const char* NEW_STUFF_ICON = "mail-unread-new";
@@ -39,7 +38,6 @@
: Plasma::PopupApplet(parent, args)
, mListener(0)
, mSourceModel(0)
-, mFilterModel(0)
, mView(new ExpandedTreeView())
, mIconWidget(new Plasma::IconWidget(this))
{
@@ -63,7 +61,6 @@
);
initSourceModel();
- initFilterModel();
initView();
initIcon();
}
@@ -99,20 +96,9 @@
#endif
}
-void IndicatorDisplay::initFilterModel()
-{
- mFilterModel = new FilterModel(this);
- mFilterModel->setAcceptedServerType("messaging");
- mFilterModel->setSourceModel(mSourceModel);
-}
-
void IndicatorDisplay::initView()
{
- #ifdef USE_FILTER
- mView->setModel(mFilterModel);
- #else
mView->setModel(mSourceModel);
- #endif
mView->setItemDelegate(new Delegate(this));
mView->setSelectionMode(QAbstractItemView::NoSelection);
@@ -185,17 +171,12 @@
}
}
-void IndicatorDisplay::slotClicked(const QModelIndex& filterIndex)
+void IndicatorDisplay::slotClicked(const QModelIndex& index)
{
QIndicate::Listener::Server* server = 0;
QIndicate::Listener::Indicator* indicator = 0;
- #ifdef USE_FILTER
- QModelIndex sourceIndex = mFilterModel->mapToSource(filterIndex);
- #else
- QModelIndex sourceIndex = filterIndex;
- #endif
- mSourceModel->getProxiesForIndex(sourceIndex, &server, &indicator);
+ mSourceModel->getProxiesForIndex(index, &server, &indicator);
mListener->display(server, indicator);
hidePopup();
@@ -283,10 +264,6 @@
qDebug();
qDebug() << "## mSourceModel";
dump(hash, mSourceModel);
- #ifdef USE_FILTER
- qDebug() << "## mFilterModel";
- dump(hash, mFilterModel);
- #endif
}
#else
void IndicatorDisplay::dumpModels()
=== modified file 'src/indicatordisplay.h'
--- src/indicatordisplay.h 2009-09-10 13:19:07 +0000
+++ src/indicatordisplay.h 2009-09-15 14:42:06 +0000
@@ -21,7 +21,6 @@
#include <qindicatelistener.h>
// Local
-#include <filtermodel.h>
#include <listenermodel.h>
class IndicatorDisplay : public Plasma::PopupApplet
@@ -52,13 +51,11 @@
private:
QIndicate::Listener* mListener;
ListenerModel* mSourceModel;
- FilterModel* mFilterModel;
QTreeView* mView;
Plasma::IconWidget* mIconWidget;
void initIcon();
void initSourceModel();
- void initFilterModel();
void initView();
void updateIcon(bool newStuff);
void updateIconState();
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2009-09-11 10:18:06 +0000
+++ tests/CMakeLists.txt 2009-09-15 14:42:06 +0000
@@ -25,7 +25,6 @@
set(filtermodeltest_SRCS
filtermodeltest.cpp
../src/listenermodel.cpp
- ../src/filtermodel.cpp
)
kde4_add_unit_test(filtermodeltest ${filtermodeltest_SRCS})
=== modified file 'tests/filtermodeltest.cpp'
--- tests/filtermodeltest.cpp 2009-09-15 12:16:56 +0000
+++ tests/filtermodeltest.cpp 2009-09-15 14:42:06 +0000
@@ -30,12 +30,6 @@
void FilterModelTest::init()
{
- mListener = new QIndicate::Listener();
-
- mListenerModel = new ListenerModel(mListener);
- mFilterModel = new FilterModel();
- mFilterModel->setSourceModel(mListenerModel);
-
mServer = QIndicate::Server::defaultInstance();
const QString desktopFile = KDESRCDIR "test.desktop";
@@ -45,12 +39,6 @@
void FilterModelTest::cleanup()
{
- delete mListener;
- mListener = 0;
- delete mFilterModel;
- mFilterModel = 0;
- delete mListenerModel;
- mListenerModel = 0;
delete mServer;
mServer = 0;
}
@@ -66,19 +54,28 @@
indicator.show();
QTest::qWait(500);
- // No index by default
- QModelIndex serverIndex = mFilterModel->index(0, 0);
+ // Create a ListenerModel with a wrong server type
+ QIndicate::Listener listener1;
+ ListenerModel listenerModel1(&listener1, "foo");
+
+ // We should not find any index
+ QTest::qWait(500);
+ QModelIndex serverIndex = listenerModel1.index(0, 0);
QVERIFY(!serverIndex.isValid());
- // Set server type
- mFilterModel->setAcceptedServerType(SERVER_TYPE);
+ // FIXME: ListenerModel can't list servers or indicators which have already
+ // been received by Listener, so we create another instance of Listener
+ // Create a ListenerModel with the correct server type
+ QIndicate::Listener listener2;
+ ListenerModel listenerModel2(&listener2, SERVER_TYPE);
// We should see the server and its indicator now
- serverIndex = mFilterModel->index(0, 0);
+ QTest::qWait(500);
+ serverIndex = listenerModel2.index(0, 0);
QVERIFY(serverIndex.isValid());
- QVERIFY(mFilterModel->hasChildren(serverIndex));
- QModelIndex indicatorIndex = mFilterModel->index(0, 0, serverIndex);
+ QVERIFY(listenerModel2.hasChildren(serverIndex));
+ QModelIndex indicatorIndex = listenerModel2.index(0, 0, serverIndex);
QCOMPARE(indicatorIndex.data().toString(), QString("John Doe"));
=== modified file 'tests/filtermodeltest.h'
--- tests/filtermodeltest.h 2009-08-07 17:00:25 +0000
+++ tests/filtermodeltest.h 2009-09-15 14:42:06 +0000
@@ -18,7 +18,6 @@
#include <qindicateserver.h>
// Local
-#include <filtermodel.h>
#include <listenermodel.h>
/**
@@ -35,8 +34,6 @@
private:
QIndicate::Listener* mListener;
QIndicate::Server* mServer;
- ListenerModel* mListenerModel;
- FilterModel* mFilterModel;
};
#endif /* FILTERMODELTEST_H */