[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/knotify
From:       Jacopo De Simoi <wilderkde () gmail ! com>
Date:       2010-11-02 10:04:44
Message-ID: 20101102100444.2C226AC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1192158 by jacopods:

FEATURE: Support for relative context present actions

REV: http://svn.reviewboard.kde.org/r/5631/


 M  +30 -0     knotify.cpp  
 M  +8 -0      knotifyconfig.cpp  


--- trunk/KDE/kdebase/runtime/knotify/knotify.cpp #1192157:1192158
@@ -172,6 +172,36 @@
 	QString presentstring=e->config.readEntry("Action");
 	QStringList presents=presentstring.split ('|');
 	
+	if (!e->config.contexts.isEmpty() && !presents.first().isEmpty()) 
+	{
+		//Check whether the present actions are absolute, relative or invalid
+		bool relative = presents.first().startsWith('+') || \
presents.first().startsWith('-'); +		bool valid = true;
+		foreach (const QString & presentAction, presents)
+			valid &=  ((presentAction.startsWith('+') || presentAction.startsWith('-')) == \
relative); +		if (!valid) 
+		{
+			kDebug() << "Context " << e->config.contexts << "present actions are invalid! \
Fallback to default present actions"; +			Event defaultEvent = \
Event(e->config.appname, ContextList(), e->config.eventid); +			QString \
defaultPresentstring=defaultEvent.config.readEntry("Action"); +			presents = \
defaultPresentstring.split ('|'); +		} else if (relative) 
+		{
+			// Obtain the list of present actions without context
+			Event noContextEvent = Event(e->config.appname, ContextList(), \
e->config.eventid); +			QString noContextPresentstring = \
noContextEvent.config.readEntry("Action"); +			QSet<QString> noContextPresents = \
noContextPresentstring.split ('|').toSet(); +			foreach (const QString & \
presentAction, presents) +			{
+				if (presentAction.startsWith('+'))
+					noContextPresents << presentAction.mid(1);
+				else
+					noContextPresents.remove(presentAction.mid(1));
+			}
+			presents = noContextPresents.toList();
+		}
+	}
+
 	foreach(const QString & action , presents)
 	{
 		if(!m_plugins.contains(action))
--- trunk/KDE/kdebase/runtime/knotify/knotifyconfig.cpp #1192157:1192158
@@ -90,7 +90,15 @@
 			if(!p.isNull())
 				return p;
 		}
+
+		if( eventsfile->hasGroup( group ) )
+		{
+			KConfigGroup cg(eventsfile, group);
+			QString p=path ?  cg.readPathEntry(entry, QString()) : \
cg.readEntry(entry,QString()); +			if(!p.isNull())
+				return p;
 	}
+	}
 //	kDebug() << entry << " not found in contexts ";
 	const QString group="Event/" + eventid ;
 	if(configfile->hasGroup( group ) )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic