[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: RFD: loading/pasting/DnD in Flake?
From: "Benjamin K. Stuhl" <benjamin.stuhl () colorado ! edu>
Date: 2006-08-25 3:57:03
Message-ID: 20060824215703.60510d05 () localhost
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Replying to myself with some patches to KoShape.h and KoTool.h to make
the discussion a bit more concrete. These aren't to be applied, since
(a) they won't compile without a bunch of porting of all the
shapes and tools, and (b) I have an SVN account now. ^_^
I'm not sure what the rules are on which libraries can link to what. In
particular, I hope it is OK to give Flake a dependency on kostore?
One thing that occurs to me as I'm writing this up: perhaps
KoTool::cut(), KoTool::paste(), and KoTool::copy() should be passed
the same arguments as KoShape::load() or KoShape::save() so that
KoTool itself can implement the basic clipboard and filter handling?
Or should KoTool::paste() be given a mime type argument?
-- BKS
Index: flake/KoShape.h
===================================================================
--- flake/KoShape.h (revision 576400)
+++ flake/KoShape.h (working copy)
@@ -34,6 +34,7 @@
class QRectF;
class QPainterPath;
class QVariant;
+class QDomElement;
class KoSelection;
class KoPointerEvent;
@@ -41,6 +42,8 @@
class KoShapeBorderModel;
class KoShapeManager;
class KoShapeUserData;
+class KoCreateShapesTool;
+class KoStore;
/**
*
@@ -106,6 +109,31 @@
*/
virtual void paintDecorations(QPainter &painter, const KoViewConverter \
&converter, bool selected);
+ /** @brief Load the entire shape
+ * Each shape is resposible for knowing how to load itself and any possible \
sub-shapes + * from a KoStore; that is done by this method. Shapes that accept \
drops or pastes will + * also need some method to communicate partial loads from \
their corresponding tool. + * @param rootElement the top-level XML element \
defining this shape; may or may not be the + * root element of the entire \
document + * @param store the container that the document is loaded from; useful \
when the XML element is + * just a reference to another file in the store, such \
as for images embedded in ODF + * @param createShapes the tool that lets a shape \
create sub-shapes for unhandled elements in + * its XML
+ */
+ virtual void load(const QDomElement &rootElement, KoStore *store, \
KoCreateShapesTool *createShapes) = 0; +
+ /** @brief Save the shape and its childre
+ * Each shape is responsible for knowing how to save itself and its children to \
a XML document in + * a KoStore; that is done by this method. Shapes that have \
tools with some concept of a selection + * will also want to impelment some \
shape-specific method of saving a subset of the shape so that + * the tool can \
serialize the selection to the clipboard or to a mouse drag. + * @param xmlWriter \
the XML document to save to + * @param manifestWriter the manifest file of the \
KoStore, useful if the shape needs to add a file to + * the store
+ * @param store the outer container for the XML document and all its associated \
files + */
+ virtual void save(KoXmlWriter *xmlWriter, KoXmlWriter *manifestWriter, KoStore \
*store) = 0; +
/**
* @brief Scale the shape using the zero-point which is the top-left corner.
* @see position()
@@ -400,6 +428,20 @@
bool keepAspectRatio() const { return m_keepAspect; }
/**
+ * Setting the shape to refuse drops means that drop and paste requests will be
+ * delegated to the parent shape or the top-level document.
+ * @param acceptDrops the new value
+ */
+ void setAcceptDrops(bool acceptDrops) { m_acceptDrops = acceptDrops; }
+
+ /**
+ * Setting the shape to refuse drops means that drop and paste requests will be
+ * delegated to the parent shape or the top-level document.
+ * @return whether this shape accepts drop or paste requests
+ */
+ bool acceptDrops() const { return m_acceptDrops; }
+
+ /**
* Return the position of this shape regardless of rotation/skew/scaling and \
regardless of
* this shape having a parent (being in a group) or not.<br>
* The returned value is the center of the shape.
@@ -527,7 +569,7 @@
int m_zIndex;
KoShapeContainer *m_parent;
- bool m_visible, m_locked, m_keepAspect;
+ bool m_visible, m_locked, m_keepAspect, m_acceptDrops;
QSet<KoShapeManager *> m_shapeManagers;
Index: flake/KoTool.h
===================================================================
--- flake/KoTool.h (revision 576400)
+++ flake/KoTool.h (working copy)
@@ -35,6 +35,7 @@
class QKeyEvent;
class QWidget;
class QPainter;
+class QPoint;
/**
* Abstract base class for all tools that manipulate flake objects.
@@ -145,6 +146,31 @@
*/
virtual void keyReleaseEvent(QKeyEvent *event);
+ /**
+ * Called when a Cut action has been requested. Implementors may need to add
+ * some sort of saveSelection() method to the tool's shape if the tool has a \
notion + * of a selection
+ */
+ virtual void cut() = 0;
+
+ /**
+ * Called when a Copy action has been requested. Implementors may need to add
+ * some sort of saveSelection() method to the tool's shape if the tool has a \
notion + * of a selection
+ */
+ virtual void copy() = 0;
+
+ /**
+ * Called when a Paste action has been requested. Implementors may need to add
+ * some sort of loadAtCursor() method to the tool's shape if the tool has a \
notion + * of a cursor. This method is also used to implement drops, in which \
case @p where + * is the position of the drop; otherwise @p where.isNull() is \
true. If the tool's + * associated shapes return false for their acceptDrops() \
method, this method will + * never be called.
+ * @param where the position that the drop was executed, or (0, 0) if there is \
no position + */
+ virtual void paste(const QPoint &where) = 0;
+
signals:
/**
@@ -177,6 +203,16 @@
*/
void sigCursorChanged(QCursor cursor);
+ /**
+ * This signal is used to inform the application that the tool does or does not
+ * currently have a selection, and so the application should enable or disable
+ * actions such as Cut or Copy which require there to be a selection. Note that
+ * tools are responsible themselves for managing the QClipboard::Selection
+ * clipboard, since filling that is implicit in having made a selection.
+ * @param hasSelection if true, the tool currently has a selection
+ */
+ void sigHasSelection(bool hasSelection);
+
protected:
/**
* Classes inheriting from this one can call this method to signify which cursor
["signature.asc" (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic