← Back to team overview

ayatana-commits team mailing list archive

[Branch ~agateau/plasma-indicatordisplay/trunk] Rev 97: Use a regexp to match server types.

 

------------------------------------------------------------
revno: 97
committer: Aurelien Gateau <aurelien.gateau@xxxxxxxxxxxxx>
branch nick: plasma-indicatordisplay
timestamp: Mon 2009-09-28 11:06:26 +0200
message:
  Use a regexp to match server types.
  
  Makes it possible to support server using a type of 'message.instant' and
  'messaging'.
modified:
  src/indicatordisplay.cpp
  src/listenermodel.cpp
  src/listenermodel.h
  tests/filtermodeltest.cpp
  tests/listenermodeltest.cpp


--
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/indicatordisplay.cpp'
--- src/indicatordisplay.cpp	2009-09-17 13:48:34 +0000
+++ src/indicatordisplay.cpp	2009-09-28 09:06:26 +0000
@@ -14,6 +14,7 @@
 // Qt
 #include <QGraphicsLinearLayout>
 #include <QLayout>
+#include <QRegExp>
 
 // KDE
 #include <KGlobalSettings>
@@ -82,7 +83,9 @@
 
 void IndicatorDisplay::initSourceModel()
 {
-    mSourceModel = new ListenerModel(mListener, "messaging");
+    // Reg exp is a hack to avoid regressions while changing app server types
+    // from "messaging" to "message.<something>"
+    mSourceModel = new ListenerModel(mListener, QRegExp("^messag(e|ing)"));
     connect(mSourceModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
             SLOT(slotRowsChanged(const QModelIndex&))
             );

=== modified file 'src/listenermodel.cpp'
--- src/listenermodel.cpp	2009-09-28 08:36:10 +0000
+++ src/listenermodel.cpp	2009-09-28 09:06:26 +0000
@@ -12,6 +12,7 @@
 #include "listenermodel.h"
 
 // Qt
+#include <QRegExp>
 #include <QTime>
 
 // KDE
@@ -45,7 +46,7 @@
     ListenerModel* q;
 
     QIndicate::Listener* mListener;
-    QString mAcceptedServerType;
+    QRegExp mAcceptedServerType;
     // Indicators we have received, but for which we haven't received a server
     // yet
     QHash<QIndicate::Listener::Server*, IndicatorSet> mWaitingIndicators;
@@ -80,7 +81,7 @@
     }
 };
 
-ListenerModel::ListenerModel(QIndicate::Listener* listener, const QString& acceptedServerType)
+ListenerModel::ListenerModel(QIndicate::Listener* listener, const QRegExp& acceptedServerType)
 : d(new ListenerModelPrivate)
 {
     d->q = this;
@@ -130,7 +131,7 @@
 
 void ListenerModel::slotServerAdded(QIndicate::Listener::Server* server, const QString& type)
 {
-    if (type != d->mAcceptedServerType) {
+    if (d->mAcceptedServerType.indexIn(type) == -1) {
         d->mWaitingIndicators.remove(server);
         return;
     }

=== modified file 'src/listenermodel.h'
--- src/listenermodel.h	2009-09-17 13:48:34 +0000
+++ src/listenermodel.h	2009-09-28 09:06:26 +0000
@@ -17,12 +17,14 @@
 // Local
 #include <qindicatelistener.h>
 
+class QRegExp;
+
 struct ListenerModelPrivate;
 class ListenerModel : public QStandardItemModel
 {
 Q_OBJECT
 public:
-    ListenerModel(QIndicate::Listener*, const QString& acceptedServerType);
+    ListenerModel(QIndicate::Listener*, const QRegExp& acceptedServerType);
     ~ListenerModel();
 
     enum AdditionalRoles

=== modified file 'tests/filtermodeltest.cpp'
--- tests/filtermodeltest.cpp	2009-09-15 14:42:06 +0000
+++ tests/filtermodeltest.cpp	2009-09-28 09:06:26 +0000
@@ -56,7 +56,7 @@
 
     // Create a ListenerModel with a wrong server type
     QIndicate::Listener listener1;
-    ListenerModel listenerModel1(&listener1, "foo");
+    ListenerModel listenerModel1(&listener1, QRegExp("^foo"));
 
     // We should not find any index
     QTest::qWait(500);
@@ -67,7 +67,7 @@
     // 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);
+    ListenerModel listenerModel2(&listener2, QRegExp('^' + SERVER_TYPE));
 
     // We should see the server and its indicator now
     QTest::qWait(500);

=== modified file 'tests/listenermodeltest.cpp'
--- tests/listenermodeltest.cpp	2009-09-17 13:48:34 +0000
+++ tests/listenermodeltest.cpp	2009-09-28 09:06:26 +0000
@@ -41,7 +41,7 @@
 {
     mListener = new QIndicate::Listener();
 
-    mModel = new ListenerModel(mListener, SERVER_TYPE);
+    mModel = new ListenerModel(mListener, QRegExp('^' + SERVER_TYPE));
 
     mServer = QIndicate::Server::defaultInstance();
     const QString desktopFile = KDESRCDIR "test.desktop";