Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 2437

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<class name="QUndoCommand" doc="/**
&lt;p&gt;The &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; class is the base class of all commands stored on a &lt;a href=&quot;QUndoStack.html&quot;&gt;&lt;tt&gt;QUndoStack&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For an overview of Qt's Undo Framework, see the &lt;a href=&quot;%2E%2E/qundo.html&quot;&gt;overview document&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; represents a single editing action on a document; for example, inserting or deleting a block of text in a text editor. &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; can apply a change to the document with &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; and undo the change with &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt;. The implementations for these functions must be provided in a derived class.&lt;/p&gt;
&lt;pre&gt;    class AppendText : public QUndoCommand
    {
    public:
        AppendText(QString *doc, const QString &amp;amp;text)
            : m_document(doc), m_text(text) { setText(&amp;quot;append text&amp;quot;); }
        virtual void undo()
            { m_document-&amp;gt;chop(m_text.length()); }
        virtual void redo()
            { m_document-&amp;gt;append(m_text); }
    private:
        QString *m_document;
        QString m_text;
    };&lt;/pre&gt;
&lt;p&gt;A &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; has an associated &lt;a href=&quot;QUndoCommand.html#text()&quot;&gt;&lt;tt&gt;text&lt;/tt&gt;&lt;/a&gt;. This is a short string describing what the command does. It is used to update the text properties of the stack's undo and redo actions; see QUndoStack::createUndoAction() and QUndoStack::createRedoAction().&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; objects are owned by the stack they were pushed on. &lt;a href=&quot;QUndoStack.html&quot;&gt;&lt;tt&gt;QUndoStack&lt;/tt&gt;&lt;/a&gt; deletes a command if it has been undone and a new command is pushed. For example:&lt;/p&gt;
&lt;pre&gt;    MyCommand *command1 = new MyCommand();
    stack-&amp;gt;push(command1);
    MyCommand *command2 = new MyCommand();
    stack-&amp;gt;push(command2);

    stack-&amp;gt;undo();

    MyCommand *command3 = new MyCommand();
    stack-&amp;gt;push(command3); &lt;span class=&quot;comment&quot;&gt;// command2 gets deleted&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;In effect, when a command is pushed, it becomes the top-most command on the stack.&lt;/p&gt;
&lt;p&gt;To support command compression, &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; has an &lt;a href=&quot;QUndoCommand.html#id()&quot;&gt;&lt;tt&gt;id&lt;/tt&gt;&lt;/a&gt; and the virtual function &lt;a href=&quot;QUndoCommand.html#mergeWith(com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;mergeWith&lt;/tt&gt;&lt;/a&gt;. These functions are used by QUndoStack::push().&lt;/p&gt;
&lt;p&gt;To support command macros, a &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; object can have any number of child commands. Undoing or redoing the parent command will cause the child commands to be undone or redone. A command can be assigned to a parent explicitly in the constructor. In this case, the command will be owned by the parent.&lt;/p&gt;
&lt;p&gt;The parent in this case is usually an empty command, in that it doesn't provide its own implementation of &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; and &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt;. Instead, it uses the base implementations of these functions, which simply call &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; or &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; on all its children. The parent should, however, have a meaningful &lt;a href=&quot;QUndoCommand.html#text()&quot;&gt;&lt;tt&gt;text&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;    QUndoCommand *insertRed = new QUndoCommand(); &lt;span class=&quot;comment&quot;&gt;// an empty command&lt;/span&gt;
    insertRed-&amp;gt;setText(&amp;quot;insert red text&amp;quot;);

    new InsertText(document, idx, text, insertRed); &lt;span class=&quot;comment&quot;&gt;// becomes child of insertRed&lt;/span&gt;
    new SetColor(document, idx, text.length(), Qt::red, insertRed);

    stack.push(insertRed);&lt;/pre&gt;
&lt;p&gt;Another way to create macros is to use the convenience functions QUndoStack::beginMacro() and QUndoStack::endMacro().&lt;/p&gt;

@see &lt;a href=&quot;QUndoStack.html&quot;&gt;&lt;tt&gt;QUndoStack&lt;/tt&gt;&lt;/a&gt; */">
    <method name="public QUndoCommand(com.trolltech.qt.gui.QUndoCommand parent)" doc="/**
&lt;p&gt;Constructs a &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; object with parent &lt;tt&gt;parent&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;If &lt;tt&gt;parent&lt;/tt&gt; is not 0, this command is appended to parent's child list. The parent command then owns this command and will delete it in its destructor.&lt;/p&gt;

@see &lt;tt&gt;~QUndoCommand&lt;/tt&gt; */"/>
    <method name="public QUndoCommand()" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt;(0). */"/>
    <method name="public QUndoCommand(java.lang.String text, com.trolltech.qt.gui.QUndoCommand parent)" doc="/**
&lt;p&gt;Constructs a &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt; object with the given &lt;tt&gt;parent&lt;/tt&gt; and &lt;tt&gt;text&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;If &lt;tt&gt;parent&lt;/tt&gt; is not 0, this command is appended to parent's child list. The parent command then owns this command and will delete it in its destructor.&lt;/p&gt;

@see &lt;tt&gt;~QUndoCommand&lt;/tt&gt; */"/>
    <method name="public QUndoCommand(java.lang.String text)" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QUndoCommand.html#QUndoCommand(java.lang.String, com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;QUndoCommand&lt;/tt&gt;&lt;/a&gt;(&lt;tt&gt;text&lt;/tt&gt;, 0). */"/>
    <method name="public final void setText(java.lang.String text)" doc="/**
&lt;p&gt;Sets the command's text to be the &lt;tt&gt;text&lt;/tt&gt; specified.&lt;/p&gt;
&lt;p&gt;The specified text should be a short user-readable string describing what this command does.&lt;/p&gt;

@see &lt;a href=&quot;QUndoCommand.html#text()&quot;&gt;&lt;tt&gt;text&lt;/tt&gt;&lt;/a&gt;
@see &lt;tt&gt;QUndoStack::createUndoAction&lt;/tt&gt;
@see &lt;tt&gt;QUndoStack::createRedoAction&lt;/tt&gt; */"/>
    <method name="public final java.lang.String text()" doc="/**
&lt;p&gt;Returns a short text string describing what this command does; for example, &amp;quot;insert text&amp;quot;.&lt;/p&gt;
&lt;p&gt;The text is used when the text properties of the stack's undo and redo actions are updated.&lt;/p&gt;

@see &lt;a href=&quot;QUndoCommand.html#setText(java.lang.String)&quot;&gt;&lt;tt&gt;setText&lt;/tt&gt;&lt;/a&gt;
@see &lt;tt&gt;QUndoStack::createUndoAction&lt;/tt&gt;
@see &lt;tt&gt;QUndoStack::createRedoAction&lt;/tt&gt; */"/>
    <method name="public int id()" doc="/**
&lt;p&gt;Returns the ID of this command.&lt;/p&gt;
&lt;p&gt;A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.&lt;/p&gt;
&lt;p&gt;If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.&lt;/p&gt;
&lt;p&gt;QUndoStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.&lt;/p&gt;

@see &lt;a href=&quot;QUndoCommand.html#mergeWith(com.trolltech.qt.gui.QUndoCommand)&quot;&gt;&lt;tt&gt;mergeWith&lt;/tt&gt;&lt;/a&gt;
@see &lt;tt&gt;QUndoStack::push&lt;/tt&gt; */"/>
    <method name="public boolean mergeWith(com.trolltech.qt.gui.QUndoCommand other)" doc="/**
&lt;p&gt;Attempts to merge this command with &lt;tt&gt;other&lt;/tt&gt;. Returns true on success; otherwise returns false.&lt;/p&gt;
&lt;p&gt;If this function returns true, calling this command's &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; must have the same effect as redoing both this command and &lt;tt&gt;other&lt;/tt&gt;. Similarly, calling this command's &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; must have the same effect as undoing &lt;tt&gt;other&lt;/tt&gt; and this command.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;QUndoStack.html&quot;&gt;&lt;tt&gt;QUndoStack&lt;/tt&gt;&lt;/a&gt; will only try to merge two commands if they have the same id, and the id is not -1.&lt;/p&gt;
&lt;p&gt;The default implementation returns false.&lt;/p&gt;
&lt;pre&gt;    bool AppendText::mergeWith(const QUndoCommand *other)
    {
        if (other-&amp;gt;id() != id()) &lt;span class=&quot;comment&quot;&gt;// make sure other is also an AppendText command&lt;/span&gt;
            return false;
        m_text += static_cast&amp;lt;const AppendText*&amp;gt;(other)-&amp;gt;m_text;
        return true;
    }&lt;/pre&gt;

@see &lt;a href=&quot;QUndoCommand.html#id()&quot;&gt;&lt;tt&gt;id&lt;/tt&gt;&lt;/a&gt;
@see &lt;tt&gt;QUndoStack::push&lt;/tt&gt; */"/>
    <method name="public void redo()" doc="/**
&lt;p&gt;Applies a change to the document. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.&lt;/p&gt;
&lt;p&gt;The default implementation calls &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; on all child commands.&lt;/p&gt;

@see &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public void undo()" doc="/**
&lt;p&gt;Reverts a change to the document. After &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; is called, the state of the document should be the same as before &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; was called. This function must be implemented in the derived class. Calling QUndoStack::push(), QUndoStack::undo() or QUndoStack::redo() from this function leads to undefined beahavior.&lt;/p&gt;
&lt;p&gt;The default implementation calls &lt;a href=&quot;QUndoCommand.html#undo()&quot;&gt;&lt;tt&gt;undo&lt;/tt&gt;&lt;/a&gt; on all child commands in reverse order.&lt;/p&gt;

@see &lt;a href=&quot;QUndoCommand.html#redo()&quot;&gt;&lt;tt&gt;redo&lt;/tt&gt;&lt;/a&gt; */"/>
</class>