summaryrefslogtreecommitdiffstats
path: root/katapult/common
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:45:19 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:45:19 +0000
commit4e1a5c3eebf50657629e2b4eba13649c2b599598 (patch)
tree7757743b67ed172d113dad73a3daa5b8aa6f871a /katapult/common
downloadkatapult-4e1a5c3eebf50657629e2b4eba13649c2b599598.tar.gz
katapult-4e1a5c3eebf50657629e2b4eba13649c2b599598.zip
Added abandoned KDE3 version of katapult
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/katapult@1084407 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'katapult/common')
-rw-r--r--katapult/common/Makefile.am19
-rw-r--r--katapult/common/actionregistry.cpp64
-rw-r--r--katapult/common/actionregistry.h48
-rw-r--r--katapult/common/cachedcatalog.cpp175
-rw-r--r--katapult/common/cachedcatalog.h55
-rw-r--r--katapult/common/imagedisplay.cpp453
-rw-r--r--katapult/common/imagedisplay.h96
-rw-r--r--katapult/common/imagedisplaysettings.ui213
-rw-r--r--katapult/common/katapultaction.cpp44
-rw-r--r--katapult/common/katapultaction.h44
-rw-r--r--katapult/common/katapultcatalog.cpp90
-rw-r--r--katapult/common/katapultcatalog.desktop24
-rw-r--r--katapult/common/katapultcatalog.h67
-rw-r--r--katapult/common/katapultdisplay.cpp116
-rw-r--r--katapult/common/katapultdisplay.desktop23
-rw-r--r--katapult/common/katapultdisplay.h78
-rw-r--r--katapult/common/katapultitem.cpp44
-rw-r--r--katapult/common/katapultitem.h47
-rw-r--r--katapult/common/match.cpp59
-rw-r--r--katapult/common/match.h46
-rw-r--r--katapult/common/status.h24
21 files changed, 1829 insertions, 0 deletions
diff --git a/katapult/common/Makefile.am b/katapult/common/Makefile.am
new file mode 100644
index 0000000..5f57229
--- /dev/null
+++ b/katapult/common/Makefile.am
@@ -0,0 +1,19 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = status.h katapultdisplay.h katapultcatalog.h katapultaction.h \
+ katapultitem.h cachedcatalog.h actionregistry.h match.h imagedisplay.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+lib_LTLIBRARIES = libkatapult.la
+
+# common library
+libkatapult_la_SOURCES = katapultitem.cpp katapultaction.cpp actionregistry.cpp katapultcatalog.cpp cachedcatalog.cpp match.cpp katapultdisplay.cpp imagedisplay.cpp imagedisplaysettings.ui
+libkatapult_la_LDFLAGS = $(all_libraries) -version-info 2:0:0
+libkatapult_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) -lDCOP -lkdefx $(LIB_KDEUI)
+
+# this is where the service type files will go
+kde_servicetypes_DATA = katapultdisplay.desktop katapultcatalog.desktop
diff --git a/katapult/common/actionregistry.cpp b/katapult/common/actionregistry.cpp
new file mode 100644
index 0000000..82f10f5
--- /dev/null
+++ b/katapult/common/actionregistry.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 "actionregistry.h"
+#include "katapultaction.h"
+#include "katapultitem.h"
+
+static ActionRegistry * actionRegistryInstance = 0;
+
+ActionRegistry::ActionRegistry()
+{
+ actions.setAutoDelete(TRUE);
+}
+
+ActionRegistry::~ActionRegistry()
+{
+}
+
+ActionRegistry * ActionRegistry::self()
+{
+ if(actionRegistryInstance == 0)
+ actionRegistryInstance = new ActionRegistry();
+ return actionRegistryInstance;
+}
+
+void ActionRegistry::registerAction(const KatapultAction *action)
+{
+ actions.append(action);
+}
+
+QPtrList<KatapultAction> ActionRegistry::actionsForItem(const KatapultItem *item) const
+{
+ QPtrList<KatapultAction> result;
+ QPtrListIterator<KatapultAction> it(actions);
+ KatapultAction *action;
+ while((action = it.current()) != 0) {
+ ++it;
+ if(action->accepts(item))
+ result.append(action);
+ }
+ return result;
+}
+
+void ActionRegistry::clear()
+{
+ actions.clear();
+}
diff --git a/katapult/common/actionregistry.h b/katapult/common/actionregistry.h
new file mode 100644
index 0000000..479837d
--- /dev/null
+++ b/katapult/common/actionregistry.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 ACTIONREGISTRY_H
+#define ACTIONREGISTRY_H
+
+#include <qptrlist.h>
+
+class KatapultItem;
+class KatapultAction;
+
+/**
+@author Joe Ferris
+*/
+class ActionRegistry{
+public:
+ ~ActionRegistry();
+
+ void registerAction(const KatapultAction *);
+ QPtrList<KatapultAction> actionsForItem(const KatapultItem *) const;
+ void clear();
+
+ static ActionRegistry * self();
+
+private:
+ ActionRegistry();
+
+ QPtrList<KatapultAction> actions;
+
+};
+
+#endif
diff --git a/katapult/common/cachedcatalog.cpp b/katapult/common/cachedcatalog.cpp
new file mode 100644
index 0000000..bf34b87
--- /dev/null
+++ b/katapult/common/cachedcatalog.cpp
@@ -0,0 +1,175 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 "cachedcatalog.moc"
+
+#include <qstringlist.h>
+#include <qstring.h>
+
+#include "cachedcatalog.h"
+#include "katapultitem.h"
+#include "match.h"
+#include "status.h"
+
+CachedCatalog::CachedCatalog()
+ : KatapultCatalog()
+{
+ cache.setAutoDelete(TRUE);
+ results.setAutoDelete(FALSE);
+}
+
+CachedCatalog::~CachedCatalog()
+{
+}
+
+unsigned int CachedCatalog::minQueryLen() const
+{
+ return 3;
+}
+
+void CachedCatalog::queryChanged()
+{
+ int newStatus = 0;
+ if(query() == "")
+ {
+ results.clear();
+ setBestMatch(Match());
+ } else {
+ if(query().length() >= minQueryLen())
+ {
+ Match newBestMatch;
+
+ if(status() & S_Active)
+ {
+ QPtrListIterator<KatapultItem> it(results);
+ KatapultItem *item;
+
+ while((item = it.current())!=0)
+ {
+ ++it;
+ Match match = queryItem(item, query());
+ if(match.isNull())
+ results.removeRef(item);
+ else if(newBestMatch.isNull() || match.rank() > newBestMatch.rank())
+ newBestMatch = match;
+ }
+ } else {
+ results.clear();
+
+ QPtrListIterator<KatapultItem> it(cache);
+ KatapultItem *item;
+ while((item=it.current())!=0)
+ {
+ ++it;
+ Match match = queryItem(item, query());
+ if(!match.isNull()) {
+ results.append(item);
+ if(newBestMatch.isNull() || match.rank() > newBestMatch.rank())
+ newBestMatch = match;
+ }
+ }
+ }
+
+ newStatus |= S_Active;
+ if(results.count() > 0)
+ {
+ newStatus |= S_HasResults;
+ if(results.count() > 1)
+ newStatus |= S_Multiple;
+ } else
+ newStatus |= S_NoResults;
+
+ setBestMatch(newBestMatch);
+ }
+ }
+ setStatus(newStatus);
+}
+
+Match CachedCatalog::queryItem(const KatapultItem *item, QString query) const
+{
+ int wordNo = 0;
+ int _rank = 0;
+ unsigned int _matched = 0;
+ QString text = item->text().lower();
+ QStringList queryWords = QStringList::split(" ", query.lower());
+ int wordMax = queryWords.count()-1;
+ QStringList words = QStringList::split(" ", text);
+ QStringList::Iterator wit = words.begin();
+ for(QStringList::Iterator qit = queryWords.begin(); qit != queryWords.end(); ++qit) {
+ QString queryWord = *qit;
+ bool didMatch = FALSE;
+ for(; wit != words.end(); ++wit) {
+ QString word = *wit;
+ if(word.startsWith(queryWord)) {
+ if(_matched != 0)
+ _matched++;
+ if(wordNo == wordMax) {
+ _matched += queryWord.length();
+ } else {
+ _matched += word.length();
+ }
+ didMatch = TRUE;
+ break;
+ }
+ if(wordNo == 0) {
+ if(_matched != 0)
+ _matched++;
+ _matched += word.length();
+ }
+ }
+ if(didMatch == FALSE) {
+ return Match();
+ }
+ wordNo++;
+ }
+
+ if(_matched > text.length())
+ return Match();
+
+ _rank = 100*query.length()/text.length();
+
+ if(_rank == 0)
+ return Match();
+ else
+ return Match(item, _rank, _matched);
+}
+
+const KatapultItem * CachedCatalog::findExact(QString text) const
+{
+ text = text.lower();
+ KatapultItem *item;
+ QPtrListIterator<KatapultItem> it(cache);
+ while((item=it.current())!=0)
+ {
+ ++it;
+ if(item->text().lower() == text)
+ return item;
+ }
+ return 0;
+}
+
+void CachedCatalog::addItem(KatapultItem *item)
+{
+ if(findExact(item->text())) {
+ qDebug("Ignored duplicate item: %s", item->text().ascii());
+ delete item;
+ } else
+ cache.append(item);
+}
diff --git a/katapult/common/cachedcatalog.h b/katapult/common/cachedcatalog.h
new file mode 100644
index 0000000..0653c5d
--- /dev/null
+++ b/katapult/common/cachedcatalog.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 CACHEDCATALOG_H
+#define CACHEDCATALOG_H
+
+#include <qptrlist.h>
+
+#include "katapultcatalog.h"
+
+class Match;
+class KatapultItem;
+
+/**
+@author Joe Ferris
+*/
+class CachedCatalog : public KatapultCatalog
+{
+ Q_OBJECT
+public:
+ CachedCatalog();
+ virtual ~CachedCatalog();
+
+ const KatapultItem * findExact(QString text) const;
+
+protected:
+ virtual void queryChanged();
+ virtual unsigned int minQueryLen() const;
+
+ void addItem(KatapultItem *);
+
+private:
+ Match queryItem(const KatapultItem *, QString) const;
+
+ QPtrList<KatapultItem> cache, results;
+
+};
+
+#endif
diff --git a/katapult/common/imagedisplay.cpp b/katapult/common/imagedisplay.cpp
new file mode 100644
index 0000000..7832198
--- /dev/null
+++ b/katapult/common/imagedisplay.cpp
@@ -0,0 +1,453 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 <imagedisplay.moc>
+
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <kwin.h>
+#include <kimageeffect.h>
+#include <kgenericfactory.h>
+#include <kconfig.h>
+#include <kfontcombo.h>
+#include <klocale.h>
+
+#include <qpainter.h>
+#include <qapplication.h>
+#include <qimage.h>
+#include <qbitmap.h>
+#include <qslider.h>
+#include <qspinbox.h>
+#include <qcursor.h>
+
+#include <status.h>
+
+#include "imagedisplay.h"
+#include "imagedisplaysettings.h"
+
+#define FADEINTERVAL 20
+#define FADECONST 2000
+
+ImageDisplay::ImageDisplay(QObject *, const char *name, const QStringList&)
+ : KatapultDisplay(name, WType_TopLevel | WStyle_Customize | WStyle_NoBorder | WStyle_StaysOnTop | WNoAutoErase | WDestructiveClose)
+{
+ KWin::setType(winId(), NET::Dock);
+ setBackgroundMode(NoBackground);
+ setFocusPolicy(QWidget::StrongFocus);
+
+ singlebg = 0;
+ doublebg = 0;
+
+ singlesize[0] = 0;
+ singlesize[1] = 0;
+ doublesize[0] = 0;
+ doublesize[1] = 0;
+ padding = 0;
+ margin[0] = 0;
+ margin[1] = 0;
+ margin[2] = 0;
+ margin[3] = 0;
+ iconsize = 0;
+
+ bgSngl = 0;
+ bgDbl = 0;
+
+ fadeImg = 0;
+
+ alpha = 0;
+ fadeTimer = new QTimer(this);
+ connect(fadeTimer, SIGNAL(timeout()), this, SLOT(continueFade()));
+
+ desktopSize = qApp->desktop()->availableGeometry(QCursor::pos());
+
+ fadeTime = 250;
+ updateFadeStep();
+}
+
+ImageDisplay::~ImageDisplay()
+{
+ if(singlebg != 0)
+ delete singlebg;
+ if(doublebg != 0)
+ delete doublebg;
+ if(bgSngl != 0)
+ delete bgSngl;
+ if(bgDbl != 0)
+ delete bgDbl;
+ if(fadeImg != 0)
+ delete fadeImg;
+}
+
+void ImageDisplay::continueFade()
+{
+ if(fadeOut)
+ {
+ if(fadeStep == 0)
+ alpha = 0;
+ else
+ alpha -= fadeStep;
+ if(alpha <= 0)
+ {
+ alpha = 0;
+ fadeTimer->stop();
+ hide();
+ }
+ } else {
+ if(fadeStep == 0)
+ alpha = 100;
+ else
+ alpha += fadeStep;
+ if(alpha > 100)
+ {
+ alpha = 100;
+ fadeTimer->stop();
+ if(fadeImg != 0)
+ {
+ delete fadeImg;
+ fadeImg = 0;
+ }
+ }
+ }
+ update();
+}
+
+void ImageDisplay::showEvent(QShowEvent *)
+{
+ // set back the display-size, because if it wouldn't be done this could be a problem-source.
+ displaySize = 0;
+
+ if(bgSngl != 0)
+ delete bgSngl;
+ if(bgDbl != 0)
+ delete bgDbl;
+
+ bgSngl = new QPixmap(QPixmap::grabWindow(qt_xrootwin(), (desktopSize.width() - singlesize[0])/2 + desktopSize.left(), (desktopSize.height() - singlesize[1])/2 + desktopSize.top(), singlesize[0], singlesize[1]));
+ bgDbl = new QPixmap(QPixmap::grabWindow(qt_xrootwin(), (desktopSize.width() - doublesize[0])/2 + desktopSize.left(), (desktopSize.height() - doublesize[1])/2 + desktopSize.top(), doublesize[0], doublesize[1]));
+
+ if(fadeImg != 0)
+ delete fadeImg;
+
+ if(fadeTime <= 1) {
+ alpha = 100;
+ placeWindow(1);
+ } else {
+ fadeOut = false;
+ alpha = 0;
+ fadeImg = new QImage(getDisplay().convertToImage());
+ fadeTimer->start(FADEINTERVAL, FALSE);
+ }
+}
+
+void ImageDisplay::hide()
+{
+ if(alpha == 0)
+ {
+ if(fadeImg != 0)
+ {
+ delete fadeImg;
+ fadeImg = 0;
+ }
+ KatapultDisplay::hide();
+ } else {
+ if(fadeImg != 0)
+ delete fadeImg;
+ fadeImg = new QImage(getDisplay().convertToImage());
+ fadeOut = TRUE;
+ if(!fadeTimer->isActive())
+ fadeTimer->start(FADEINTERVAL, FALSE);
+ }
+}
+
+void ImageDisplay::drawText(QPixmap & pixmap, int x, int width, QString text, int hilight) const
+{
+ int fontSize = maxFontSize;
+ QFont font(fontFace, fontSize);
+ QFontMetrics metrics(font);
+
+ while(fontSize > minFontSize && metrics.width(text) > width) {
+ fontSize--;
+ font.setPointSize(fontSize);
+ metrics = QFontMetrics(font);
+ }
+
+ while(hilight > 1 && metrics.width(text) > width) {
+ text = text.remove(0, 1);
+ hilight--;
+ }
+
+ int useChars = text.length();
+
+ while(metrics.width(text, useChars) > width) {
+ useChars--;
+ }
+ text = text.left(useChars);
+
+ QString hilighted = text.left(hilight);
+ QString remaining = text.right(text.length() - hilighted.length());
+
+ x += (width-metrics.width(text))/2;
+
+ QPainter painter(&pixmap);
+ painter.setFont(font);
+
+ painter.setPen(colorGroup().color(QColorGroup::Link));
+ painter.drawText(x, singlesize[1]-offset[3], hilighted);
+ painter.setPen(QColor(255, 255, 255));
+ painter.drawText(x+metrics.width(hilighted), singlesize[1]-offset[3], remaining);
+}
+
+QPixmap ImageDisplay::getDisplay()
+{
+ if(status() & S_HasResults)
+ {
+ // show best match
+ QPixmap pixmap(*bgDbl);
+ QPainter painter(&pixmap);
+
+ painter.drawPixmap(0, 0, *doublebg);
+
+ QFontMetrics metrics = painter.fontMetrics();
+ QRect bounds;
+ QPixmap icon;
+
+ int itemSpace = (doublesize[0]-offset[0]-offset[2]-padding)/2;
+
+ const KatapultItem *_item = item();
+ if(_item != 0)
+ {
+ icon = _item->icon(iconsize);
+ painter.drawPixmap(offset[0]+(itemSpace-iconsize)/2, offset[1], icon);
+ drawText(pixmap, offset[0], itemSpace, _item->text(), selected());
+ }
+
+ const KatapultAction *_action = action();
+ if(_action != 0)
+ {
+ int x = offset[0]+itemSpace+padding+padding;
+ icon = _action->icon(iconsize);
+ painter.drawPixmap(x+(itemSpace-iconsize)/2, offset[1], icon);
+ drawText(pixmap, x, itemSpace, _action->text(), 0);
+ }
+ painter.end();
+
+ if(displaySize != 2)
+ {
+ placeWindow(2);
+ displaySize = 2;
+ }
+
+ return pixmap;
+ } else {
+ // show splash or error
+ QPixmap pixmap(*bgSngl);
+ QPainter painter(&pixmap);
+
+ painter.drawPixmap(0, 0, *singlebg);
+
+ QString label;
+ QPixmap icon;
+
+ if(status() & S_Active)
+ {
+ icon = KGlobal::iconLoader()->loadIcon("unknown", KIcon::NoGroup, 128);
+ if(query().isEmpty())
+ label = i18n("No items matched.");
+ else
+ label = query();
+ } else {
+ icon = KGlobal::iconLoader()->loadIcon("katapult", KIcon::NoGroup, 128);
+ if(query().isEmpty())
+ label = "Katapult";
+ else {
+ label = query();
+ painter.setPen(QColor(16, 48, 254));
+ }
+ }
+
+ painter.drawPixmap(offset[0]+(singlesize[0]-offset[0]-offset[2]-128)/2, offset[1], icon);
+
+ drawText(pixmap, offset[0], singlesize[0]-offset[0]-offset[2], label, 0);
+
+/* painter.drawText(offset[0], singlesize[1]-offset[3]-30, singlesize[0]-offset[0]-offset[2], 30,
+ Qt::AlignHCenter | Qt::AlignBottom | Qt::SingleLine, label);*/
+ painter.end();
+
+ if(displaySize != 1)
+ {
+ placeWindow(1);
+ displaySize = 1;
+ }
+
+ return pixmap;
+ }
+}
+
+void ImageDisplay::placeWindow(int size)
+{
+ if(size == 2) {
+ move((desktopSize.width() - doublesize[0])/2 + desktopSize.left(), (desktopSize.height() - doublesize[1])/2 + desktopSize.top());
+ resize(doublesize[0], doublesize[1]);
+ } else {
+ move((desktopSize.width() - singlesize[0])/2 + desktopSize.left(), (desktopSize.height() - singlesize[1])/2 + desktopSize.top());
+ resize(singlesize[0], singlesize[1]);
+ }
+}
+
+void ImageDisplay::paintEvent(QPaintEvent *)
+{
+ if(alpha == 0)
+ {
+ if(displaySize == 2)
+ bitBlt(this, 0, 0, bgDbl);
+ else
+ bitBlt(this, 0, 0, bgSngl);
+ } else if(fadeImg != 0) {
+ QImage buffer;
+ if(displaySize == 2)
+ buffer = bgDbl->convertToImage();
+ else
+ buffer = bgSngl->convertToImage();
+
+ KImageEffect::blend(*fadeImg, buffer, (float)alpha/100);
+ bitBlt(this, 0, 0, &buffer);
+ } else {
+ QPixmap pixmap = getDisplay();
+ bitBlt(this, 0, 0, &pixmap);
+ }
+}
+
+void ImageDisplay::setSingleBG(QPixmap *singlebg)
+{
+ this->singlebg = singlebg;
+}
+
+void ImageDisplay::setDoubleBG(QPixmap *doublebg)
+{
+ this->doublebg = doublebg;
+}
+
+void ImageDisplay::setSingleSize(int width, int height)
+{
+ singlesize[0] = width;
+ singlesize[1] = height;
+}
+
+void ImageDisplay::setDoubleSize(int width, int height)
+{
+ doublesize[0] = width;
+ doublesize[1] = height;
+}
+
+void ImageDisplay::setMargin(int left, int top, int right, int bottom)
+{
+ margin[0] = left;
+ margin[1] = top;
+ margin[2] = right;
+ margin[3] = bottom;
+ updateOffset();
+}
+
+void ImageDisplay::setPadding(int padding)
+{
+ this->padding = padding;
+ updateOffset();
+}
+
+void ImageDisplay::setIconSize(int iconsize)
+{
+ this->iconsize = iconsize;
+}
+
+void ImageDisplay::updateOffset()
+{
+ offset[0] = margin[0] + padding;
+ offset[1] = margin[1] + padding;
+ offset[2] = margin[2] + padding;
+ offset[3] = margin[3] + padding;
+}
+
+void ImageDisplay::readSettings(KConfigBase *config)
+{
+ fadeTime = config->readUnsignedNumEntry("FadeTime", 250);
+ updateFadeStep();
+// fadeStep = fadeTime/FADEINTERVAL;
+ QFont defaultFont = KGlobalSettings::generalFont();
+ fontFace = config->readEntry("FontFace", defaultFont.family());
+ minFontSize = config->readUnsignedNumEntry("MinFontSize", 7);
+ maxFontSize = config->readUnsignedNumEntry("MaxFontSize", 14);
+}
+
+void ImageDisplay::writeSettings(KConfigBase *config)
+{
+ config->writeEntry("FadeTime", fadeTime);
+ config->writeEntry("FontFace", fontFace);
+ config->writeEntry("MinFontSize", minFontSize);
+ config->writeEntry("MaxFontSize", maxFontSize);
+}
+
+QWidget * ImageDisplay::configure()
+{
+ ImageDisplaySettings *settings = new ImageDisplaySettings();
+
+ settings->fadeTime->setValue(fadeTime);
+ connect(settings->fadeTime, SIGNAL(valueChanged(int)), this, SLOT(setFadeOut(int)));
+
+ settings->displayFont->setCurrentFont(fontFace);
+ connect(settings->displayFont, SIGNAL(textChanged(const QString &)), this, SLOT(setFont(const QString &)));
+
+ settings->minFontSize->setValue(minFontSize);
+ connect(settings->minFontSize, SIGNAL(valueChanged(int)), this, SLOT(setMinFontSize(int)));
+
+ settings->maxFontSize->setValue(maxFontSize);
+ connect(settings->maxFontSize, SIGNAL(valueChanged(int)), this, SLOT(setMaxFontSize(int)));
+
+ return settings;
+}
+
+void ImageDisplay::setFont(const QString &font)
+{
+ fontFace = font;
+}
+
+void ImageDisplay::setMinFontSize(int size)
+{
+ minFontSize = size;
+}
+
+void ImageDisplay::setMaxFontSize(int size)
+{
+ maxFontSize = size;
+}
+
+void ImageDisplay::setFadeOut(int fadeTime)
+{
+ this->fadeTime = fadeTime;
+ updateFadeStep();
+}
+
+void ImageDisplay::updateFadeStep()
+{
+ if(fadeTime == 0)
+ fadeTime = 1;
+ fadeStep = FADECONST/fadeTime;
+ if(fadeStep > 100)
+ fadeStep = 100;
+}
diff --git a/katapult/common/imagedisplay.h b/katapult/common/imagedisplay.h
new file mode 100644
index 0000000..e0d4fc7
--- /dev/null
+++ b/katapult/common/imagedisplay.h
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 IMAGEDISPLAY_H
+#define IMAGEDISPLAY_H
+
+#include <qevent.h>
+#include <qpixmap.h>
+#include <qtimer.h>
+#include <qimage.h>
+
+#include "katapultdisplay.h"
+
+class Katapult;
+class QFont;
+
+/**
+@author Joe Ferris, Bastian Holst
+*/
+class ImageDisplay : public KatapultDisplay
+{
+ Q_OBJECT
+public:
+ ImageDisplay(QObject *, const char *, const QStringList&);
+ virtual ~ImageDisplay();
+
+public slots:
+ void continueFade();
+ virtual void hide();
+
+ virtual void readSettings(KConfigBase *);
+ virtual void writeSettings(KConfigBase *);
+ virtual QWidget * configure();
+
+ void setFont(const QString &);
+ void setMinFontSize(int);
+ void setMaxFontSize(int);
+ void setFadeOut(int);
+ void updateFadeStep();
+
+protected:
+ virtual void showEvent(QShowEvent *);
+ virtual void paintEvent(QPaintEvent *);
+
+ void setSingleBG(QPixmap *);
+ void setDoubleBG(QPixmap *);
+ void setSingleSize(int width, int height);
+ void setDoubleSize(int width, int heught);
+ void setMargin(int left, int top, int right, int bottom);
+ void setPadding(int);
+ void setIconSize(int);
+
+ QPixmap getDisplay();
+ void drawText(QPixmap &, int, int, QString, int) const;
+ void placeWindow(int);
+
+private:
+ void updateOffset();
+
+ QPixmap *bgSngl, *bgDbl, *singlebg, *doublebg;
+ QRect desktopSize;
+ QImage *fadeImg;
+ QTimer *fadeTimer;
+ QString fontFace;
+ int minFontSize, maxFontSize;
+ int alpha;
+ bool fadeOut;
+ int fadeTime, fadeStep;
+ int displaySize;
+ // 0: left, 1: top, 2: right, 3: bottom
+ int margin[4];
+ int offset[4];
+ // 0: width, 1: height
+ int singlesize[2];
+ int doublesize[2];
+ int padding;
+ int iconsize;
+};
+
+#endif
diff --git a/katapult/common/imagedisplaysettings.ui b/katapult/common/imagedisplaysettings.ui
new file mode 100644
index 0000000..c78d2a4
--- /dev/null
+++ b/katapult/common/imagedisplaysettings.ui
@@ -0,0 +1,213 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>ImageDisplaySettings</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ImageDisplaySettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>411</width>
+ <height>385</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Length of fade-in/fade-out:</string>
+ </property>
+ </widget>
+ <widget class="QSlider">
+ <property name="name">
+ <cstring>fadeTime</cstring>
+ </property>
+ <property name="maxValue">
+ <number>2000</number>
+ </property>
+ <property name="lineStep">
+ <number>100</number>
+ </property>
+ <property name="pageStep">
+ <number>250</number>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="tickmarks">
+ <enum>NoMarks</enum>
+ </property>
+ <property name="tickInterval">
+ <number>1000</number>
+ </property>
+ </widget>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>autoFontSize</cstring>
+ </property>
+ <property name="title">
+ <string>Display Font</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Font face:</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>91</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KFontCombo">
+ <property name="name">
+ <cstring>displayFont</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout7</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Minimum font size:</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>181</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>minFontSize</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Maximum font size:</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>191</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>maxFontSize</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>160</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kfontcombo.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/katapult/common/katapultaction.cpp b/katapult/common/katapultaction.cpp
new file mode 100644
index 0000000..d0dd13f
--- /dev/null
+++ b/katapult/common/katapultaction.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 <qpixmap.h>
+
+#include "katapultaction.h"
+
+KatapultAction::~KatapultAction(){}
+
+QString KatapultAction::text() const
+{
+ return QString::null;
+}
+
+QPixmap KatapultAction::icon(int size) const
+{
+ return QPixmap(size, size);
+}
+
+void KatapultAction::execute(const KatapultItem *) const
+{
+}
+
+bool KatapultAction::accepts(const KatapultItem *) const
+{
+ return false;
+}
diff --git a/katapult/common/katapultaction.h b/katapult/common/katapultaction.h
new file mode 100644
index 0000000..9198920
--- /dev/null
+++ b/katapult/common/katapultaction.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 KATAPULTACTION_H
+#define KATAPULTACTION_H
+
+#include <qstring.h>
+#include <qptrlist.h>
+
+class QPixmap;
+class KatapultItem;
+
+/**
+@author Joe Ferris
+*/
+class KatapultAction {
+
+public:
+ virtual ~KatapultAction();
+
+ virtual void execute(const KatapultItem *) const;
+ virtual bool accepts(const KatapultItem *) const;
+ virtual QString text() const;
+ virtual QPixmap icon(int) const;
+
+};
+
+#endif
diff --git a/katapult/common/katapultcatalog.cpp b/katapult/common/katapultcatalog.cpp
new file mode 100644
index 0000000..f90420a
--- /dev/null
+++ b/katapult/common/katapultcatalog.cpp
@@ -0,0 +1,90 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 "katapultcatalog.moc"
+#include "katapultcatalog.h"
+#include "match.h"
+
+KatapultCatalog::KatapultCatalog()
+{
+ _bestMatch = Match();
+ _status = 0;
+ _query = "";
+}
+
+
+KatapultCatalog::~KatapultCatalog()
+{
+}
+
+void KatapultCatalog::queryChanged()
+{
+}
+
+void KatapultCatalog::initialize()
+{
+}
+
+void KatapultCatalog::setQuery(QString _query)
+{
+ if(this->_query != _query) {
+ this->_query = _query;
+ queryChanged();
+ }
+}
+
+void KatapultCatalog::setStatus(int _status)
+{
+ this->_status = _status;
+}
+
+void KatapultCatalog::setBestMatch(Match _bestMatch)
+{
+ this->_bestMatch = _bestMatch;
+}
+
+QString KatapultCatalog::query() const
+{
+ return _query;
+}
+
+int KatapultCatalog::status() const
+{
+ return _status;
+}
+
+Match KatapultCatalog::bestMatch() const
+{
+ return _bestMatch;
+}
+
+void KatapultCatalog::readSettings(KConfigBase *)
+{
+}
+
+void KatapultCatalog::writeSettings(KConfigBase *)
+{
+}
+
+QWidget * KatapultCatalog::configure()
+{
+ return 0;
+}
+
diff --git a/katapult/common/katapultcatalog.desktop b/katapult/common/katapultcatalog.desktop
new file mode 100644
index 0000000..d66385f
--- /dev/null
+++ b/katapult/common/katapultcatalog.desktop
@@ -0,0 +1,24 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=Katapult/Catalog
+Comment=A Katapult catalog plugin
+Comment[ar]=بريمج مستعرض Katapult
+Comment[bg]=Приставка за каталог на Katapult
+Comment[br]=Ul lugent katalog evit Katapult
+Comment[da]=Et mappe-plugin for Katapult
+Comment[de]=Ein Katapult-Katalog-Modul
+Comment[el]=Ένα πρόσθετο καταλόγου Katapult
+Comment[es]=Una extensión del catálogo Katapult
+Comment[et]=Katapulti kataloogiplugin
+Comment[fr]=Un module externe de catalogue pour Katapult
+Comment[gl]=Plugin de catálogo de Katapult
+Comment[it]=Un plugin per i cataloghi di Katapult
+Comment[ja]=Katapult カタログプラグイン
+Comment[nb]=Et programtillegg for Katapult-katalog
+Comment[nl]=Een Katapult-catalogusplugin
+Comment[pt]=Um 'plugin' de catálogo do Katapult
+Comment[pt_BR]=Um 'plugin' de catálogo do Katapult
+Comment[sv]=Ett katalogiseringsinsticksprogram för Katapult
+Comment[tr]=Bir Katapult katalog eklentisi
+Comment[uk]=Втулок каталогів для Катапульти
+
diff --git a/katapult/common/katapultcatalog.h b/katapult/common/katapultcatalog.h
new file mode 100644
index 0000000..9576a8a
--- /dev/null
+++ b/katapult/common/katapultcatalog.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 KATAPULTCATALOG_H
+#define KATAPULTCATALOG_H
+
+#include <qobject.h>
+#include <qstring.h>
+#include <qptrlist.h>
+
+#include "match.h"
+
+class QWidget;
+class KConfigBase;
+
+/**
+@author Joe Ferris
+*/
+class KatapultCatalog : public QObject {
+ Q_OBJECT
+
+public:
+ KatapultCatalog();
+ virtual ~KatapultCatalog();
+
+ void setQuery(QString);
+
+ int status() const;
+ Match bestMatch() const;
+
+ virtual void initialize();
+ virtual void readSettings(KConfigBase *);
+ virtual void writeSettings(KConfigBase *);
+ virtual QWidget * configure();
+
+protected:
+ QString query() const;
+
+ void setStatus(int);
+ void setBestMatch(Match);
+
+ virtual void queryChanged();
+
+private:
+ QString _query;
+ int _status;
+ Match _bestMatch;
+
+};
+
+#endif
diff --git a/katapult/common/katapultdisplay.cpp b/katapult/common/katapultdisplay.cpp
new file mode 100644
index 0000000..2dbe460
--- /dev/null
+++ b/katapult/common/katapultdisplay.cpp
@@ -0,0 +1,116 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 "katapultdisplay.moc"
+
+#include "katapultdisplay.h"
+
+KatapultDisplay::KatapultDisplay(const char *name, WFlags f)
+ : QWidget(0, name, f)
+{
+ _query = "";
+ _item = 0;
+ _action = 0;
+ _status = 0;
+ _selectionLength = 0;
+}
+
+KatapultDisplay::~KatapultDisplay()
+{
+}
+
+void KatapultDisplay::focusOutEvent(QFocusEvent *)
+{
+ emit focusOut();
+}
+
+void KatapultDisplay::keyPressEvent(QKeyEvent *e)
+{
+ emit keyReleased(e);
+}
+
+// Deprecated - added for backwards compatibility
+void KatapultDisplay::keyReleaseEvent(QKeyEvent *e)
+{
+}
+
+void KatapultDisplay::setQuery(QString _query)
+{
+ this->_query = _query;
+}
+
+void KatapultDisplay::setSelected(unsigned int length)
+{
+ _selectionLength = length;
+}
+
+unsigned int KatapultDisplay::selected() const
+{
+ return _selectionLength;
+}
+
+void KatapultDisplay::setItem(const KatapultItem *_item)
+{
+ this->_item = _item;
+}
+
+void KatapultDisplay::setAction(const KatapultAction *_action)
+{
+ this->_action = _action;
+}
+
+void KatapultDisplay::setStatus(int _status)
+{
+ this->_status = _status;
+}
+
+QString KatapultDisplay::query() const
+{
+ return _query;
+}
+
+const KatapultItem * KatapultDisplay::item() const
+{
+ return _item;
+}
+
+const KatapultAction * KatapultDisplay::action() const
+{
+ return _action;
+}
+
+int KatapultDisplay::status() const
+{
+ return _status;
+}
+
+void KatapultDisplay::readSettings(KConfigBase *)
+{
+}
+
+void KatapultDisplay::writeSettings(KConfigBase *)
+{
+}
+
+QWidget * KatapultDisplay::configure()
+{
+ return 0;
+}
+
diff --git a/katapult/common/katapultdisplay.desktop b/katapult/common/katapultdisplay.desktop
new file mode 100644
index 0000000..335cdf1
--- /dev/null
+++ b/katapult/common/katapultdisplay.desktop
@@ -0,0 +1,23 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=Katapult/Display
+Comment=A Katapult display plugin
+Comment[ar]=بريمج عارض Katapult
+Comment[bg]=Приставка за показване на Katapult
+Comment[da]=Et visningsplugin for Katapult
+Comment[de]=Ein Katapult-Anzeige-Modul
+Comment[el]=Ένα πρόσθετο εμφάνισης Katapult
+Comment[es]=Una extensión para mostrar Katapult
+Comment[et]=Katapulti vaateplugin
+Comment[fr]=Un module externe d'affichage pour Katapult
+Comment[gl]=Plugin de visión de Katapult
+Comment[it]=Un plugin per i display di Katapult
+Comment[ja]=Katapult 表示プラグイン
+Comment[nb]=Et Katapult-programtillegg for visning
+Comment[nl]=Een Katapult-displayplugin
+Comment[pt]=Um 'plugin' de visualização do Katapult
+Comment[pt_BR]=Um 'plugin' de visualização do Katapult
+Comment[sv]=Ett visningsinsticksprogram för Katapult
+Comment[tr]=Bir Katapult gösterim eklentisi
+Comment[uk]=Втулок дисплея для Катапульти
+
diff --git a/katapult/common/katapultdisplay.h b/katapult/common/katapultdisplay.h
new file mode 100644
index 0000000..286238c
--- /dev/null
+++ b/katapult/common/katapultdisplay.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 KATAPULTDISPLAY_H
+#define KATAPULTDISPLAY_H
+
+#include <qwidget.h>
+#include <qstring.h>
+#include <qevent.h>
+
+#include "katapultitem.h"
+#include "katapultaction.h"
+
+class Katapult;
+class KConfigBase;
+
+/**
+@author Joe Ferris
+*/
+class KatapultDisplay : public QWidget
+{
+ Q_OBJECT
+
+public:
+ KatapultDisplay(const char *, WFlags);
+ virtual ~KatapultDisplay();
+
+ void setQuery(QString);
+ void setSelected(unsigned int);
+ void setItem(const KatapultItem *);
+ void setAction(const KatapultAction *);
+ void setStatus(int);
+
+ virtual void readSettings(KConfigBase *);
+ virtual void writeSettings(KConfigBase *);
+ virtual QWidget * configure();
+
+signals:
+ void keyReleased(QKeyEvent *);
+ void focusOut();
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void focusOutEvent(QFocusEvent *);
+
+ QString query() const;
+ unsigned int selected() const;
+ const KatapultItem * item() const;
+ const KatapultAction * action() const;
+ int status() const;
+
+private:
+ QString _query;
+ unsigned int _selectionLength;
+ const KatapultItem *_item;
+ const KatapultAction *_action;
+ int _status;
+ Katapult *app;
+};
+
+#endif
diff --git a/katapult/common/katapultitem.cpp b/katapult/common/katapultitem.cpp
new file mode 100644
index 0000000..7ac00f1
--- /dev/null
+++ b/katapult/common/katapultitem.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 "katapultitem.moc"
+
+#include <qpixmap.h>
+#include <qstring.h>
+
+#include "katapultitem.h"
+
+KatapultItem::KatapultItem()
+{
+}
+
+KatapultItem::~KatapultItem()
+{
+}
+
+QString KatapultItem::text() const
+{
+ return QString::null;
+}
+
+QPixmap KatapultItem::icon(int) const
+{
+ return QSize(0, 0);
+}
diff --git a/katapult/common/katapultitem.h b/katapult/common/katapultitem.h
new file mode 100644
index 0000000..f38422d
--- /dev/null
+++ b/katapult/common/katapultitem.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 KATAPULTITEM_H
+#define KATAPULTITEM_H
+
+#include <qobject.h>
+
+#include "katapultaction.h"
+
+class QPixmap;
+class QString;
+
+/**
+@author Joe Ferris
+*/
+class KatapultItem : public QObject {
+ Q_OBJECT
+public:
+
+ KatapultItem();
+ virtual ~KatapultItem();
+
+ virtual QString text() const;
+ virtual QPixmap icon(int) const;
+
+signals:
+ void itemChanged();
+};
+
+#endif
diff --git a/katapult/common/match.cpp b/katapult/common/match.cpp
new file mode 100644
index 0000000..5a346b3
--- /dev/null
+++ b/katapult/common/match.cpp
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 <qobject.h>
+
+#include "match.h"
+
+Match::Match()
+{
+ this->_rank = 0;
+ this->_item = 0;
+ this->_matched = 0;
+ this->_null = TRUE;
+}
+
+Match::Match(const KatapultItem *_item, int _rank, unsigned int _matched)
+{
+ this->_rank = _rank;
+ this->_item = _item;
+ this->_matched = _matched;
+ this->_null = FALSE;
+}
+
+int Match::rank() const
+{
+ return _rank;
+}
+
+unsigned int Match::matched() const
+{
+ return _matched;
+}
+
+const KatapultItem * Match::item() const
+{
+ return _item;
+}
+
+bool Match::isNull() const
+{
+ return _null;
+}
diff --git a/katapult/common/match.h b/katapult/common/match.h
new file mode 100644
index 0000000..818158b
--- /dev/null
+++ b/katapult/common/match.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 MATCH_H
+#define MATCH_H
+
+class KatapultItem;
+
+/**
+@author Joe Ferris
+*/
+class Match {
+public:
+ Match();
+ Match(const KatapultItem *, int, unsigned int);
+
+ int rank() const;
+ const KatapultItem * item() const;
+ bool isNull() const;
+ unsigned int matched() const;
+
+private:
+ bool _null;
+ int _rank;
+ unsigned int _matched;
+ const KatapultItem *_item;
+
+};
+
+#endif
diff --git a/katapult/common/status.h b/katapult/common/status.h
new file mode 100644
index 0000000..a7aba0d
--- /dev/null
+++ b/katapult/common/status.h
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joe Ferris *
+ * jferris@optimistictech.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#define S_Active 1
+#define S_NoResults 2
+#define S_HasResults 4
+#define S_Multiple 8