Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / interfaces / context.cpp
blob35ba3ed25971f5ac01a4190825091bdb25f78c9f
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.
30 #include "context.h"
32 #include <QDir>
33 #include <QList>
35 #include <ktexteditor/document.h>
37 namespace KDevelop
40 Context::Context()
41 : d(0)
44 Context::~Context()
47 bool Context::hasType( int aType ) const
49 return aType == this->type();
52 class EditorContextPrivate
54 public:
55 EditorContextPrivate( KTextEditor::View* view )
56 : m_view( view )
58 m_url = view->document()->url();
59 m_position = view->cursorPosition();
62 KUrl m_url;
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()
74 delete d;
77 int EditorContext::type() const
79 return Context::EditorContext;
82 KUrl EditorContext::url() const
84 return d->m_url;
87 KTextEditor::Cursor EditorContext::position() const
89 return d->m_position;
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
104 return d->m_view;
107 class FileContextPrivate
109 public:
110 FileContextPrivate( const KUrl::List &urls )
111 : m_urls( urls )
114 KUrl::List m_urls;
117 FileContext::FileContext( const KUrl::List &urls )
118 : Context(), d( new FileContextPrivate( urls ) )
121 FileContext::~FileContext()
123 delete d;
126 int FileContext::type() const
128 return Context::FileContext;
131 KUrl::List FileContext::urls() const
133 return d->m_urls;
136 class ProjectItemContextPrivate
138 public:
139 ProjectItemContextPrivate( const QList<ProjectBaseItem*> &items )
140 : m_items( items )
143 QList<ProjectBaseItem*> m_items;
146 ProjectItemContext::ProjectItemContext( const QList<ProjectBaseItem*> &items )
147 : Context(), d( new ProjectItemContextPrivate( items ) )
150 ProjectItemContext::~ProjectItemContext()
152 delete d;
155 int ProjectItemContext::type() const
157 return Context::ProjectItemContext;
160 QList<ProjectBaseItem*> ProjectItemContext::items() const
162 return d->m_items;