[calligra] /: Move insert pagebreak handling from Words to texttool

C. Boemann cbo at boemann.dk
Tue Mar 27 19:04:06 BST 2012


Okay to backport to 2.4 ?

On Tuesday 27 March 2012 20:00:37 C. Boemann wrote:
> Git commit 4e778319817bec12a4b53877f5a2b42ed0448131 by C. Boemann.
> Committed on 27/03/2012 at 19:36.
> Pushed by boemann into branch 'master'.
> 
> Move insert pagebreak handling from Words to texttool
> And also fix that view doesn't move when inserting text or pagebreak
> that casuses the new position to be visible.
> BUG: 296891
> 
> M  +22   -1    plugins/textshape/TextTool.cpp
> M  +2    -0    plugins/textshape/TextTool.h
> M  +3    -22   words/part/KWView.cpp
> M  +0    -2    words/part/KWView.h
> 
> http://commits.kde.org/calligra/4e778319817bec12a4b53877f5a2b42ed0448131
> 
> diff --git a/plugins/textshape/TextTool.cpp
> b/plugins/textshape/TextTool.cpp index b4cf15a..fa10b08 100644
> --- a/plugins/textshape/TextTool.cpp
> +++ b/plugins/textshape/TextTool.cpp
> @@ -334,6 +334,15 @@ void TextTool::createActions()
>      action->setShortcut(Qt::SHIFT + Qt::Key_Return);
>      connect(action, SIGNAL(triggered()), this, SLOT(lineBreak()));
> 
> +    action  = new KAction(QString(), this);
> +    addAction("insert_framebreak", action);
> +    action->setShortcut(KShortcut(Qt::CTRL + Qt::Key_Return));
> +    connect(action, SIGNAL(triggered()), this, SLOT(insertFrameBreak()));
> +    //action->setText(i18n("Page Break"));
> +    //action->setToolTip(i18n("Force the remainder of the text into the
> next page")); +    //action->setWhatsThis(i18n("All text after this point
> will be moved into the next page.")); +
> +
>      action  = new KAction(i18n("Font..."), this);
>      addAction("format_font", action);
>      action->setShortcut(Qt::ALT + Qt::CTRL + Qt::Key_F);
> @@ -1419,7 +1428,11 @@ void TextTool::keyPressEvent(QKeyEvent *event)
>          m_caretTimer.start();
>          m_caretTimerState = true; // turn caret on while typing
>      }
> -    ensureCursorVisible();
> +    if (moveOperation != QTextCursor::NoMove)
> +        // this difference in handling is need to prevent leaving a trail
> of old cursors onscreen +        ensureCursorVisible();
> +    else
> +        m_delayedEnsureVisible = true;
> 
>      updateSelectionHandler();
>  }
> @@ -1992,6 +2005,14 @@ void TextTool::insertIndexMarker()
>      m_textEditor.data()->insertIndexMarker();
>  }
> 
> +void TextTool::insertFrameBreak()
> +{
> +    m_textEditor.data()->insertFrameBreak();
> +
> +    ensureCursorVisible();
> +    m_delayedEnsureVisible = true;
> +}
> +
>  void TextTool::setStyle(KoCharacterStyle *style)
>  {
>      KoCharacterStyle *charStyle = style;
> diff --git a/plugins/textshape/TextTool.h b/plugins/textshape/TextTool.h
> index e195a20..5107620 100644
> --- a/plugins/textshape/TextTool.h
> +++ b/plugins/textshape/TextTool.h
> @@ -179,6 +179,8 @@ private slots:
>      void softHyphen();
>      /// insert a linebreak at the caret position
>      void lineBreak();
> +    /// force the remainder of the text into the next page
> +    void insertFrameBreak();
>      /// align all of the selected text left
>      void alignLeft();
>      /// align all of the selected text right
> diff --git a/words/part/KWView.cpp b/words/part/KWView.cpp
> index 010123d..0ac5285 100644
> --- a/words/part/KWView.cpp
> +++ b/words/part/KWView.cpp
> @@ -193,12 +193,13 @@ QWidget *KWView::canvas() const
>  void KWView::updateReadWrite(bool readWrite)
>  {
>      m_actionFormatFrameSet->setEnabled(readWrite);
> -    m_actionInsertFrameBreak->setEnabled(readWrite);
>      m_actionViewHeader->setEnabled(readWrite);
>      m_actionViewFooter->setEnabled(readWrite);
>      m_actionViewSnapToGrid->setEnabled(readWrite);
>      m_actionAddBookmark->setEnabled(readWrite);
> -    QAction *action = actionCollection()->action("insert_variable");
> +    QAction *action = actionCollection()->action("insert_framebreak");
> +    if (action) action->setEnabled(readWrite);
> +    action = actionCollection()->action("insert_variable");
>      if (action) action->setEnabled(readWrite);
>      action = actionCollection()->action("select_bookmark"); // TODO fix
> the dialog to honor read-only instead if (action)
> action->setEnabled(readWrite);
> @@ -232,14 +233,6 @@ void KWView::setupActions()
>      m_actionFormatFrameSet->setEnabled(false);
>      connect(m_actionFormatFrameSet, SIGNAL(triggered()), this,
> SLOT(editFrameProperties()));
> 
> -    m_actionInsertFrameBreak  = new KAction(QString(), this);
> -    actionCollection()->addAction("insert_framebreak",
> m_actionInsertFrameBreak); -   
> m_actionInsertFrameBreak->setShortcut(KShortcut(Qt::CTRL +
> Qt::Key_Return)); -    connect(m_actionInsertFrameBreak,
> SIGNAL(triggered()), this, SLOT(insertFrameBreak())); -   
> m_actionInsertFrameBreak->setText(i18n("Page Break"));
> -    m_actionInsertFrameBreak->setToolTip(i18n("Force the remainder of the
> text into the next page")); -   
> m_actionInsertFrameBreak->setWhatsThis(i18n("All text after this point
> will be moved into the next page.")); -
>      m_actionViewHeader = new KAction(i18n("Create Header"), this);
>      actionCollection()->addAction("insert_header", m_actionViewHeader);
>      if (m_currentPage.isValid())
> @@ -539,18 +532,6 @@ void KWView::createTemplate()
>      d.remove(fileName);
>  }
> 
> -void KWView::insertFrameBreak()
> -{
> -    KoTextEditor *editor =
> KoTextEditor::getTextEditorFromCanvas(canvasBase()); -    if (editor) {
> -        // this means we have the text tool selected right now.
> -        editor->insertFrameBreak();
> -    } else if (m_document->mainFrameSet()) { // lets just add one to the
> main text frameset -        KoTextDocument
> doc(m_document->mainFrameSet()->document()); -       
> doc.textEditor()->insertFrameBreak();
> -    }
> -}
> -
>  void KWView::addBookmark()
>  {
>      QString name, suggestedName;
> diff --git a/words/part/KWView.h b/words/part/KWView.h
> index cea2cd1..339937b 100644
> --- a/words/part/KWView.h
> +++ b/words/part/KWView.h
> @@ -144,8 +144,6 @@ private slots:
>      void editFrameProperties();
>      /// called if another shape got selected
>      void selectionChanged();
> -    /// force the remainder of the text into the next page
> -    void insertFrameBreak();
>      /// insert a bookmark on current text cursor location or selection
>      void addBookmark();
>      /// go to previously bookmarked text cursor location or selection



More information about the calligra-devel mailing list