some house cleaning
svn path=/trunk/KDE/kdebase/workspace/lib/plasma/; revision=672677
This commit is contained in:
parent
80866f4a99
commit
ac270ef3e0
136
appletLayout.cpp
136
appletLayout.cpp
@ -1,136 +0,0 @@
|
||||
#include "appletLayout.h"
|
||||
|
||||
#include <QLayoutItem>
|
||||
#include <QSizePolicy>
|
||||
#include <QRect>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
struct AppletLayoutItem
|
||||
{
|
||||
public:
|
||||
AppletLayoutItem(QLayoutItem *it);
|
||||
|
||||
private:
|
||||
QLayoutItem *item;
|
||||
};
|
||||
|
||||
class AppletLayout::Private
|
||||
{
|
||||
public:
|
||||
~Private()
|
||||
{
|
||||
QLayoutItem *item;
|
||||
while ((item = takeAt(0)))
|
||||
delete item;
|
||||
}
|
||||
QLayoutItem *takeAt(int index)
|
||||
{
|
||||
if (index >= 0 && index < itemList.size())
|
||||
return itemList.takeAt(index);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
QList<QLayoutItem *> itemList;
|
||||
};
|
||||
|
||||
AppletLayout::AppletLayout(QWidget *parent)
|
||||
: QLayout(parent),
|
||||
d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
AppletLayout::~AppletLayout()
|
||||
{
|
||||
delete d; d = 0;
|
||||
}
|
||||
|
||||
|
||||
void AppletLayout::addItem(QLayoutItem *item)
|
||||
{
|
||||
d->itemList.append(item);
|
||||
}
|
||||
|
||||
Qt::Orientations AppletLayout::expandingDirections() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AppletLayout::hasHeightForWidth() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int AppletLayout::heightForWidth(int width) const
|
||||
{
|
||||
int height = layoutApplets(QRect(0, 0, width, 0), true);
|
||||
return height;
|
||||
}
|
||||
|
||||
int AppletLayout::count() const
|
||||
{
|
||||
return d->itemList.size();
|
||||
}
|
||||
|
||||
QLayoutItem *AppletLayout::itemAt(int index) const
|
||||
{
|
||||
return d->itemList.value(index);
|
||||
}
|
||||
|
||||
QSize AppletLayout::minimumSize() const
|
||||
{
|
||||
QSize size;
|
||||
QLayoutItem *item;
|
||||
foreach (item, d->itemList)
|
||||
size = size.expandedTo(item->minimumSize());
|
||||
|
||||
size += QSize(2*margin(), 2*margin());
|
||||
return size;
|
||||
}
|
||||
|
||||
void AppletLayout::setGeometry(const QRect &rect)
|
||||
{
|
||||
QLayout::setGeometry(rect);
|
||||
layoutApplets(rect, false);
|
||||
}
|
||||
|
||||
QSize AppletLayout::sizeHint() const
|
||||
{
|
||||
return minimumSize();
|
||||
}
|
||||
|
||||
QLayoutItem * AppletLayout::takeAt(int index)
|
||||
{
|
||||
return d->takeAt(index);
|
||||
}
|
||||
|
||||
int AppletLayout::layoutApplets(const QRect &rect, bool computeHeightOnly) const
|
||||
{
|
||||
int x = rect.x();
|
||||
int y = rect.y();
|
||||
int lineHeight = 0;
|
||||
|
||||
QLayoutItem *item;
|
||||
foreach (item, d->itemList) {
|
||||
int nextX = x + item->sizeHint().width() + spacing();
|
||||
if (nextX - spacing() > rect.right() && lineHeight > 0) {
|
||||
x = rect.x();
|
||||
y = y + lineHeight + spacing();
|
||||
nextX = x + item->sizeHint().width() + spacing();
|
||||
lineHeight = 0;
|
||||
}
|
||||
|
||||
if (!computeHeightOnly)
|
||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||
|
||||
x = nextX;
|
||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||
}
|
||||
return y + lineHeight - rect.y();
|
||||
}
|
||||
|
||||
} //end namespace Plasma
|
||||
|
||||
|
||||
#include "appletLayout.moc"
|
@ -1,49 +0,0 @@
|
||||
#ifndef APPLET_LAYOUT_H
|
||||
#define APPLET_LAYOUT_H
|
||||
|
||||
#include <QLayout>
|
||||
#include <QSize>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
class QLayoutItem;
|
||||
class QRect;
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
/**
|
||||
* AppletLayout is our custom layouting engine
|
||||
* for applets. It reacts to state transition (removal,addition
|
||||
* of applets) by emitting corresponding signals which AppletCompositor
|
||||
* can intercept and respond with some nice animation/effect.
|
||||
*/
|
||||
class PLASMA_EXPORT AppletLayout : public QLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AppletLayout(QWidget *parent);
|
||||
~AppletLayout();
|
||||
|
||||
virtual void addItem(QLayoutItem *item);
|
||||
virtual Qt::Orientations expandingDirections() const;
|
||||
virtual bool hasHeightForWidth() const;
|
||||
virtual int heightForWidth(int) const;
|
||||
virtual int count() const;
|
||||
virtual QLayoutItem *itemAt(int index) const;
|
||||
virtual QSize minimumSize() const;
|
||||
virtual void setGeometry(const QRect &rect);
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QLayoutItem *takeAt(int index);
|
||||
Q_SIGNALS:
|
||||
void mergeTwoApplets();
|
||||
void splitTwoApplets();
|
||||
protected:
|
||||
int layoutApplets(const QRect &rect, bool computeHeightOnly) const;
|
||||
private:
|
||||
class Private;
|
||||
Private *d;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,13 +1,2 @@
|
||||
include_directories( ${CMAKE_SOURCE_DIR}/workspace/plasma/lib )
|
||||
|
||||
|
||||
########### next target ###############
|
||||
|
||||
set(testAppletInfo_SRCS testAppletInfo.cpp )
|
||||
|
||||
kde4_automoc(${testAppletInfo_SRCS})
|
||||
|
||||
kde4_add_executable(testAppletInfo ${testAppletInfo_SRCS})
|
||||
|
||||
target_link_libraries(testAppletInfo ${KDE4_KDECORE_LIBS} )
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Plugin
|
||||
Encoding=UTF-8
|
||||
Name=Non-Unique Native Applet
|
||||
Name[el]=Μη μοναδικό εγγενές εφαρμογίδιο
|
||||
Name[nds]=Nich eensoortet echt Lüttprogramm
|
||||
Name[nl]=Niet-uniek eigen applet
|
||||
Name[sv]=Icke-unikt inbyggt miniprogram
|
||||
Name[x-test]=xxNon-Unique Native Appletxx
|
||||
Name[zh_TW]=非唯一原始小程式
|
||||
Comment=A natively compiled applet
|
||||
Comment[el]=Ένα εγγενές μεταγλωττισμένο εφαρμογίδιο
|
||||
Comment[nds]=En normaal kompileert Lüttprogramm
|
||||
Comment[nl]=Een eigengecompileerd applet
|
||||
Comment[sv]=Ett inkompilerat miniprogram
|
||||
Comment[x-test]=xxA natively compiled appletxx
|
||||
Comment[zh_TW]=原始編譯小程式
|
||||
Icon=native
|
||||
|
||||
X-KDE-Library=plasma_applet_native
|
||||
X-KDE-UniqueApplet=false
|
@ -1,259 +0,0 @@
|
||||
/*
|
||||
Unit tests for Plasma::AppletInfo
|
||||
|
||||
Copyright (C) 2005 Aaron Seigo <aseigo@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2 as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <QDir>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kcomponentdata.h>
|
||||
|
||||
#include "appletinfo.h"
|
||||
#include "testAppletInfo.h"
|
||||
|
||||
TestAppletInfo::TestAppletInfo(QObject* parent)
|
||||
: QObject(parent),
|
||||
m_componentData("testappletinfo")
|
||||
{
|
||||
m_aboutData = new KAboutData("Test Applet Info", "testappletinfo", "1");
|
||||
QString pwd = QDir::currentPath();
|
||||
notUniqueNative = new Plasma::AppletInfo(pwd + "/nativeApplet.desktop");
|
||||
uniqueJavascript = new Plasma::AppletInfo(pwd + "/uniqueJavaScriptApplet.desktop");
|
||||
}
|
||||
|
||||
TestAppletInfo::~TestAppletInfo()
|
||||
{
|
||||
delete m_aboutData;
|
||||
}
|
||||
|
||||
void TestAppletInfo::name_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->name()
|
||||
<< "Non-Unique Native Applet";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->name()
|
||||
<< "Unique Javascript Applet";
|
||||
}
|
||||
|
||||
void TestAppletInfo::name()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::comment_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->comment()
|
||||
<< "A natively compiled applet";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->comment()
|
||||
<< "An applet written in JavaScript";
|
||||
}
|
||||
|
||||
void TestAppletInfo::comment()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::icon_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->icon()
|
||||
<< "native";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->icon()
|
||||
<< "javascript";
|
||||
}
|
||||
|
||||
void TestAppletInfo::icon()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::library_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->library()
|
||||
<< "plasma_applet_native";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->library()
|
||||
<< "plasma_applet_javascript";
|
||||
}
|
||||
|
||||
void TestAppletInfo::library()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::languageBindings_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->languageBindings()
|
||||
<< "native";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->languageBindings()
|
||||
<< "javascript";
|
||||
}
|
||||
|
||||
void TestAppletInfo::languageBindings()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::desktopFilePath_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
QString pwd = QDir::currentPath();
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFilePath()
|
||||
<< pwd + "/nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFilePath()
|
||||
<< pwd + "/uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
void TestAppletInfo::desktopFilePath()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::desktopFile_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFile()
|
||||
<< "nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFile()
|
||||
<< "uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
void TestAppletInfo::desktopFile()
|
||||
{
|
||||
FETCH(QString, expected);
|
||||
FETCH(QString, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::unique_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("bool", "expected");
|
||||
t.defineElement("bool", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
|
||||
<< false;
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
|
||||
<< true;
|
||||
}
|
||||
|
||||
void TestAppletInfo::unique()
|
||||
{
|
||||
FETCH(bool, expected);
|
||||
FETCH(bool, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::hidden_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("bool", "expected");
|
||||
t.defineElement("bool", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->hidden()
|
||||
<< false;
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->hidden()
|
||||
<< true;
|
||||
}
|
||||
|
||||
void TestAppletInfo::hidden()
|
||||
{
|
||||
FETCH(bool, expected);
|
||||
FETCH(bool, actual);
|
||||
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::assignment()
|
||||
{
|
||||
Plasma::AppletInfo assigned = *notUniqueNative;
|
||||
COMPARE(assigned.name(), notUniqueNative->name());
|
||||
COMPARE(assigned.comment(), notUniqueNative->comment());
|
||||
COMPARE(assigned.icon(), notUniqueNative->icon());
|
||||
COMPARE(assigned.library(), notUniqueNative->library());
|
||||
COMPARE(assigned.languageBindings(), notUniqueNative->languageBindings());
|
||||
COMPARE(assigned.desktopFilePath(), notUniqueNative->desktopFilePath());
|
||||
COMPARE(assigned.desktopFile(), notUniqueNative->desktopFile());
|
||||
COMPARE(assigned.unique(), notUniqueNative->unique());
|
||||
COMPARE(assigned.hidden(), notUniqueNative->hidden());
|
||||
}
|
||||
|
||||
void TestAppletInfo::copyConstructor()
|
||||
{
|
||||
Plasma::AppletInfo* tempCopy = new Plasma::AppletInfo(*notUniqueNative);
|
||||
Plasma::AppletInfo copied(*tempCopy);
|
||||
delete tempCopy;
|
||||
COMPARE(copied.name(), notUniqueNative->name());
|
||||
COMPARE(copied.comment(), notUniqueNative->comment());
|
||||
COMPARE(copied.icon(), notUniqueNative->icon());
|
||||
COMPARE(copied.library(), notUniqueNative->library());
|
||||
COMPARE(copied.languageBindings(), notUniqueNative->languageBindings());
|
||||
COMPARE(copied.desktopFilePath(), notUniqueNative->desktopFilePath());
|
||||
COMPARE(copied.desktopFile(), notUniqueNative->desktopFile());
|
||||
COMPARE(copied.unique(), notUniqueNative->unique());
|
||||
COMPARE(copied.hidden(), notUniqueNative->hidden());
|
||||
}
|
||||
|
||||
void TestAppletInfo::dragAndDrop()
|
||||
{
|
||||
QMimeData* data = new QMimeData;
|
||||
notUniqueNative->populateMimeData(data);
|
||||
VERIFY(Plasma::AppletInfo::canDecode(data));
|
||||
Plasma::AppletInfo dropped = Plasma::AppletInfo::fromMimeData(data);
|
||||
COMPARE(dropped.desktopFile(), notUniqueNative->desktopFile());
|
||||
delete data;
|
||||
}
|
||||
|
||||
QTTEST_MAIN(TestAppletInfo)
|
||||
#include "testAppletInfo.moc"
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
Unit tests for Plasma::AppletInfo
|
||||
|
||||
Copyright (C) 2005 Aaron Seigo <aseigo@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2 as published by
|
||||
the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef testappletinfo_h_
|
||||
#define testappletinfo_h_
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <kcomponentdata.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class AppletInfo;
|
||||
}
|
||||
class KAboutData;
|
||||
|
||||
class TestAppletInfo: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestAppletInfo(QObject* parent = 0);
|
||||
~TestAppletInfo();
|
||||
|
||||
private Q_SLOTS:
|
||||
void name_data(QtTestTable& t);
|
||||
void name();
|
||||
void comment_data(QtTestTable& t);
|
||||
void comment();
|
||||
void icon_data(QtTestTable& t);
|
||||
void icon();
|
||||
void library_data(QtTestTable& t);
|
||||
void library();
|
||||
void languageBindings_data(QtTestTable& t);
|
||||
void languageBindings();
|
||||
void desktopFilePath_data(QtTestTable& t);
|
||||
void desktopFilePath();
|
||||
void desktopFile_data(QtTestTable& t);
|
||||
void desktopFile();
|
||||
void unique_data(QtTestTable& t);
|
||||
void unique();
|
||||
void hidden_data(QtTestTable& t);
|
||||
void hidden();
|
||||
void assignment();
|
||||
void copyConstructor();
|
||||
void dragAndDrop();
|
||||
|
||||
private:
|
||||
Plasma::AppletInfo* notUniqueNative;
|
||||
Plasma::AppletInfo* uniqueJavascript;
|
||||
KAboutData* m_aboutData;
|
||||
KComponentData m_componentData;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Plugin
|
||||
Encoding=UTF-8
|
||||
Name=Unique Javascript Applet
|
||||
Name[el]=Μοναδικό εφαρμογίδιο Javascript
|
||||
Name[nds]=Eensoortet JavaScript-Lüttprogramm
|
||||
Name[nl]=Uniek JavaScript-applet
|
||||
Name[sv]=Unikt Javascript-miniprogram
|
||||
Name[x-test]=xxUnique Javascript Appletxx
|
||||
Name[zh_TW]=獨一的 Javascript 小程式
|
||||
Comment=An applet written in JavaScript
|
||||
Comment[de]=Eine in JavaScript geschriebene Anwendung
|
||||
Comment[el]=Ένα εφαρμογίδιο γραμμένο σε JavaScript
|
||||
Comment[es]=Una miniaplicación escrita en JavaScript
|
||||
Comment[nds]=En Lüttprogramm, schreven in JavaScript
|
||||
Comment[nl]=Een applet geschreven in JavaScript
|
||||
Comment[sv]=Ett miniprogram skrivet i Javascript
|
||||
Comment[x-test]=xxAn applet written in JavaScriptxx
|
||||
Comment[zh_TW]=用 Javascript 寫的小程式
|
||||
Icon=javascript
|
||||
Hidden=true
|
||||
|
||||
X-KDE-Library=plasma_applet_javascript
|
||||
X-KDE-LanguageBindings=JavaScript
|
||||
X-KDE-UniqueApplet=true
|
Loading…
Reference in New Issue
Block a user