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/quickopen/Makefile.am | 17 ++ parts/quickopen/README.dox | 52 +++++ parts/quickopen/kdevpart_quickopen.rc | 15 ++ parts/quickopen/kdevquickopen.desktop | 80 +++++++ parts/quickopen/quickopen_part.cpp | 139 +++++++++++++ parts/quickopen/quickopen_part.h | 57 +++++ parts/quickopen/quickopenbase.ui | 178 ++++++++++++++++ parts/quickopen/quickopenclassdialog.cpp | 219 +++++++++++++++++++ parts/quickopen/quickopenclassdialog.h | 56 +++++ parts/quickopen/quickopendialog.cpp | 155 ++++++++++++++ parts/quickopen/quickopendialog.h | 63 ++++++ parts/quickopen/quickopenfiledialog.cpp | 121 +++++++++++ parts/quickopen/quickopenfiledialog.h | 49 +++++ parts/quickopen/quickopenfunctionchooseform.cpp | 56 +++++ parts/quickopen/quickopenfunctionchooseform.h | 48 +++++ parts/quickopen/quickopenfunctionchooseformbase.ui | 231 +++++++++++++++++++++ parts/quickopen/quickopenfunctiondialog.cpp | 229 ++++++++++++++++++++ parts/quickopen/quickopenfunctiondialog.h | 60 ++++++ 18 files changed, 1825 insertions(+) create mode 100644 parts/quickopen/Makefile.am create mode 100644 parts/quickopen/README.dox create mode 100644 parts/quickopen/kdevpart_quickopen.rc create mode 100644 parts/quickopen/kdevquickopen.desktop create mode 100644 parts/quickopen/quickopen_part.cpp create mode 100644 parts/quickopen/quickopen_part.h create mode 100644 parts/quickopen/quickopenbase.ui create mode 100644 parts/quickopen/quickopenclassdialog.cpp create mode 100644 parts/quickopen/quickopenclassdialog.h create mode 100644 parts/quickopen/quickopendialog.cpp create mode 100644 parts/quickopen/quickopendialog.h create mode 100644 parts/quickopen/quickopenfiledialog.cpp create mode 100644 parts/quickopen/quickopenfiledialog.h create mode 100644 parts/quickopen/quickopenfunctionchooseform.cpp create mode 100644 parts/quickopen/quickopenfunctionchooseform.h create mode 100644 parts/quickopen/quickopenfunctionchooseformbase.ui create mode 100644 parts/quickopen/quickopenfunctiondialog.cpp create mode 100644 parts/quickopen/quickopenfunctiondialog.h (limited to 'parts/quickopen') diff --git a/parts/quickopen/Makefile.am b/parts/quickopen/Makefile.am new file mode 100644 index 00000000..be12b32f --- /dev/null +++ b/parts/quickopen/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/interfaces/extensions \ + -I$(top_srcdir)/lib/interfaces/external -I$(top_srcdir)/lib/util -I$(top_srcdir)/lib/widgets $(all_includes) + +kde_module_LTLIBRARIES = libkdevquickopen.la +libkdevquickopen_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevquickopen_la_LIBADD = $(top_builddir)/lib/libkdevelop.la $(top_builddir)/lib/widgets/libkdevwidgets.la $(LIB_KHTML) + +libkdevquickopen_la_SOURCES = quickopen_part.cpp quickopendialog.cpp quickopenclassdialog.cpp quickopenbase.ui quickopenfiledialog.cpp quickopenfunctiondialog.cpp quickopenfunctionchooseformbase.ui quickopenfunctionchooseform.cpp + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevquickopen.desktop + +rcdir = $(kde_datadir)/kdevquickopen +rc_DATA = kdevpart_quickopen.rc +noinst_HEADERS = quickopendialog.h quickopenclassdialog.h quickopenfiledialog.h quickopenfunctiondialog.h quickopenfunctionchooseform.h diff --git a/parts/quickopen/README.dox b/parts/quickopen/README.dox new file mode 100644 index 00000000..a4463178 --- /dev/null +++ b/parts/quickopen/README.dox @@ -0,0 +1,52 @@ +/** \class QuickOpenPart +Put a brief description here, the brief description ends at the first dot. +Put a more detailed description of your part in these lines. It can span +over several lines. You can even use some html commands in these lines like: +This is code, html links link text, +and images. + +\authors $AUTHOR$ +\authors 2nd author full name +... +\authors nth author full name + +\maintainer $AUTHOR$ +\maintainer 2nd maintainer full name +... +\maintainer nth maintainer full name + +\feature Describe the first feature +\feature Describe the second feature +... +\feature Describe the last feature + +\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet. +.. +\bug Describe a the nth bug that you know of, but probably hasn't been reported yet. + +\requirement Describe a the 1st requirement of your part. +\requirement Describe a the 2nd requirement of your part. +... +\requirement Describe a the nth requirement of your part. + +\todo Describe a the 1st TODO of your part. +\todo Describe a the 2nd TODO of your part. +... +\todo Describe a the nth TODO of your part. + +\faq First frequenly asked question about your part ? Answer. +\faq Second frequenly asked question about your part ? Answer. +... +\faq Last frequenly asked question about your part ? Answer. + +\note First note text. +\note Second note text. +... +\note Last note text. + +\warning First warning text. +\warning Second warning text. +... +\warning Last warning text. + +*/ diff --git a/parts/quickopen/kdevpart_quickopen.rc b/parts/quickopen/kdevpart_quickopen.rc new file mode 100644 index 00000000..6a50fc22 --- /dev/null +++ b/parts/quickopen/kdevpart_quickopen.rc @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/parts/quickopen/kdevquickopen.desktop b/parts/quickopen/kdevquickopen.desktop new file mode 100644 index 00000000..1f497292 --- /dev/null +++ b/parts/quickopen/kdevquickopen.desktop @@ -0,0 +1,80 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=Provides an efficient way of finding/opening files, classes and methods in a large project. Appears in the File and Tools menus when loaded. +Comment[ca]=Proporciona un mètode eficient per a cercar i obrir fitxers, classes i mètodes en un projecte gran. Quan està carregat apareix en el menú Fitxer i Eines. +Comment[da]=Giver en effektiv måde at finde/åbne, filer, klasser og metoder i et stort projekt. Viser sig i Fil- og værktøjsmenuerne når den er indlæst. +Comment[de]=Stellt eine effektive Möglichkeit zum Suchen und Öffnen von Dateien in einem großen Projekt zur Verfügung. Erscheint im Menü "Datei", wenn es geladen ist. +Comment[el]=Προσφέρει μια εύχρηστη μέθοδο αναζήτησης/ανοίγματος αρχείων, κλάσεων και μεθόδων σε ένα μεγάλο έργο. Εμφανίζεται στα μενού αρχείων και εργαλείων όταν φορτωθεί. +Comment[es]=Proporciona un método para para buscar/abrir archivos, clases y métodos de un proyecto grande. Aparece en los menús Archivo y Herramientas cuando está cargado. +Comment[et]=Võimaldab hõlpsasti leida/avada faile, klasse ja meetodeid suures projektis. Laadimisel kättesaadav faili- ja tööriistade menüüs. +Comment[eu]=Proiektu handi batean fitxategiak, klaseak eta metodoak aurkitzeko/irekitzeko aukera eskeintzen du. Fitxategia eta Tresnak menutan agertzen da kargatzean. +Comment[fa]=راه مؤثری برای یافتن/باز کردن پرونده‌ها، رده‌ها و روشها در پروژه‌های بزرگ فراهم می‌کند. در هنگام بارگذاری در گزینگان ابزار و پرونده ظاهر می‌شود. +Comment[fr]=Fournit une manière efficace pour chercher / ouvrir des fichiers, classes et méthodes dans des grands projets. Apparaît dans les menus « Fichier » et « Outils » lorsque chargé. +Comment[gl]=Proporciona un método eficiente para atopar/abrir ficheiros, clases e métodos nun proxecto grande. Aparece nos menús Ficheiro e Ferramentas cando se carga. +Comment[hu]=Segítséget nyújt nagy projekteknél fájlok, osztályok és tagfüggvények kereséséhez, megnyitásához. Betöltéskor a Fájl és Eszközök menübe kerül. +Comment[it]=Offre un modo efficiente per trovare/aprire file, classi e metodi in un progetto di ampia dimensione. Appare nel menu File e Strumenti quando caricato. +Comment[ja]=大規模なプロジェクトでのファイルやクラス、メソッドを検索したり開く効率的な方法を提供します。読み込まれると、ファイルとツールのメニューに現れます。 +Comment[ms]=Menyediakan cara efisien untuk mencari/membuka fail, kelas dan kaedah dalam projek besar. Muncul sebagai menu Fail dan Alatan apabila dimuatkan. +Comment[nds]=Stellt en effektiv Metood för't Söken un Opmaken vun Dateien, Klassen un Metoden in grötter Projekten praat. Dukt in't Menü "Datei" un "Warktüüch" op, wenn laadt. +Comment[ne]=ठूलो परियोजनामा फाइल फेला पार्ने/खोल्ने, कक्षहरू र विधिको उपयुक्त तरिका प्रदान गर्दछ । लोड भएको बेलामा फाइल र उपकरणमा देखा पर्दछ । +Comment[nl]=Biedt een snelle manier om bestanden te vinden/openen in een groot project. Verschijnt in menu Bestand en Gereedschap als het geladen is. +Comment[pl]=Umożliwia wyszukiwanie/otwieranie plików, klas i metod w dużym projekcie. Po wczytaniu pojawia się w menu Plik i Narzędzia. +Comment[pt]=Oferece uma forma eficiente de procurar/abrir ficheiros, classes e métodos num projecto grande. Aparece nos menus Ficheiro e Ferramentas quando é carregado. +Comment[pt_BR]=Fornece uma maneira eficiente de procurar/abrir arquivos, classes e métodos em um grande projeto. Aparece nos menus Arquivo e Ferramentas quando carregado. +Comment[ru]=Предоставляет эффективное средство нахождения и открытия файлов и классов в больших проектах. +Comment[sk]=Poskytuje efektívny spôsob hľadania/otvárania súborov, tried a metód vo veľkom projekte. Po načítaní sa objaví v menu Súbor a Nástroje. +Comment[sr]=Обезбеђује ефикасан начин проналажења/отварања фајлова, класа и метода у великом пројекту. Појављује се у менијима „Фајл“ и „Алати“ када је учитан. +Comment[sr@Latn]=Obezbeđuje efikasan način pronalaženja/otvaranja fajlova, klasa i metoda u velikom projektu. Pojavljuje se u menijima „Fajl“ i „Alati“ kada je učitan. +Comment[sv]=Erbjuder ett effektivt sätt att hitta och öppna filer, klasser och metoder i ett stort projekt. Finns i menyn Arkiv och Verktyg när det laddats. +Comment[ta]=பெரிய திட்ட பணிகளில் உள்ள கோப்பினை திறக்க/தேட இது ஒரு நல்ல வழியை தரும். ஏற்றியபின் கோப்பு பட்டியலில் இது தோன்றும். +Comment[tg]=Воситаи зуд ёфтан, кушодани файлҳо ва синфҳо дар лоиҳаҳоро имкон медиҳад. +Comment[tr]=Büyük bir projede dosyaları, sınıfları ve yöntemleri bulmak ve açmak için verimli bir yol sunar. Yüklendiğinde Dosya ve Araçlar menüsünde durur. +Comment[zh_CN]=提供在大工程中查找/打开文件、类和方法的有效方法。启动后显示在文件菜单中。 +Comment[zh_TW]=在大型專案中有效率地尋找/開啟檔案、類別與方法。載入後可以在檔案與工具選單中找到。 +Name=KDevQuickOpen +Name[da]=KDevelop hurtigåbner +Name[de]=Schnellöffner-Komponente (KDevelop) +Name[hi]=के-डेव-क्विक-ओपन +Name[nds]=KDevelop-Fixopmaker +Name[pl]=KDevSzybkieOtwarcie +Name[sk]=KDev rýchle otvorenie +Name[sv]=KDevelop snabböppna +Name[ta]=KDev சீக்கிரம் திற +Name[zh_TW]=KDevelop 快速開啟 +GenericName=QuickOpen +GenericName[ca]=Obertura ràpida +GenericName[da]=Hurtigåbner +GenericName[de]=Schnellöffner +GenericName[el]=ΓρήγοροΆνοιγμα +GenericName[es]=Apertura rápida +GenericName[et]=Kiiresti avamine +GenericName[fa]=باز کردن سریع +GenericName[fr]=Ouverture rapide +GenericName[gl]=Apertura rápida +GenericName[hi]=क्विक-ओपन +GenericName[hu]=Gyors fájlmegnyitó +GenericName[it]=Apertura rapida +GenericName[ja]=簡易読み込み +GenericName[nds]=Gau opmaken +GenericName[ne]=शीघ्र खुला +GenericName[nl]=Snel openen +GenericName[pl]=Szybkie otwarcie +GenericName[pt]=Abertura Rápida +GenericName[ru]=Быстрое открытие +GenericName[sk]=Rýchle otvorenie +GenericName[sl]=Hitro odprtje +GenericName[sr]=Брзо отварање +GenericName[sr@Latn]=Brzo otvaranje +GenericName[sv]=Snabböppna +GenericName[ta]=சீக்கிரம் திற +GenericName[tg]=Ба зуди кушодан +GenericName[tr]=HızlıAç +GenericName[zh_CN]=快速打开 +GenericName[zh_TW]=快速開啟 +Icon=kdevelop +ServiceTypes=KDevelop/QuickOpen +X-KDevelop-Scope=Project +X-KDE-Library=libkdevquickopen +X-KDevelop-Version=5 +X-KDevelop-Properties=CodeNavigation diff --git a/parts/quickopen/quickopen_part.cpp b/parts/quickopen/quickopen_part.cpp new file mode 100644 index 00000000..dbfab9e6 --- /dev/null +++ b/parts/quickopen/quickopen_part.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include "quickopen_part.h" +#include "quickopenclassdialog.h" +#include "quickopenfunctiondialog.h" +#include "quickopenfiledialog.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "kdeveditorutil.h" + +typedef KDevGenericFactory QuickOpenFactory; +static const KDevPluginInfo data("kdevquickopen"); +K_EXPORT_COMPONENT_FACTORY( libkdevquickopen, QuickOpenFactory( data ) ) + +using namespace KTextEditor; + +QuickOpenPart::QuickOpenPart(QObject *parent, const char *name, const QStringList& ) + : KDevQuickOpen(&data, parent, name ? name : "QuickOpenPart" ) +{ + setInstance(QuickOpenFactory::instance()); + setXMLFile("kdevpart_quickopen.rc"); + + m_actionQuickOpen = new KAction( i18n("Quick Open File..."), CTRL + ALT + Key_O, + this, SLOT(slotQuickFileOpen()), + actionCollection(), "quick_open" ); + m_actionQuickOpen->setToolTip(i18n("Quick open file in project")); + m_actionQuickOpen->setWhatsThis(i18n("Quick open

Provides a file name input form with completion listbox to quickly open file in a project.")); + + m_actionQuickOpenClass = new KAction( i18n("Quick Open Class..."), CTRL + ALT + Key_C, + this, SLOT(slotQuickOpenClass()), + actionCollection(), "quick_open_class" ); + m_actionQuickOpenClass->setToolTip(i18n("Find class in project")); + m_actionQuickOpenClass->setWhatsThis(i18n("Find class

Provides a class name input form with completion listbox to quickly open a file where the class is defined.")); + + m_actionFunctionOpen = new KAction( i18n("Quick Open Method..."), CTRL + ALT + Key_M, this, SLOT(slotQuickOpenFunction()), actionCollection(), "quick_open_function" ); + m_actionFunctionOpen->setToolTip(i18n("Quick open function in project")); + + m_switchToAction = new KAction(i18n("Switch To..."), KShortcut("CTRL+/"), this, SLOT(slotSwitchTo()), actionCollection(), "file_switchto"); + m_switchToAction->setToolTip(i18n("Switch to")); + m_switchToAction->setWhatsThis(i18n("Switch to

Prompts to enter the name of previously opened file to switch to.")); + + connect( core(), SIGNAL(projectOpened()), this, SLOT(slotProjectOpened()) ); + connect( core(), SIGNAL(projectClosed()), this, SLOT(slotProjectClosed()) ); +} + + +QuickOpenPart::~QuickOpenPart() +{ +} + +void QuickOpenPart::slotProjectOpened( ) +{ +} + +void QuickOpenPart::slotProjectClosed( ) +{ +} + +void QuickOpenPart::slotQuickFileOpen( ) +{ + QuickOpenFileDialog dlg( this, mainWindow()->main() ); + dlg.exec(); +} + +void QuickOpenPart::slotQuickOpenClass( ) +{ + QuickOpenClassDialog dlg( this, mainWindow()->main() ); + dlg.nameEdit->setText( KDevEditorUtil::currentWord( dynamic_cast( partController()->activePart() ) ) ); + dlg.exec(); +} + +void QuickOpenPart::slotQuickOpenFunction() +{ + QuickOpenFunctionDialog dlg( this, mainWindow()->main() ); + dlg.nameEdit->setText( KDevEditorUtil::currentWord( dynamic_cast( partController()->activePart() ) ) ); + dlg.exec(); +} + +void QuickOpenPart::slotSwitchTo() +{ + QuickOpenFileDialog dlg( this, partController()->openURLs(), mainWindow()->main() ); + dlg.exec(); +} + +void QuickOpenPart::selectItem( ItemDom item ) +{ + Extensions::KDevCodeBrowserFrontend* f = extension< Extensions::KDevCodeBrowserFrontend > ( "KDevelop/CodeBrowserFrontend" ); + + if(f != 0) { + ItemDom itemDom( &(*item) ); + f->jumpedToItem( itemDom ); + } else { + kdDebug() << "could not find the proper extension\n"; + } +} + +void QuickOpenPart::quickOpenFile(const KURL::List urls) +{ + QuickOpenFileDialog dlg( this, urls, mainWindow()->main() ); + dlg.exec(); +} + + +#include "quickopen_part.moc" diff --git a/parts/quickopen/quickopen_part.h b/parts/quickopen/quickopen_part.h new file mode 100644 index 00000000..78ab3e45 --- /dev/null +++ b/parts/quickopen/quickopen_part.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef __KDEVPART_QUICKOPEN_H__ +#define __KDEVPART_QUICKOPEN_H__ + +#include +#include +#include + +class KAction; + +class QuickOpenPart : public KDevQuickOpen +{ + Q_OBJECT +public: + QuickOpenPart(QObject *parent, const char *name, const QStringList &); + virtual ~QuickOpenPart(); + + void selectItem( ItemDom item ); + + virtual void quickOpenFile(const KURL::List urls); + +private slots: + void slotProjectOpened(); + void slotProjectClosed(); + void slotQuickFileOpen(); + void slotQuickOpenClass(); + void slotQuickOpenFunction(); + void slotSwitchTo(); + +private: + KAction* m_actionQuickOpen; + KAction* m_actionQuickOpenClass; + KAction* m_actionFunctionOpen; + KAction* m_switchToAction; +}; + + +#endif diff --git a/parts/quickopen/quickopenbase.ui b/parts/quickopen/quickopenbase.ui new file mode 100644 index 00000000..38e0fcab --- /dev/null +++ b/parts/quickopen/quickopenbase.ui @@ -0,0 +1,178 @@ + +QuickOpenDialogBase + + + QuickOpenDialogBase + + + + 0 + 0 + 369 + 331 + + + + Quick Open + + + true + + + + unnamed + + + + nameLabel + + + [NAME] + + + nameEdit + + + + + itemListLabel + + + [ITEM LIST] + + + itemList + + + + + itemList + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &OK + + + + + + true + + + true + + + + + buttonCancel + + + &Cancel + + + + + + true + + + + + + + nameEdit + + + + + + + buttonCancel + clicked() + QuickOpenDialogBase + reject() + + + buttonOk + clicked() + QuickOpenDialogBase + slotReturnPressed() + + + itemList + doubleClicked(QListBoxItem*) + QuickOpenDialogBase + slotExecuted(QListBoxItem*) + + + nameEdit + returnPressed() + QuickOpenDialogBase + slotReturnPressed() + + + nameEdit + textChanged(const QString&) + QuickOpenDialogBase + slotTextChanged(const QString&) + + + itemList + returnPressed(QListBoxItem*) + QuickOpenDialogBase + slotReturnPressed() + + + + nameEdit + itemList + buttonOk + buttonCancel + + + slotTextChanged( const QString & ) + executed( QListBoxItem * ) + slotExecuted( QListBoxItem * ) + slotReturnPressed() + + + + klistbox.h + klineedit.h + + diff --git a/parts/quickopen/quickopenclassdialog.cpp b/parts/quickopen/quickopenclassdialog.cpp new file mode 100644 index 00000000..9eec73a5 --- /dev/null +++ b/parts/quickopen/quickopenclassdialog.cpp @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "quickopenclassdialog.h" +#include "quickopen_part.h" +#include "quickopenfunctionchooseform.h" + +QuickOpenClassDialog::QuickOpenClassDialog(QuickOpenPart* part, QWidget* parent, const char* name, bool modal, WFlags fl) + : QuickOpenDialog( part, parent, name, modal, fl ) +{ + nameLabel->setText( i18n("Class &name:") ); + itemListLabel->setText( i18n("Class &list:") ); + + findAllClasses( m_items ); + QStringList_unique( m_items ); + + nameEdit->setFocus(); + + itemList->insertStringList( m_items ); + itemList->setCurrentItem(0); +} + +QuickOpenClassDialog::~QuickOpenClassDialog() +{ +} + +void QuickOpenClassDialog::slotExecuted( QListBoxItem* /*item*/ ) +{ + accept(); +} + +void QuickOpenClassDialog::accept() +{ + if( QListBoxItem* item = itemList->selectedItem() ) + { + ClassList klasses = findClass( item->text() ); + if( klasses.count() == 1 ) + { + ClassDom klass = klasses.first(); + int startLine, startColumn; + klass->getStartPosition( &startLine, &startColumn ); + m_part->partController()->editDocument( KURL( klass->fileName() ), startLine ); + selectClassViewItem( ItemDom(&(*klass)) ); + } + else if (klasses.count() > 1 ) + { + //several classes with the same name found + QString fileStr; + + QuickOpenFunctionChooseForm fdlg( this, "" ); + fdlg.setCaption(i18n("Select The Location of Class %1").arg(klasses.first()->name())); + fdlg.textLabel2->setText(i18n("Class name:")); + + for( ClassList::const_iterator it = klasses.constBegin(); it != klasses.constEnd() ; ++it ) + { + ClassDom klass = *it; + //assemble class name to display (maybe with scope info and specialization) + QString classStr = m_part->languageSupport()->formatModelItem(klass); + if(klass->hasSpecializationDeclaration()) + classStr += klass->getSpecializationDeclaration(); + if(!klass->scope().isEmpty()) + classStr += " (in " + klass->scope().join("::") + ")"; + fdlg.argBox->insertItem(classStr); + + fileStr = KURL( klass->fileName() ).fileName(); + KURL full_url( klass->fileName() ); + KURL base_url( m_part->project()->projectDirectory()+"/" ); + fdlg.fileBox->insertItem(fileStr); + fdlg.setRelativePath(fdlg.fileBox->count()-1, + KURL::relativeURL( base_url, full_url )); + } + if( fdlg.exec() ){ + int id = fdlg.argBox->currentItem(); + if( id>-1 && id < (int) klasses.count() ){ + ClassDom model = klasses[id]; + int line, col; + model->getStartPosition( &line, &col ); + selectClassViewItem( ItemDom(&(*model)) ); + QString fileNameStr = model->fileName(); + m_part->partController()->editDocument( KURL(fileNameStr), line ); + } + } + } + } + + QDialog::accept(); +} + +void QuickOpenClassDialog::slotReturnPressed( ) +{ + maybeUpdateSelection(); + accept(); +} + +void QuickOpenClassDialog::findAllClasses( QStringList& lst ) +{ + findAllClasses( lst, m_part->codeModel()->globalNamespace() ); +} + +void QuickOpenClassDialog::findAllClasses( QStringList& lst, const ClassDom klass ) +{ + QStringList fullName = klass->scope(); + fullName << klass->name(); + lst << fullName.join( "::" ); + + const ClassList classList = klass->classList(); + for( ClassList::ConstIterator it=classList.begin(); it!=classList.end(); ++it ) + findAllClasses( lst, *it ); +} + +void QuickOpenClassDialog::findAllClasses( QStringList& lst, const NamespaceDom ns ) +{ + const NamespaceList namespaceList = ns->namespaceList(); + for( NamespaceList::ConstIterator it=namespaceList.begin(); it!=namespaceList.end(); ++it ) + findAllClasses( lst, *it ); + + const ClassList classList = ns->classList(); + for( ClassList::ConstIterator it=classList.begin(); it!=classList.end(); ++it ) + findAllClasses( lst, *it ); +} + +ClassList QuickOpenClassDialog::findClass( const QString& name ) +{ + QStringList path = QStringList::split( "::", name ); + return findClass( path, m_part->codeModel()->globalNamespace() ); +} + +ClassList QuickOpenClassDialog::findClass( QStringList& path, const NamespaceDom ns ) +{ + ClassList list; + if( path.isEmpty() ) + return list; + + QString current = path.front(); + if( ns->hasNamespace(current) ) + { + path.pop_front(); + list += findClass( path, ns->namespaceByName(current) ); + path.push_front( current ); + } + + if( ns->hasClass(current) ) + { + path.pop_front(); + list += findClass( path, ns->classByName(current) ); + } + + return list; +} + +ClassList QuickOpenClassDialog::findClass( QStringList& path, const ClassList klasses ) +{ + ClassList list; + if( path.isEmpty() ) + { + list += klasses; + return list; + } + + for (ClassList::const_iterator it = klasses.constBegin(); it != klasses.constEnd(); ++it) + { + list += findClass(path, *it); + } + + return list; +} + +ClassList QuickOpenClassDialog::findClass( QStringList &path, const ClassDom klass ) +{ + ClassList list; + if( path.isEmpty() ) + { + list << klass; + return list; + } + + QString current = path.front(); + if( klass->hasClass(current) ) + { + path.pop_front(); + list += findClass( path, klass->classByName(current) ); + path.push_front(current); + } + + return list; +} + +#include "quickopenclassdialog.moc" + diff --git a/parts/quickopen/quickopenclassdialog.h b/parts/quickopen/quickopenclassdialog.h new file mode 100644 index 00000000..afed19c8 --- /dev/null +++ b/parts/quickopen/quickopenclassdialog.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef QUICKOPENCLASSDIALOG_H +#define QUICKOPENCLASSDIALOG_H + +#include "quickopendialog.h" +#include +#include + +class QuickOpenPart; + +class QuickOpenClassDialog : public QuickOpenDialog +{ + Q_OBJECT +public: + QuickOpenClassDialog(QuickOpenPart* part, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + virtual ~QuickOpenClassDialog(); + +public slots: + virtual void slotExecuted( QListBoxItem* ); + virtual void slotReturnPressed(); + +protected: + void findAllClasses( QStringList& classList ); + void findAllClasses( QStringList& classList, const ClassDom klass ); + void findAllClasses( QStringList& classList, const NamespaceDom ns ); + + ClassList findClass( const QString& name ); + ClassList findClass( QStringList& path, const NamespaceDom ns ); + ClassList findClass( QStringList& path, const ClassList klasses ); + ClassList findClass( QStringList& path, const ClassDom klass ); + +protected slots: + virtual void accept(); +}; + +#endif + diff --git a/parts/quickopen/quickopendialog.cpp b/parts/quickopen/quickopendialog.cpp new file mode 100644 index 00000000..d12c6f44 --- /dev/null +++ b/parts/quickopen/quickopendialog.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) KDevelop Authors , (C) 2004 + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include +#include + +#include +#include +#include + +#include "quickopendialog.h" +#include "quickopen_part.h" + +QuickOpenDialog::QuickOpenDialog(QuickOpenPart* part, QWidget* parent, const char* name, bool modal, WFlags fl) + : QuickOpenDialogBase( parent, name, modal, fl ), m_part( part ) +{ + nameEdit->installEventFilter(this); + connect( &m_typeTimeout, SIGNAL(timeout()), this, SLOT(slotTextChangedDelayed()) ); +} + +QuickOpenDialog::~QuickOpenDialog() +{ +} + +void QuickOpenDialog::slotTextChanged(const QString &) +{ + m_typeTimeout.start( 100, true ); +} + +void QuickOpenDialog::maybeUpdateSelection() { + if( m_typeTimeout.isActive() ) + { + m_typeTimeout.stop(); + slotTextChangedDelayed(); + } +} + +void QuickOpenDialog::setFirstItemSelected() +{ + // Make sure the list has a current item or our event will not be handled properly. + itemList->setCurrentItem(0); + // We are doing this indirectly because the event handler does things for multiple + // selections we cannot do through the public interface. + QKeyEvent e(QEvent::KeyPress, Qt::Key_Home, 0, 0); + QApplication::sendEvent(itemList, &e); +} + +void QuickOpenDialog::slotTextChangedDelayed() +{ + itemList->clear(); + itemList->insertStringList( wildCardCompletion( nameEdit->text() ) ); + setFirstItemSelected(); +} + +bool QuickOpenDialog::eventFilter( QObject * watched, QEvent * e ) +{ + if (!watched || !e) + return true; + + if ((watched == nameEdit) && (e->type() == QEvent::KeyPress)) + { + QKeyEvent *ke = (QKeyEvent*)e; + if (ke->key() == Key_Up) + { + QApplication::sendEvent(itemList, e); + nameEdit->blockSignals(true); + itemSelectionChanged(); + nameEdit->blockSignals(false); + return true; + } else if (ke->key() == Key_Down) + { + QApplication::sendEvent(itemList, e); + nameEdit->blockSignals(true); + itemSelectionChanged(); + nameEdit->blockSignals(false); + return true; + } else if ((ke->key() == Key_Next) || (ke->key() == Key_Prior)) + { + QApplication::sendEvent(itemList, e); + nameEdit->blockSignals(true); + itemSelectionChanged(); + nameEdit->blockSignals(false); + } + } + + return QWidget::eventFilter(watched, e); +} + +void QuickOpenDialog::selectClassViewItem(ItemDom item) +{ + m_part->selectItem( item ); +} + +QStringList QuickOpenDialog::wildCardCompletion(const QString & text) +{ + if ( text.isEmpty() ) return m_items; + + QRegExp re( text, false, true ); + QStringList matches; + QStringList::const_iterator it = m_items.begin(); + while( it != m_items.end() ) + { + if ( (*it).find( re ) != -1 ) + { + matches << *it; + } + ++it; + } + + return matches; +} + +void QuickOpenDialog::QStringList_unique( QStringList & list ) +{ + if ( list.size() < 2 ) return; + + list.sort(); + + QStringList::iterator it = list.begin(); + QStringList::iterator it2 = it; + while ( it2 != list.end() ) + { + ++it2; + while ( it2 != list.end() && *it2 == *it ) + { + it2 = list.remove( it2 ); + } + it = it2; + } +} + +void QuickOpenDialog::itemSelectionChanged() { + nameEdit->setText(itemList->currentText()); +} + +#include "quickopendialog.moc" + +// kate: space-indent on; indent-width 4; tab-width 4; show-tabs on; diff --git a/parts/quickopen/quickopendialog.h b/parts/quickopen/quickopendialog.h new file mode 100644 index 00000000..7eb989c6 --- /dev/null +++ b/parts/quickopen/quickopendialog.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) KDevelop Authors , (C) 2004 + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef QUICKOPENDIALOG_H +#define QUICKOPENDIALOG_H + +#include +#include + +#include + +#include "quickopenbase.h" + +class QuickOpenPart; +class KCompletion; + +class QuickOpenDialog : public QuickOpenDialogBase +{ + Q_OBJECT + +public: + QuickOpenDialog(QuickOpenPart* part, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + virtual ~QuickOpenDialog(); + + virtual bool eventFilter(QObject *watched, QEvent *e); + + void selectClassViewItem(ItemDom item); + +public slots: + virtual void slotTextChanged(const QString&); + virtual void slotTextChangedDelayed(); + +protected: + void maybeUpdateSelection(); + void setFirstItemSelected(); + virtual void itemSelectionChanged(); + void QStringList_unique( QStringList & list ); + QStringList wildCardCompletion( const QString & text ); + QStringList m_items; + QuickOpenPart* m_part; + QTimer m_typeTimeout; + +}; + +#endif + diff --git a/parts/quickopen/quickopenfiledialog.cpp b/parts/quickopen/quickopenfiledialog.cpp new file mode 100644 index 00000000..96474367 --- /dev/null +++ b/parts/quickopen/quickopenfiledialog.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include +#include + + +#include +#include +#include +#include +#include + + +#include +#include + +#include "quickopenfiledialog.h" +#include "quickopen_part.h" + +QuickOpenFileDialog::QuickOpenFileDialog(QuickOpenPart* part, QWidget* parent, const char* name, bool modal, WFlags fl) + : QuickOpenDialog( part, parent, name, modal, fl ), m_hasFullPaths( false ) +{ + nameLabel->setText( i18n("File &name:") ); + itemListLabel->setText( i18n("File &list:") ); + + m_items = m_part->project()->allFiles(); + + nameEdit->setFocus(); + + itemList->setSelectionMode( QListBox::Extended ); + itemList->insertStringList( m_items ); + setFirstItemSelected(); +} + +QuickOpenFileDialog::QuickOpenFileDialog(QuickOpenPart* part, const KURL::List & urls, QWidget* parent, const char* name, bool modal, WFlags fl) + : QuickOpenDialog( part, parent, name, modal, fl ), m_hasFullPaths( true ) +{ + nameLabel->setText( i18n("File &name:") ); + itemListLabel->setText( i18n("File &list:") ); + + m_items = urls.toStringList(); + QStringList_unique( m_items ); + + if (m_part->project()) + { + for (unsigned int i = 0; i < m_items.count(); ++i) + { + QString url = m_items[i]; + QString projectUrl = "file://" + m_part->project()->projectDirectory(); + if (url.startsWith(projectUrl)) + m_items[i] = url.mid(projectUrl.length() + 1); + } + } + + nameEdit->setFocus(); + + itemList->setSelectionMode( QListBox::Extended ); + itemList->insertStringList( m_items ); + setFirstItemSelected(); +} + +QuickOpenFileDialog::~QuickOpenFileDialog() +{ +} + +void QuickOpenFileDialog::slotExecuted( QListBoxItem* item ) +{ + if ( !item ) return; + + if ( m_hasFullPaths ) + { + m_part->partController()->editDocument( KURL::fromPathOrURL( item->text() ) ); + } + else + { + m_part->partController()->editDocument( KURL::fromPathOrURL( m_part->project()->projectDirectory() + "/" + item->text() ) ); + } + accept(); +} + +void QuickOpenFileDialog::slotReturnPressed( ) +{ + maybeUpdateSelection(); + + for (int i = 0; i < itemList->count(); ++i) + { + if (itemList->isSelected(i)) + { + if (m_hasFullPaths) + { + m_part->partController()->editDocument(KURL::fromPathOrURL(itemList->item(i)->text())); + } + else + { + m_part->partController()->editDocument(KURL::fromPathOrURL(m_part->project()->projectDirectory() + "/" + itemList->item(i)->text())); + } + } + } + accept(); +} + +#include "quickopenfiledialog.moc" + diff --git a/parts/quickopen/quickopenfiledialog.h b/parts/quickopen/quickopenfiledialog.h new file mode 100644 index 00000000..0f36f1f8 --- /dev/null +++ b/parts/quickopen/quickopenfiledialog.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2003 Roberto Raggi (roberto@kdevelop.org) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef QUICKOPENFILEDIALOG_H +#define QUICKOPENFILEDIALOG_H + +#include "quickopendialog.h" +#include + +#include + +class QuickOpenPart; +class KCompletion; + +class QuickOpenFileDialog : public QuickOpenDialog +{ + Q_OBJECT +public: + QuickOpenFileDialog(QuickOpenPart* part, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + QuickOpenFileDialog(QuickOpenPart* part, const KURL::List &, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 ); + virtual ~QuickOpenFileDialog(); + +public slots: + virtual void slotExecuted( QListBoxItem* ); + virtual void slotReturnPressed(); + +private: + bool m_hasFullPaths; +}; + +#endif + diff --git a/parts/quickopen/quickopenfunctionchooseform.cpp b/parts/quickopen/quickopenfunctionchooseform.cpp new file mode 100644 index 00000000..c83a8765 --- /dev/null +++ b/parts/quickopen/quickopenfunctionchooseform.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2004 Ahn, Duk J.(adjj22@kornet.net) (adjj1@hanmail.net) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include +#include +#include + +#include + +#include "quickopenfunctionchooseform.h" + +QuickOpenFunctionChooseForm::QuickOpenFunctionChooseForm(QWidget* parent, const char* name, bool modal, WFlags fl) +: QuickOpenFunctionChooseFormBase(parent,name, modal,fl) +{ + setCaption( i18n("Select One Argument or File of Function %1").arg( name ) ); + slotArgsChange( 0 ); + slotFileChange( 0 ); +} + +QuickOpenFunctionChooseForm::~QuickOpenFunctionChooseForm() +{ +} + +void QuickOpenFunctionChooseForm::slotArgsChange( int id ) +{ + argBox->setCurrentItem( id ); +} + +void QuickOpenFunctionChooseForm::slotFileChange( int id ) +{ + fileBox->setCurrentItem( id ); + filepathlabel->setText( m_relPaths[id] ); +} + + +#include "quickopenfunctionchooseform.moc" + diff --git a/parts/quickopen/quickopenfunctionchooseform.h b/parts/quickopen/quickopenfunctionchooseform.h new file mode 100644 index 00000000..2529ed46 --- /dev/null +++ b/parts/quickopen/quickopenfunctionchooseform.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2004 Ahn, Duk J.(adjj22@kornet.net) (adjj1@hanmail.net) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef QUICKOPENFUNCTIONCHOOSEFORM_H +#define QUICKOPENFUNCTIONCHOOSEFORM_H + +#include "quickopenfunctionchooseformbase.h" + +#include + +class QuickOpenFunctionChooseForm : public QuickOpenFunctionChooseFormBase +{ + Q_OBJECT + +public: + QuickOpenFunctionChooseForm(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~QuickOpenFunctionChooseForm(); + + void setRelativePath(int id, const QString &path) { m_relPaths[id] = path; } + +public slots: + virtual void slotArgsChange( int id ); + virtual void slotFileChange( int id ); + +private: + QMap m_relPaths; + +}; + +#endif + diff --git a/parts/quickopen/quickopenfunctionchooseformbase.ui b/parts/quickopen/quickopenfunctionchooseformbase.ui new file mode 100644 index 00000000..09c872d9 --- /dev/null +++ b/parts/quickopen/quickopenfunctionchooseformbase.ui @@ -0,0 +1,231 @@ + +QuickOpenFunctionChooseFormBase + + + QuickOpenFunctionChooseFormBase + + + + 0 + 0 + 642 + 373 + + + + + unnamed + + + + filepathlabel + + + + 7 + 0 + 0 + 0 + + + + + + + + + cancelBtn + + + + 7 + 0 + 0 + 0 + + + + &Cancel + + + + + okBtn + + + + 7 + 0 + 0 + 0 + + + + &OK + + + true + + + false + + + + + layout1 + + + + unnamed + + + + textLabel1 + + + File name: + + + + + fileBox + + + + 7 + 7 + 0 + 0 + + + + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 261 + 31 + + + + + + layout3 + + + + unnamed + + + + textLabel2 + + + + 7 + 5 + 0 + 0 + + + + Function arguments list: + + + + + argBox + + + + 7 + 7 + 0 + 0 + + + + -1 + + + + + + + + + okBtn + clicked() + QuickOpenFunctionChooseFormBase + accept() + + + argBox + highlighted(int) + QuickOpenFunctionChooseFormBase + slotFileChange(int) + + + fileBox + highlighted(int) + QuickOpenFunctionChooseFormBase + slotArgsChange(int) + + + argBox + returnPressed(QListBoxItem*) + QuickOpenFunctionChooseFormBase + accept() + + + argBox + clicked(QListBoxItem*) + QuickOpenFunctionChooseFormBase + accept() + + + fileBox + returnPressed(QListBoxItem*) + QuickOpenFunctionChooseFormBase + accept() + + + fileBox + clicked(QListBoxItem*) + QuickOpenFunctionChooseFormBase + accept() + + + cancelBtn + clicked() + QuickOpenFunctionChooseFormBase + reject() + + + + fileBox + argBox + okBtn + cancelBtn + + + slotFileChange( int id ) + slotArgsChange( int id ) + + + + ksqueezedtextlabel.h + klistbox.h + klistbox.h + + diff --git a/parts/quickopen/quickopenfunctiondialog.cpp b/parts/quickopen/quickopenfunctiondialog.cpp new file mode 100644 index 00000000..ede3450b --- /dev/null +++ b/parts/quickopen/quickopenfunctiondialog.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (C) 2004 Ahn, Duk J.(adjj22@kornet.net) (adjj1@hanmail.net) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +#include "quickopenfunctionchooseform.h" +#include "quickopenfunctiondialog.h" + +QuickOpenFunctionDialog::QuickOpenFunctionDialog( QuickOpenPart *part, QWidget* parent, const char* name, bool modal, WFlags fl) +: QuickOpenDialog(part, parent, name, modal, fl) +{ + nameLabel->setText( i18n("Function &name:") ); + itemListLabel->setText( i18n("Function &list:") ); + + fillItemList(); + + itemList->insertStringList( wildCardCompletion( "" ) ); + + nameEdit->setFocus(); + + itemList->setCurrentItem( 0 ); +} + +void QuickOpenFunctionDialog::fillItemList() { + m_items.clear(); + m_functionDefList.clear(); + FileList fileList = m_part->codeModel()->fileList(); + + // for each one file, get all functions + FileDom fileDom; + for( FileList::Iterator it = fileList.begin() ; it!=fileList.end() ; ++it ){ + fileDom = *it; + FunctionDefinitionList defs = CodeModelUtils::allFunctionDefinitionsDetailed( fileDom ).functionList; + if( defs.isEmpty() ) { + m_functionDefList += CodeModelUtils::allFunctionsDetailed( fileDom ).functionList; + } else { + for( FunctionDefinitionList::iterator it = defs.begin(); it != defs.end(); ++it ) + (m_functionDefList).append( (*it).data() ); + } + } + + for( FunctionList::const_iterator it = m_functionDefList.begin(); it != m_functionDefList.end(); ++it ) + m_items << (*it)->name(); + QStringList_unique( m_items ); +} + +QuickOpenFunctionDialog::~QuickOpenFunctionDialog() +{ +} + +void QuickOpenFunctionDialog::gotoFile( QString name ) +{ + FunctionModel *fmodel; + FunctionList funcList; + FunctionDom fdom; + + for( FunctionList::ConstIterator it = m_functionDefList.begin() ; it!=m_functionDefList.end() ; ++it ){ + fdom = *it; + fmodel = fdom.data(); + if( fmodel->name() == name ){ + funcList.append( fdom ); + } + } + if( funcList.count() == 1 ){ + fdom = funcList.first(); + fmodel = fdom.data(); + QString fileNameStr = fmodel->fileName(); + int startline, startcol; + fmodel->getStartPosition( &startline, &startcol ); + m_part->partController()->editDocument( KURL( fileNameStr), startline, startcol ); + selectClassViewItem( ItemDom(&(*fmodel)) ); + + }else if( funcList.count() > 1 ){ + QString fileStr; + + QuickOpenFunctionChooseForm fdlg( this, name.ascii() ); + + for( FunctionList::Iterator it = funcList.begin() ; it!=funcList.end() ; ++it ){ + fmodel = (*it).data(); + + fdlg.argBox->insertItem( m_part->languageSupport()->formatModelItem(fmodel) + + (fmodel->scope().isEmpty() ? "" : " (in " + fmodel->scope().join("::") + ")")); + fileStr = KURL( fmodel->fileName() ).fileName(); + KURL full_url( fmodel->fileName() ); + KURL base_url( part()->project()->projectDirectory()+"/" ); + fdlg.setRelativePath(fdlg.fileBox->count(), + KURL::relativeURL( base_url, full_url )); + fdlg.fileBox->insertItem(fileStr); + } + if( fdlg.exec() ){ + int id = fdlg.argBox->currentItem(); + if( id>-1 && id < (int) funcList.count() ){ + FunctionModel *model = funcList[id].data(); + int line, col; + model->getStartPosition( &line, &col ); + selectClassViewItem( ItemDom(&(*model)) ); + QString fileNameStr = model->fileName(); + m_part->partController()->editDocument( KURL(fileNameStr), line ); + } + } + } + else{ + KMessageBox::error( this, i18n("Error: cannot find matching name function.") ); + } + + accept(); +} + +void QuickOpenFunctionDialog::slotExecuted(QListBoxItem* item) +{ + if( item ){ + gotoFile( item->text() ); + } +} + +void QuickOpenFunctionDialog::executed(QListBoxItem*) +{ +} + +void QuickOpenFunctionDialog::itemSelectionChanged() { + QString text = nameEdit->text(); + QString txt = text; + QStringList parts = QStringList::split("::", text); + if( !text.endsWith( "::" ) && !parts.isEmpty() ) + parts.pop_back(); + parts << itemList->currentText(); + nameEdit->setText(parts.join("::")); +} + +void QuickOpenFunctionDialog::slotTextChangedDelayed() { + QString text = nameEdit->text(); + QString txt = text; + QStringList parts = QStringList::split("::", text); + if(text.endsWith("::") || parts.isEmpty()) { + txt = ""; + }else{ + txt = parts.back(); + parts.pop_back(); + } + QValueList regExpParts; + for( QStringList::const_iterator it = parts.begin(); it != parts.end(); ++it ) { + regExpParts << QRegExp( *it, false, true ); + } + + QString scope = parts.join("::"); + + if( m_scope != scope ) { + if( !scope.startsWith(m_scope) ) { ///Not a specialization, so reload all function-definitions + fillItemList(); + } + + if(!parts.isEmpty()) { + FunctionList accepted; + QStringList acceptedItems; + FunctionList::iterator it = m_functionDefList.begin(); + while(it != m_functionDefList.end()) { + QStringList scope = (*it)->scope(); + QValueList::iterator mit = regExpParts.begin(); + QStringList::iterator sit = scope.begin(); + bool fail = false; + while(mit != regExpParts.end()) { + while(sit != scope.end() && !(*mit).exactMatch( *sit ) ) ++sit; + if(sit == scope.end()) { + fail = true; + break; + } + ++mit; + } + if(!fail) { + accepted.append(*it); + acceptedItems << (*it)->name(); + } + ++it; + } + m_functionDefList = accepted; + m_items = acceptedItems; + QStringList_unique( m_items ); + } + + m_scope = scope; + } + + itemList->clear(); + itemList->insertStringList( wildCardCompletion( txt ) ); + itemList->setCurrentItem(0); +} + +void QuickOpenFunctionDialog::slotReturnPressed() +{ + maybeUpdateSelection(); + QListBoxItem *listboxItem = itemList->selectedItem(); + slotExecuted( listboxItem ); +} + +#include "quickopenfunctiondialog.moc" + diff --git a/parts/quickopen/quickopenfunctiondialog.h b/parts/quickopen/quickopenfunctiondialog.h new file mode 100644 index 00000000..14432b48 --- /dev/null +++ b/parts/quickopen/quickopenfunctiondialog.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2004 Ahn, Duk J.(adjj22@kornet.net) (adjj1@hanmail.net) + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#ifndef QUICKOPENFUNCTIONDLG_H +#define QUICKOPENFUNCTIONDLG_H + +#include + +#include "quickopendialog.h" +#include "quickopen_part.h" + +class KCompletion; +class QuickOpenPart; + +class QuickOpenFunctionDialog : public QuickOpenDialog +{ + Q_OBJECT + +public: + QuickOpenFunctionDialog( QuickOpenPart* part, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~QuickOpenFunctionDialog(); + + void gotoFile( QString name ); + + QuickOpenPart* part(){ return m_part; }; + +public slots: + virtual void slotExecuted(QListBoxItem*);//itemList executed, returnPressed + virtual void executed(QListBoxItem*); // + virtual void slotReturnPressed(); //buttonOk clicked, nameEdit returnPressed + virtual void slotTextChangedDelayed(); + virtual void itemSelectionChanged(); + +protected: + void fillItemList(); + QString m_scope; + FunctionList m_functionDefList; + QStringList m_functionStrList; + +}; + +#endif + -- cgit v1.2.3