summaryrefslogtreecommitdiffstats
path: root/parts/quickopen/quickopen_part.cpp
blob: 3a8a10c40ac26c335b30fd2e1796e6fa7cf5b4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 *  Copyright (C) 2003 Roberto Raggi ([email protected])
 *
 *  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., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 *
 */

#include "quickopen_part.h"
#include "quickopenclassdialog.h"
#include "quickopenfunctiondialog.h"
#include "quickopenfiledialog.h"

#include <tdeaction.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <klineedit.h>
#include <tdevgenericfactory.h>
#include <tdevplugininfo.h>

#include <tdemainwindow.h>

#include <tdeparts/part.h>
#include <tdetexteditor/document.h>

#include <tdevmainwindow.h>
#include <tdevcore.h>
#include <tdevpartcontroller.h>
#include <tdevproject.h>
#include <codebrowserfrontend.h>

#include "tdeveditorutil.h"

typedef TDevGenericFactory<QuickOpenPart> QuickOpenFactory;
static const TDevPluginInfo data("tdevquickopen");
K_EXPORT_COMPONENT_FACTORY( libtdevquickopen, QuickOpenFactory( data ) )

using namespace KTextEditor;

QuickOpenPart::QuickOpenPart(TQObject *parent, const char *name, const TQStringList& )
    : KDevQuickOpen(&data, parent, name ? name : "QuickOpenPart" )
{
    setInstance(QuickOpenFactory::instance());
    setXMLFile("tdevpart_quickopen.rc");

    m_actionQuickOpen = new TDEAction( i18n("Quick Open File..."), CTRL + ALT + Key_O,
				       this, TQT_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 TDEAction( i18n("Quick Open Class..."), CTRL + ALT + Key_C,
				          this, TQT_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 TDEAction( i18n("Quick Open Method..."), CTRL + ALT + Key_M, this, TQT_SLOT(slotQuickOpenFunction()), actionCollection(), "quick_open_function" );
    m_actionFunctionOpen->setToolTip(i18n("Quick open function in project"));

    m_switchToAction = new TDEAction(i18n("Switch To..."), TDEShortcut("CTRL+/"), this, TQT_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(), TQT_SIGNAL(projectOpened()), this, TQT_SLOT(slotProjectOpened()) );
    connect( core(), TQT_SIGNAL(projectClosed()), this, TQT_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( TDevEditorUtil::currentWord( dynamic_cast<KTextEditor::Document*>( partController()->activePart() ) ) );
    dlg.exec();
}

void QuickOpenPart::slotQuickOpenFunction()
{
    QuickOpenFunctionDialog dlg( this, mainWindow()->main() );
    dlg.nameEdit->setText( TDevEditorUtil::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::TDevCodeBrowserFrontend* f = extension< Extensions::TDevCodeBrowserFrontend > ( "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"