Bug 139552 - Missing conditions for smart playlists: "does not start with" and "does not end with"
Summary: Missing conditions for smart playlists: "does not start with" and "does not e...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Unclassified
Component: Playlists/Saved Playlists (show other bugs)
Version: 1.4.4
Platform: Gentoo Packages Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-03 13:15 UTC by Elias Probst
Modified: 2007-01-08 18:55 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Probst 2007-01-03 13:15:40 UTC
Version:           1.4.4 (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages

At the conditions for defining a Smart Playlist, I'm missing the following ones:

"Does not start with"
"Does not end with"
as there are also the opposites to other conditions like:
"Contains" -> "Does not contain"
and
"Is" -> "Is not"

It would be also nice to have a directory picker when the condition is "Mountpoint" or "Directory".
Comment 1 Peter C. Ndikuwera 2007-01-08 16:13:38 UTC
SVN commit 621290 by pndiku:

BUG: 139552
* Add "does not start with" and "does not end with" conditions to
the Smart Playlist editor[1].
* Add dropdown picker for Mount Points in Smart Playlist Editor.

[1] I acknowledge that this may be overkill. :-)


 M  +12 -0     playlistbrowseritem.cpp  
 M  +21 -4     smartplaylisteditor.cpp  


--- trunk/extragear/multimedia/amarok/src/playlistbrowseritem.cpp #621289:621290
@@ -3219,8 +3219,20 @@
                         filters[0].prepend( "./" );
                 qb.addFilter( table, value, filters[0], QueryBuilder::modeBeginMatch );
             }
+            else if ( condition == i18n( "does not start with" ) )
+            {
+                // need to take care of absolute paths
+                if ( field == "tags.url" )
+                    if ( filters[0].startsWith( "/" ) )
+                        filters[0].prepend( '.' );
+                    else if ( !filters[0].startsWith( "./" ) )
+                        filters[0].prepend( "./" );
+                qb.excludeFilter( table, value, filters[0], QueryBuilder::modeBeginMatch );
+            }
             else if ( condition == i18n( "ends with" ) )
                 qb.addFilter( table, value, filters[0], QueryBuilder::modeEndMatch );
+            else if ( condition == i18n( "does not end with" ) )
+                qb.excludeFilter( table, value, filters[0], QueryBuilder::modeEndMatch );
             else if ( condition == i18n( "is greater than") || condition == i18n( "is after" ) )
                 qb.addNumericFilter( table, value, filters[0], QueryBuilder::modeGreater );
             else if ( condition == i18n( "is smaller than") || condition == i18n( "is before" ) )
--- trunk/extragear/multimedia/amarok/src/smartplaylisteditor.cpp #621289:621290
@@ -10,6 +10,7 @@
 #include "debug.h"
 #include "collectiondb.h"
 #include "metabundle.h"
+#include "mountpointmanager.h"
 #include "smartplaylisteditor.h"
 
 #include <kcombobox.h>
@@ -714,8 +715,21 @@
         }
         searchCriteria += CollectionDB::likeCondition( value, false, true );
     }
+    else if( criteria == i18n("does not start with") )
+    {
+        if( field == "tags.url" )
+        {
+            if( value.startsWith( "/" ) )
+                value = '.' + value;
+            if( !value.startsWith( "./" ) )
+                value = "./" + value;
+        }
+        searchCriteria += " NOT " + CollectionDB::likeCondition( value, false, true );
+    }
     else if( criteria == i18n("ends with") )
         searchCriteria += CollectionDB::likeCondition( value, true, false );
+    else if( criteria == i18n("does not end with") )
+        searchCriteria += " NOT " + CollectionDB::likeCondition( value, true, false );
     else if( criteria == i18n("is greater than") || criteria == i18n("is after") )
         searchCriteria += " > " + value;
     else if( criteria == i18n("is smaller than") || criteria == i18n("is before" ) )
@@ -768,8 +782,8 @@
     loadEditWidgets();
     m_currentValueType = valueType;
 
-    //enable auto-completion for artist, album and genre
-    if( valueType == AutoCompletionString ) { //Artist, Composer, Album, Genre
+    //enable auto-completion for artist, album, composer, label, mountpoint and genre
+    if( valueType == AutoCompletionString ) {
         QStringList items;
         m_comboBox->clear();
         m_comboBox->completionObject()->clear();
@@ -783,6 +797,8 @@
            items = CollectionDB::instance()->albumList();
         else if (currentField == FLabel ) //label
             items = CollectionDB::instance()->labelList();
+        else if (currentField == FMountPoint ) //mount point
+            items = MountPointManager::instance()->collectionFolders();
         else  //genre
            items = CollectionDB::instance()->genreList();
 
@@ -953,7 +969,8 @@
         case String:
         case AutoCompletionString:
             items << i18n( "contains" ) << i18n( "does not contain" ) << i18n( "is" ) << i18n( "is not" )
-                  << i18n( "starts with" ) << i18n( "ends with" );
+                  << i18n( "starts with" ) << i18n( "does not start with" ) 
+                  << i18n( "ends with" ) << i18n( "does not end with" );
             break;
 
         case Rating:
@@ -992,12 +1009,12 @@
         case FAlbum:
         case FGenre:
         case FLabel:
+        case FMountPoint:
             valueType = AutoCompletionString;
             break;
         case FTitle:
         case FComment:
         case FFilePath:
-        case FMountPoint:
             valueType = String;
             break;
         case FLength:
Comment 2 Elias Probst 2007-01-08 18:55:13 UTC
Thank you for fixing it!
Will this go into 1.4.5?
I don't think it's overkill... I wouldn't have made a wish out of it, if I hadn't really needed it ;-)