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 kdedirs;
00045 kdedirs.push_back( ::getenv(
"KDEDIR") +
QString(
"/include") );
00046 kdedirs.push_back(
"/usr/lib/kde/include" );
00047 kdedirs.push_back(
"/usr/local/kde/include" );
00048 kdedirs.push_back(
"/usr/local/include" );
00049 kdedirs.push_back(
"/usr/kde/include" );
00050 kdedirs.push_back(
"/usr/include/kde" );
00051 kdedirs.push_back(
"/usr/include" );
00052 kdedirs.push_back(
"/opt/kde3/include" );
00053 kdedirs.push_back(
"/opt/kde/include" );
00054
00055
for( QStringList::Iterator it=kdedirs.begin(); it!=kdedirs.end(); ++it )
00056 {
00057
QString kdedir = *it;
00058
if( !kdedir.isEmpty() && isValidKDELibsDir(kdedir) )
00059
if (!kdeListBox->findItem(kdedir, ExactMatch))
00060 kdeListBox->insertItem( kdedir );
00061 }
00062 }
00063
00064
SettingsDialog::~SettingsDialog()
00065 {
00066 }
00067
00068
00069 void SettingsDialog::slotSelectionChanged(
QListBoxItem* item)
00070 {
00071
#if QT_VERSION < 0x030100
00072
if( !
QListBox_selectedItem(kdeListBox) ){
00073
#else
00074
if( !kdeListBox->selectedItem() ){
00075
#endif
00076
emit enabled(
false );
00077
return;
00078 }
00079
00080 emit enabled(
true );
00081 }
00082
00083 bool SettingsDialog::isValidKDELibsDir(
const QString & path )
const
00084
{
00085
return QFile::exists( path +
"/kapplication.h" );
00086 }
00087
00088 QString SettingsDialog::kdeDir( )
const
00089
{
00090
return kdeListBox->currentText();
00091 }
00092
00093
00094
#include "settingsdialog.moc"
00095
00096