summaryrefslogtreecommitdiffstats
path: root/src/backgroundmanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-05-17 08:20:48 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-05-17 08:20:48 +0000
commitaa0726b20f398264f0a2abc60215be044b106f9c (patch)
tree070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/backgroundmanager.cpp
parentd3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff)
downloadbasket-aa0726b20f398264f0a2abc60215be044b106f9c.tar.gz
basket-aa0726b20f398264f0a2abc60215be044b106f9c.zip
TQt4 port basket
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1232416 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/backgroundmanager.cpp')
-rw-r--r--src/backgroundmanager.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/backgroundmanager.cpp b/src/backgroundmanager.cpp
index c289eca..14a2ac2 100644
--- a/src/backgroundmanager.cpp
+++ b/src/backgroundmanager.cpp
@@ -22,9 +22,9 @@
#include <kglobal.h>
#include <kstandarddirs.h>
#include <ksimpleconfig.h>
-#include <qpainter.h>
-#include <qdir.h>
-#include <qimage.h>
+#include <tqpainter.h>
+#include <tqdir.h>
+#include <tqimage.h>
#include <iostream>
@@ -32,7 +32,7 @@
/** class BackgroundEntry: */
-BackgroundEntry::BackgroundEntry(const QString &location)
+BackgroundEntry::BackgroundEntry(const TQString &location)
{
this->location = location;
name = KURL(location).fileName();
@@ -50,7 +50,7 @@ BackgroundEntry::~BackgroundEntry()
/** class OpaqueBackgroundEntry: */
-OpaqueBackgroundEntry::OpaqueBackgroundEntry(const QString &name, const QColor &color)
+OpaqueBackgroundEntry::OpaqueBackgroundEntry(const TQString &name, const TQColor &color)
{
this->name = name;
this->color = color;
@@ -68,14 +68,14 @@ OpaqueBackgroundEntry::~OpaqueBackgroundEntry()
BackgroundManager::BackgroundManager()
{
/// std::cout << "BackgroundManager: Found the following background images in ";
- QStringList directories = KGlobal::dirs()->resourceDirs("data"); // eg. { "/home/seb/.kde/share/apps/", "/usr/share/apps/" }
+ TQStringList directories = KGlobal::dirs()->resourceDirs("data"); // eg. { "/home/seb/.kde/share/apps/", "/usr/share/apps/" }
// For each folder:
- for (QStringList::Iterator it = directories.begin(); it != directories.end(); ++it) {
+ for (TQStringList::Iterator it = directories.begin(); it != directories.end(); ++it) {
// For each file in those directories:
- QDir dir(*it + "basket/backgrounds/", /*nameFilder=*/"*.png", /*sortSpec=*/QDir::Name | QDir::IgnoreCase, /*filterSpec=*/QDir::Files | QDir::NoSymLinks);
+ TQDir dir(*it + "basket/backgrounds/", /*nameFilder=*/"*.png", /*sortSpec=*/TQDir::Name | TQDir::IgnoreCase, /*filterSpec=*/TQDir::Files | TQDir::NoSymLinks);
/// std::cout << *it + "basket/backgrounds/ ";
- QStringList files = dir.entryList();
- for (QStringList::Iterator it2 = files.begin(); it2 != files.end(); ++it2) // TODO: If an image name is present in two folders?
+ TQStringList files = dir.entryList();
+ for (TQStringList::Iterator it2 = files.begin(); it2 != files.end(); ++it2) // TODO: If an image name is present in two folders?
addImage(*it + "basket/backgrounds/" + *it2);
}
@@ -83,19 +83,19 @@ BackgroundManager::BackgroundManager()
/// for (BackgroundsList::Iterator it = m_backgroundsList.begin(); it != m_backgroundsList.end(); ++it)
/// std::cout << "* " << (*it)->location << " [ref: " << (*it)->name << "]" << std::endl;
- connect( &m_garbageTimer, SIGNAL(timeout()), this, SLOT(doGarbage()) );
+ connect( &m_garbageTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(doGarbage()) );
}
BackgroundManager::~BackgroundManager()
{
}
-void BackgroundManager::addImage(const QString &fullPath)
+void BackgroundManager::addImage(const TQString &fullPath)
{
m_backgroundsList.append(new BackgroundEntry(fullPath));
}
-BackgroundEntry* BackgroundManager::backgroundEntryFor(const QString &image)
+BackgroundEntry* BackgroundManager::backgroundEntryFor(const TQString &image)
{
for (BackgroundsList::Iterator it = m_backgroundsList.begin(); it != m_backgroundsList.end(); ++it)
if ((*it)->name == image)
@@ -103,7 +103,7 @@ BackgroundEntry* BackgroundManager::backgroundEntryFor(const QString &image)
return 0;
}
-OpaqueBackgroundEntry* BackgroundManager::opaqueBackgroundEntryFor(const QString &image, const QColor &color)
+OpaqueBackgroundEntry* BackgroundManager::opaqueBackgroundEntryFor(const TQString &image, const TQColor &color)
{
for (OpaqueBackgroundsList::Iterator it = m_opaqueBackgroundsList.begin(); it != m_opaqueBackgroundsList.end(); ++it)
if ((*it)->name == image && (*it)->color == color)
@@ -111,14 +111,14 @@ OpaqueBackgroundEntry* BackgroundManager::opaqueBackgroundEntryFor(const QString
return 0;
}
-bool BackgroundManager::subscribe(const QString &image)
+bool BackgroundManager::subscribe(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
if (entry) {
// If it's the first time something subscribe to this image:
if (!entry->pixmap) {
// Try to load the pixmap:
- entry->pixmap = new QPixmap(entry->location);
+ entry->pixmap = new TQPixmap(entry->location);
// Try to figure out if it's a tiled background image or not (default to NO):
KSimpleConfig config(entry->location + ".config", /*readOnly=*/true);
config.setGroup("BasKet Background Image Configuration");
@@ -139,7 +139,7 @@ bool BackgroundManager::subscribe(const QString &image)
}
}
-bool BackgroundManager::subscribe(const QString &image, const QColor &color)
+bool BackgroundManager::subscribe(const TQString &image, const TQColor &color)
{
BackgroundEntry *backgroundEntry = backgroundEntryFor(image);
@@ -155,9 +155,9 @@ bool BackgroundManager::subscribe(const QString &image, const QColor &color)
if (!opaqueBackgroundEntry) {
/// std::cout << "BackgroundManager: Computing (" << image << "," << color.name() << ")..." << std::endl;
opaqueBackgroundEntry = new OpaqueBackgroundEntry(image, color);
- opaqueBackgroundEntry->pixmap = new QPixmap(backgroundEntry->pixmap->size());
+ opaqueBackgroundEntry->pixmap = new TQPixmap(backgroundEntry->pixmap->size());
opaqueBackgroundEntry->pixmap->fill(color);
- QPainter painter(opaqueBackgroundEntry->pixmap);
+ TQPainter painter(opaqueBackgroundEntry->pixmap);
painter.drawPixmap(0, 0, *(backgroundEntry->pixmap));
painter.end();
m_opaqueBackgroundsList.append(opaqueBackgroundEntry);
@@ -168,7 +168,7 @@ bool BackgroundManager::subscribe(const QString &image, const QColor &color)
return true;
}
-void BackgroundManager::unsubscribe(const QString &image)
+void BackgroundManager::unsubscribe(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
@@ -182,7 +182,7 @@ void BackgroundManager::unsubscribe(const QString &image)
requestDelayedGarbage();
}
-void BackgroundManager::unsubscribe(const QString &image, const QColor &color)
+void BackgroundManager::unsubscribe(const TQString &image, const TQColor &color)
{
OpaqueBackgroundEntry *entry = opaqueBackgroundEntryFor(image, color);
@@ -196,7 +196,7 @@ void BackgroundManager::unsubscribe(const QString &image, const QColor &color)
requestDelayedGarbage();
}
-QPixmap* BackgroundManager::pixmap(const QString &image)
+TQPixmap* BackgroundManager::pixmap(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
@@ -208,7 +208,7 @@ QPixmap* BackgroundManager::pixmap(const QString &image)
return entry->pixmap;
}
-QPixmap* BackgroundManager::opaquePixmap(const QString &image, const QColor &color)
+TQPixmap* BackgroundManager::opaquePixmap(const TQString &image, const TQColor &color)
{
OpaqueBackgroundEntry *entry = opaqueBackgroundEntryFor(image, color);
@@ -220,7 +220,7 @@ QPixmap* BackgroundManager::opaquePixmap(const QString &image, const QColor &col
return entry->pixmap;
}
-bool BackgroundManager::tiled(const QString &image)
+bool BackgroundManager::tiled(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
@@ -232,7 +232,7 @@ bool BackgroundManager::tiled(const QString &image)
return entry->tiled;
}
-bool BackgroundManager::exists(const QString &image)
+bool BackgroundManager::exists(const TQString &image)
{
for (BackgroundsList::iterator it = m_backgroundsList.begin(); it != m_backgroundsList.end(); ++it)
if ((*it)->name == image)
@@ -240,19 +240,19 @@ bool BackgroundManager::exists(const QString &image)
return false;
}
-QStringList BackgroundManager::imageNames()
+TQStringList BackgroundManager::imageNames()
{
- QStringList list;
+ TQStringList list;
for (BackgroundsList::iterator it = m_backgroundsList.begin(); it != m_backgroundsList.end(); ++it)
list.append((*it)->name);
return list;
}
-QPixmap* BackgroundManager::preview(const QString &image)
+TQPixmap* BackgroundManager::preview(const TQString &image)
{
static const int MAX_WIDTH = 100;
static const int MAX_HEIGHT = 75;
- static const QColor PREVIEW_BG = Qt::white;
+ static const TQColor PREVIEW_BG = TQt::white;
BackgroundEntry *entry = backgroundEntryFor(image);
@@ -266,8 +266,8 @@ QPixmap* BackgroundManager::preview(const QString &image)
return entry->preview;
// Then, try to load the preview from file:
- QString previewPath = KGlobal::dirs()->findResource("data", "basket/backgrounds/previews/" + entry->name);
- QPixmap *previewPixmap = new QPixmap(previewPath);
+ TQString previewPath = KGlobal::dirs()->findResource("data", "basket/backgrounds/previews/" + entry->name);
+ TQPixmap *previewPixmap = new TQPixmap(previewPath);
// Success:
if (!previewPixmap->isNull()) {
/// std::cout << "BackgroundManager: Loaded image preview for " << entry->location << " from file " << previewPath << std::endl;
@@ -283,9 +283,9 @@ QPixmap* BackgroundManager::preview(const QString &image)
// Already used? Good: we don't have to load it...
if (!entry->pixmap) {
- // Note: it's a code duplication from BackgroundManager::subscribe(const QString &image),
+ // Note: it's a code duplication from BackgroundManager::subscribe(const TQString &image),
// Because, as we are loading the pixmap we ALSO need to know if it's a tile or not, in case that image will soon be used (and not destroyed by the garbager):
- entry->pixmap = new QPixmap(entry->location);
+ entry->pixmap = new TQPixmap(entry->location);
// Try to figure out if it's a tiled background image or not (default to NO):
KSimpleConfig config(entry->location + ".config", /*readOnly=*/true);
config.setGroup("BasKet Background Image Configuration");
@@ -309,17 +309,17 @@ QPixmap* BackgroundManager::preview(const QString &image)
height = MAX_HEIGHT;
}
// And create the resulting pixmap:
- QPixmap *result = new QPixmap(width, height);
+ TQPixmap *result = new TQPixmap(width, height);
result->fill(PREVIEW_BG);
- QImage imageToScale = entry->pixmap->convertToImage();
- QPixmap pmScaled;
+ TQImage imageToScale = entry->pixmap->convertToImage();
+ TQPixmap pmScaled;
pmScaled.convertFromImage(imageToScale.smoothScale(width, height));
- QPainter painter(result);
+ TQPainter painter(result);
painter.drawPixmap(0, 0, pmScaled);
painter.end();
// Saving it to file for later:
- QString folder = KGlobal::dirs()->saveLocation("data", "basket/backgrounds/previews/");
+ TQString folder = KGlobal::dirs()->saveLocation("data", "basket/backgrounds/previews/");
result->save(folder + entry->name, "PNG");
// Ouf! That's done:
@@ -328,7 +328,7 @@ QPixmap* BackgroundManager::preview(const QString &image)
return entry->preview;
}
-QString BackgroundManager::pathForImageName(const QString &image)
+TQString BackgroundManager::pathForImageName(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
if (entry == 0)
@@ -337,14 +337,14 @@ QString BackgroundManager::pathForImageName(const QString &image)
return entry->location;
}
-QString BackgroundManager::previewPathForImageName(const QString &image)
+TQString BackgroundManager::previewPathForImageName(const TQString &image)
{
BackgroundEntry *entry = backgroundEntryFor(image);
if (entry == 0)
return "";
else {
- QString previewPath = KGlobal::dirs()->findResource("data", "basket/backgrounds/previews/" + entry->name);
- QDir dir;
+ TQString previewPath = KGlobal::dirs()->findResource("data", "basket/backgrounds/previews/" + entry->name);
+ TQDir dir;
if (!dir.exists(previewPath))
return "";
else