KDevelop API Documentation

languages/cpp/pcsimporter/qtimporter/settingsdialog.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2003 by Roberto Raggi * 00003 * roberto@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 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 /* original source from qt-3.2.1/src/widgets/qlistbox.cpp 00022 QListBoxItem* QListBox::selectedItem() const 00023 { 00024 if ( d->selectionMode != Single ) 00025 return 0; 00026 if ( isSelected( currentItem() ) ) 00027 return d->current; 00028 return 0; 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 /*$SPECIALIZATION$*/ 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
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:43 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003