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

List:       kde-commits
Subject:    playground/libs/krichtext
From:       Thomas McGuire <Thomas.McGuire () gmx ! net>
Date:       2008-05-04 14:35:51
Message-ID: 1209911751.419803.28948.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 803936 by tmcguire:

Some cleanups.
Important ones are:
- add some consts
- prevent infinte recursion in krichtextwidget, by using
  KRichTextEdit::foo() instead of this->foo(), inside a function
  also named foo.



 M  +2 -2      krichtextedit.cpp  
 M  +2 -2      krichtextedit.h  
 M  +19 -26    krichtextwidget.cpp  
 M  +20 -17    krichtextwidget.h  
 M  +2 -2      nestedlisthelper.cpp  
 M  +3 -10     nestedlisthelper.h  


--- trunk/playground/libs/krichtext/krichtextedit.cpp #803935:803936
@@ -460,12 +460,12 @@
 // }
 
 
-bool KRichTextEdit::canIndentList()
+bool KRichTextEdit::canIndentList() const
 {
     return d->nestedListHelper->canIndent();
 }
 
-bool KRichTextEdit::canDedentList()
+bool KRichTextEdit::canDedentList() const
 {
     return d->nestedListHelper->canDedent();
 }
--- trunk/playground/libs/krichtext/krichtextedit.h #803935:803936
@@ -141,14 +141,14 @@
      *
      * @sa canDedentList
      */
-    bool canIndentList();
+    bool canIndentList() const;
 
     /**
      * Returns true if the list item at the current position can be dedented.
      *
      * @sa canIndentList
      */
-    bool canDedentList();
+    bool canDedentList() const;
 
   public Q_SLOTS:
 
--- trunk/playground/libs/krichtext/krichtextwidget.cpp #803935:803936
@@ -104,7 +104,7 @@
             this, SLOT(updateMiscActions()));
 
     updateMiscActions();
-    updateCharFormatActions( this->currentCharFormat() );
+    updateCharFormatActions( currentCharFormat() );
 
 }
 
@@ -113,11 +113,6 @@
     delete d;
 }
 
-KRichTextEdit *KRichTextWidget::richTextEdit()
-{
-    return static_cast<KRichTextEdit*>(this);
-}
-
 KRichTextWidget::RichTextSupport KRichTextWidget::richTextSupport() const
 {
     return d->richTextSupport;
@@ -334,13 +329,12 @@
 
 void KRichTextWidget::slotChangeListStyle(int index)
 {
-    this->slotChangeListStyle(index);
+    KRichTextEdit::slotChangeListStyle(index);
     updateMiscActions();
 }
 
 void KRichTextWidget::updateCharFormatActions(const QTextCharFormat &format)
 {
-
     QFont f = format.font();
 
     if ( d->richTextSupport & SupportFontFamily )
@@ -372,14 +366,13 @@
     {
         d->action_text_strikeout->setChecked(f.strikeOut());
     }
-
 }
 
 void KRichTextWidget::updateMiscActions()
 {
     if ( d->richTextSupport & SupportAlignment )
     {
-        Qt::Alignment a = this->alignment();
+        Qt::Alignment a = alignment();
         if (a & Qt::AlignLeft) {
             d->action_align_left->setChecked(true);
         } else if (a & Qt::AlignHCenter) {
@@ -394,8 +387,8 @@
 
     if ( d->richTextSupport & SupportChangeListStyle )
     {
-        if ( this->textCursor().currentList() ){
-            d->action_list_style->setCurrentItem( \
-this->textCursor().currentList()->format().style() ); +        if ( \
textCursor().currentList() ){ +            d->action_list_style->setCurrentItem( \
-textCursor().currentList()->format().style() );  } else {
             d->action_list_style->setCurrentItem( 0 );
         }
@@ -404,19 +397,19 @@
 
     if ( d->richTextSupport & SupportIndentLists  )
     {
-        d->action_list_indent->setEnabled( this->canIndentList() );
+        d->action_list_indent->setEnabled( canIndentList() );
     }
 
     if ( d->richTextSupport & SupportDedentLists  )
     {
-        d->action_list_dedent->setEnabled( this->canDedentList() );
+        d->action_list_dedent->setEnabled( canDedentList() );
     }
 
 }
 
 void KRichTextWidget::setTextForegroundColor()
 {
-    QColor currentTextForegroundColor = this->textColor();
+    QColor currentTextForegroundColor = textColor();
 
     int result = KColorDialog::getColor( currentTextForegroundColor, \
KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() , this );  \
if(!currentTextForegroundColor.isValid()) @@ -424,13 +417,13 @@
     if ( result != QDialog::Accepted  )
         return;
 
-    this->slotTextForegroundColor( currentTextForegroundColor );
+    KRichTextEdit::slotTextForegroundColor( currentTextForegroundColor );
 
 }
 
 void KRichTextWidget::setTextBackgroundColor()
 {
-    QColor currentTextBackgroundColor = this->textColor();
+    QColor currentTextBackgroundColor = textColor();
 
     int result = KColorDialog::getColor( currentTextBackgroundColor, \
KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() , this );  \
if(!currentTextBackgroundColor.isValid()) @@ -438,19 +431,19 @@
     if ( result != QDialog::Accepted  )
         return;
 
-    this->slotTextBackgroundColor( currentTextBackgroundColor );
+    KRichTextEdit::slotTextBackgroundColor( currentTextBackgroundColor );
 
 }
 
 void KRichTextWidget::manageLink()
 {
-    this->selectLinkText();
+    selectLinkText();
     KLinkDialog *linkDialog = new KLinkDialog(this);
-    linkDialog->setLinkText(this->currentLinkText());
-    linkDialog->setLinkUrl(this->currentLinkUrl());
+    linkDialog->setLinkText(currentLinkText());
+    linkDialog->setLinkUrl(currentLinkUrl());
 
     if (linkDialog->exec()) {
-        this->updateLink(linkDialog->linkUrl(), linkDialog->linkText());
+        updateLink(linkDialog->linkUrl(), linkDialog->linkText());
     }
 
     delete linkDialog;
@@ -463,7 +456,7 @@
     {
         return;
     }
-    this->setCurrentCharFormat(d->painterFormat);
+    setCurrentCharFormat(d->painterFormat);
     d->painterActive = false;
     d->action_format_painter->setChecked( false );
 }
@@ -472,15 +465,15 @@
 {
     if (active)
     {
-        d->painterFormat = this->currentCharFormat();
+        d->painterFormat = currentCharFormat();
         d->painterActive = true;
-        this->viewport()->setCursor(QCursor(KIcon("draw-brush").pixmap(32, 32), 0, \
32)); +        viewport()->setCursor(QCursor(KIcon("draw-brush").pixmap(32, 32), 0, \
32));  }
     else
     {
         d->painterFormat = QTextCharFormat();
         d->painterActive = false;
-        this->viewport()->unsetCursor();
+        viewport()->unsetCursor();
     }
 }
 
--- trunk/playground/libs/krichtext/krichtextwidget.h #803935:803936
@@ -19,14 +19,15 @@
 #ifndef KRICHTEXTWIDGET_H
 #define KRICHTEXTWIDGET_H
 
+#include "krichtextedit.h"
+
 #include <kdemacros.h>
 #include <KXMLGUIClient>
-#include "krichtextedit.h"
 
+
 #include <QObject>
-#include <QtGui/QFont>
-#include <QtGui/QColor>
-#include <QtCore/QFlags>
+//#include <QtGui/QColor>
+//#include <QtCore/QFlags>
 
 
 class QTextCharFormat;
@@ -93,15 +94,15 @@
     };
     Q_DECLARE_FLAGS(RichTextSupport, RichTextSupportValues)
 
- /**
-  * @brief Constructor
-  */
- KRichTextWidget( QWidget * );
+    /**
+     * @brief Constructor
+     */
+    KRichTextWidget( QWidget * );
 
- /**
-  * @brief Destructor
-  */
- ~KRichTextWidget();
+    /**
+     * @brief Destructor
+     */
+    ~KRichTextWidget();
 
     /**
      * @brief Create the KAboutData for the part
@@ -122,19 +123,21 @@
     RichTextSupport richTextSupport() const;
 
     /**
-     * @brief Get the internal KRichTextEdit
-     * @return instance of KRichTextEdit
+     * Replaces all the content of the text edit with the given string.
+     * If the string is in rich text format, the text is inserted as rich text,
+     * otherwise it is inserted as plain text.
+     *
+     * @param text the text to insert
      */
-    KRichTextEdit *richTextEdit();
+    void setTextOrHtml(const QString &text);
 
-    void setTextOrHtml(const QString &);
-
 public slots:
 
     /**
      * @brief Opens a dialog to allow the user to select a foreground color.
      */
     void setTextForegroundColor();
+
     /**
      * @brief Opens a dialog to allow the user to select a background color.
      */
--- trunk/playground/libs/krichtext/nestedlisthelper.cpp #803935:803936
@@ -79,7 +79,7 @@
     return handled;
 }
 
-bool NestedListHelper::canIndent()
+bool NestedListHelper::canIndent() const
 {
     if ( ( textEdit->textCursor().block().isValid() )
 //            && (  textEdit->textCursor().block().previous().isValid() )
@@ -102,7 +102,7 @@
     return false;
 }
 
-bool NestedListHelper::canDedent()
+bool NestedListHelper::canDedent() const
 {
     QTextBlock thisBlock = textEdit->textCursor().block();
     QTextBlock nextBlock = thisBlock.next();
--- trunk/playground/libs/krichtext/nestedlisthelper.h #803935:803936
@@ -79,24 +79,18 @@
      */
     bool handleAfterKeyPressEvent(QKeyEvent *event);
 
-    
     bool handleAfterDropEvent(QDropEvent *event);
 
-    
     /**
      * Increases the indent (nesting level) on the current list item or selection.
      */
     void handleOnIndentMore();
-    
 
-    
     /**
      * Decreases the indent (nesting level) on the current list item or selection.
      */
     void handleOnIndentLess();
 
-    
-    
     /**
      * Changes the style of the current list or creates a new list with 
      * the specified style.
@@ -117,9 +111,8 @@
      *
      * @return Whether the item can be indented.
      */
-    bool canIndent();
+    bool canIndent() const;
 
-    
     /**
      * \brief Check whether the current item in the list may be dedented.
      *
@@ -129,8 +122,8 @@
      *
      * @return Whether the item can be dedented.
      */
-    bool canDedent();
-    
+    bool canDedent() const;
+
 private:
     void reformatBoundingItemSpacing( QTextBlock block );
     void reformatBoundingItemSpacing();


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

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