[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ktexteditor-devel
Subject:    Access to the currently displayed document range
From:       Michel Ludwig <michel.ludwig () kdemail ! net>
Date:       2008-03-26 9:35:13
Message-ID: 200803261035.13500.michel.ludwig () kdemail ! net
[Download RAW message or body]

Hi again,

I'm currently implementing on-the-fly spell checking in Kile, and I've come to 
a point where it actually works, but things tend to slow in large documents. 
For example, one document has over 6000 SmartRanges installed on it after the 
spell checking and it is really painful to do some editing then.

So, I've been looking for a way to restrict the number of SmartRanges that 
need to be installed on a document at a specific moment in time, but I 
couldn't find a way to actually get the currently displayed document range. 
Hence, I propose a new interface again :-)

The attached "VisibilityInterface" (I don't like the name too much) adds a 
signal that notifies listeners of changes to the visible document range, and 
the method " getDisplayedRange()" is added which returns the currently 
displayed range.


Thanks again,

Michel

["visibilityinterface.h" (text/x-c++hdr)]

/* This file is part of the KDE libraries
   Copyright (C) 2008 Michel Ludwig <michel.ludwig@kdemail.net>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   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 KDELIBS_KTEXTEDITOR_VISIBILITYINTERFACE_H
#define KDELIBS_KTEXTEDITOR_VISIBILITYINTERFACE_H

#include <ktexteditor/ktexteditor_export.h>

class KConfigGroup;

#include <QtCore/QObject>

#include <KTextEditor/Range>

namespace KTextEditor
{
/**
 * \brief Visibility interface extension for the View.
 *
 * \ingroup kte_group_view_extensions
 *
 * \section visibility_intro Introduction
 *
 * The VisibilityInterface is an extension for Views which allows for notifications when the
 * currently displayed document range changes.
 *
 * \section visibility_support Adding Visibility Support
 *
 * To add support for action access a KTextEditor implementation has to derive the
 * View class from VisibilityInterface and reimplement the purely virtual methods defined
 * in this interfaces.
 *
 * \section visibility_access Accessing the VisibilityInterface
 *
 * The VisibilityInterface is supposed to be an extension interface for a View, i.e. the
 * View inherits the interface \e provided that it implements the interface. Use qobject_cast to
 * access the implementation:
 * \code
 * // object is of type KTextEditor::View*
 * KTextEditor::VisibilityInterface *iface =
 *     qobject_cast<KTextEditor::VisibilityInterface*>( object );
 *
 * if( iface ) {
 *     // interface is supported
 *     // do stuff
 * }
 * \endcode
 *
 * \see KTextEditor::View
 * \author Michel Ludwig \<michel.ludwig@kdemail.net\>
 */
class KTEXTEDITOR_EXPORT VisibilityInterface
{
  public:
    /**
     * Constructor.
     */
    VisibilityInterface();

    /**
     * Virtual destructor.
     */
    virtual ~VisibilityInterface() {}

  Q_SIGNALS:
    /**
     * This signal is emitted whenever the displayed document range in \p view
     * changes.
     * \param view View whose displayed document range changes
     */
    void displayedRangeChanged(KTextEditor::View *view);

  public:
    /**
     * Get the range of the document which is currently displayed in the View.
     *
     * \return      Pointer to the range of the document which is currently
     *              displayed. 
     */
    virtual KTextEditor::Range* getDisplayedRange() = 0;

   private:
    class VisibilityInterfacePrivate* const d;
};

}

Q_DECLARE_INTERFACE(KTextEditor::VisibilityInterface, "org.kde.KTextEditor.VisibilityInterface")

#endif

// kate: space-indent on; indent-width 2; replace-tabs on;


_______________________________________________
KTextEditor-Devel mailing list
KTextEditor-Devel@kde.org
https://mail.kde.org/mailman/listinfo/ktexteditor-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic