Bug 136841 - dynamic playlist filter "length" useless
Summary: dynamic playlist filter "length" useless
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.4.4
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-04 20:19 UTC by Pit Garbe
Modified: 2006-11-05 12:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pit Garbe 2006-11-04 20:19:40 UTC
Version:           1.4.4 (using KDE KDE 3.5.5)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I wanted to make a dynamic playlist, that contains only tracks, that are longer than a specific length, say 30 minutes.

There is a filter for the tracklength. It can be set from 0 to 180, but there is no unit to select, like minutes, seconds, hours? So I pushed it to 180, but still lots and lots of songs where included in the playlist, with only 4 or 5 minutes playtime. So I guess the filter means 180 seconds. Which is very useless for me. Please add time units for people like me.
Thanks.
Comment 1 Maximilian Kossick 2006-11-05 12:53:59 UTC
SVN commit 602110 by mkossick:

make smart playlists based on track length more useful by adding a combobox for the used time 
unit:seconds, minutes or hours
BUG: 136841

 M  +19 -0     playlistbrowseritem.cpp  
 M  +74 -1     smartplaylisteditor.cpp  
 M  +2 -1      smartplaylisteditor.h  


--- trunk/extragear/multimedia/amarok/src/playlistbrowseritem.cpp #602109:602110
@@ -3306,7 +3306,26 @@
                 }
             }
 
+            if ( value & QueryBuilder::valLength ) {
+                QString period = criteria.attribute( "period" );
+                uint time1 = filters[0].toInt();
+                if ( period == "minutes" )
+                    time1 *= 60;
+                else if ( period == "hours" )
+                    time1 *= 3600;
+                filters[0] = QString::number( time1 );
+                if ( condition == i18n( "is between" ) )
+                {
+                    uint time2 = filters[1].toInt();
+                    if ( period == "minutes" )
+                        time2 *= 60;
+                    else if ( period == "hours" )
+                        time2 *= 3600;
+                    filters[1] = QString::number( time2 );
+                }
+            }
 
+
             if ( condition == i18n( "contains" ) )
                 qb.addFilter( table, value, filters[0] );
             else if ( condition == i18n( "does not contain" ) )
--- trunk/extragear/multimedia/amarok/src/smartplaylisteditor.cpp #602109:602110
@@ -633,7 +633,7 @@
                 if( condition == i18n("is in the last") || condition == i18n("is not in the last") ) {
                     m_intSpinBox1->setValue( values.first().toInt() );
                     QString period = criteria.attribute("period");
-                    if (period=="days")
+                    if (period=="days" || period.isEmpty() )
                         m_dateCombo->setCurrentItem(0);
                     else if (period=="months")
                         m_dateCombo->setCurrentItem(1);
@@ -651,6 +651,20 @@
                 }
                 break;
             }
+            case Length:
+            {
+                m_intSpinBox1->setValue( values.first().toInt() );
+                if( condition == i18n("is between") )
+                    m_intSpinBox2->setValue( values.last().toInt() );
+                QString period = criteria.attribute( "period" );
+                if ( period == "seconds" || period.isEmpty() ) //for compatibility
+                    m_lengthCombo->setCurrentItem( 0 );
+                else if ( period == "minutes" )
+                    m_lengthCombo->setCurrentItem( 1 );
+                else
+                    m_lengthCombo->setCurrentItem( 2 );
+                break;
+            }
             default: ;
         };
     }
@@ -710,6 +724,16 @@
             }
             break;
          }
+         case Length:
+         {
+            values << QString::number( m_intSpinBox1->value() );
+            // 0 = seconds, 1=minutes, 2=hours
+            criteria.setAttribute( "period", !m_lengthCombo->currentItem() ? "seconds" : (m_lengthCombo->currentItem() == 1 ? "minutes" : "hours") );
+            if( condition == i18n( "is between" ) ) {
+                values << QString::number( m_intSpinBox2->value() );
+            }
+            break;
+         }
          default: ;
     }
     foreach( values ) {
@@ -779,6 +803,30 @@
             }
             break;
         }
+        case Length:
+        {
+            int n = m_intSpinBox1->value();
+            int time;
+            if( m_lengthCombo->currentItem() == 0 ) //seconds
+                time = n;
+            else if( m_lengthCombo->currentItem() == 1 ) //minutes
+                time = 60*n;
+            else
+                time = 3600*n; //hours
+            value = QString::number( time );
+            if( criteria == i18n("is between")  ) {
+                int n2 = m_intSpinBox2->value();
+                int time2;
+                if( m_lengthCombo->currentItem() == 0 ) //seconds
+                    time2 = n2;
+                else if( m_lengthCombo->currentItem() == 1 ) //minutes
+                    time2 = 60*n2;
+                else
+                    time2 = 3600*n2; //hours
+                value += " AND " + QString::number( time2 );
+            }
+            break;
+        }
         default: ;
     };
 
@@ -1016,6 +1064,28 @@
             break;
         }
 
+        case Length:
+        {
+            m_intSpinBox1 = new KIntSpinBox( m_editBox );
+            int maxValue = 1000;
+            m_intSpinBox1->setMaxValue( maxValue );
+            m_intSpinBox1->setFocus();
+            m_intSpinBox1->show();
+            if( m_criteriaCombo->currentText() == i18n("is between") ) {
+                m_rangeLabel = new QLabel( i18n("and"), m_editBox );
+                m_rangeLabel->setAlignment( AlignCenter );
+                m_rangeLabel->show();
+                m_intSpinBox2 = new KIntSpinBox( m_editBox );
+                m_intSpinBox2->setMaxValue( maxValue );
+                m_intSpinBox2->show();
+            }
+            m_lengthCombo = new KComboBox( m_editBox );
+            m_lengthCombo->insertItem( i18n( "Seconds" ) );
+            m_lengthCombo->insertItem( i18n( "Minutes" ) );
+            m_lengthCombo->insertItem( i18n( "Hours" ) );
+            m_lengthCombo->show();
+        }
+
         default: ;
     };
 
@@ -1037,6 +1107,7 @@
             break;
 
         case Rating:
+        case Length:
         case Number:
             items << i18n( "is" ) << i18n( "is not" ) << i18n( "is greater than" ) << i18n( "is smaller than" )
                   << i18n( "is between" );
@@ -1080,6 +1151,8 @@
             valueType = String;
             break;
         case FLength:
+            valueType = Length;
+            break;
         case FTrack:
         case FScore:
         case FPlayCounter:
--- trunk/extragear/multimedia/amarok/src/smartplaylisteditor.h #602109:602110
@@ -106,7 +106,7 @@
         void loadEditWidgets();
 
     private:
-        enum ValueType { String, AutoCompletionString, Number, Year, Date, Rating };
+        enum ValueType { String, AutoCompletionString, Number, Year, Date, Rating, Length };
 
         void loadCriteriaList( int valueType, QString condition = QString::null );
         int getValueType( int fieldIndex );
@@ -133,6 +133,7 @@
         QDateEdit *m_dateEdit2;
         KComboBox *m_dateCombo;
         QLabel *m_rangeLabel;
+	KComboBox *m_lengthCombo;
 };
 
 inline int