KDevelop API Documentation

parts/filecreate/filecreate_widget3.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2003 by Julian Rockey * 00003 * linux@jrockey.com * 00004 * thanks: Roberto Raggi for QSimpleRichText stuff * 00005 * * 00006 * This program is free software; you can redistribute it and/or modify * 00007 * it under the terms of the GNU General Public License as published by * 00008 * the Free Software Foundation; either version 2 of the License, or * 00009 * (at your option) any later version. * 00010 ***************************************************************************/ 00011 00012 #include <qptrlist.h> 00013 #include <qwhatsthis.h> 00014 00015 #include <kparts/part.h> 00016 #include <klibloader.h> 00017 #include <kurl.h> 00018 #include <kdebug.h> 00019 #include <klocale.h> 00020 #include <kiconloader.h> 00021 #include <kdevcore.h> 00022 00023 #include "filecreate_widget3.h" 00024 00025 #include "kdevproject.h" 00026 #include "filecreate_part.h" 00027 #include "filecreate_filetype.h" 00028 #include "filecreate_listitem.h" 00029 00030 namespace FileCreate { 00031 00032 ListWidget::ListWidget(FileCreatePart *part) 00033 : KListView(0, "KDevFileCreate"), TypeChooser(part) 00034 { 00035 setIcon( SmallIcon("filenew2") ); 00036 setResizeMode( LastColumn ); 00037 setAllColumnsShowFocus(true); 00038 setRootIsDecorated(true); 00039 00040 addColumn(""); 00041 addColumn(""); 00042 00043 QWhatsThis::add(this, i18n("<b>New file</b><p>This part makes the creation of new files easier. Select a type in the list to create a file. " 00044 "The list of project file types can be configured in project settings dialog, <b>New File Wizard</b> tab. " 00045 "Globally available file types are listed and can be configured in KDevelop settings dialog, <b>New File Wizard</b> tab.")); 00046 00047 00048 connect( this, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotTypeSelected(QListViewItem*)) ); 00049 } 00050 00051 00052 ListWidget::~ListWidget() 00053 { 00054 } 00055 00056 void ListWidget::setCurrent(const FileType * current) { 00057 00058 bool found = false; 00059 QListViewItem * lvi = firstChild(); 00060 while(lvi && !found) { 00061 ListItem * li = dynamic_cast<ListItem*>(lvi); 00062 if (li) { 00063 if (li->filetype()==current) { 00064 found=true; 00065 setSelected(li,true); 00066 } 00067 } 00068 if (lvi->nextSibling()) 00069 lvi = lvi->nextSibling(); 00070 else { 00071 while (lvi && !lvi->nextSibling()) 00072 lvi = lvi->parent(); 00073 } 00074 } 00075 00076 } 00077 00078 void ListWidget::resizeEvent(QResizeEvent *event) { 00079 ListItem *li = dynamic_cast<ListItem*>(firstChild()); 00080 while(li) { 00081 li->prepareResize(); 00082 li = dynamic_cast<ListItem*>(li->nextSibling()); 00083 } 00084 KListView::resizeEvent(event); 00085 } 00086 00087 void ListWidget::refresh() { 00088 clear(); 00089 QPtrList<FileType> filetypes = m_part->getFileTypes(); 00090 for(FileType * filetype = filetypes.first(); 00091 filetype!=NULL; 00092 filetype=filetypes.next()) { 00093 if (filetype->enabled()) { 00094 QPtrList<FileType> subtypes = filetype->subtypes(); 00095 if (subtypes.count()==0) 00096 new ListItem( this, filetype ); 00097 for(FileType * subtype = subtypes.first(); 00098 subtype!=NULL; 00099 subtype=subtypes.next()) { 00100 if (subtype->enabled()) 00101 new ListItem( this, subtype ); 00102 } 00103 } 00104 } 00105 } 00106 00107 void ListWidget::slotTypeSelected(QListViewItem * item) { 00108 ListItem * fileitem = dynamic_cast<ListItem*>(item); 00109 if (!fileitem) return; 00110 00111 const FileType * filetype = fileitem->filetype(); 00112 00113 TypeChooser::filetypeSelected(filetype); 00114 } 00115 00116 00117 } 00118 #include "filecreate_widget3.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:51 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003