00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include "settingsdialog.h"
00013
#include <klistbox.h>
00014
#include <kcombobox.h>
00015
#include <qfile.h>
00016
#include <qdir.h>
00017
#include <qregexp.h>
00018
#include <cstdlib>
00019
00020
#if QT_VERSION < 0x030100
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 QListBoxItem*
QListBox_selectedItem(
QListBox* cpQListBox)
00032 {
00033
if ( cpQListBox->selectionMode() != QListBox::Single )
00034
return 0;
00035
if ( cpQListBox->isSelected( cpQListBox->currentItem() ) )
00036
return cpQListBox->item(cpQListBox->currentItem());
00037
return 0;
00038 }
00039
#endif
00040
00041 SettingsDialog::SettingsDialog(
QWidget* parent,
const char* name, WFlags fl)
00042 :
SettingsDialogBase(parent,name,fl)
00043 {
00044
QStringList qtdirs;
00045 qtdirs.push_back( ::getenv(
"QTDIR") );
00046 qtdirs.push_back(
"/usr/lib/qt3" );
00047 qtdirs.push_back(
"/usr/lib/qt" );
00048 qtdirs.push_back(
"/usr/share/qt3" );
00049
00050
for( QStringList::Iterator it=qtdirs.begin(); it!=qtdirs.end(); ++it )
00051 {
00052
QString qtdir = *it;
00053
if( !qtdir.isEmpty() && isValidQtDir(qtdir) )
00054
if (!qtListBox->findItem(qtdir, ExactMatch))
00055 qtListBox->insertItem( qtdir );
00056 }
00057 }
00058
00059
SettingsDialog::~SettingsDialog()
00060 {
00061 }
00062
00063
00064
void SettingsDialog::slotSelectionChanged(
QListBoxItem* item)
00065 {
00066
#if QT_VERSION < 0x030100
00067
if( !
QListBox_selectedItem(qtListBox) ){
00068
#else
00069
if( !
qtListBox->selectedItem() ){
00070
#endif
00071
emit
enabled(
false );
00072
return;
00073 }
00074
00075
QDir dir(
qtDir() +
"/include" );
00076
QStringList qconfigFileList = dir.entryList(
"qconfig-*.h" );
00077
qtConfiguration->clear();
00078
QRegExp rx(
"qconfig-(\\w+)\\.h" );
00079
for( QStringList::Iterator it=qconfigFileList.begin(); it!=qconfigFileList.end(); ++it )
00080 {
00081 (
void) rx.exactMatch( *it );
00082
qtConfiguration->insertItem( rx.cap(1) );
00083 }
00084
00085 emit
enabled(
true );
00086 }
00087
00088 bool SettingsDialog::isValidQtDir(
const QString & path )
const
00089
{
00090
return QFile::exists( path +
"/include/qt.h" );
00091 }
00092
00093 QString SettingsDialog::qtDir( )
const
00094
{
00095
return qtListBox->currentText();
00096 }
00097
00098 QString SettingsDialog::configuration( )
const
00099
{
00100
return qtConfiguration->currentText();
00101 }
00102
00103
00104
#include "settingsdialog.moc"
00105
00106