itunesdb::SmartPlaylistRuleSet Class Reference

#include <smartplaylistrules.h>

Inheritance diagram for itunesdb::SmartPlaylistRuleSet:

ITunesDBSPLRuleSet List of all members.

Public Member Functions

virtual bool addStringRule (SPLStringField field, SPLStringAction action, const QString &testString, int position=-1)
virtual bool addUIntRule (SPLUIntField field, SPLUIntAction action, Q_UINT64 fromValue, Q_UINT64 toValue, Q_INT64 fromDate, Q_INT64 toDate, Q_UINT64 fromUnits, Q_UINT64 toUnits, int position=-1)
bool addUIntRule (SPLUIntField field, SPLUIntAction action, Q_UINT64 fromValue, Q_UINT64 toValue, int position=-1)
bool addInTheLastRule (SPLUIntField field, bool negateRule, Q_INT64 value, Q_UINT64 units, int position=-1)
const SmartPlaylistRulegetRuleAt (uint position)
bool removeRuleAt (uint position)
void clear ()
bool isLiveUpdate () const
void setLiveUpdateFlag (bool liveupdate)
bool isCheckRules () const
void setCheckRulesFlag (bool checkRules)
bool isCheckLimits () const
virtual void setLimits (SPLLimitSort limitSort, SPLLimitType limitType, Q_UINT32 limitValue)
void enableLimits (bool enable)
SPLLimitSort getLimitSort () const
SPLLimitType getLimitType () const
bool isMatchAny () const
void setMatchAnyFlag (bool matchAny)
bool checkedTracksOnly () const
void setCheckedTracksOnlyFlag (bool checkedOnly)
const RuleList & getRules () const
uint getNumRules () const
QString toString () const

Protected Member Functions

 SmartPlaylistRuleSet (const SmartPlaylistRuleSet &src)
uint readRules (QDataStream &instream, uint length)
bool readHeader (QDataStream &instream, uint length)
uint writeRules (QDataStream &outstream) const
uint writeHeader (QDataStream &outstream) const
virtual SmartPlaylistRulecreateStringRule (SPLStringField field, SPLStringAction action, const QString &testString)
virtual SmartPlaylistRulecreateUIntRule (SPLUIntField field, SPLUIntAction action, Q_UINT64 fromValue, Q_UINT64 toValue, Q_INT64 fromDate, Q_INT64 toDate, Q_UINT64 fromUnits, Q_UINT64 toUnits)

Protected Attributes

bool mMatchAny
Q_UINT32 unk5
Q_UINT8 mLiveUpdate
Q_UINT8 mCheckLimits
Q_UINT8 mCheckRules
Q_UINT8 mCheckedOnly
Q_UINT8 mReverseLimitSort
SPLLimitSort mLimitSort
SPLLimitType mLimitType
Q_UINT32 mLimitValue
RuleList mRules

Friends

class Playlist

Detailed Description

This class represents all the rules, limits and switches making up a Smart Playlist. Here is an example on how to create a "recently played" Smart Playlist:

  // enable smart playlist behaviour and get the ruleset
  SmartPlaylistRuleSet& ruleSet = a_playlist_ptr->enableSmartPlaylist();

  // add the rule "last played in the last 2 weeks"
  ruleSet.addInTheLastRule( FIELD_LASTPLAYED, false, -2, IN_THE_LAST_WEEKS );

  // limit to the first 30 songs, sorted by last played date
  ruleSet.setLimits( LIMIT_SORT_LASTPLAYED, LIMIT_TYPE_SONGS, 30 );

  // match ANY rule (doesn't really matter since we only have one rule)
  ruleSet.setMatchAnyFlag( true );

  // enable live update (updates the playlist on the go)
  ruleSet.setLiveUpdateFlag( true );
 


Member Function Documentation

bool itunesdb::SmartPlaylistRuleSet::addStringRule ( SPLStringField  field,
SPLStringAction  action,
const QString &  testString,
int  position = -1 
) [virtual]

Adds a string based rule to the rule set and returns true if successful.

Parameters:
field field ID to identify the track field in question
action the compare operation to use when comparing the field with testString
testString the String to compare the field with
position the position the rule will be inserted to the rule set. Set to -1 to append the rule to the end

Reimplemented in ITunesDBSPLRuleSet.

bool itunesdb::SmartPlaylistRuleSet::addUIntRule ( SPLUIntField  field,
SPLUIntAction  action,
Q_UINT64  fromValue,
Q_UINT64  toValue,
Q_INT64  fromDate,
Q_INT64  toDate,
Q_UINT64  fromUnits,
Q_UINT64  toUnits,
int  position = -1 
) [virtual]

Adds a uint based rule to the rule set and returns true if successful.
For rules with plain integer type fields like BPM, rating or play count the from and to values need to be set to the range or value you care about. See addUIntRule( SPLUIntField, SPLUIntAction, Q_UINT64, Q_UINT64) for a simpler way to achieve this.
For timestamp type rules like "last played in the last 2 weeks" you need to set the from and to values to the offset of the time range to care about, or to SPL_VALUE_NOW if the desired date offset is "now". The from and to values declare the time range and the units the time is measured in.
Now, if you need to declare the aforementioned rule you set the time range [from-to] to ["now - 2 weeks" - "now"] by setting both the from and to values to SPL_VALUE_NOW, set the fromDate to -2 the to date to 0 and the units to IN_THE_LAST_WEEKS as fromUnits and 1 as toUnits.

See also:
addInTheLastRule() for a better way to create these kinda rules.

http://ipodlinux.org/ITunesDB#Smart_Playlist_Rules for more details

Parameters:
field field ID to identify the track field in question
action the compare operation to use
fromValue the "from" value
toValue the "to" value
fromDate the "from" date
toDate the "to" date
fromUnits the units the from value is measured in (fromValue gets multiplied with the units)
toUnits the units the to value is measured in (toValue gets multiplied with the units)
position the position the rule will be inserted to the rule set. Set to -1 to append the rule to the end

Reimplemented in ITunesDBSPLRuleSet.

bool itunesdb::SmartPlaylistRuleSet::addUIntRule ( SPLUIntField  field,
SPLUIntAction  action,
Q_UINT64  fromValue,
Q_UINT64  toValue,
int  position = -1 
) [inline]

Convenience method. This creates a UInt based rule setting the from and to values as provided and using sane defaults for the rest.

Parameters:
field field ID to identify the track field in question
action the compare operation to use
fromValue the "from" value
toValue the "to" value
position the position the rule will be inserted to the rule set. Set to -1 to append the rule to the end

bool itunesdb::SmartPlaylistRuleSet::addInTheLastRule ( SPLUIntField  field,
bool  negateRule,
Q_INT64  value,
Q_UINT64  units,
int  position = -1 
) [inline]

Convenience method. This creates a UInt based "In The Last" rule with the given parameters

Parameters:
field field ID, to identify the field in question.
negateRule if true, this negates the rule to "Not In The Last"
value the time to evaluate; like in the last [WEEKS|DAYS|HOURS|etc]
units the units the value is mesaured in; base is seconds. The Predefined values IN_THE_LAST_[SECONDS|DAYS|WEEKS] may be used
position the position the rule will be inserted to the rule set. Set to -1 to append the rule to the end

const SmartPlaylistRule* itunesdb::SmartPlaylistRuleSet::getRuleAt ( uint  position  )  [inline]

Returns the Rule at the specified position or NULL if no such rule exists.

Parameters:
position the position
Returns:
the rule at the position or NULL.

bool itunesdb::SmartPlaylistRuleSet::removeRuleAt ( uint  position  ) 

Removes the rule at the specified position. The list will be compacted, so all the rules after the rule to be removed will be moved one position towards the start of the list.

Parameters:
position the position to remove the rule from
Returns:
true if the operation was successfull, false otherwise.

void itunesdb::SmartPlaylistRuleSet::clear (  ) 

Removes all the rule from this RuleSet

bool itunesdb::SmartPlaylistRuleSet::isLiveUpdate (  )  const [inline]

Returns true if the playlist may be updated by the iPod itself.

void itunesdb::SmartPlaylistRuleSet::setLiveUpdateFlag ( bool  liveupdate  ) 

Sets the live update flag.

bool itunesdb::SmartPlaylistRuleSet::isCheckRules (  )  const [inline]

Returns true if the smart playlist checks the rules

void itunesdb::SmartPlaylistRuleSet::setCheckRulesFlag ( bool  checkRules  ) 

Set the checkRules flag.

bool itunesdb::SmartPlaylistRuleSet::isCheckLimits (  )  const [inline]

Returns true if the limits will/need_to be checked

void itunesdb::SmartPlaylistRuleSet::setLimits ( SPLLimitSort  limitSort,
SPLLimitType  limitType,
Q_UINT32  limitValue 
) [virtual]

Sets the limit for this smart playlist and enable limit checking

void itunesdb::SmartPlaylistRuleSet::enableLimits ( bool  enable  ) 

enables or disables limit checking.

SPLLimitSort itunesdb::SmartPlaylistRuleSet::getLimitSort (  )  const [inline]

returns the limit sort field

SPLLimitType itunesdb::SmartPlaylistRuleSet::getLimitType (  )  const [inline]

Returns the limit type

bool itunesdb::SmartPlaylistRuleSet::isMatchAny (  )  const [inline]

Returns true if only one rule needs to match.

void itunesdb::SmartPlaylistRuleSet::setMatchAnyFlag ( bool  matchAny  ) 

Sets the "match any" flag

bool itunesdb::SmartPlaylistRuleSet::checkedTracksOnly (  )  const [inline]

Returns true if only "checked" tracks should be matched against the rules.

void itunesdb::SmartPlaylistRuleSet::setCheckedTracksOnlyFlag ( bool  checkedOnly  ) 

sets the checkedTracksOnlyFlag.

Parameters:
checkedOnly If set to true only "checked" tracks should be matched against the rules.

const itunesdb::RuleList & itunesdb::SmartPlaylistRuleSet::getRules (  )  const

Returns the rules making up this smart playlist rule set.

uint itunesdb::SmartPlaylistRuleSet::getNumRules (  )  const

Returns the number of rules

QString itunesdb::SmartPlaylistRuleSet::toString (  )  const

Returns a String representation of this rule set.

uint itunesdb::SmartPlaylistRuleSet::readRules ( QDataStream &  instream,
uint  length 
) [protected]

read Rules from type 51 MHOD data, starting at SLst and returns the number of rules read

Parameters:
instream the stream to read from positioned at the MHOD data
length the MHOD data length in bytes (blocklen - headerlen)
Returns:
the number of rules read from the stream

bool itunesdb::SmartPlaylistRuleSet::readHeader ( QDataStream &  instream,
uint  length 
) [protected]

reads the SPL Header from a type 50 MHOD and returns if the operation succeeded.

Parameters:
instream the stream to read from positioned at the MHOD data
length the MHOD data length in bytes (blocklen - headerlen)
Returns:
true if the header got read successfully, false otherwise

uint itunesdb::SmartPlaylistRuleSet::writeRules ( QDataStream &  outstream  )  const [protected]

Writes the rules back to the stream and returns the number of bytes written.

Parameters:
outstream the stream to write the MHOD51 data to.
Returns:
the number of bytes written

uint itunesdb::SmartPlaylistRuleSet::writeHeader ( QDataStream &  outstream  )  const [protected]

Writes the header to the stream as a type 50 MHOD and returns the number of bytes written.

Parameters:
outstream the stream to write the MHOD50 data to.
Returns:
the number of bytes written


The documentation for this class was generated from the following files:
Generated on Tue Dec 12 16:39:27 2006 for libqtpod.kdevelop by  doxygen 1.5.1