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

« back to all changes in this revision

Viewing changes to languages/cpp/pcsimporter/qtimporter/settingsdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
*   Copyright (C) 2003 by Roberto Raggi                                   *
 
3
*   roberto@kdevelop.org                                                  *
 
4
*                                                                         *
 
5
*   This program is free software; you can redistribute it and/or modify  *
 
6
*   it under the terms of the GNU General Public License as published by  *
 
7
*   the Free Software Foundation; either version 2 of the License, or     *
 
8
*   (at your option) any later version.                                   *
 
9
*                                                                         *
 
10
***************************************************************************/
 
11
 
 
12
#include "settingsdialog.h"
 
13
#include <klistbox.h>
 
14
#include <kcombobox.h>
 
15
#include <qfile.h>
 
16
#include <qdir.h>
 
17
#include <qregexp.h>
 
18
#include <cstdlib>
 
19
 
 
20
#if QT_VERSION < 0x030100 
 
21
/* original source from qt-3.2.1/src/widgets/qlistbox.cpp
 
22
QListBoxItem* QListBox::selectedItem() const
 
23
{
 
24
    if ( d->selectionMode != Single )
 
25
        return 0;
 
26
    if ( isSelected( currentItem() ) )
 
27
        return  d->current;
 
28
    return 0;
 
29
}
 
30
*/
 
31
QListBoxItem* QListBox_selectedItem( QListBox* cpQListBox )
 
32
{
 
33
        if ( cpQListBox->selectionMode() != QListBox::Single )
 
34
                return 0;
 
35
        if ( cpQListBox->isSelected( cpQListBox->currentItem() ) )
 
36
                return cpQListBox->item( cpQListBox->currentItem() );
 
37
        return 0;
 
38
}
 
39
#endif
 
40
 
 
41
SettingsDialog::SettingsDialog( QWidget* parent, const char* name, WFlags fl )
 
42
                : SettingsDialogBase( parent, name, fl )
 
43
{
 
44
        QStringList qtdirs;
 
45
        qtdirs.push_back( ::getenv( "QTDIR" ) );
 
46
        qtdirs.push_back( "/usr/lib/qt3" );
 
47
        qtdirs.push_back( "/usr/lib/qt" );
 
48
        qtdirs.push_back( "/usr/share/qt3" );
 
49
 
 
50
        for ( QStringList::Iterator it = qtdirs.begin(); it != qtdirs.end(); ++it )
 
51
        {
 
52
                QString qtdir = *it;
 
53
                if ( !qtdir.isEmpty() && isValidQtDir( qtdir ) )
 
54
                        if ( !qtListBox->findItem( qtdir, ExactMatch ) )
 
55
                                qtListBox->insertItem( qtdir );
 
56
        }
 
57
}
 
58
 
 
59
SettingsDialog::~SettingsDialog()
 
60
{}
 
61
 
 
62
/*$SPECIALIZATION$*/
 
63
void SettingsDialog::slotSelectionChanged( QListBoxItem* // item
 
64
                                         )
 
65
{
 
66
#if QT_VERSION < 0x030100
 
67
        if ( !QListBox_selectedItem( qtListBox ) )
 
68
        {
 
69
#else
 
70
        if ( !qtListBox->selectedItem() )
 
71
        {
 
72
#endif
 
73
                emit enabled( false );
 
74
                return ;
 
75
        }
 
76
 
 
77
        QDir dir( qtDir() + "/include" );
 
78
        QStringList qconfigFileList = dir.entryList( "qconfig-*.h" );
 
79
        qtConfiguration->clear();
 
80
        QRegExp rx( "qconfig-(\\w+)\\.h" );
 
81
        for ( QStringList::Iterator it = qconfigFileList.begin(); it != qconfigFileList.end(); ++it )
 
82
        {
 
83
                ( void ) rx.exactMatch( *it );
 
84
                qtConfiguration->insertItem( rx.cap( 1 ) );
 
85
        }
 
86
 
 
87
        emit enabled( true );
 
88
}
 
89
 
 
90
bool SettingsDialog::isValidQtDir( const QString & path ) const
 
91
{
 
92
        return QFile::exists( path + "/include/qt.h" );
 
93
}
 
94
 
 
95
QString SettingsDialog::qtDir( ) const
 
96
{
 
97
        return qtListBox->currentText();
 
98
}
 
99
 
 
100
QString SettingsDialog::configuration( ) const
 
101
{
 
102
        return qtConfiguration->currentText();
 
103
}
 
104
 
 
105
#include "settingsdialog.moc" 
 
106
//kate: indent-mode csands; tab-width 4; space-indent off;