From 642ac28d101aa9114b62f5753c0d0e7f080c6d55 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sat, 14 Nov 2009 03:58:33 +0000 Subject: [PATCH] scripting friendlyness svn path=/trunk/KDE/kdelibs/; revision=1048880 --- widgets/tabbar.h | 24 ++++++++++++------------ widgets/textbrowser.cpp | 3 +-- widgets/textedit.cpp | 13 +++++++++++-- widgets/textedit.h | 13 +++++++++++++ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/widgets/tabbar.h b/widgets/tabbar.h index a9945c1b8..4c2897f37 100644 --- a/widgets/tabbar.h +++ b/widgets/tabbar.h @@ -73,8 +73,8 @@ public: * @arg content the page content that will be shown by this tab * @return the index of the inserted tab */ - int insertTab(int index, const QIcon &icon, const QString &label, - QGraphicsLayoutItem *content = 0); + Q_INVOKABLE int insertTab(int index, const QIcon &icon, const QString &label, + QGraphicsLayoutItem *content = 0); /** * Adds a new tab in the desired position @@ -88,7 +88,7 @@ public: * @arg content the page content that will be shown by this tab * @return the index of the inserted tab */ - int insertTab(int index, const QString &label, QGraphicsLayoutItem *content = 0); + Q_INVOKABLE int insertTab(int index, const QString &label, QGraphicsLayoutItem *content = 0); /** * Adds a new tab in the last position @@ -98,7 +98,7 @@ public: * @arg content the page content that will be shown by this tab * @return the index of the inserted tab */ - int addTab(const QIcon &icon, const QString &label, QGraphicsLayoutItem *content = 0); + Q_INVOKABLE int addTab(const QIcon &icon, const QString &label, QGraphicsLayoutItem *content = 0); /** * Adds a new tab in the last position @@ -109,14 +109,14 @@ public: * @arg content the page content that will be shown by this tab * @return the index of the inserted tab */ - int addTab(const QString &label, QGraphicsLayoutItem *content = 0); + Q_INVOKABLE int addTab(const QString &label, QGraphicsLayoutItem *content = 0); /** * Removes a tab, contents are deleted * * @arg index the index of the tab to remove */ - void removeTab(int index); + Q_INVOKABLE void removeTab(int index); /** * Removes a tab, the page is reparented to 0 and is returned @@ -124,7 +124,7 @@ public: * @arg index the index of the tab to remove * @since 4.4 */ - QGraphicsLayoutItem *takeTab(int index); + Q_INVOKABLE QGraphicsLayoutItem *takeTab(int index); /** * Returns the contents of a page @@ -132,7 +132,7 @@ public: * @arg index the index of the tab to retrieve * @since 4.4 */ - QGraphicsLayoutItem *tabAt(int index); + Q_INVOKABLE QGraphicsLayoutItem *tabAt(int index); /** * @return the index of the tab currently active @@ -150,14 +150,14 @@ public: * @arg index the index of the tab to modify * @arg label the new text label of the given tab */ - void setTabText(int index, const QString &label); + Q_INVOKABLE void setTabText(int index, const QString &label); /** * @return the text label of the given tab * * @arg index the index of the tab we want to know its label */ - QString tabText(int index) const; + Q_INVOKABLE QString tabText(int index) const; /** * Sets an icon for a given tab @@ -165,14 +165,14 @@ public: * @arg index the index of the tab to modify * @arg icon the new icon for the given tab */ - void setTabIcon(int index, const QIcon &icon); + Q_INVOKABLE void setTabIcon(int index, const QIcon &icon); /** * @return the current icon for a given tab * * @arg index the index of the tab we want to know its icon */ - QIcon tabIcon(int index) const; + Q_INVOKABLE QIcon tabIcon(int index) const; /** * shows or hides the tabbar, used if you just want to display the diff --git a/widgets/textbrowser.cpp b/widgets/textbrowser.cpp index 2942cf298..c67300628 100644 --- a/widgets/textbrowser.cpp +++ b/widgets/textbrowser.cpp @@ -124,8 +124,7 @@ TextBrowser::~TextBrowser() void TextBrowser::setText(const QString &text) { - //FIXME I'm not certain about using only the html methods. look at this again later. - static_cast(widget())->setHtml(text); + static_cast(widget())->setText(text); } QString TextBrowser::text() const diff --git a/widgets/textedit.cpp b/widgets/textedit.cpp index da8eb5dab..3828fe339 100644 --- a/widgets/textedit.cpp +++ b/widgets/textedit.cpp @@ -88,8 +88,7 @@ TextEdit::~TextEdit() void TextEdit::setText(const QString &text) { - //FIXME I'm not certain about using only the html methods. look at this again later. - static_cast(widget())->setHtml(text); + static_cast(widget())->setText(text); } QString TextEdit::text() const @@ -97,6 +96,16 @@ QString TextEdit::text() const return static_cast(widget())->toHtml(); } +void TextEdit::setReadOnly(bool readOnly) +{ + static_cast(widget())->setReadOnly(readOnly); +} + +bool TextEdit::isReadOnly() const +{ + return static_cast(widget())->isReadOnly(); +} + void TextEdit::setStyleSheet(const QString &stylesheet) { widget()->setStyleSheet(stylesheet); diff --git a/widgets/textedit.h b/widgets/textedit.h index dbffbe727..47e9a4a5b 100644 --- a/widgets/textedit.h +++ b/widgets/textedit.h @@ -45,6 +45,7 @@ class PLASMA_EXPORT TextEdit : public QGraphicsProxyWidget Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QString stylesheet READ styleSheet WRITE setStyleSheet) Q_PROPERTY(KTextEdit *nativeWidget READ nativeWidget WRITE setNativeWidget) + Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) public: explicit TextEdit(QGraphicsWidget *parent = 0); @@ -62,6 +63,18 @@ public: */ QString text() const; + /** + * Sets the text area to be read only or interactive + * @arg true to make it read only, false for interactive + * @since 4.4 + */ + void setReadOnly(bool readOnly); + + /** + * @return true if the text area is non-interacive + */ + bool isReadOnly() const; + /** * Sets the stylesheet used to control the visual display of this TextEdit *