~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to buildtools/pascal/service.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2001-2002 by Bernd Gehrmann                             *
3
 
 *   bernd@kdevelop.org                                                    *
4
 
 *   Copyright (C) 2003 Alexander Dymo                                     *
5
 
 *   cloudtemple@mksat.net                                                 *
6
 
 *                                                                         *
7
 
 *   This program is free software; you can redistribute it and/or modify  *
8
 
 *   it under the terms of the GNU General Public License as published by  *
9
 
 *   the Free Software Foundation; either version 2 of the License, or     *
10
 
 *   (at your option) any later version.                                   *
11
 
 *                                                                         *
12
 
 ***************************************************************************/
13
 
#include <qcombobox.h>
14
 
#include <qvaluelist.h>
15
 
 
16
 
#include <kservice.h>
17
 
#include <kdebug.h>
18
 
 
19
 
#include "service.h"
20
 
 
21
 
 
22
 
void ServiceComboBox::insertStringList(QComboBox *combo, const QValueList<KService::Ptr> &list,
23
 
                            QStringList *names, QStringList *execs)
24
 
{
25
 
    QValueList<KService::Ptr>::ConstIterator it;
26
 
    for (it = list.begin(); it != list.end(); ++it) {
27
 
        combo->insertItem((*it)->comment());
28
 
        (*names) << (*it)->desktopEntryName();
29
 
        (*execs) << (*it)->exec();
30
 
        kdDebug() << "insertStringList item " << (*it)->name() << "," << (*it)->exec() << endl;
31
 
    }
32
 
}
33
 
 
34
 
QString ServiceComboBox::currentText(QComboBox *combo, const QStringList &names)
35
 
{
36
 
    if (combo->currentItem() == -1)
37
 
        return QString::null;
38
 
    return names[combo->currentItem()];
39
 
}
40
 
 
41
 
void ServiceComboBox::setCurrentText(QComboBox *combo, const QString &str, const QStringList &names)
42
 
{
43
 
    QStringList::ConstIterator it;
44
 
    int i = 0;
45
 
    for (it = names.begin(); it != names.end(); ++it) {
46
 
        if (*it == str) {
47
 
            combo->setCurrentItem(i);
48
 
            break;
49
 
        }
50
 
        ++i;
51
 
    }
52
 
}
53
 
 
54
 
int ServiceComboBox::itemForText(const QString &str, const QStringList &names)
55
 
{
56
 
    QStringList::ConstIterator it;
57
 
    int i = 0;
58
 
    for (it = names.begin(); it != names.end(); ++it) {
59
 
        if (*it == str) {
60
 
            return i;
61
 
        }
62
 
        ++i;
63
 
    }
64
 
    return 0;
65
 
}
66
 
 
67
 
QString ServiceComboBox::defaultCompiler()
68
 
{
69
 
    KTrader::OfferList offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'");
70
 
    QValueList<KService::Ptr>::ConstIterator it;
71
 
    for (it = offers.begin(); it != offers.end(); ++it) {
72
 
        if ((*it)->property("X-KDevelop-Default").toBool()) {
73
 
            return (*it)->name();;
74
 
        }
75
 
    }
76
 
    return "";
77
 
}