diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /parts/quickopen | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
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
Diffstat (limited to 'parts/quickopen')
-rw-r--r-- | parts/quickopen/Makefile.am | 17 | ||||
-rw-r--r-- | parts/quickopen/README.dox | 52 | ||||
-rw-r--r-- | parts/quickopen/kdevpart_quickopen.rc | 15 | ||||
-rw-r--r-- | parts/quickopen/kdevquickopen.desktop | 80 | ||||
-rw-r--r-- | parts/quickopen/quickopen_part.cpp | 139 | ||||
-rw-r--r-- | parts/quickopen/quickopen_part.h | 57 | ||||
-rw-r--r-- | parts/quickopen/quickopenbase.ui | 178 | ||||
-rw-r--r-- | parts/quickopen/quickopenclassdialog.cpp | 219 | ||||
-rw-r--r-- | parts/quickopen/quickopenclassdialog.h | 56 | ||||
-rw-r--r-- | parts/quickopen/quickopendialog.cpp | 155 | ||||
-rw-r--r-- | parts/quickopen/quickopendialog.h | 63 | ||||
-rw-r--r-- | parts/quickopen/quickopenfiledialog.cpp | 121 | ||||
-rw-r--r-- | parts/quickopen/quickopenfiledialog.h | 49 | ||||
-rw-r--r-- | parts/quickopen/quickopenfunctionchooseform.cpp | 56 | ||||
-rw-r--r-- | parts/quickopen/quickopenfunctionchooseform.h | 48 | ||||
-rw-r--r-- | parts/quickopen/quickopenfunctionchooseformbase.ui | 231 | ||||
-rw-r--r-- | parts/quickopen/quickopenfunctiondialog.cpp | 229 | ||||
-rw-r--r-- | parts/quickopen/quickopenfunctiondialog.h | 60 |
18 files changed, 1825 insertions, 0 deletions
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: +<code>This is code</code>, html links <a href="http://somelocation">link text</a>, +and images. + +\authors <a href="mailto:$EMAIL$">$AUTHOR$</a> +\authors <a href="mailto:2nd author AT provider.com">2nd author full name</a> +... +\authors <a href="mailto:nth author AT provider.com">nth author full name</a> + +\maintainer <a href="mailto:$EMAIL$">$AUTHOR$</a> +\maintainer <a href="mailto:2nd maintainer AT provider.com">2nd maintainer full name</a> +... +\maintainer <a href="mailto:nth maintainer AT provider.com">nth maintainer full name</a> + +\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 <b>First frequenly asked question about your part ?</b> Answer. +\faq <b>Second frequenly asked question about your part ?</b> Answer. +... +\faq <b>Last frequenly asked question about your part ?</b> 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 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="quickopen" library="libquickopenplugin" version="4"> +<MenuBar> + <Menu name="file"> + <Action name="quick_open" group="open_merge"/> + </Menu> + <Menu name="view"> + <Action name="file_switchto"/> + </Menu> + <Menu name="tools"> + <Action name="quick_open_class"/> + <Action name="quick_open_function"/> + </Menu> +</MenuBar> +</kpartplugin> 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 <kaction.h> +#include <kiconloader.h> +#include <klocale.h> +#include <klineedit.h> +#include <kdevgenericfactory.h> +#include <kdevplugininfo.h> + +#include <kmainwindow.h> + +#include <kparts/part.h> +#include <ktexteditor/document.h> + +#include <kdevmainwindow.h> +#include <kdevcore.h> +#include <kdevpartcontroller.h> +#include <kdevproject.h> +#include <codebrowserfrontend.h> + +#include "kdeveditorutil.h" + +typedef KDevGenericFactory<QuickOpenPart> 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("<b>Quick open</b><p>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("<b>Find class</b><p>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("<b>Switch to</b><p>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<KTextEditor::Document*>( partController()->activePart() ) ) ); + dlg.exec(); +} + +void QuickOpenPart::slotQuickOpenFunction() +{ + QuickOpenFunctionDialog dlg( this, mainWindow()->main() ); + dlg.nameEdit->setText( KDevEditorUtil::currentWord( dynamic_cast<KTextEditor::Document*>( 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 <qguardedptr.h> +#include <kdevquickopen.h> +#include <codemodel.h> + +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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QuickOpenDialogBase</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QuickOpenDialogBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>369</width> + <height>331</height> + </rect> + </property> + <property name="caption"> + <string>Quick Open</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>nameLabel</cstring> + </property> + <property name="text"> + <string>[NAME]</string> + </property> + <property name="buddy" stdset="0"> + <cstring>nameEdit</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>itemListLabel</cstring> + </property> + <property name="text"> + <string>[ITEM LIST]</string> + </property> + <property name="buddy" stdset="0"> + <cstring>itemList</cstring> + </property> + </widget> + <widget class="KListBox" row="3" column="0"> + <property name="name"> + <cstring>itemList</cstring> + </property> + </widget> + <widget class="QLayoutWidget" row="4" column="0"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + <widget class="KLineEdit" row="1" column="0"> + <property name="name"> + <cstring>nameEdit</cstring> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>slotReturnPressed()</slot> + </connection> + <connection> + <sender>itemList</sender> + <signal>doubleClicked(QListBoxItem*)</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>slotExecuted(QListBoxItem*)</slot> + </connection> + <connection> + <sender>nameEdit</sender> + <signal>returnPressed()</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>slotReturnPressed()</slot> + </connection> + <connection> + <sender>nameEdit</sender> + <signal>textChanged(const QString&)</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>slotTextChanged(const QString&)</slot> + </connection> + <connection> + <sender>itemList</sender> + <signal>returnPressed(QListBoxItem*)</signal> + <receiver>QuickOpenDialogBase</receiver> + <slot>slotReturnPressed()</slot> + </connection> +</connections> +<tabstops> + <tabstop>nameEdit</tabstop> + <tabstop>itemList</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> +</tabstops> +<slots> + <slot>slotTextChanged( const QString & )</slot> + <slot>executed( QListBoxItem * )</slot> + <slot>slotExecuted( QListBoxItem * )</slot> + <slot>slotReturnPressed()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistbox.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> 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 <kdevproject.h> +#include <kdevpartcontroller.h> +#include <kdevlanguagesupport.h> + +#include <klistbox.h> +#include <klocale.h> +#include <kdebug.h> +#include <kcompletion.h> +#include <klineedit.h> + +#include <qregexp.h> +#include <qlabel.h> + +#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 <codemodel.h> +#include <qstringlist.h> + +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 <kdevelop-devel@kdevelop.org>, (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 <qapplication.h> +#include <qregexp.h> + +#include <klistbox.h> +#include <klineedit.h> +#include <kdebug.h> + +#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 <kdevelop-devel@kdevelop.org>, (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 <qstringlist.h> +#include <qtimer.h> + +#include <codemodel.h> + +#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 <kdevproject.h> +#include <kdevpartcontroller.h> + + +#include <klistbox.h> +#include <klocale.h> +#include <kdebug.h> +#include <kcompletion.h> +#include <klineedit.h> + + +#include <qregexp.h> +#include <qlabel.h> + +#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 <qstringlist.h> + +#include <kurl.h> + +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 <klistbox.h> +#include <klocale.h> +#include <kurl.h> +#include <kdebug.h> +#include <ksqueezedtextlabel.h> + +#include <codemodel.h> + +#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 <qmap.h> + +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<int, QString> 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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>QuickOpenFunctionChooseFormBase</class> +<widget class="QDialog"> + <property name="name"> + <cstring>QuickOpenFunctionChooseFormBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>642</width> + <height>373</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KSqueezedTextLabel" row="1" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>filepathlabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QPushButton" row="2" column="3"> + <property name="name"> + <cstring>cancelBtn</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="2"> + <property name="name"> + <cstring>okBtn</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>File name:</string> + </property> + </widget> + <widget class="KListBox"> + <property name="name"> + <cstring>fileBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + <spacer row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>261</width> + <height>31</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget" row="0" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Function arguments list:</string> + </property> + </widget> + <widget class="KListBox"> + <property name="name"> + <cstring>argBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentItem"> + <number>-1</number> + </property> + </widget> + </vbox> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>okBtn</sender> + <signal>clicked()</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>argBox</sender> + <signal>highlighted(int)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>slotFileChange(int)</slot> + </connection> + <connection> + <sender>fileBox</sender> + <signal>highlighted(int)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>slotArgsChange(int)</slot> + </connection> + <connection> + <sender>argBox</sender> + <signal>returnPressed(QListBoxItem*)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>argBox</sender> + <signal>clicked(QListBoxItem*)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>fileBox</sender> + <signal>returnPressed(QListBoxItem*)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>fileBox</sender> + <signal>clicked(QListBoxItem*)</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>cancelBtn</sender> + <signal>clicked()</signal> + <receiver>QuickOpenFunctionChooseFormBase</receiver> + <slot>reject()</slot> + </connection> +</connections> +<tabstops> + <tabstop>fileBox</tabstop> + <tabstop>argBox</tabstop> + <tabstop>okBtn</tabstop> + <tabstop>cancelBtn</tabstop> +</tabstops> +<slots> + <slot specifier="pure virtual">slotFileChange( int id )</slot> + <slot specifier="pure virtual">slotArgsChange( int id )</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>ksqueezedtextlabel.h</includehint> + <includehint>klistbox.h</includehint> + <includehint>klistbox.h</includehint> +</includehints> +</UI> 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 <klocale.h> +#include <qlabel.h> +#include <qvaluelist.h> + +#include <kcompletion.h> +#include <kdebug.h> +#include <klistbox.h> +#include <kmessagebox.h> +#include <klineedit.h> + +#include <kdevplugin.h> +#include <codemodel_utils.h> +#include <kdevpartcontroller.h> +#include <kdevproject.h> +#include <kdevlanguagesupport.h> +#include <qregexp.h> + + +#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<QRegExp> 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<QRegExp>::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 <codemodel.h> + +#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 + |