KDevelop API Documentation

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 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 /*$SPECIALIZATION$*/
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 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:30 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003