diff --git a/kdevplatform/language/duchain/types/containertypes.h b/kdevplatform/language/duchain/types/containertypes.h index 00efe05abd..93afa151fc 100644 --- a/kdevplatform/language/duchain/types/containertypes.h +++ b/kdevplatform/language/duchain/types/containertypes.h @@ -1,213 +1,215 @@ /* * This file is part of KDevelop * Copyright (C) 2011-2014 Sven Brauch * * This program 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 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 General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this program. If not, see . */ #ifndef KDEVPLATFORM_CONTAINER_TYPES_H #define KDEVPLATFORM_CONTAINER_TYPES_H #include "structuretype.h" #include "typesystemdata.h" #include "typeutils.h" #include "../duchainlock.h" #include namespace KDevelop { class KDEVPLATFORMLANGUAGE_EXPORT ListTypeData : public KDevelop::StructureTypeData { public: ListTypeData() : KDevelop::StructureTypeData() , m_contentType() { } ListTypeData(const ListTypeData& rhs) : KDevelop::StructureTypeData(rhs) , m_contentType(rhs.m_contentType) { } explicit ListTypeData(const KDevelop::StructureTypeData& rhs) : KDevelop::StructureTypeData(rhs) , m_contentType() { } IndexedType m_contentType; }; /** * @brief Represents a list-like object which can have a content type. * * Example for Python: + * @code * # in the file describing the built-in list type * class List: # (1) * pass * * # in the user's code: * a = [] # (2) * a.append(3) # (3) + * @endcode * * This type class can be used to determine the type of a as "list of int" as follows: * (1) When creating the type for the List class, * create a ListType instead of a structure type. * (Your language plugin somehow needs to know * which classes are list-like; Python does this * through special comments for the class) * (2) Set the type of a to the type declared by the * List class, as usual. * (3) Call * \code * static_cast(a->abstractType())->addContentType(int_type) * \endcode * (Your language plugin needs to know which methods * add their argument's content to the type's content; * Python does this through special comments for the method) */ class KDEVPLATFORMLANGUAGE_EXPORT ListType : public KDevelop::StructureType { public: typedef TypePtr Ptr; ListType(); ListType(const ListType& rhs); explicit ListType(StructureTypeData& data); /** * @brief Adds @p typeToAdd to the content type of this list. * * If the list currently has no type, it is set to this type. * If @p typeToAdd equals this list's content type, or is a useless type * nothing happens. * Otherwise, the type of the list becomes an unsure type of the previous * and @p typeToAdd. * * Pass your language's UnsureType as a template parameter, as it will eventually * need to be instantiated. * * @note If the type is already assigned to a declaration, the duchain * must be write-locked when this is called. * * @param typeToAdd The new type the list's contents can possibly be of. */ template void addContentType(AbstractType::Ptr typeToAdd) { auto newContentType = TypeUtils::mergeTypes(contentType().abstractType(), typeToAdd); d_func_dynamic()->m_contentType = IndexedType(newContentType); } /** * @brief Replaces this list's content type by @p newType. */ void replaceContentType(const AbstractType::Ptr& newType); /** * @brief Get this lists's content type. */ IndexedType contentType() const; /** * @brief Return only the container type, not the content type in a string. */ QString containerToString() const; /** * @brief Formats this type (base type and content type) in a string. */ QString toString() const override; AbstractType* clone() const override; uint hash() const override; bool equals(const AbstractType* rhs) const override; enum { Identity = 58 }; typedef ListTypeData Data; protected: TYPE_DECLARE_DATA(ListType); }; class KDEVPLATFORMLANGUAGE_EXPORT MapTypeData : public ListTypeData { public: MapTypeData() : ListTypeData() , m_keyType() { } MapTypeData(const MapTypeData& rhs) : ListTypeData(rhs) , m_keyType(rhs.m_keyType) { } explicit MapTypeData(const ListTypeData& rhs) : ListTypeData(rhs) , m_keyType() { } IndexedType m_keyType; }; /** * @brief Represents a hashmap-like object which can have a key and a content type. * * @see ListType * This works the same as ListType, except that you can also track the object's key type. */ class KDEVPLATFORMLANGUAGE_EXPORT MapType : public ListType { public: typedef TypePtr Ptr; MapType(); MapType(const MapType& rhs); explicit MapType(ListTypeData& data); /** * @brief Add @p typeToAdd to this map's key type. * Behaves like addContentType, except that it modifies the key type instead. */ template void addKeyType(AbstractType::Ptr typeToAdd) { auto newKeyType = TypeUtils::mergeTypes(keyType().abstractType(), typeToAdd); DUChainWriteLocker lock; d_func_dynamic()->m_keyType = IndexedType(newKeyType); } /** * @brief Set this map's key type to @p newType. */ void replaceKeyType(const AbstractType::Ptr& newType); /** * @brief Get this map's key type. */ IndexedType keyType() const; /** * @brief Formats this type (base type and key+content type) in a string. */ QString toString() const override; AbstractType* clone() const override; uint hash() const override; bool equals(const AbstractType* rhs) const override; enum { Identity = 57 }; typedef MapTypeData Data; protected: TYPE_DECLARE_DATA(MapType); }; } // namespace KDevelop #endif // KDEVPLATFORM_CONTAINER_TYPES_H // kate: space-indent on; indent-width 4 diff --git a/kdevplatform/language/duchain/types/typepointer.h b/kdevplatform/language/duchain/types/typepointer.h index 71f8f26a93..eccc10dcc1 100644 --- a/kdevplatform/language/duchain/types/typepointer.h +++ b/kdevplatform/language/duchain/types/typepointer.h @@ -1,88 +1,88 @@ /* * This file is part of the KDE libraries. * * Copyright 2005 Frerich Raabe * Copyright 2007-2008 David Nolden * Copyright 2014 Kevin Funk * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef KDEVPLATFORM_TYPEPOINTER_H #define KDEVPLATFORM_TYPEPOINTER_H #include namespace KDevelop { /** * @brief QExplicitlySharedDataPointer wrapper with convenience functions attached */ template class TypePtr : public QExplicitlySharedDataPointer { using Base = QExplicitlySharedDataPointer; public: using Base::QExplicitlySharedDataPointer; using Base::operator=; ///Uses dynamic_cast to cast this pointer to the given type template TypePtr cast(U * /*dummy*/ = nullptr) const { return TypePtr(dynamic_cast(Base::data())); } /** * Convert TypePtr to TypePtr, using a static_cast. * This will compile whenever T* and U* are compatible, i.e. * T is a subclass of U or vice-versa. * Example syntax: - * + * @code * TypePtr tPtr; * TypePtr uPtr = TypePtr::staticCast( tPtr ); - * + * @endcode */ template static TypePtr staticCast( const TypePtr& o ) { return TypePtr( static_cast( o.data() ) ); } /** * Convert TypePtr to TypePtr, using a dynamic_cast. * This will compile whenever T* and U* are compatible, i.e. * T is a subclass of U or vice-versa. * Example syntax: - * + * @code * TypePtr tPtr; * TypePtr uPtr = TypePtr::dynamicCast( tPtr ); - * + * @endcode * Since a dynamic_cast is used, if U derives from T, and tPtr isn't an instance of U, uPtr will be 0. */ template static TypePtr dynamicCast( const TypePtr& o ) { return TypePtr( dynamic_cast( o.data() ) ); } }; } #endif diff --git a/kdevplatform/util/activetooltip.h b/kdevplatform/util/activetooltip.h index 72a3db89ed..819e37fdc7 100644 --- a/kdevplatform/util/activetooltip.h +++ b/kdevplatform/util/activetooltip.h @@ -1,94 +1,96 @@ /* This file is part of the KDE project Copyright 2007 Vladimir Prus Copyright 2009-2010 David Nolden 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. */ #ifndef KDEVPLATFORM_ACTIVE_TOOLTIP_H #define KDEVPLATFORM_ACTIVE_TOOLTIP_H #include #include "utilexport.h" namespace KDevelop { /** This class implements a tooltip that can contain arbitrary widgets that the user can interact with. Usage example: + @code KDevelop::ActiveToolTip* tooltip = new KDevelop::ActiveToolTip(mainWindow, QCursor::pos()); QVBoxLayout* layout = new QVBoxLayout(tooltip); layout->addWidget(widget); tooltip->resize( tooltip->sizeHint() ); ActiveToolTip::showToolTip(tooltip); + @endcode */ class KDEVPLATFORMUTIL_EXPORT ActiveToolTip : public QWidget { Q_OBJECT public: ///@param parent Parent widget. Must not be zero, else the widget won't be shown. /// @param position Position where to show the tooltip, in global coordinates. ActiveToolTip(QWidget *parent, const QPoint& position); ~ActiveToolTip() override; ///Shows and registers the given tool-tip. ///This should be used instead of just calling show() to make multiple different ///tooltips work together. ///The tooltip is owned by the manager after this is called. It will delete itself. ///@param tooltip The tooltip to show. It should not be visible yet, show() will eventually be called from here, with some delay. /// The ownership stays with the caller. ///@param priority The priority of this tooltip. Lower is better. Multiple tooltips will be stacked down in the given order. /// If it is zero, the given tooltip will be shown exclusively. ///@param uniqueId If this is nonempty, ActiveTooltip will make sure that only one tooltip with the given id is shown at a time static void showToolTip(ActiveToolTip* tooltip, float priority = 100, const QString& uniqueId = QString()); bool eventFilter(QObject *object, QEvent *e) override; bool insideThis(QObject* object); void showEvent(QShowEvent*) override; void resizeEvent(QResizeEvent*) override; void paintEvent(QPaintEvent*) override; void adjustRect(); ///Clicks within the friend widget are allowed void addFriendWidget(QWidget* widget); ///Set rect of handle (object) this tool tip is created for ///Moving mouse inside this rect, and between this and bounding geometry won't hide the tooltip void setHandleRect(const QRect& rect); ///Set the area within which the mouse can be moved freely without hiding the tooltip void setBoundingGeometry(const QRect& geometry); Q_SIGNALS: void resized(); // Emitted whenever mouse-activity is noticed within the tooltip area void mouseIn(); // Emitted whenever mouse-activity is noticed outside of the tooltip area void mouseOut(); private: void closeEvent(QCloseEvent* ) override; private: const QScopedPointer d; }; } #endif diff --git a/kdevplatform/vcs/vcsrevision.h b/kdevplatform/vcs/vcsrevision.h index e43a5d51bc..2e241066ce 100644 --- a/kdevplatform/vcs/vcsrevision.h +++ b/kdevplatform/vcs/vcsrevision.h @@ -1,171 +1,171 @@ /* This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * Copyright 2007 Matthew Woehlke * * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #ifndef KDEVPLATFORM_VCSREVISION_H #define KDEVPLATFORM_VCSREVISION_H #include "vcsexport.h" #include class QStringList; class QString; namespace KDevelop { /** * Encapsulates a vcs revision number, date or range of revisions. * * The type of the QVariant value depends on the type of the revision, * the following table lists the standard types and the according datatype * in the QVariant: * * * * * * * *
Revision typeQVariant type
GlobalNumberqlonglong/QString
FileNumberqlonglong/QString
DateQDateTime
SpecialKDevelop::VcsRevision::RevisionSpecialType or int, see explanation below
* * The vcs plugins need to register the Revision and RevisionSpecialType with * qRegisterMetaType. * * Also Users of this class should set RevisionSpecialType QVariant values via - * + * @code * setRevisionValue( qVariantFromValue( val ), KDevelop::VcsRevision::Special); - * + * @endcode * instead of - * + * @code * setRevisionValue( qVariantFromValue( val ), KDevelop::VcsRevision::Special); - * + * @endcode * * If the latter method is used the QVariant will be an Integer, which might not * be handled by the vcs plugin and is possibly ambiguous with the qlonglong * parameters. * */ class KDEVPLATFORMVCS_EXPORT VcsRevision { public: /** * @note Not all VCS's support both FileNumber and GlobalNumber. For those * that don't, asking for one may give you the other, therefore you should * check which is returned. For example, CVS does not support GlobalNumber, * and Subversion does not support FileNumber, while Perforce supports both. */ enum RevisionType { Special = 0 /**< One of the special versions in RevisionSpecialType. */, GlobalNumber = 1 /**< Global repository version when item was last changed. */, FileNumber = 2 /**< Item's independent version number. */, Date = 3, /**< The date of the revision to check out */ Invalid = 4 /**< The type is not set, this is an invalid revision. */, UserType = 1000 /**< This should be used by subclasses as base for their own types. */ }; enum RevisionSpecialType { Head = 0 /**< Latest revision in the repository. */, Working = 1 /**< The local copy (including any changes made). */, Base = 2 /**< The repository source of the local copy. */, Previous = 3 /**< The version prior the other one (only valid in functions that take two revisions). */, Start = 4, /**< The first commit in a repository. */ UserSpecialType = 1000 /**< This should be used by subclasses as base for their own special types. */ }; VcsRevision(); virtual ~VcsRevision(); VcsRevision( const VcsRevision& ); VcsRevision& operator=( const VcsRevision& ); /** * Set the value of this revision */ void setRevisionValue( const QVariant& rev, RevisionType type ); /** * returns the type of the revision */ RevisionType revisionType() const; RevisionSpecialType specialType() const; /** * Return the value of this revision. * * See the class documentation for the different QVariant types */ QVariant revisionValue() const; /** * This returns the value of the revision, suitable for displaying to the * user. For numbers it just returns the number converted to a string, for * the special types it returns the literal value of the special type and * for a datetime value it returns a localized string of the datetime value. */ QString prettyValue() const; bool operator==( const KDevelop::VcsRevision&) const; /** * Helper function to create a vcs revision for one of the special types */ static VcsRevision createSpecialRevision( KDevelop::VcsRevision::RevisionSpecialType type ); protected: /** * Get the keys that make up the internal data of this revision instance */ QStringList keys() const; /** * get the value for a given key, this retrieves internal data and is * meant to be used by subclasses */ QVariant getValue( const QString& key ) const; /** * change the value of the given internal data */ void setValue( const QString& key, const QVariant& value ); /** * write methods for subclasses to easily set the type and value */ void setType( RevisionType t); void setSpecialType( RevisionSpecialType t); void setValue( const QVariant& ); private: const QScopedPointer d; }; KDEVPLATFORMVCS_EXPORT uint qHash( const KDevelop::VcsRevision& rev); } Q_DECLARE_METATYPE(KDevelop::VcsRevision) Q_DECLARE_METATYPE(KDevelop::VcsRevision::RevisionSpecialType) #endif