diff options
Diffstat (limited to 'amarok/src/collectiondb.h')
-rw-r--r-- | amarok/src/collectiondb.h | 174 |
1 files changed, 91 insertions, 83 deletions
diff --git a/amarok/src/collectiondb.h b/amarok/src/collectiondb.h index ab38b6cb..3c96538c 100644 --- a/amarok/src/collectiondb.h +++ b/amarok/src/collectiondb.h @@ -195,6 +195,7 @@ class PostgresqlConnection : public DbConnection class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver { Q_OBJECT + TQ_OBJECT friend class SimilarArtistsInsertionJob; @@ -246,9 +247,9 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver #ifdef USE_MYSQL // We have to escape "\" for mysql, but can't do so for sqlite ( m_dbConnType == DbConnection::mysql ) - ? string.replace("\\", "\\\\").replace( '\'', "''" ) : + ? string.tqreplace("\\", "\\\\").tqreplace( '\'', "''" ) : #endif - string.replace( '\'', "''" ); + string.tqreplace( '\'', "''" ); } TQString boolT() const { if (getDbConnectionType() == DbConnection::postgresql) return "true"; else return "1"; } @@ -256,13 +257,13 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver inline bool boolFromSql( const TQString &b ) { return ( b == boolT() || b == "t" ); } //textColumnType should be used for normal strings, which need to be compared //either case-sensitively or -insensitively - TQString textColumnType( int length=255 ) const { if ( getDbConnectionType() == DbConnection::postgresql ) return "TEXT"; else return TQString("VARCHAR(%1)").arg(length); } + TQString textColumnType( int length=255 ) const { if ( getDbConnectionType() == DbConnection::postgresql ) return "TEXT"; else return TQString("VARCHAR(%1)").tqarg(length); } //exactTextColumnType should be used for strings that must be stored exactly, such //as URLs (necessary for holding control chars etc. if present in URL), except for //trailing spaces. Comparisions should always be done case-sensitively. //As we create indices on these columns, we have to restrict them to //<= 255 chars for mysql < 5.0.3 - TQString exactTextColumnType( int length=1024 ) const { if ( getDbConnectionType() == DbConnection::mysql ) return TQString( "VARBINARY(%1)" ).arg( length>255 ? 255 : length ); else return textColumnType( length ); } + TQString exactTextColumnType( int length=1024 ) const { if ( getDbConnectionType() == DbConnection::mysql ) return TQString( "VARBINARY(%1)" ).tqarg( length>255 ? 255 : length ); else return textColumnType( length ); } // We might consider using LONGTEXT type, as some lyrics could be VERY long..??? TQString longTextColumnType() const { if ( getDbConnectionType() == DbConnection::postgresql ) return "TEXT"; else return "TEXT"; } TQString randomFunc() const { if ( getDbConnectionType() == DbConnection::postgresql ) return "random()"; else return "RAND()"; } @@ -328,10 +329,10 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver void aftCheckPermanentTables( const TQString &currdeviceid, const TQString &currid, const TQString &currurl ); void doAFTStuff( MetaBundle *bundle, const bool tempTables = true ); void emitFileAdded( const TQString &absPath, - const TQString &uniqueid = TQString::null ); + const TQString &uniqueid = TQString() ); void emitFilesAdded( const TQMap<TQString,TQString> &map ) { emit filesAdded( map ); } void emitFileDeleted( const TQString &absPath, - const TQString &uniqueid = TQString::null ); + const TQString &uniqueid = TQString() ); bool newUniqueIdForFile( const TQString &path ); bool removeUniqueIdFromFile( const TQString &path ); TQString urlFromUniqueId( const TQString &id ); @@ -340,20 +341,20 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver //podcast methods /// Insert a podcast channel into the database. If @param replace is true, replace the row /// use updatePodcastChannel() always in preference - bool addPodcastChannel( const PodcastChannelBundle &pcb, const bool &replace=false ); + bool addPodcastChannel( const PodcastChannelBundle &pcb, const bool &tqreplace=false ); /// Insert a podcast episode into the database. If @param idToUpdate is provided, replace the row /// use updatePodcastEpisode() always in preference int addPodcastEpisode( const PodcastEpisodeBundle &episode, const int idToUpdate=0 ); - int addPodcastFolder( const TQString &name, const int parent_id=0, const bool isOpen=false ); + int addPodcastFolder( const TQString &name, const int tqparent_id=0, const bool isOpen=false ); TQValueList<PodcastChannelBundle> getPodcastChannels(); PodcastEpisodeBundle getPodcastEpisodeById( int id ); - TQValueList<PodcastEpisodeBundle> getPodcastEpisodes( const KURL &parent, bool newOnly=false, int limit=-1 ); + TQValueList<PodcastEpisodeBundle> getPodcastEpisodes( const KURL &tqparent, bool newOnly=false, int limit=-1 ); void removePodcastChannel( const KURL &url ); // will remove all episodes too void removePodcastEpisode( const int id ); void removePodcastFolder( const int id ); void updatePodcastChannel( const PodcastChannelBundle &b ); void updatePodcastEpisode( const int id, const PodcastEpisodeBundle &b ); - void updatePodcastFolder( const int folder_id, const TQString &name, const int parent_id=0, const bool isOpen=false ); + void updatePodcastFolder( const int folder_id, const TQString &name, const int tqparent_id=0, const bool isOpen=false ); // these return false when no bundle was available bool getPodcastChannelBundle( const KURL &url, PodcastChannelBundle *channel ); bool getPodcastEpisodeBundle( const KURL &url, PodcastEpisodeBundle *channel ); @@ -434,7 +435,7 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver /** Saves images located on the user's filesystem */ bool setAlbumImage( const TQString& artist, const TQString& album, const KURL& url ); /** Saves images obtained from CoverFetcher */ - bool setAlbumImage( const TQString& artist, const TQString& album, TQImage img, const TQString& amazonUrl = TQString::null, const TQString& asin = TQString::null ); + bool setAlbumImage( const TQString& artist, const TQString& album, TQImage img, const TQString& amazonUrl = TQString(), const TQString& asin = TQString() ); TQString findAmazonImage( const TQString &artist, const TQString &album, const uint width = 1 ); TQString findDirectoryImage( const TQString& artist, const TQString& album, uint width = 0 ); @@ -442,8 +443,8 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver TQString findMetaBundleImage( const MetaBundle &trackInformation, const uint = 1 ); /// ensure the sql only return urls to tracks for efficiency - static TQPixmap createDragPixmapFromSQL( const TQString &sql, TQString textOverRide=TQString::null ); - static TQPixmap createDragPixmap( const KURL::List &urls, TQString textOverRide=TQString::null ); + static TQPixmap createDragPixmapFromSQL( const TQString &sql, TQString textOverRide=TQString() ); + static TQPixmap createDragPixmap( const KURL::List &urls, TQString textOverRide=TQString() ); static const int DRAGPIXMAP_OFFSET_X = -12; static const int DRAGPIXMAP_OFFSET_Y = -28; @@ -472,7 +473,7 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver static TQString makeShadowedImage( const TQString& albumImage, bool cache = true ); //local cover methods - void addImageToAlbum( const TQString& image, TQValueList< QPair<TQString, TQString> > info, const bool temporary ); + void addImageToAlbum( const TQString& image, TQValueList< TQPair<TQString, TQString> > info, const bool temporary ); TQString notAvailCover( const bool withShadow = false, int width = 1 ); //embedded cover methods @@ -481,7 +482,7 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver void applySettings(); - void setLyrics( const TQString& url, const TQString& lyrics, const TQString &uniqueid = TQString::null ); + void setLyrics( const TQString& url, const TQString& lyrics, const TQString &uniqueid = TQString() ); TQString getLyrics( const TQString& url ); /** Remove from the amazon table the item with the specified md5sum **/ @@ -493,7 +494,7 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver bool isConnected(); void releasePreviousConnection(TQThread *currThread); - void invalidateArtistAlbumCache() { m_validArtistCache=false; m_validComposerCache=false; m_validAlbumCache=false; }; + void tqinvalidateArtistAlbumCache() { m_validArtistCache=false; m_validComposerCache=false; m_validAlbumCache=false; }; void vacuum(); @@ -503,13 +504,13 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver void cancelMovingFileJob(); protected: - TQCString md5sum( const TQString& artist, const TQString& album, const TQString& file = TQString::null ); + TQCString md5sum( const TQString& artist, const TQString& album, const TQString& file = TQString() ); void engineTrackEnded( int finalPosition, int trackLength, const TQString &reason ); /** Manages regular folder monitoring scan */ void timerEvent( TQTimerEvent* e ); public slots: - void fetchCover( TQWidget* parent, const TQString& artist, const TQString& album, bool noedit, TQListViewItem* item = 0 ); + void fetchCover( TQWidget* tqparent, const TQString& artist, const TQString& album, bool noedit, TQListViewItem* item = 0 ); void scanMonitor(); void startScan(); void stopScan(); @@ -645,12 +646,19 @@ class LIBAMAROK_EXPORT CollectionDB : public TQObject, public EngineObserver TQMutex m_mutex; }; +#ifdef Q_MOC_RUN +// MOC_SKIP_BEGIN +class INotify : public JobBase +// MOC_SKIP_END +#else // Q_MOC_RUN class INotify : public ThreadManager::DependentJob +#endif // Q_MOC_RUN { Q_OBJECT + TQ_OBJECT public: - INotify( CollectionDB *parent, int fd ); + INotify( CollectionDB *tqparent, int fd ); ~INotify(); static INotify *instance() { return s_instance; } @@ -661,7 +669,7 @@ class INotify : public ThreadManager::DependentJob private: virtual bool doJob(); - CollectionDB* m_parent; + CollectionDB* m_tqparent; int m_fd; static INotify* s_instance; @@ -681,53 +689,53 @@ class QueryBuilder optRandomize = 8, optShowAll = 16 /* get all songs, not just mounted ones */ }; /* This has been an enum in the past, but 32 bits wasn't enough anymore :-( */ - static const Q_INT64 valDummy = 0; - static const Q_INT64 valID = 1LL << 0; - static const Q_INT64 valName = 1LL << 1; - static const Q_INT64 valURL = 1LL << 2; - static const Q_INT64 valTitle = 1LL << 3; - static const Q_INT64 valTrack = 1LL << 4; - static const Q_INT64 valScore = 1LL << 5; - static const Q_INT64 valComment = 1LL << 6; - static const Q_INT64 valBitrate = 1LL << 7; - static const Q_INT64 valLength = 1LL << 8; - static const Q_INT64 valSamplerate = 1LL << 9; - static const Q_INT64 valPlayCounter = 1LL << 10; - static const Q_INT64 valCreateDate = 1LL << 11; - static const Q_INT64 valAccessDate = 1LL << 12; - //static const Q_INT64 valPercentage = 1LL << 13; // same as valScore - static const Q_INT64 valArtistID = 1LL << 14; - static const Q_INT64 valAlbumID = 1LL << 15; - static const Q_INT64 valYearID = 1LL << 16; - static const Q_INT64 valGenreID = 1LL << 17; - static const Q_INT64 valDirectory = 1LL << 18; - static const Q_INT64 valLyrics = 1LL << 19; - static const Q_INT64 valRating = 1LL << 20; - static const Q_INT64 valComposerID = 1LL << 21; - static const Q_INT64 valDiscNumber = 1LL << 22; - static const Q_INT64 valFilesize = 1LL << 23; - static const Q_INT64 valFileType = 1LL << 24; - static const Q_INT64 valIsCompilation = 1LL << 25; - static const Q_INT64 valBPM = 1LL << 26; + static const TQ_INT64 valDummy = 0; + static const TQ_INT64 valID = 1LL << 0; + static const TQ_INT64 valName = 1LL << 1; + static const TQ_INT64 valURL = 1LL << 2; + static const TQ_INT64 valTitle = 1LL << 3; + static const TQ_INT64 valTrack = 1LL << 4; + static const TQ_INT64 valScore = 1LL << 5; + static const TQ_INT64 valComment = 1LL << 6; + static const TQ_INT64 valBitrate = 1LL << 7; + static const TQ_INT64 valLength = 1LL << 8; + static const TQ_INT64 valSamplerate = 1LL << 9; + static const TQ_INT64 valPlayCounter = 1LL << 10; + static const TQ_INT64 valCreateDate = 1LL << 11; + static const TQ_INT64 valAccessDate = 1LL << 12; + //static const TQ_INT64 valPercentage = 1LL << 13; // same as valScore + static const TQ_INT64 valArtistID = 1LL << 14; + static const TQ_INT64 valAlbumID = 1LL << 15; + static const TQ_INT64 valYearID = 1LL << 16; + static const TQ_INT64 valGenreID = 1LL << 17; + static const TQ_INT64 valDirectory = 1LL << 18; + static const TQ_INT64 valLyrics = 1LL << 19; + static const TQ_INT64 valRating = 1LL << 20; + static const TQ_INT64 valComposerID = 1LL << 21; + static const TQ_INT64 valDiscNumber = 1LL << 22; + static const TQ_INT64 valFilesize = 1LL << 23; + static const TQ_INT64 valFileType = 1LL << 24; + static const TQ_INT64 valIsCompilation = 1LL << 25; + static const TQ_INT64 valBPM = 1LL << 26; // podcast relevant: - static const Q_INT64 valCopyright = 1LL << 27; - static const Q_INT64 valParent = 1LL << 28; - static const Q_INT64 valWeblink = 1LL << 29; - static const Q_INT64 valAutoscan = 1LL << 30; - static const Q_INT64 valFetchtype = 1LL << 31; - static const Q_INT64 valAutotransfer = 1LL << 32; - static const Q_INT64 valPurge = 1LL << 33; - static const Q_INT64 valPurgeCount = 1LL << 34; - static const Q_INT64 valIsNew = 1LL << 35; + static const TQ_INT64 valCopyright = 1LL << 27; + static const TQ_INT64 valParent = 1LL << 28; + static const TQ_INT64 valWeblink = 1LL << 29; + static const TQ_INT64 valAutoscan = 1LL << 30; + static const TQ_INT64 valFetchtype = 1LL << 31; + static const TQ_INT64 valAutotransfer = 1LL << 32; + static const TQ_INT64 valPurge = 1LL << 33; + static const TQ_INT64 valPurgeCount = 1LL << 34; + static const TQ_INT64 valIsNew = 1LL << 35; // dynamic collection relevant: - static const Q_INT64 valDeviceId = 1LL << 36; - static const Q_INT64 valRelativePath = 1LL << 37; - static const Q_INT64 valDeviceLabel = 1LL << 38; - static const Q_INT64 valMountPoint = 1LL << 39; + static const TQ_INT64 valDeviceId = 1LL << 36; + static const TQ_INT64 valRelativePath = 1LL << 37; + static const TQ_INT64 valDeviceLabel = 1LL << 38; + static const TQ_INT64 valMountPoint = 1LL << 39; //label relevant - static const Q_INT64 valType = 1LL << 40; + static const TQ_INT64 valType = 1LL << 40; - static Q_INT64 valForFavoriteSorting(); + static TQ_INT64 valForFavoriteSorting(); void sortByFavorite(); // sortByFavoriteAvg() add the average rating, if enabled, the average score, if enabled, @@ -742,8 +750,8 @@ class QueryBuilder QueryBuilder(); - void addReturnValue( int table, Q_INT64 value, bool caseSensitive = false /* unless value refers to a string */ ); - void addReturnFunctionValue( int function, int table, Q_INT64 value); + void addReturnValue( int table, TQ_INT64 value, bool caseSensitive = false /* unless value refers to a string */ ); + void addReturnFunctionValue( int function, int table, TQ_INT64 value); uint countReturnValues(); // Note: the filter chain begins in AND mode @@ -757,30 +765,30 @@ class QueryBuilder void addURLFilters( const TQStringList& filter ); void addFilter( int tables, const TQString& filter); - void addFilter( int tables, Q_INT64 value, const TQString& filter, int mode = modeNormal, bool exact = false ); + void addFilter( int tables, TQ_INT64 value, const TQString& filter, int mode = modeNormal, bool exact = false ); void addFilters( int tables, const TQStringList& filter ); void excludeFilter( int tables, const TQString& filter ); - void excludeFilter( int tables, Q_INT64 value, const TQString& filter, int mode = modeNormal, bool exact = false ); + void excludeFilter( int tables, TQ_INT64 value, const TQString& filter, int mode = modeNormal, bool exact = false ); void addMatch( int tables, const TQString& match, bool interpretUnknown = true, bool caseSensitive = true ); - void addMatch( int tables, Q_INT64 value, const TQString& match, bool interpretUnknown = true, bool caseSensitive = true ); + void addMatch( int tables, TQ_INT64 value, const TQString& match, bool interpretUnknown = true, bool caseSensitive = true ); void addMatches( int tables, const TQStringList& match, bool interpretUnknown = true, bool caseSensitive = true ); void excludeMatch( int tables, const TQString& match ); - void having( int table, Q_INT64 value, int function, int mode, const TQString& match ); + void having( int table, TQ_INT64 value, int function, int mode, const TQString& match ); - void exclusiveFilter( int tableMatching, int tableNotMatching, Q_INT64 value ); + void exclusiveFilter( int tableMatching, int tableNotMatching, TQ_INT64 value ); // For numeric filters: // modeNormal means strict equality; modeBeginMatch and modeEndMatch are not // allowed; modeBetween needs a second value endRange - void addNumericFilter(int tables, Q_INT64 value, const TQString &n, + void addNumericFilter(int tables, TQ_INT64 value, const TQString &n, int mode = modeNormal, - const TQString &endRange = TQString::null); + const TQString &endRange = TQString()); void setOptions( int options ); - void sortBy( int table, Q_INT64 value, bool descending = false ); - void sortByFunction( int function, int table, Q_INT64 value, bool descending = false ); - void groupBy( int table, Q_INT64 value ); + void sortBy( int table, TQ_INT64 value, bool descending = false ); + void sortByFunction( int function, int table, TQ_INT64 value, bool descending = false ); + void groupBy( int table, TQ_INT64 value ); void setLimit( int startPos, int length ); // Returns the results in random order. @@ -788,16 +796,16 @@ class QueryBuilder // that field. // The shuffle is cumulative with other sorts, but any sorts after this are // pointless because of the precision of the random function. - void shuffle( int table = 0, Q_INT64 value = 0 ); + void shuffle( int table = 0, TQ_INT64 value = 0 ); static const int dragFieldCount; - static TQString dragSQLFields(); - void initSQLDrag(); + static TQString dragSTQLFields(); + void initSTQLDrag(); void buildQuery( bool withDeviceidPlaceholder = false ); TQString getQuery(); //use withDeviceidPlaceholder = false if the query isn't run immediately (*CurrentTimeT*) - //and replace (*MountedDeviceSelection*) with CollectionDB::instance()->deviceIdSelection() + //and tqreplace (*MountedDeviceSelection*) with CollectionDB::instance()->deviceIdSelection() TQString query( bool withDeviceidPlaceholder = false ) { buildQuery( withDeviceidPlaceholder ); return m_query; }; void clear(); @@ -805,16 +813,16 @@ class QueryBuilder // Transform a string table.value "field" into enum values // @return true if we succeeded - bool getField(const TQString &tableValue, int *table, Q_INT64 *value); + bool getField(const TQString &tableValue, int *table, TQ_INT64 *value); private: TQString tableName( int table ); - const TQString &valueName( Q_INT64 value ); + const TQString &valueName( TQ_INT64 value ); TQString functionName( int functions ); - bool coalesceField( int table, Q_INT64 value ); + bool coalesceField( int table, TQ_INT64 value ); int getTableByName(const TQString &name); - Q_INT64 getValueByName(const TQString &field); + TQ_INT64 getValueByName(const TQString &field); TQStringList cleanURL( TQStringList result ); |