summaryrefslogtreecommitdiffstats
path: root/katapult/plugins/catalogs/programcatalog/programcatalog.cpp
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/plugins/catalogs/programcatalog/programcatalog.cpp
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/plugins/catalogs/programcatalog/programcatalog.cpp')
-rw-r--r--katapult/plugins/catalogs/programcatalog/programcatalog.cpp153
1 files changed, 153 insertions, 0 deletions
diff --git a/katapult/plugins/catalogs/programcatalog/programcatalog.cpp b/katapult/plugins/catalogs/programcatalog/programcatalog.cpp
new file mode 100644
index 0000000..1c83394
--- /dev/null
+++ b/katapult/plugins/catalogs/programcatalog/programcatalog.cpp
@@ -0,0 +1,153 @@
+/***************************************************************************
+ * 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 <kservicegroup.h>
+#include <ksycocaentry.h>
+#include <ksycocatype.h>
+#include <kapplication.h>
+#include <knuminput.h>
+#include <kcombobox.h>
+
+#include <qcheckbox.h>
+
+#include "settings.h"
+#include "programcatalog.h"
+#include "program.h"
+#include "actionregistry.h"
+#include "actionrunprogram.h"
+
+K_EXPORT_COMPONENT_FACTORY( katapult_programcatalog,
+ KGenericFactory<ProgramCatalog>( "katapult_programcatalog" ) )
+
+ProgramCatalog::ProgramCatalog(QObject *, const char *, const QStringList&)
+ : CachedCatalog()
+{
+ _minQueryLen = 1;
+ _ignoreIconless = TRUE;
+ _ignoreTerminal = TRUE;
+ _useExecName = FALSE;
+ ActionRegistry::self()->registerAction(new ActionRunProgram());
+}
+
+ProgramCatalog::~ProgramCatalog()
+{
+}
+
+void ProgramCatalog::initialize()
+{
+ cacheProgramList(QString::null);
+}
+
+void ProgramCatalog::cacheProgramList(QString relPath)
+{
+ KServiceGroup::Ptr group = KServiceGroup::group(relPath);
+ if(!group || !group->isValid())
+ return;
+
+ KServiceGroup::List list = group->entries();
+ if(list.isEmpty())
+ return;
+
+ KServiceGroup::List::ConstIterator it = list.begin();
+ for(; it != list.end(); ++it)
+ {
+ KSycocaEntry *e = *it;
+
+ if(e != 0) {
+ if(e->isType(KST_KServiceGroup))
+ {
+ KServiceGroup::Ptr g(static_cast<KServiceGroup *>(e));
+ if(!g->noDisplay())
+ cacheProgramList(g->relPath());
+ } else if(e->isType(KST_KService))
+ {
+ KService::Ptr s(static_cast<KService *>(e));
+ if(s->type() == "Application" &&
+ (!_ignoreIconless || !s->icon().isEmpty()) &&
+ (!_ignoreTerminal || !s->terminal()) && !s->noDisplay()
+ ) {
+ addItem(new Program(s, _useExecName));
+ }
+ }
+ }
+ }
+}
+
+unsigned int ProgramCatalog::minQueryLen() const
+{
+ return _minQueryLen;
+}
+
+void ProgramCatalog::readSettings(KConfigBase *config)
+{
+ _minQueryLen = config->readUnsignedNumEntry("MinQueryLen", 1);
+ _ignoreIconless = config->readBoolEntry("IgnoreIconless", TRUE);
+ _useExecName = config->readBoolEntry("UseExecName", FALSE);
+ _ignoreTerminal = config->readBoolEntry("IgnoreTerminal", TRUE);
+}
+
+void ProgramCatalog::writeSettings(KConfigBase *config)
+{
+ config->writeEntry("MinQueryLen", _minQueryLen);
+ config->writeEntry("IgnoreIconless", _ignoreIconless);
+ config->writeEntry("UseExecName", _useExecName);
+ config->writeEntry("IgnoreTerminal", _ignoreTerminal);
+}
+
+QWidget * ProgramCatalog::configure()
+{
+ ProgramCatalogSettings *settings = new ProgramCatalogSettings();
+
+ settings->minQueryLen->setValue(_minQueryLen);
+ connect(settings->minQueryLen, SIGNAL(valueChanged(int)), this, SLOT(minQueryLenChanged(int)));
+
+ settings->ignoreIconless->setChecked(_ignoreIconless);
+ connect(settings->ignoreIconless, SIGNAL(toggled(bool)), this, SLOT(toggleIgnoreIconless(bool)));
+
+ settings->useExecName->setChecked(_useExecName);
+ connect(settings->useExecName, SIGNAL(toggled(bool)), this, SLOT(toggleUseExecName(bool)));
+
+ settings->ignoreTerminal->setChecked(_ignoreTerminal);
+ connect(settings->ignoreTerminal, SIGNAL(toggled(bool)), this, SLOT(toggleIgnoreTerminal(bool)));
+
+ return settings;
+}
+
+void ProgramCatalog::minQueryLenChanged(int _minQueryLen)
+{
+ this->_minQueryLen = _minQueryLen;
+}
+
+void ProgramCatalog::toggleIgnoreIconless(bool _ignoreIconless)
+{
+ this->_ignoreIconless = _ignoreIconless;
+}
+
+void ProgramCatalog::toggleUseExecName(bool _useExecName)
+{
+ this->_useExecName = _useExecName;
+}
+
+void ProgramCatalog::toggleIgnoreTerminal(bool _ignoreTerminal)
+{
+ this->_ignoreTerminal = _ignoreTerminal;
+}
+
+#include "programcatalog.moc"