KDevelop API Documentation

parts/appwizard/appwizarddlg.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2001-2002 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * Copyright (C) 2001 by Sandy Meier * 00005 * smeier@kdevelop.org * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 ***************************************************************************/ 00013 00014 #include "appwizarddlg.h" 00015 00016 #include <qvbox.h> 00017 #include <qbuttongroup.h> 00018 #include <qcombobox.h> 00019 #include <qtabwidget.h> 00020 #include <qwidgetstack.h> 00021 #include <qdir.h> 00022 #include <qfileinfo.h> 00023 #include <qgrid.h> 00024 #include <qheader.h> 00025 #include <qlistview.h> 00026 #include <qmap.h> 00027 #include <qmultilineedit.h> 00028 #include <qpushbutton.h> 00029 #include <qradiobutton.h> 00030 #include <qregexp.h> 00031 #include <qtextstream.h> 00032 #include <qtextview.h> 00033 #include <qtoolbutton.h> 00034 #include <qtooltip.h> 00035 #include <qvalidator.h> 00036 #include <kconfig.h> 00037 #include <kdebug.h> 00038 #include <kglobal.h> 00039 #include <kglobalsettings.h> 00040 #include <klocale.h> 00041 #include <kmessagebox.h> 00042 #include <kprocess.h> 00043 #include <kstandarddirs.h> 00044 #include <ktempfile.h> 00045 #include <kiconloader.h> 00046 #include <kfiledialog.h> 00047 #include <kfile.h> 00048 #include <kapplication.h> 00049 00050 #include <ktrader.h> 00051 #include <kparts/componentfactory.h> 00052 00053 #include "kdevversioncontrol.h" 00054 #include "kdevmakefrontend.h" 00055 #include "appwizardfactory.h" 00056 #include "appwizardpart.h" 00057 #include "filepropspage.h" 00058 #include "misc.h" 00059 00060 00061 AppWizardDialog::AppWizardDialog(AppWizardPart *part, QWidget *parent, const char *name) 00062 : AppWizardDialogBase(parent, name,true), m_pCurrentAppInfo(0) 00063 { 00064 kdDebug( 9000 ) << " ** AppWizardDialog::AppWizardDialog()" << endl; 00065 00066 connect( this, SIGNAL( selected( const QString & ) ), this, SLOT( pageChanged() ) ); 00067 00068 helpButton()->hide(); 00069 templates_listview->header()->hide(); 00070 00071 m_pathIsValid=false; 00072 m_part = part; 00073 m_projectLocationWasChanged=false; 00074 m_appsInfo.setAutoDelete(true); 00075 m_tempFiles.setAutoDelete(true); 00076 00077 KConfig *config = kapp->config(); 00078 config->setGroup("General Options"); 00079 QString defaultProjectsDir = config->readPathEntry("DefaultProjectsDir", QDir::homeDirPath()+"/"); 00080 00081 KStandardDirs *dirs = AppWizardFactory::instance()->dirs(); 00082 QStringList m_templateNames = dirs->findAllResources("apptemplates", QString::null, false, true); 00083 00084 kdDebug(9010) << "Templates: " << endl; 00085 QStringList categories; 00086 00087 QStringList::Iterator it; 00088 for (it = m_templateNames.begin(); it != m_templateNames.end(); ++it) { 00089 kdDebug(9010) << (*it) << endl; 00090 KConfig config(KGlobal::dirs()->findResource("apptemplates", *it)); 00091 config.setGroup("General"); 00092 00093 ApplicationInfo *info = new ApplicationInfo; 00094 info->templateName = (*it); 00095 info->name = config.readEntry("Name"); 00096 info->icon = config.readEntry("Icon"); 00097 info->comment = config.readEntry("Comment"); 00098 info->fileTemplates = config.readEntry("FileTemplates"); 00099 info->openFilesAfterGeneration = config.readListEntry("ShowFilesAfterGeneration"); 00100 QString destDir = config.readPathEntry("DefaultDestinatonDir", defaultProjectsDir); 00101 destDir.replace(QRegExp("HOMEDIR"), QDir::homeDirPath()); 00102 info->defaultDestDir = destDir; 00103 QString category = config.readEntry("Category"); 00104 // format category to a unique status 00105 if (category.right(1) == "/") 00106 category.remove(category.length()-1, 1); // remove / 00107 if (category.left(1) != "/") 00108 category.prepend("/"); // prepend / 00109 categories.append(category); 00110 info->category = category; 00111 m_appsInfo.append(info); 00112 } 00113 00114 // Insert categories into list view 00115 categories.sort(); 00116 for (it = categories.begin(); it != categories.end(); ++it) 00117 insertCategoryIntoTreeView(*it); 00118 00119 // Insert items into list view 00120 QPtrListIterator<ApplicationInfo> ait(m_appsInfo); 00121 for (; ait.current(); ++ait) { 00122 QListViewItem *item = m_categoryMap.find(ait.current()->category); 00123 if (item) 00124 item = new QListViewItem(item, ait.current()->name); 00125 else 00126 kdDebug(9010) << "Error can't find category in categoryMap: " 00127 << ait.current()->category << endl; 00128 ait.current()->item = item; 00129 } 00130 00131 QString author, email; 00132 AppWizardUtil::guessAuthorAndEmail(&author, &email); 00133 author_edit->setText(author); 00134 email_edit->setText(email); 00135 QToolTip::add( dest_edit->button(), i18n("Choose projects directory") ); 00136 dest_edit->setURL(defaultProjectsDir); 00137 dest_edit->setMode(KFile::Directory|KFile::ExistingOnly); 00138 00139 /* //add a new page (fileprops) 00140 QString projectname = "Test"; 00141 FilePropsPage* m_sdi_fileprops_page = new FilePropsPage(this,"fileprops"); 00142 QPtrList<ClassFileProp>* props_temp = new QPtrList<ClassFileProp>; 00143 ClassFileProp* prop = new ClassFileProp(); 00144 prop->m_classname = projectname + "App"; 00145 prop->m_headerfile = projectname.lower() + "app.h"; 00146 prop->m_implfile = projectname.lower() + "app.cpp"; 00147 prop->m_baseclass = "KMainWindow"; 00148 prop->m_description = "The base class for the application window. It sets up the main window and reads the config file as well as providing a menubar, toolbar and statusbar. An instance of the View creates your center view, which is connected to the window's Doc object."; 00149 prop->m_change_baseclass = false; 00150 prop->m_key = "App"; 00151 props_temp->append(prop); 00152 00153 prop = new ClassFileProp(); 00154 prop->m_classname = projectname + "View"; 00155 prop->m_headerfile = projectname.lower() + "view.h"; 00156 prop->m_implfile = projectname.lower() + "view.cpp"; 00157 prop->m_baseclass = "QWidget"; 00158 prop->m_description = "The View class provides the view widget for the App instance. The View instance inherits QWidget as a base class and represents the view object of a KMainWindow. As View is part of the document-view model, it needs a reference to the document object connected with it by the App class to manipulate and display the document structure provided by the Doc class."; 00159 prop->m_change_baseclass = true; 00160 prop->m_key = "View"; 00161 props_temp->append(prop); 00162 00163 prop = new ClassFileProp(); 00164 prop->m_classname = projectname + "Doc"; 00165 prop->m_headerfile = projectname.lower() + "doc.h"; 00166 prop->m_implfile = projectname.lower() + "doc.cpp"; 00167 prop->m_baseclass = "QObject"; 00168 prop->m_description = "The Doc class provides a document object that can be used in conjunction with the classes App and View to create a document-view model for standard KDE applications based on KApplication and KMainWindow. Doc contains the methods for serialization of the document data from and to files"; 00169 prop->m_change_baseclass = true; 00170 prop->m_key = "Doc"; 00171 props_temp->append(prop); 00172 00173 m_sdi_fileprops_page->setClassFileProps(*props_temp); 00174 */ 00175 loadVcs(); 00176 00177 // addPage(m_sdi_fileprops_page,"Class/File Properties"); 00178 00179 // licenseChanged(); 00180 00181 setNextEnabled(generalPage, false); 00182 // nextButton()->setEnabled(!appname_edit->text().isEmpty()); 00183 00184 // QRegExp appname_regexp ("[a-zA-Z][a-zA-Z0-9_]*"); //Non-Unicode version 00185 /* appname will start with a letter, and will contain letters, 00186 digits or underscores. */ 00187 QRegExp appname_regexp ("[a-zA-Z][a-zA-Z0-9_]*"); 00188 // How about names like "__" or "123" for project name? Are they legal? 00189 QRegExpValidator *appname_edit_validator; 00190 appname_edit_validator = new QRegExpValidator (appname_regexp, 00191 appname_edit, 00192 "AppNameValidator"); 00193 appname_edit->setValidator(appname_edit_validator); 00194 } 00195 00196 AppWizardDialog::~AppWizardDialog() 00197 {} 00198 00199 void AppWizardDialog::loadVcs() 00200 { 00201 m_vcsForm = new VcsForm(); 00202 00203 int i=0; 00204 m_vcsForm->combo->insertItem( i18n("no version control system", "None"), i ); 00205 m_vcsForm->stack->addWidget( 0, i++ ); 00206 00207 // We query for all vcs plugins for KDevelop 00208 QStringList availableVcs = m_part->registeredVersionControls(); 00209 00210 for(QStringList::const_iterator it( availableVcs.begin() ); it != availableVcs.end(); ++it) 00211 { 00212 KDevVersionControl *vcs = m_part->versionControlByName( (*it) ); 00213 QString vcsName = vcs->uid(); 00214 00215 QWidget *newProjectWidget = vcs->newProjectWidget( m_vcsForm->stack ); 00216 if (newProjectWidget) { 00217 m_vcsForm->combo->insertItem( vcsName, i ); 00218 m_vcsForm->stack->addWidget( newProjectWidget, i++ ); 00219 } 00220 else 00221 { 00222 kdDebug( 9000 ) << " ** Warning: VCS has not widget. Skipping. " << endl; 00223 } 00224 } 00225 00226 addPage( m_vcsForm, i18n("Version Control System") ); 00227 } 00228 00229 00230 void AppWizardDialog::textChanged() 00231 { 00232 licenseChanged(); 00233 00234 bool invalid = !m_pCurrentAppInfo 00235 || appname_edit->text().isEmpty() 00236 || !m_pathIsValid 00237 || author_edit->text().isEmpty() 00238 || version_edit->text().isEmpty(); 00239 setFinishEnabled(m_lastPage, !invalid); 00240 nextButton()->setEnabled(!invalid); 00241 00242 } 00243 00244 00245 void AppWizardDialog::licenseChanged() 00246 { 00247 QString str = 00248 "/***************************************************************************\n" 00249 " * Copyright (C) %1 by %2 *\n" 00250 " * %3 *\n" 00251 " * *\n"; 00252 00253 QString author = author_edit->text(); 00254 QString email = email_edit->text(); 00255 00256 str = str.arg(QDate::currentDate().year()).arg(author.left(45),-45).arg(email.left(67),-67); 00257 00258 switch (license_combo->currentItem()) 00259 { 00260 case 0: 00261 str += 00262 " * This program is free software; you can redistribute it and/or modify *\n" 00263 " * it under the terms of the GNU General Public License as published by *\n" 00264 " * the Free Software Foundation; either version 2 of the License, or *\n" 00265 " * (at your option) any later version. *\n" 00266 " * *\n" 00267 " * This program is distributed in the hope that it will be useful, *\n" 00268 " * but WITHOUT ANY WARRANTY; without even the implied warranty of *\n" 00269 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\n" 00270 " * GNU General Public License for more details. *\n" 00271 " * *\n" 00272 " * You should have received a copy of the GNU General Public License *\n" 00273 " * along with this program; if not, write to the *\n" 00274 " * Free Software Foundation, Inc., *\n" 00275 " * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *\n"; 00276 break; 00277 case 1: 00278 str += 00279 " * Permission is hereby granted, free of charge, to any person obtaining *\n" 00280 " * a copy of this software and associated documentation files (the *\n" 00281 " * \"Software\"), to deal in the Software without restriction, including *\n" 00282 " * without limitation the rights to use, copy, modify, merge, publish, *\n" 00283 " * distribute, sublicense, and/or sell copies of the Software, and to *\n" 00284 " * permit persons to whom the Software is furnished to do so, subject to *\n" 00285 " * the following conditions: *\n" 00286 " * *\n" 00287 " * The above copyright notice and this permission notice shall be *\n" 00288 " * included in all copies or substantial portions of the Software. *\n" 00289 " * *\n" 00290 " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, *\n" 00291 " * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *\n" 00292 " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*\n" 00293 " * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR *\n" 00294 " * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *\n" 00295 " * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *\n" 00296 " * OTHER DEALINGS IN THE SOFTWARE. *\n"; 00297 break; 00298 case 2: 00299 str += 00300 " * This program may be distributed under the terms of the Q Public *\n" 00301 " * License as defined by Trolltech AS of Norway and appearing in the *\n" 00302 " * file LICENSE.QPL included in the packaging of this file. *\n" 00303 " * *\n" 00304 " * This program is distributed in the hope that it will be useful, *\n" 00305 " * but WITHOUT ANY WARRANTY; without even the implied warranty of *\n" 00306 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *\n"; 00307 break; 00308 case 3: 00309 str += 00310 " * This program is free software; you can redistribute it and/or modify *\n" 00311 " * it under the terms of the GNU Library General Public License as *\n" 00312 " * published by the Free Software Foundation; either version 2 of the *\n" 00313 " * License, or (at your option) any later version. *\n" 00314 " * *\n" 00315 " * This program is distributed in the hope that it will be useful, *\n" 00316 " * but WITHOUT ANY WARRANTY; without even the implied warranty of *\n" 00317 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\n" 00318 " * GNU General Public License for more details. *\n" 00319 " * *\n" 00320 " * You should have received a copy of the GNU Library General Public *\n" 00321 " * License along with this program; if not, write to the *\n" 00322 " * Free Software Foundation, Inc., *\n" 00323 " * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *\n"; 00324 } 00325 00326 str += " ***************************************************************************/\n"; 00327 00328 QValueList<AppWizardFileTemplate>::Iterator it; 00329 for (it = m_fileTemplates.begin(); it != m_fileTemplates.end(); ++it) { 00330 QString style = (*it).style; 00331 QMultiLineEdit *edit = (*it).edit; 00332 00333 QString text; 00334 if (style == "CStyle") { 00335 text = str; 00336 } else if (style == "PStyle") { 00337 text = str; 00338 text.replace(QRegExp("/\\**\n \\*"), "{\n "); 00339 text.replace(QRegExp("\\*\n \\*"), " \n "); 00340 text.replace(QRegExp(" *\\**/\n"), "}\n"); 00341 } else if (style == "AdaStyle") { 00342 text = str; 00343 text.replace(QRegExp("/\\*"), "--"); 00344 text.replace(QRegExp(" \\*"), "--"); 00345 text.replace(QRegExp("\\*/"), "*"); 00346 } else if (style == "ShellStyle") { 00347 text = str; 00348 text.replace(QRegExp("\\*|/"), "#"); 00349 text.replace(QRegExp("\n ##"), "\n##"); 00350 text.replace(QRegExp("\n #"), "\n# "); 00351 } 00352 00353 edit->setText(text); 00354 } 00355 } 00356 00357 00358 void AppWizardDialog::accept() 00359 { 00360 QFileInfo fi(finalLoc_label->text()); 00361 // check /again/ whether the dir already exists; maybe users create it in the meantime 00362 if (fi.exists()) { 00363 KMessageBox::sorry(this, i18n("The directory you have chosen as the location for " 00364 "the project already exists.")); 00365 showPage(generalPage); 00366 appname_edit->setFocus(); 00367 projectLocationChanged(); 00368 return; 00369 } 00370 00371 if (!fi.dir().exists()) { 00372 // create dir if it doesn't exist 00373 KShellProcess p("/bin/sh"); 00374 p.clearArguments(); 00375 p << "mkdirhier"; 00376 p << KShellProcess::quote(finalLoc_label->text()); 00377 p.start(KProcess::Block,KProcess::AllOutput); 00378 } 00379 00380 // if dir still does not exist 00381 if (!fi.dir().exists()) { 00382 KMessageBox::sorry(this, i18n("The directory above the chosen location does not exist and cannot be created.")); 00383 showPage(generalPage); 00384 dest_edit->setFocus(); 00385 return; 00386 } 00387 00388 /* // this piece of code is rendered useless by the QValidator 00389 QString appname = appname_edit->text(); 00390 for (uint i=0; i < appname.length(); ++i) 00391 if (!appname[i].isLetterOrNumber() && appname[i] != '_') { 00392 KMessageBox::sorry(this, i18n("Your application name should only contain letters and numbers, " 00393 "as it will be used as the top level directory name.")); 00394 showPage(generalPage); 00395 appname_edit->setFocus(); 00396 return; 00397 } 00398 */ 00399 00400 QString source, script; 00401 QFileInfo finfo(m_pCurrentAppInfo->templateName); 00402 QDir dir(finfo.dir()); 00403 dir.cdUp(); 00404 source = dir.absPath(); 00405 script = dir.filePath("template-" + finfo.fileName() + "/script"); 00406 00407 QString license = 00408 (license_combo->currentItem()<4)? license_combo->currentText() : i18n("Custom"); 00409 00410 QString licensefile; 00411 switch (license_combo->currentItem()) 00412 { 00413 case 0: licensefile = "COPYING"; break; 00414 case 1: licensefile = "LICENSE.BSD"; break; 00415 case 2: licensefile = "LICENSE.QPL"; break; 00416 case 3: licensefile = "COPYING.LIB"; break; 00417 default: ; 00418 } 00419 00420 QStringList templateFiles; 00421 QValueList<AppWizardFileTemplate>::Iterator it; 00422 for (it = m_fileTemplates.begin(); it != m_fileTemplates.end(); ++it) { 00423 KTempFile *tempFile = new KTempFile(); 00424 m_tempFiles.append(tempFile); 00425 00426 QFile f; 00427 f.open(IO_WriteOnly, tempFile->handle()); 00428 QTextStream temps(&f); 00429 temps << (*it).edit->text(); 00430 f.flush(); 00431 00432 templateFiles << (*it).suffix; 00433 templateFiles << tempFile->name(); 00434 } 00435 00436 m_cmdline = "perl "; 00437 m_cmdline += script; 00438 m_cmdline += " --author="; 00439 m_cmdline += KShellProcess::quote(QString::fromLocal8Bit(author_edit->text().utf8())); 00440 m_cmdline += " --email="; 00441 m_cmdline += KShellProcess::quote(email_edit->text()); 00442 m_cmdline += " --version="; 00443 m_cmdline += KShellProcess::quote(version_edit->text()); 00444 m_cmdline += " --appname="; 00445 m_cmdline += KShellProcess::quote(appname_edit->text()); 00446 m_cmdline += " --dest="; 00447 m_cmdline += KShellProcess::quote(finalLoc_label->text()); 00448 m_cmdline += " --source="; 00449 m_cmdline += KShellProcess::quote(source); 00450 m_cmdline += " --license="; 00451 m_cmdline += KShellProcess::quote(license); 00452 m_cmdline += " --licensefile="; 00453 m_cmdline += KShellProcess::quote(licensefile); 00454 m_cmdline += " --filetemplates="; 00455 m_cmdline += KShellProcess::quote(templateFiles.join(",")); 00456 00457 m_part->makeFrontend()->queueCommand(QString::null, m_cmdline); 00458 00459 if (m_vcsForm->stack->id(m_vcsForm->stack->visibleWidget())) { 00460 KDevVersionControl* pVC = m_part->versionControlByName( m_vcsForm->combo->currentText() ); 00461 if (pVC) { 00462 kdDebug( 9000 ) << "Creating new project with selected VCS ..." << endl; 00463 pVC->createNewProject(finalLoc_label->text()); 00464 } 00465 else 00466 { 00467 kdDebug( 9000 ) << "Could not grab the selected VCS: " << m_vcsForm->combo->currentText() << endl; 00468 } 00469 } 00470 00471 QWizard::accept(); 00472 } 00473 00474 00475 void AppWizardDialog::templatesTreeViewClicked(QListViewItem *item) 00476 { 00477 // Delete old file template pages 00478 while (!m_fileTemplates.isEmpty()) { 00479 QMultiLineEdit *edit = m_fileTemplates.first().edit; 00480 removePage(edit); 00481 delete edit; 00482 m_fileTemplates.remove(m_fileTemplates.begin()); 00483 } 00484 m_lastPage = 0; 00485 00486 ApplicationInfo *info = templateForItem(item); 00487 if (info) { 00488 m_pCurrentAppInfo = info; 00489 if (!info->icon.isEmpty()) { 00490 QFileInfo fi(info->templateName); 00491 QDir dir(fi.dir()); 00492 dir.cdUp(); 00493 QPixmap pm; 00494 pm.load(dir.filePath("template-" + fi.fileName() + "/" + info->icon)); 00495 icon_label->setPixmap(pm); 00496 } else { 00497 icon_label->clear(); 00498 } 00499 desc_textview->setText(info->comment); 00500 // dest_edit->setURL(info->defaultDestDir); 00501 m_projectLocationWasChanged = false; 00502 //projectNameChanged(); // set the dest new 00503 00504 // Create new file template pages 00505 QStringList l = QStringList::split(",", info->fileTemplates); 00506 QStringList::ConstIterator it = l.begin(); 00507 while (it != l.end()) { 00508 AppWizardFileTemplate fileTemplate; 00509 fileTemplate.suffix = *it; 00510 ++it; 00511 if (it != l.end()) { 00512 fileTemplate.style = *it; 00513 ++it; 00514 } else 00515 fileTemplate.style = ""; 00516 00517 QMultiLineEdit *edit = new QMultiLineEdit(this); 00518 edit->setWordWrap(QTextEdit::NoWrap); 00519 edit->setFont(KGlobalSettings::fixedFont()); 00520 if (it == l.end()) 00521 m_lastPage = edit; 00522 fileTemplate.edit = edit; 00523 addPage(edit, i18n("Template for .%1 Files").arg(fileTemplate.suffix)); 00524 m_fileTemplates.append(fileTemplate); 00525 } 00526 // licenseChanged(); // update template editors 00527 textChanged(); // calls licenseChanged() && update Next button state 00528 } else { 00529 m_pCurrentAppInfo=0; 00530 icon_label->clear(); 00531 desc_textview->clear(); 00532 nextButton()->setEnabled(false); 00533 } 00534 } 00535 00536 00537 void AppWizardDialog::destButtonClicked(const QString& dir) 00538 { 00539 if(!dir.isEmpty()) { 00540 00541 // set new location as default project dir? 00542 KConfig *config = kapp->config(); 00543 config->setGroup("General Options"); 00544 QDir defPrjDir( config->readPathEntry("DefaultProjectsDir", QDir::homeDirPath()) ); 00545 QDir newDir (dir); 00546 kdDebug(9010) << "DevPrjDir == newdir?: " << defPrjDir.absPath() << " == " << newDir.absPath() << endl; 00547 if (defPrjDir != newDir) { 00548 if (KMessageBox::questionYesNo(this, i18n("Set default project location to: ") + newDir.absPath() + "?", 00549 i18n("New Project")) == KMessageBox::Yes) 00550 { 00551 config->writePathEntry("DefaultProjectsDir", newDir.absPath() + "/"); 00552 config->sync(); 00553 } 00554 } 00555 } 00556 } 00557 00558 00559 void AppWizardDialog::projectNameChanged() 00560 { 00561 // Location was already edited by hand => don't change 00562 } 00563 00564 00565 void AppWizardDialog::projectLocationChanged() 00566 { 00567 // Jakob Simon-Gaarde: Got tired of the anoying bug with the appname/location confussion. 00568 // This version insures WYSIWYG and checks pathvalidity 00569 finalLoc_label->setText(dest_edit->url() + (dest_edit->url().right(1)=="/" ? "":"/") + appname_edit->text().lower()); 00570 QDir qd(dest_edit->url()); 00571 QFileInfo fi(dest_edit->url() + "/" + appname_edit->text().lower()); 00572 if (!qd.exists() || appname_edit->displayText().isEmpty()||fi.exists()) 00573 { 00574 if (!fi.exists() || appname_edit->displayText().isEmpty()) { 00575 finalLoc_label->setText(finalLoc_label->text() + i18n("invalid location", " (invalid)")); 00576 } else { 00577 finalLoc_label->setText(finalLoc_label->text() + i18n(" (dir/file already exist)")); 00578 } 00579 m_pathIsValid=false; 00580 } else { 00581 m_pathIsValid=true; 00582 } 00583 bool invalid = !m_pCurrentAppInfo 00584 || appname_edit->text().isEmpty() 00585 || !m_pathIsValid 00586 || author_edit->text().isEmpty() 00587 || version_edit->text().isEmpty(); 00588 setFinishEnabled(m_lastPage, !invalid); 00589 nextButton()->setEnabled(!invalid); 00590 } 00591 00592 00593 void AppWizardDialog::insertCategoryIntoTreeView(const QString &completeCategoryPath) 00594 { 00595 kdDebug(9010) << "TemplateCategory: " << completeCategoryPath << endl; 00596 QStringList categories = QStringList::split("/", completeCategoryPath); 00597 QString category =""; 00598 QListViewItem* pParentItem=0; 00599 00600 QStringList::ConstIterator it; 00601 for (it = categories.begin(); it != categories.end(); ++it) { 00602 category = category + "/" + *it; 00603 QListViewItem *item = m_categoryMap.find(category); 00604 if (!item) { // not found, create it 00605 if (!pParentItem) 00606 pParentItem = new QListViewItem(templates_listview,*it); 00607 else 00608 pParentItem = new QListViewItem(pParentItem,*it); 00609 00610 pParentItem->setPixmap(0, SmallIcon("folder")); 00611 //pParentItem->setOpen(true); 00612 kdDebug(9010) << "Category: " << category << endl; 00613 m_categoryMap.insert(category,pParentItem); 00614 } else { 00615 pParentItem = item; 00616 } 00617 } 00618 } 00619 00620 00621 ApplicationInfo *AppWizardDialog::templateForItem(QListViewItem *item) 00622 { 00623 QPtrListIterator<ApplicationInfo> it(m_appsInfo); 00624 for (; it.current(); ++it) 00625 if (it.current()->item == item) 00626 return it.current(); 00627 00628 return 0; 00629 } 00630 00631 QStringList AppWizardDialog::getFilesToOpenAfterGeneration() 00632 { 00633 for ( QStringList::Iterator it = m_pCurrentAppInfo->openFilesAfterGeneration.begin(); 00634 it != m_pCurrentAppInfo->openFilesAfterGeneration.end(); ++it ) { 00635 (*it) = (*it).replace(QRegExp("APPNAMEUC"), getProjectName().upper()); 00636 (*it) = (*it).replace(QRegExp("APPNAMELC"), getProjectName().lower()); 00637 (*it) = (*it).replace(QRegExp("APPNAME"), getProjectName()); 00638 } 00639 return m_pCurrentAppInfo->openFilesAfterGeneration; 00640 } 00641 00642 void AppWizardDialog::pageChanged() 00643 { 00644 kdDebug(9010) << "AppWizardDialog::pageChanged()" << endl; 00645 projectLocationChanged(); 00646 } 00647 00648 #include "appwizarddlg.moc" 00649
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:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003