KDevelop API Documentation

languages/cpp/ccconfigwidget.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Daniel Engelschalt * 00003 * daniel.engelschalt@gmx.net * 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 // qt includes 00012 #include <qtabwidget.h> 00013 #include <qbuttongroup.h> 00014 #include <qcheckbox.h> 00015 #include <qlineedit.h> 00016 #include <qspinbox.h> 00017 #include <qradiobutton.h> 00018 #include <qcombobox.h> 00019 #include <qmultilineedit.h> 00020 #include <qslider.h> 00021 #include <qheader.h> 00022 00023 // kde includes 00024 #include <kdevproject.h> 00025 #include <kfiledialog.h> 00026 #include <klocale.h> 00027 #include <kmessagebox.h> 00028 #include <kdebug.h> 00029 #include <kstandarddirs.h> 00030 #include <kfileitem.h> 00031 #include <kurlrequester.h> 00032 #include <klistview.h> 00033 #include <knuminput.h> 00034 #include <kmainwindow.h> 00035 00036 // kdevelop includes 00037 #include <domutil.h> 00038 #include <kdevcoderepository.h> 00039 #include <kdevmainwindow.h> 00040 #include <kdevcoderepository.h> 00041 #include <catalog.h> 00042 00043 #include "ccconfigwidget.h" 00044 #include "cppsupportpart.h" 00045 #include "cppcodecompletionconfig.h" 00046 #include "createpcsdialog.h" 00047 00048 using namespace std; 00049 00050 00051 CCConfigWidget::CCConfigWidget( CppSupportPart* part, QWidget* parent, const char* name ) 00052 : CCConfigWidgetBase( parent, name ) 00053 { 00054 m_pPart = part; 00055 connect( m_pPart->codeRepository(), SIGNAL(catalogRegistered(Catalog* )), this, SLOT(catalogRegistered(Catalog* )) ); 00056 connect( m_pPart->codeRepository(), SIGNAL(catalogUnregistered(Catalog* )), this, SLOT(catalogUnregistered(Catalog* )) ); 00057 00058 initFileTemplatesTab( ); 00059 initCodeCompletionTab( ); 00060 00061 inputCodeCompletion->setRange( 0, 2000, 100 ); 00062 inputArgumentsHint->setRange( 0, 2000, 100 ); 00063 } 00064 00065 void CCConfigWidget::initFileTemplatesTab( ) 00066 { 00067 QDomDocument dom = *m_pPart->projectDom(); 00068 interface_suffix->setText(DomUtil::readEntry(dom, "/cppsupportpart/filetemplates/interfacesuffix", ".h")); 00069 implementation_suffix->setText(DomUtil::readEntry(dom, "/cppsupportpart/filetemplates/implementationsuffix", ".cpp")); 00070 } 00071 00072 CCConfigWidget::~CCConfigWidget( ) 00073 { 00074 } 00075 00076 void CCConfigWidget::accept( ) 00077 { 00078 saveFileTemplatesTab(); 00079 saveCodeCompletionTab(); 00080 } 00081 00082 void CCConfigWidget::saveFileTemplatesTab( ) 00083 { 00084 QDomDocument dom = *m_pPart->projectDom(); 00085 DomUtil::writeEntry(dom, "/cppsupportpart/filetemplates/interfacesuffix",interface_suffix->text()); 00086 DomUtil::writeEntry(dom, "/cppsupportpart/filetemplates/implementationsuffix",implementation_suffix->text()); 00087 } 00088 00089 void CCConfigWidget::initCodeCompletionTab( ) 00090 { 00091 advancedOptions->header()->hide(); 00092 00093 CppCodeCompletionConfig* c = m_pPart->codeCompletionConfig(); 00094 00095 inputCodeCompletion->setValue( c->codeCompletionDelay() ); 00096 inputArgumentsHint->setValue( c->argumentsHintDelay() ); 00097 checkAutomaticCodeCompletion->setChecked( c->automaticCodeCompletion() ); 00098 checkAutomaticArgumentsHint->setChecked( c->automaticArgumentsHint() ); 00099 00100 QListViewItem* codeCompletionOptions = new QListViewItem( advancedOptions, i18n("Code Completion Options") ); 00101 codeCompletionOptions->setExpandable( true ); 00102 00103 //QListViewItem* argumentsHintOptions = new QListViewItem( advancedOptions, i18n("Arguments Hint Options") ); 00104 00105 m_includeGlobalFunctions = new QCheckListItem( codeCompletionOptions, i18n("Include Global Functions"), QCheckListItem::CheckBox ); 00106 m_includeGlobalFunctions->setOn( c->includeGlobalFunctions() ); 00107 00108 m_includeTypes = new QCheckListItem( codeCompletionOptions, i18n("Include Types"), QCheckListItem::CheckBox ); 00109 m_includeTypes->setOn( c->includeTypes() ); 00110 00111 m_includeEnums = new QCheckListItem( codeCompletionOptions, i18n("Include Enums"), QCheckListItem::CheckBox ); 00112 m_includeEnums->setOn( c->includeEnums() ); 00113 00114 m_includeTypedefs = new QCheckListItem( codeCompletionOptions, i18n("Include Typedefs"), QCheckListItem::CheckBox ); 00115 m_includeTypedefs->setOn( c->includeTypedefs() ); 00116 00117 m_pcsOptions = new QListViewItem( advancedOptions, i18n("Persistant Class Store") ); 00118 QValueList<Catalog*> catalogs = m_pPart->codeRepository()->registeredCatalogs(); 00119 for( QValueList<Catalog*>::Iterator it=catalogs.begin(); it!=catalogs.end(); ++it ) 00120 { 00121 Catalog* c = *it; 00122 QFileInfo dbInfo( c->dbName() ); 00123 QCheckListItem* item = new QCheckListItem( m_pcsOptions, dbInfo.baseName(), QCheckListItem::CheckBox ); 00124 item->setOn( c->enabled() ); 00125 00126 m_catalogs[ item ] = c; 00127 } 00128 } 00129 00130 void CCConfigWidget::saveCodeCompletionTab( ) 00131 { 00132 CppCodeCompletionConfig* c = m_pPart->codeCompletionConfig(); 00133 00134 c->setCodeCompletionDelay( inputCodeCompletion->value() ); 00135 c->setArgumentsHintDelay( inputArgumentsHint->value() ); 00136 00137 c->setAutomaticCodeCompletion( checkAutomaticCodeCompletion->isChecked() ); 00138 c->setAutomaticArgumentsHint( checkAutomaticArgumentsHint->isChecked() ); 00139 00140 c->setIncludeGlobalFunctions( m_includeGlobalFunctions->isOn() ); 00141 c->setIncludeTypes( m_includeTypes->isOn() ); 00142 c->setIncludeEnums( m_includeEnums->isOn() ); 00143 c->setIncludeTypedefs( m_includeTypedefs->isOn() ); 00144 00145 for( QMap<QCheckListItem*, Catalog*>::Iterator it=m_catalogs.begin(); it!=m_catalogs.end(); ++it ) 00146 { 00147 it.data()->setEnabled( it.key()->isOn() ); 00148 } 00149 00150 c->store(); 00151 } 00152 00153 void CCConfigWidget::slotNewPCS( ) 00154 { 00155 CreatePCSDialog dlg( m_pPart, m_pPart->mainWindow()->main() ); 00156 dlg.importerListView->setFocus(); 00157 dlg.exec(); 00158 } 00159 00160 void CCConfigWidget::catalogRegistered( Catalog * c ) 00161 { 00162 QFileInfo dbInfo( c->dbName() ); 00163 QCheckListItem* item = new QCheckListItem( m_pcsOptions, dbInfo.baseName(), QCheckListItem::CheckBox ); 00164 item->setOn( c->enabled() ); 00165 00166 m_catalogs[ item ] = c; 00167 } 00168 00169 void CCConfigWidget::catalogUnregistered( Catalog * c ) 00170 { 00171 for( QMap<QCheckListItem*, Catalog*>::Iterator it=m_catalogs.begin(); it!=m_catalogs.end(); ++it ) 00172 { 00173 if( it.data() == c ){ 00174 QCheckListItem* item = it.key(); 00175 delete( item ); 00176 m_catalogs.remove( it ); 00177 break; 00178 } 00179 } 00180 } 00181 00182 #include "ccconfigwidget.moc"
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:41 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003