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