From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- parts/filecreate/filecreate_widget3.cpp | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 parts/filecreate/filecreate_widget3.cpp (limited to 'parts/filecreate/filecreate_widget3.cpp') diff --git a/parts/filecreate/filecreate_widget3.cpp b/parts/filecreate/filecreate_widget3.cpp new file mode 100644 index 00000000..f766cbcf --- /dev/null +++ b/parts/filecreate/filecreate_widget3.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + * Copyright (C) 2003 by Julian Rockey * + * linux@jrockey.com * + * thanks: Roberto Raggi for QSimpleRichText stuff * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "filecreate_widget3.h" + +#include "kdevproject.h" +#include "filecreate_part.h" +#include "filecreate_filetype.h" +#include "filecreate_listitem.h" + +namespace FileCreate { + + ListWidget::ListWidget(FileCreatePart *part) + : KListView(0, "KDevFileCreate"), TypeChooser(part) + { + setIcon( SmallIcon("filenew2") ); + setCaption(i18n("File Create")); + setResizeMode( AllColumns ); + setAllColumnsShowFocus(true); + setRootIsDecorated(true); + + addColumn(""); + addColumn(""); + + QWhatsThis::add(this, i18n("New file

This part makes the creation of new files easier. Select a type in the list to create a file. " + "The list of project file types can be configured in project settings dialog, New File Wizard tab. " + "Globally available file types are listed and can be configured in KDevelop settings dialog, New File Wizard tab.")); + + + connect( this, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotTypeSelected(QListViewItem*)) ); + } + + + ListWidget::~ListWidget() + { + } + + void ListWidget::setCurrent(const FileType * current) { + + bool found = false; + QListViewItem * lvi = firstChild(); + while(lvi && !found) { + ListItem * li = dynamic_cast(lvi); + if (li) { + if (li->filetype()==current) { + found=true; + setSelected(li,true); + } + } + if (lvi->nextSibling()) + lvi = lvi->nextSibling(); + else { + while (lvi && !lvi->nextSibling()) + lvi = lvi->parent(); + } + } + + } + + void ListWidget::resizeEvent(QResizeEvent *event) { + ListItem *li = dynamic_cast(firstChild()); + while(li) { + li->prepareResize(); + li = dynamic_cast(li->nextSibling()); + } + KListView::resizeEvent(event); + } + + void ListWidget::refresh() { + clear(); + QPtrList filetypes = m_part->getFileTypes(); + for(FileType * filetype = filetypes.first(); + filetype!=NULL; + filetype=filetypes.next()) { + if (filetype->enabled()) { + QPtrList subtypes = filetype->subtypes(); + if (subtypes.count()==0) + new ListItem( this, filetype ); + for(FileType * subtype = subtypes.first(); + subtype!=NULL; + subtype=subtypes.next()) { + if (subtype->enabled()) + new ListItem( this, subtype ); + } + } + } + } + + void ListWidget::slotTypeSelected(QListViewItem * item) { + ListItem * fileitem = dynamic_cast(item); + if (!fileitem) return; + + const FileType * filetype = fileitem->filetype(); + + TypeChooser::filetypeSelected(filetype); + } + + +} +#include "filecreate_widget3.moc" -- cgit v1.2.3