filecreate_widget3.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
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 setCaption(i18n("File Create"));
00037 setResizeMode( AllColumns );
00038 setAllColumnsShowFocus(true);
00039 setRootIsDecorated(true);
00040
00041 addColumn("");
00042 addColumn("");
00043
00044 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. "
00045 "The list of project file types can be configured in project settings dialog, <b>New File Wizard</b> tab. "
00046 "Globally available file types are listed and can be configured in KDevelop settings dialog, <b>New File Wizard</b> tab."));
00047
00048
00049 connect( this, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotTypeSelected(QListViewItem*)) );
00050 }
00051
00052
00053 ListWidget::~ListWidget()
00054 {
00055 }
00056
00057 void ListWidget::setCurrent(const FileType * current) {
00058
00059 bool found = false;
00060 QListViewItem * lvi = firstChild();
00061 while(lvi && !found) {
00062 ListItem * li = dynamic_cast<ListItem*>(lvi);
00063 if (li) {
00064 if (li->filetype()==current) {
00065 found=true;
00066 setSelected(li,true);
00067 }
00068 }
00069 if (lvi->nextSibling())
00070 lvi = lvi->nextSibling();
00071 else {
00072 while (lvi && !lvi->nextSibling())
00073 lvi = lvi->parent();
00074 }
00075 }
00076
00077 }
00078
00079 void ListWidget::resizeEvent(QResizeEvent *event) {
00080 ListItem *li = dynamic_cast<ListItem*>(firstChild());
00081 while(li) {
00082 li->prepareResize();
00083 li = dynamic_cast<ListItem*>(li->nextSibling());
00084 }
00085 KListView::resizeEvent(event);
00086 }
00087
00088 void ListWidget::refresh() {
00089 clear();
00090 QPtrList<FileType> filetypes = m_part->getFileTypes();
00091 for(FileType * filetype = filetypes.first();
00092 filetype!=NULL;
00093 filetype=filetypes.next()) {
00094 if (filetype->enabled()) {
00095 QPtrList<FileType> subtypes = filetype->subtypes();
00096 if (subtypes.count()==0)
00097 new ListItem( this, filetype );
00098 for(FileType * subtype = subtypes.first();
00099 subtype!=NULL;
00100 subtype=subtypes.next()) {
00101 if (subtype->enabled())
00102 new ListItem( this, subtype );
00103 }
00104 }
00105 }
00106 }
00107
00108 void ListWidget::slotTypeSelected(QListViewItem * item) {
00109 ListItem * fileitem = dynamic_cast<ListItem*>(item);
00110 if (!fileitem) return;
00111
00112 const FileType * filetype = fileitem->filetype();
00113
00114 TypeChooser::filetypeSelected(filetype);
00115 }
00116
00117
00118 }
00119 #include "filecreate_widget3.moc"
This file is part of the documentation for KDevelop Version 3.1.2.