service.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <qcombobox.h>
00014 #include <qvaluelist.h>
00015
00016 #include <kservice.h>
00017 #include <kdebug.h>
00018
00019 #include "service.h"
00020
00021
00022 void ServiceComboBox::insertStringList(QComboBox *combo, const QValueList<KService::Ptr> &list,
00023 QStringList *names, QStringList *execs)
00024 {
00025 QValueList<KService::Ptr>::ConstIterator it;
00026 for (it = list.begin(); it != list.end(); ++it) {
00027 combo->insertItem((*it)->comment());
00028 (*names) << (*it)->desktopEntryName();
00029 (*execs) << (*it)->exec();
00030 kdDebug() << "insertStringList item " << (*it)->name() << "," << (*it)->exec() << endl;
00031 }
00032 }
00033
00034 QString ServiceComboBox::currentText(QComboBox *combo, const QStringList &names)
00035 {
00036 if (combo->currentItem() == -1)
00037 return QString::null;
00038 return names[combo->currentItem()];
00039 }
00040
00041 void ServiceComboBox::setCurrentText(QComboBox *combo, const QString &str, const QStringList &names)
00042 {
00043 QStringList::ConstIterator it;
00044 int i = 0;
00045 for (it = names.begin(); it != names.end(); ++it) {
00046 if (*it == str) {
00047 combo->setCurrentItem(i);
00048 break;
00049 }
00050 ++i;
00051 }
00052 }
00053
00054 int ServiceComboBox::itemForText(const QString &str, const QStringList &names)
00055 {
00056 QStringList::ConstIterator it;
00057 int i = 0;
00058 for (it = names.begin(); it != names.end(); ++it) {
00059 if (*it == str) {
00060 return i;
00061 }
00062 ++i;
00063 }
00064 return 0;
00065 }
00066
00067 QString ServiceComboBox::defaultCompiler()
00068 {
00069 KTrader::OfferList offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'");
00070 QValueList<KService::Ptr>::ConstIterator it;
00071 for (it = offers.begin(); it != offers.end(); ++it) {
00072 if ((*it)->property("X-KDevelop-Default").toBool()) {
00073 return (*it)->name();;
00074 }
00075 }
00076 return "";
00077 }
This file is part of the documentation for KDevelop Version 3.1.2.