summaryrefslogtreecommitdiffstats
path: root/juk/covermanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:43:15 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:43:15 +0000
commite654398e46e37abf457b2b1122ab898d2c51c49f (patch)
treed39ee6440f3c3663c3ead84a2d4cc2d034667e96 /juk/covermanager.cpp
parente4f29b18e19394b9352f52a6c0d0d0e3932cf511 (diff)
downloadtdemultimedia-e654398e46e37abf457b2b1122ab898d2c51c49f.tar.gz
tdemultimedia-e654398e46e37abf457b2b1122ab898d2c51c49f.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1157644 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'juk/covermanager.cpp')
-rw-r--r--juk/covermanager.cpp142
1 files changed, 71 insertions, 71 deletions
diff --git a/juk/covermanager.cpp b/juk/covermanager.cpp
index 1fe36cc4..f7530daa 100644
--- a/juk/covermanager.cpp
+++ b/juk/covermanager.cpp
@@ -13,17 +13,17 @@
* *
***************************************************************************/
-#include <qpixmap.h>
-#include <qmap.h>
-#include <qstring.h>
-#include <qfile.h>
-#include <qimage.h>
-#include <qdir.h>
-#include <qdatastream.h>
-#include <qdict.h>
-#include <qcache.h>
-#include <qmime.h>
-#include <qbuffer.h>
+#include <tqpixmap.h>
+#include <tqmap.h>
+#include <tqstring.h>
+#include <tqfile.h>
+#include <tqimage.h>
+#include <tqdir.h>
+#include <tqdatastream.h>
+#include <tqdict.h>
+#include <tqcache.h>
+#include <tqmime.h>
+#include <tqbuffer.h>
#include <kdebug.h>
#include <kstaticdeleter.h>
@@ -35,7 +35,7 @@
// This is a dictionary to map the track path to their ID. Otherwise we'd have
// to store this info with each CollectionListItem, which would break the cache
// of users who upgrade, and would just generally be a big mess.
-typedef QDict<coverKey> TrackLookupMap;
+typedef TQDict<coverKey> TrackLookupMap;
// This is responsible for making sure that the CoverManagerPrivate class
// gets properly destructed on shutdown.
@@ -44,24 +44,24 @@ static KStaticDeleter<CoverManagerPrivate> sd;
const char *CoverDrag::mimetype = "application/x-juk-coverid";
// Caches the QPixmaps for the covers so that the covers are not all kept in
// memory for no reason.
-typedef QCache<QPixmap> CoverPixmapCache;
+typedef TQCache<TQPixmap> CoverPixmapCache;
CoverManagerPrivate *CoverManager::m_data = 0;
// Used to save and load CoverData from a QDataStream
-QDataStream &operator<<(QDataStream &out, const CoverData &data);
-QDataStream &operator>>(QDataStream &in, CoverData &data);
+TQDataStream &operator<<(TQDataStream &out, const CoverData &data);
+TQDataStream &operator>>(TQDataStream &in, CoverData &data);
//
// Implementation of CoverData struct
//
-QPixmap CoverData::pixmap() const
+TQPixmap CoverData::pixmap() const
{
return CoverManager::coverFromData(*this, CoverManager::FullSize);
}
-QPixmap CoverData::thumbnail() const
+TQPixmap CoverData::thumbnail() const
{
return CoverManager::coverFromData(*this, CoverManager::Thumbnail);
}
@@ -123,7 +123,7 @@ public:
* @return the full path and filename of the file storing the cover
* lookup map and the translations between pathnames and ids.
*/
- QString coverLocation() const;
+ TQString coverLocation() const;
};
//
@@ -131,8 +131,8 @@ public:
//
void CoverManagerPrivate::createDataDir() const
{
- QDir dir;
- QString dirPath(QDir::cleanDirPath(coverLocation() + "/.."));
+ TQDir dir;
+ TQString dirPath(TQDir::cleanDirPath(coverLocation() + "/.."));
if(!dir.exists(dirPath))
KStandardDirs::makeDir(dirPath);
}
@@ -144,7 +144,7 @@ void CoverManagerPrivate::saveCovers() const
// Make sure the directory exists first.
createDataDir();
- QFile file(coverLocation());
+ TQFile file(coverLocation());
kdDebug() << "Opening covers db: " << coverLocation() << endl;
@@ -153,7 +153,7 @@ void CoverManagerPrivate::saveCovers() const
return;
}
- QDataStream out(&file);
+ TQDataStream out(&file);
// Write out the version and count
out << Q_UINT32(0) << Q_UINT32(covers.count());
@@ -167,7 +167,7 @@ void CoverManagerPrivate::saveCovers() const
// Now write out the track mapping.
out << Q_UINT32(tracks.count());
- QDictIterator<coverKey> trackMapIt(tracks);
+ TQDictIterator<coverKey> trackMapIt(tracks);
while(trackMapIt.current()) {
out << trackMapIt.currentKey() << Q_UINT32(*trackMapIt.current());
++trackMapIt;
@@ -178,14 +178,14 @@ void CoverManagerPrivate::loadCovers()
{
kdDebug() << k_funcinfo << endl;
- QFile file(coverLocation());
+ TQFile file(coverLocation());
if(!file.open(IO_ReadOnly)) {
// Guess we don't have any covers yet.
return;
}
- QDataStream in(&file);
+ TQDataStream in(&file);
Q_UINT32 count, version;
// First thing we'll read in will be the version.
@@ -214,7 +214,7 @@ void CoverManagerPrivate::loadCovers()
in >> count;
for(Q_UINT32 i = 0; i < count; ++i) {
- QString path;
+ TQString path;
Q_UINT32 id;
in >> path >> id;
@@ -230,7 +230,7 @@ void CoverManagerPrivate::loadCovers()
}
}
-QString CoverManagerPrivate::coverLocation() const
+TQString CoverManagerPrivate::coverLocation() const
{
return KGlobal::dirs()->saveLocation("appdata") + "coverdb/covers";
}
@@ -251,10 +251,10 @@ coverKey CoverManagerPrivate::nextId() const
//
// Implementation of CoverDrag
//
-CoverDrag::CoverDrag(coverKey id, QWidget *src) : QDragObject(src, "coverDrag"),
+CoverDrag::CoverDrag(coverKey id, TQWidget *src) : TQDragObject(src, "coverDrag"),
m_id(id)
{
- QPixmap cover = CoverManager::coverFromId(id);
+ TQPixmap cover = CoverManager::coverFromId(id);
if(!cover.isNull())
setPixmap(cover);
}
@@ -269,20 +269,20 @@ const char *CoverDrag::format(int i) const
return 0;
}
-QByteArray CoverDrag::encodedData(const char *mimetype) const
+TQByteArray CoverDrag::encodedData(const char *mimetype) const
{
if(qstrcmp(CoverDrag::mimetype, mimetype) == 0) {
- QByteArray data;
- QDataStream ds(data, IO_WriteOnly);
+ TQByteArray data;
+ TQDataStream ds(data, IO_WriteOnly);
ds << Q_UINT32(m_id);
return data;
}
else if(qstrcmp(mimetype, "image/png") == 0) {
- QPixmap large = CoverManager::coverFromId(m_id, CoverManager::FullSize);
- QImage img = large.convertToImage();
- QByteArray data;
- QBuffer buffer(data);
+ TQPixmap large = CoverManager::coverFromId(m_id, CoverManager::FullSize);
+ TQImage img = large.convertToImage();
+ TQByteArray data;
+ TQBuffer buffer(data);
buffer.open(IO_WriteOnly);
img.save(&buffer, "PNG"); // Write in PNG format.
@@ -290,21 +290,21 @@ QByteArray CoverDrag::encodedData(const char *mimetype) const
return data;
}
- return QByteArray();
+ return TQByteArray();
}
-bool CoverDrag::canDecode(const QMimeSource *e)
+bool CoverDrag::canDecode(const TQMimeSource *e)
{
return e->provides(mimetype);
}
-bool CoverDrag::decode(const QMimeSource *e, coverKey &id)
+bool CoverDrag::decode(const TQMimeSource *e, coverKey &id)
{
if(!canDecode(e))
return false;
- QByteArray data = e->encodedData(mimetype);
- QDataStream ds(data, IO_ReadOnly);
+ TQByteArray data = e->encodedData(mimetype);
+ TQDataStream ds(data, IO_ReadOnly);
Q_UINT32 i;
ds >> i;
@@ -316,10 +316,10 @@ bool CoverDrag::decode(const QMimeSource *e, coverKey &id)
//
// Implementation of CoverManager methods.
//
-coverKey CoverManager::idFromMetadata(const QString &artist, const QString &album)
+coverKey CoverManager::idFromMetadata(const TQString &artist, const TQString &album)
{
// Search for the string, yay! It might make sense to use a cache here,
- // if so it's not hard to add a QCache.
+ // if so it's not hard to add a TQCache.
CoverDataMap::ConstIterator it = begin();
CoverDataMap::ConstIterator endIt = end();
@@ -331,12 +331,12 @@ coverKey CoverManager::idFromMetadata(const QString &artist, const QString &albu
return NoMatch;
}
-QPixmap CoverManager::coverFromId(coverKey id, Size size)
+TQPixmap CoverManager::coverFromId(coverKey id, Size size)
{
CoverDataPtr info = coverInfo(id);
if(!info)
- return QPixmap();
+ return TQPixmap();
if(size == Thumbnail)
return info->thumbnail();
@@ -344,9 +344,9 @@ QPixmap CoverManager::coverFromId(coverKey id, Size size)
return info->pixmap();
}
-QPixmap CoverManager::coverFromData(const CoverData &coverData, Size size)
+TQPixmap CoverManager::coverFromData(const CoverData &coverData, Size size)
{
- QString path = coverData.path;
+ TQString path = coverData.path;
// Prepend a tag to the path to separate in the cache between full size
// and thumbnail pixmaps. If we add a different kind of pixmap in the
@@ -357,31 +357,31 @@ QPixmap CoverManager::coverFromData(const CoverData &coverData, Size size)
path.prepend('t');
// Check in cache for the pixmap.
- QPixmap *pix = data()->pixmapCache[path];
+ TQPixmap *pix = data()->pixmapCache[path];
if(pix) {
kdDebug(65432) << "Found pixmap in cover cache.\n";
return *pix;
}
// Not in cache, load it and add it.
- pix = new QPixmap(coverData.path);
+ pix = new TQPixmap(coverData.path);
if(pix->isNull())
- return QPixmap();
+ return TQPixmap();
if(size == Thumbnail) {
// Convert to image for smoothScale()
- QImage image = pix->convertToImage();
- pix->convertFromImage(image.smoothScale(80, 80, QImage::ScaleMin));
+ TQImage image = pix->convertToImage();
+ pix->convertFromImage(image.smoothScale(80, 80, TQImage::ScaleMin));
}
- QPixmap returnValue = *pix; // Save it early.
+ TQPixmap returnValue = *pix; // Save it early.
if(!data()->pixmapCache.insert(path, pix, pix->height() * pix->width()))
delete pix;
return returnValue;
}
-coverKey CoverManager::addCover(const QPixmap &large, const QString &artist, const QString &album)
+coverKey CoverManager::addCover(const TQPixmap &large, const TQString &artist, const TQString &album)
{
kdDebug() << k_funcinfo << endl;
@@ -395,7 +395,7 @@ coverKey CoverManager::addCover(const QPixmap &large, const QString &artist, con
// Save it to file first!
- QString ext = QString("/coverdb/coverID-%1.png").arg(id);
+ TQString ext = TQString("/coverdb/coverID-%1.png").arg(id);
coverData->path = KGlobal::dirs()->saveLocation("appdata") + ext;
kdDebug() << "Saving pixmap to " << coverData->path << endl;
@@ -413,15 +413,15 @@ coverKey CoverManager::addCover(const QPixmap &large, const QString &artist, con
data()->covers[id] = coverData;
// Make sure the new cover isn't inadvertently cached.
- data()->pixmapCache.remove(QString("f%1").arg(coverData->path));
- data()->pixmapCache.remove(QString("t%1").arg(coverData->path));
+ data()->pixmapCache.remove(TQString("f%1").arg(coverData->path));
+ data()->pixmapCache.remove(TQString("t%1").arg(coverData->path));
return id;
}
-coverKey CoverManager::addCover(const QString &path, const QString &artist, const QString &album)
+coverKey CoverManager::addCover(const TQString &path, const TQString &artist, const TQString &album)
{
- return addCover(QPixmap(path), artist, album);
+ return addCover(TQPixmap(path), artist, album);
}
bool CoverManager::hasCover(coverKey id)
@@ -436,17 +436,17 @@ bool CoverManager::removeCover(coverKey id)
// Remove cover from cache.
CoverDataPtr coverData = coverInfo(id);
- data()->pixmapCache.remove(QString("f%1").arg(coverData->path));
- data()->pixmapCache.remove(QString("t%1").arg(coverData->path));
+ data()->pixmapCache.remove(TQString("f%1").arg(coverData->path));
+ data()->pixmapCache.remove(TQString("t%1").arg(coverData->path));
// Remove references to files that had that track ID.
- QDictIterator<coverKey> it(data()->tracks);
+ TQDictIterator<coverKey> it(data()->tracks);
for(; it.current(); ++it)
if(*it.current() == id)
data()->tracks.remove(it.currentKey());
// Remove covers from disk.
- QFile::remove(coverData->path);
+ TQFile::remove(coverData->path);
// Finally, forget that we ever knew about this cover.
data()->covers.remove(id);
@@ -454,7 +454,7 @@ bool CoverManager::removeCover(coverKey id)
return true;
}
-bool CoverManager::replaceCover(coverKey id, const QPixmap &large)
+bool CoverManager::replaceCover(coverKey id, const TQPixmap &large)
{
if(!hasCover(id))
return false;
@@ -462,8 +462,8 @@ bool CoverManager::replaceCover(coverKey id, const QPixmap &large)
CoverDataPtr coverData = coverInfo(id);
// Empty old pixmaps from cache.
- data()->pixmapCache.remove(QString("%1%2").arg("t", coverData->path));
- data()->pixmapCache.remove(QString("%1%2").arg("f", coverData->path));
+ data()->pixmapCache.remove(TQString("%1%2").arg("t", coverData->path));
+ data()->pixmapCache.remove(TQString("%1%2").arg("f", coverData->path));
large.save(coverData->path, "PNG");
return true;
@@ -497,12 +497,12 @@ CoverDataMap::ConstIterator CoverManager::end()
return data()->covers.constEnd();
}
-QValueList<coverKey> CoverManager::keys()
+TQValueList<coverKey> CoverManager::keys()
{
return data()->covers.keys();
}
-void CoverManager::setIdForTrack(const QString &path, coverKey id)
+void CoverManager::setIdForTrack(const TQString &path, coverKey id)
{
coverKey *oldId = data()->tracks.find(path);
if(oldId && (id == *oldId))
@@ -524,7 +524,7 @@ void CoverManager::setIdForTrack(const QString &path, coverKey id)
}
}
-coverKey CoverManager::idForTrack(const QString &path)
+coverKey CoverManager::idForTrack(const TQString &path)
{
coverKey *coverPtr = data()->tracks.find(path);
@@ -549,7 +549,7 @@ CoverDataPtr CoverManager::coverInfo(coverKey id)
* @param data the CoverData to write out.
* @return the data stream that the data was written to.
*/
-QDataStream &operator<<(QDataStream &out, const CoverData &data)
+TQDataStream &operator<<(TQDataStream &out, const CoverData &data)
{
out << data.artist;
out << data.album;
@@ -565,7 +565,7 @@ QDataStream &operator<<(QDataStream &out, const CoverData &data)
* @param data the CoverData to read into.
* @return the data stream read from.
*/
-QDataStream &operator>>(QDataStream &in, CoverData &data)
+TQDataStream &operator>>(TQDataStream &in, CoverData &data)
{
in >> data.artist;
in >> data.album;