summaryrefslogtreecommitdiffstats
path: root/languages/pascal/compiler/dccoptions/dccoptionsplugin.cpp
blob: d1ed9aec81f168985d80fea6138185e4c6f541a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/***************************************************************************
 *   Copyright (C) 2003 Alexander Dymo                                     *
 *   cloudtemple@mksat.net                                                 *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
#include <tqvbox.h>
#include <tqdialog.h>

#include <kdebug.h>
#include <klocale.h>
#include <kgenericfactory.h>

#include "dccoptionsplugin.h"

#include "optiontabs.h"

K_EXPORT_COMPONENT_FACTORY( libkdevdccoptions, KGenericFactory<DccOptionsPlugin>( "kdevdccoptions" ) )

DccOptionsPlugin::DccOptionsPlugin(TQObject *tqparent, const char *name, const TQStringList/* &args*/)
    : KDevCompilerOptions(tqparent, name)
{
}

DccOptionsPlugin::~DccOptionsPlugin()
{
}

TQString DccOptionsPlugin::exec(TQWidget *tqparent, const TQString &flags)
{
    DccOptionsDialog *dlg = new DccOptionsDialog(tqparent, "dcc options dialog");
    TQString newFlags = flags;
    dlg->setFlags(flags);
    if(dlg->exec() == TQDialog::Accepted)
        newFlags = dlg->flags();
    delete dlg;
    return newFlags;
}


DccOptionsDialog::DccOptionsDialog( TQWidget * tqparent, const char * name )
    : KDialogBase(Tabbed, i18n("Delphi Compiler Options"), Ok|Cancel, Ok, tqparent, name, true)
{
    TQVBox *vbox;

    vbox = addVBoxPage(i18n("General"));
    general = new GeneralTab(vbox, "general tab");

    vbox = addVBoxPage(i18n("Locations I"));
    locations = new LocationsTab(vbox, "locations tab");

    vbox = addVBoxPage(i18n("Locations II"));
    locations2 = new Locations2Tab(vbox, "locations2 tab");

    vbox = addVBoxPage(i18n("Code Generation"));
    codegen = new CodegenTab(vbox, "codegen tab");

    vbox = addVBoxPage(i18n("Debug && Optimization"));
    debug_optim = new DebugOptimTab(vbox, "debug and optim tab");

    vbox = addVBoxPage(i18n("Linker"));
    linker = new LinkerTab(vbox, "linker tab");
}

DccOptionsDialog::~DccOptionsDialog( )
{
}

void DccOptionsDialog::setFlags( const TQString & flags )
{
    TQStringList flaglist = TQStringList::split(" ", flags);

    general->readFlags(&flaglist);
    codegen->readFlags(&flaglist);
    debug_optim->readFlags(&flaglist);
    locations->readFlags(&flaglist);
    locations2->readFlags(&flaglist);
    linker->readFlags(&flaglist);

    unrecognizedFlags = flaglist;
}

TQString DccOptionsDialog::flags( ) const
{
    TQStringList flaglist;

    general->writeFlags(&flaglist);
    locations->writeFlags(&flaglist);
    locations2->writeFlags(&flaglist);
    codegen->writeFlags(&flaglist);
    debug_optim->writeFlags(&flaglist);
    linker->writeFlags(&flaglist);

    TQString flags;
    TQStringList::ConstIterator li;
    for (li = flaglist.begin(); li != flaglist.end(); ++li) {
        flags += (*li);
        flags += " ";
    }

    for (li = unrecognizedFlags.begin(); li != unrecognizedFlags.end(); ++li) {
        flags += (*li);
        flags += " ";
    }

    flags.truncate(flags.length()-1);
    return flags;
}

#include "dccoptionsplugin.moc"