You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdevelop/lib/interfaces/kdevcore.cpp

299 lines
6.8 KiB

/* This file is part of the KDE project
Copyright (C) 2001-2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
Copyright (C) 2002-2003 Roberto Raggi <roberto@tdevelop.org>
Copyright (C) 2003 Mario Scalas <mario.scalas@libero.it>
Copyright (C) 2003 Amilcar do Carmo Lucas <amilcar@ida.ing.tu-bs.de>
Copyright (C) 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
Copyright (C) 2004 Alexander Dymo <adymo@tdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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 Library General Public License
along with this library; 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 "KDevCoreIface.h"
#include "kdevcore.h"
#include "urlutil.h"
///////////////////////////////////////////////////////////////////////////////
// class Context
///////////////////////////////////////////////////////////////////////////////
Context::Context()
{
}
Context::~Context()
{
}
bool Context::hasType( int aType ) const
{
return aType == this->type();
}
///////////////////////////////////////////////////////////////////////////////
// class EditorContext
///////////////////////////////////////////////////////////////////////////////
class EditorContext::Private
{
public:
Private( const KURL &url, int line, int col, const TQString &linestr,
const TQString &wordstr )
: m_url(url), m_line(line), m_col(col),
m_linestr(linestr), m_wordstr(wordstr)
{
}
KURL m_url;
int m_line, m_col;
TQString m_linestr, m_wordstr;
};
EditorContext::EditorContext( const KURL &url, int line, int col,
const TQString &linestr, const TQString &wordstr )
: Context(), d( new Private(url, line, col, linestr, wordstr) )
{
}
EditorContext::~EditorContext()
{
delete d;
d = 0;
}
int EditorContext::type() const
{
return Context::EditorContext;
}
const KURL &EditorContext::url() const
{
return d->m_url;
}
int EditorContext::line() const
{
return d->m_line;
}
int EditorContext::col() const
{
return d->m_col;
}
TQString EditorContext::currentLine() const
{
return d->m_linestr;
}
TQString EditorContext::currentWord() const
{
return d->m_wordstr;
}
///////////////////////////////////////////////////////////////////////////////
// class FileContext
///////////////////////////////////////////////////////////////////////////////
class FileContext::Private
{
public:
Private( const KURL::List &someURLs ) : m_urls(someURLs)
{
if (m_urls.count() == 0)
{
m_fileName = "INVALID-FILENAME";
m_isDirectory = false; // well, "true" should be ok too ...
}
else
{
m_fileName = m_urls[0].path();
m_isDirectory = URLUtil::isDirectory( m_urls[0] );
}
}
Private( const TQString &fileName, bool isDirectory )
: m_fileName(fileName), m_isDirectory(isDirectory)
{
}
KURL::List m_urls;
/// \FIXME the following data members should be removed, but first other
// parts should be modified to comply with this change.
TQString m_fileName;
bool m_isDirectory;
};
FileContext::FileContext( const KURL::List &someURLs )
: Context(), d( new Private(someURLs) )
{
}
FileContext::~FileContext()
{
delete d;
d = 0;
}
int FileContext::type() const
{
return Context::FileContext;
}
const KURL::List &FileContext::urls() const
{
return d->m_urls;
}
///////////////////////////////////////////////////////////////////////////////
// class DocumentationContext
///////////////////////////////////////////////////////////////////////////////
class DocumentationContext::Private
{
public:
Private( const TQString &url, const TQString &selection )
: m_url(url), m_selection(selection)
{
}
TQString m_url;
TQString m_selection;
};
DocumentationContext::DocumentationContext( const TQString &url, const TQString &selection )
: Context(), d( new Private(url, selection) )
{
}
DocumentationContext::DocumentationContext( const DocumentationContext &aContext )
: Context(), d( 0 )
{
*this = aContext;
}
DocumentationContext &DocumentationContext::operator=( const DocumentationContext &aContext)
{
if (d) {
delete d; d = 0;
}
d = new Private( *aContext.d );
return *this;
}
DocumentationContext::~DocumentationContext()
{
delete d;
d = 0;
}
int DocumentationContext::type() const
{
return Context::DocumentationContext;
}
TQString DocumentationContext::url() const
{
return d->m_url;
}
TQString DocumentationContext::selection() const
{
return d->m_selection;
}
///////////////////////////////////////////////////////////////////////////////
// class CodeModelItemContext
///////////////////////////////////////////////////////////////////////////////
class CodeModelItemContext::Private
{
public:
Private( const CodeModelItem* item ) : m_item( item ) {}
const CodeModelItem* m_item;
};
CodeModelItemContext::CodeModelItemContext( const CodeModelItem* item )
: Context(), d( new Private(item) )
{
}
CodeModelItemContext::~CodeModelItemContext()
{
delete d;
d = 0;
}
int CodeModelItemContext::type() const
{
return Context::CodeModelItemContext;
}
const CodeModelItem* CodeModelItemContext::item() const
{
return d->m_item;
}
///////////////////////////////////////////////////////////////////////////////
// class ProjectModelItemContext
///////////////////////////////////////////////////////////////////////////////
class ProjectModelItemContext::Private
{
public:
Private( const ProjectModelItem* item ) : m_item( item ) {}
const ProjectModelItem* m_item;
};
ProjectModelItemContext::ProjectModelItemContext( const ProjectModelItem* item )
: Context(), d( new Private(item) )
{
}
ProjectModelItemContext::~ProjectModelItemContext()
{
delete d;
d = 0;
}
int ProjectModelItemContext::type() const
{
return Context::ProjectModelItemContext;
}
const ProjectModelItem* ProjectModelItemContext::item() const
{
return d->m_item;
}
///////////////////////////////////////////////////////////////////////////////
// class KDevCore
///////////////////////////////////////////////////////////////////////////////
KDevCore::KDevCore( TQObject *parent, const char *name )
: TQObject( parent, name )
{
new KDevCoreIface(this);
}
KDevCore::~KDevCore()
{
}
#include "kdevcore.moc"