1 /* This file is part of KDevelop
2 Copyright 2001-2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
3 Copyright 2001-2002 Bernd Gehrmann <bernd@kdevelop.org>
4 Copyright 2001 Sandy Meier <smeier@kdevelop.org>
5 Copyright 2002 Daniel Engelschalt <daniel.engelschalt@gmx.net>
6 Copyright 2002 Simon Hausmann <hausmann@kde.org>
7 Copyright 2002-2003 Roberto Raggi <roberto@kdevelop.org>
8 Copyright 2003 Mario Scalas <mario.scalas@libero.it>
9 Copyright 2003 Harald Fernengel <harry@kdevelop.org>
10 Copyright 2003,2006 Hamish Rodda <rodda@kde.org>
11 Copyright 2004 Alexander Dymo <adymo@kdevelop.org>
12 Copyright 2006 Adam Treat <treat@kde.org>
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Library General Public
16 License as published by the Free Software Foundation; either
17 version 2 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Library General Public License for more details.
24 You should have received a copy of the GNU Library General Public License
25 along with this library; see the file COPYING.LIB. If not, write to
26 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA.
35 #include <ktexteditor/document.h>
47 bool Context::hasType( int aType
) const
49 return aType
== this->type();
52 class EditorContextPrivate
55 EditorContextPrivate( KTextEditor::View
* view
)
58 m_url
= view
->document()->url();
59 m_position
= view
->cursorPosition();
63 KTextEditor::Cursor m_position
;
64 QString m_currentLine
, m_currentWord
;
65 KTextEditor::View
* m_view
;
68 EditorContext::EditorContext( KTextEditor::View
* view
)
69 : Context(), d( new EditorContextPrivate( view
) )
72 EditorContext::~EditorContext()
77 int EditorContext::type() const
79 return Context::EditorContext
;
82 KUrl
EditorContext::url() const
87 KTextEditor::Cursor
EditorContext::position() const
92 QString
EditorContext::currentLine() const
94 return d
->m_currentLine
;
97 QString
EditorContext::currentWord() const
99 return d
->m_currentWord
;
102 KTextEditor::View
* EditorContext::view() const
107 class FileContextPrivate
110 FileContextPrivate( const KUrl::List
&urls
)
117 FileContext::FileContext( const KUrl::List
&urls
)
118 : Context(), d( new FileContextPrivate( urls
) )
121 FileContext::~FileContext()
126 int FileContext::type() const
128 return Context::FileContext
;
131 KUrl::List
FileContext::urls() const
136 class ProjectItemContextPrivate
139 ProjectItemContextPrivate( const QList
<ProjectBaseItem
*> &items
)
143 QList
<ProjectBaseItem
*> m_items
;
146 ProjectItemContext::ProjectItemContext( const QList
<ProjectBaseItem
*> &items
)
147 : Context(), d( new ProjectItemContextPrivate( items
) )
150 ProjectItemContext::~ProjectItemContext()
155 int ProjectItemContext::type() const
157 return Context::ProjectItemContext
;
160 QList
<ProjectBaseItem
*> ProjectItemContext::items() const