KDevelop API Documentation

configwidgetproxy.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Jens Dagerbo <jens.dagerbo@swipnet.se>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 
00021 
00022 #include <qstring.h>
00023 #include <qvbox.h>
00024 
00025 #include <kdebug.h>
00026 #include <kdialogbase.h>
00027 #include <kiconloader.h>
00028 
00029 #include <kdevcore.h>
00030 
00031 
00032 #include "configwidgetproxy.h"
00033 
00034 
00035 ConfigWidgetProxy::ConfigWidgetProxy( KDevCore * core )
00036 {
00037     connect( core, SIGNAL(configWidget(KDialogBase*)), this, SLOT(slotConfigWidget( KDialogBase*)) );
00038     connect( core, SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(slotProjectConfigWidget( KDialogBase*)) );
00039 }
00040 
00041 ConfigWidgetProxy::~ConfigWidgetProxy()
00042 {}
00043 
00044 void ConfigWidgetProxy::createGlobalConfigPage( QString const & title, unsigned int pagenumber, QString const & icon )
00045 {
00046     _globalTitleMap.insert( pagenumber, qMakePair( title, icon ) );
00047 }
00048 
00049 void ConfigWidgetProxy::createProjectConfigPage( QString const & title, unsigned int pagenumber, QString const & icon )
00050 {
00051     _projectTitleMap.insert( pagenumber, qMakePair( title, icon ) );
00052 }
00053 
00054 void ConfigWidgetProxy::removeConfigPage( int pagenumber )
00055 {
00056     _globalTitleMap.remove( pagenumber );
00057     _projectTitleMap.remove( pagenumber );
00058 }
00059 
00060 void ConfigWidgetProxy::slotConfigWidget( KDialogBase * dlg )
00061 {
00062     TitleMap::Iterator it = _globalTitleMap.begin();
00063     while ( it != _globalTitleMap.end() )
00064     {
00065         _pageMap.insert( dlg->addVBoxPage( it.data().first, it.data().first, BarIcon( it.data().second, KIcon::SizeMedium ) ), it.key() );
00066         ++it;
00067     }
00068 
00069     connect( dlg, SIGNAL(aboutToShowPage(QWidget*)), this, SLOT( slotAboutToShowPage(QWidget*)) );  
00070     connect( dlg, SIGNAL(destroyed()), this, SLOT(slotConfigWidgetDestroyed()) );
00071 }
00072 
00073 void ConfigWidgetProxy::slotProjectConfigWidget( KDialogBase * dlg )
00074 {
00075     TitleMap::Iterator it = _projectTitleMap.begin();
00076     while ( it != _projectTitleMap.end() )
00077     {
00078         _pageMap.insert( dlg->addVBoxPage( it.data().first, it.data().first, BarIcon( it.data().second, KIcon::SizeMedium ) ), it.key() );
00079         ++it;
00080     }
00081     
00082     connect( dlg, SIGNAL(aboutToShowPage(QWidget*)), this, SLOT( slotAboutToShowPage(QWidget*)) );  
00083     connect( dlg, SIGNAL(destroyed()), this, SLOT(slotConfigWidgetDestroyed()) );
00084 }
00085 
00086 void ConfigWidgetProxy::slotConfigWidgetDestroyed( )
00087 {
00088     _pageMap.clear();
00089 }
00090 
00091 void ConfigWidgetProxy::slotAboutToShowPage( QWidget * page )
00092 {
00093     if ( !page ) return;
00094     
00095     PageMap::Iterator it = _pageMap.find( page );
00096     if ( it != _pageMap.end() )
00097     {
00098         emit insertConfigWidget( static_cast<KDialogBase*>(const_cast<QObject*>(sender())), page, it.data() );
00099         _pageMap.remove( it );
00100     }
00101 }
00102 
00103 #include "configwidgetproxy.moc"
00104 
00105 // kate: space-indent off; indent-width 4; replace-tabs off; tab-width 4;
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003