KDevelop API Documentation

service.cpp

Go to the documentation of this file.
00001 /* $Id: service.cpp,v 1.2 2003/09/28 18:13:14 dymo Exp $
00002  * Copyright (C) 2001-2002 by Bernd Gehrmann
00003  * bernd@kdevelop.org
00004  * Copyright (C) 2003 Oliver Kellogg
00005  * okellogg@users.sourceforge.net
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
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 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:20 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003