diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index 3c2ea6f8..fb399254 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -660,6 +660,11 @@ bool QtWindow::setText(const String& name, const String& text, } else w.textEdit()->setText(qtSetUtf8(text)); + { + QScrollBar* bar = w.textEdit()->verticalScrollBar(); + if (bar) + bar->setSliderPosition(bar->maximum()); + } return true; case QtWidget::Label: w.label()->setText(qtSetUtf8(text)); @@ -1068,7 +1073,7 @@ bool QtWindow::clearTable(const String& name) return false; } -bool QtWindow::getText(const String& name, String& text) +bool QtWindow::getText(const String& name, String& text, bool richText) { XDebug(QtDriver::self(),DebugAll,"QtWindow(%s) getText(%s) [%p]", m_id.c_str(),name.c_str(),this); @@ -1083,7 +1088,10 @@ bool QtWindow::getText(const String& name, String& text) text = qtGetUtf8(w.lineEdit()->text()); return true; case QtWidget::TextEdit: - text = qtGetUtf8(w.textEdit()->toPlainText()); + if (!richText) + text = qtGetUtf8(w.textEdit()->toPlainText()); + else + text = qtGetUtf8(w.textEdit()->toHtml()); return true; case QtWidget::Label: text = qtGetUtf8(w.label()->text()); diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index a72843bd..9587f788 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -251,7 +251,16 @@ public: virtual bool setTableRow(const String& name, const String& item, const NamedList* data); virtual bool getTableRow(const String& name, const String& item, NamedList* data = 0); virtual bool clearTable(const String& name); - virtual bool getText(const String& name, String& text); + + /** + * Get an element's text + * @param name Name of the element + * @param text The destination string + * @param richText True to get the element's roch text if supported. + * @return True if the operation was successfull + */ + virtual bool getText(const String& name, String& text, bool richText = false); + virtual bool getCheck(const String& name, bool& checked); virtual bool getSelect(const String& name, String& item); diff --git a/engine/Client.cpp b/engine/Client.cpp index 10fb26e1..e5d5e34f 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -608,7 +608,7 @@ void ClientThreadProxy::process() m_rval = client->clearTable(m_name); break; case getText: - m_rval = client->getText(m_name,*m_rtext,m_wnd,m_skip); + m_rval = client->getText(m_name,*m_rtext,m_rbool?*m_rbool:false,m_wnd,m_skip); break; case getCheck: m_rval = client->getCheck(m_name,*m_rbool,m_wnd,m_skip); @@ -1348,18 +1348,18 @@ bool Client::clearTable(const String& name, Window* wnd, Window* skip) } // function for obtaining the text from the "name" widget -bool Client::getText(const String& name, String& text, Window* wnd, Window* skip) +bool Client::getText(const String& name, String& text, bool richText, Window* wnd, Window* skip) { if (needProxy()) { - ClientThreadProxy proxy(ClientThreadProxy::getText,name,&text,0,wnd,skip); + ClientThreadProxy proxy(ClientThreadProxy::getText,name,&text,&richText,wnd,skip); return proxy.execute(); } if (wnd) - return wnd->getText(name,text); + return wnd->getText(name,text,richText); ObjList* l = &m_windows; for (; l; l = l->next()) { wnd = static_cast(l->get()); - if (wnd && (wnd != skip) && wnd->getText(name,text)) + if (wnd && (wnd != skip) && wnd->getText(name,text,richText)) return true; } return false; diff --git a/engine/ClientLogic.cpp b/engine/ClientLogic.cpp index 04e05f59..bc64fd95 100644 --- a/engine/ClientLogic.cpp +++ b/engine/ClientLogic.cpp @@ -133,7 +133,7 @@ static bool checkParam(NamedList& p, const char* param, const String& widget, if (!Client::self()) return false; String value; - Client::self()->getText(widget,value,wnd); + Client::self()->getText(widget,value,false,wnd); value.trimBlanks(); bool ok = value && !(checkNotSel && value.matches(Client::s_notSelected)); if (ok) @@ -798,7 +798,7 @@ bool ClientLogic::backspace(const String& name, Window* wnd) return false; String str; - if (Client::self()->getText(name,str,wnd) && + if (Client::self()->getText(name,str,false,wnd) && (!str || Client::self()->setText(name,str.substr(0,str.length()-1),false,wnd))) Client::self()->setFocus(name,false,wnd); return true; @@ -881,7 +881,7 @@ static inline void saveAccParam(NamedList& params, const String& prefix, const String& param, Window* wnd) { String val; - if (!Client::self()->getText(prefix+param,val,wnd)) + if (!Client::self()->getText(prefix+param,val,false,wnd)) return; if (val) params.setParam(param,val); @@ -901,10 +901,10 @@ bool ClientLogic::acceptAccount(NamedList* params, Window* wnd) const char* err = 0; while (true) { #define SET_ERR_BREAK(e) { err = e; break; } - Client::self()->getText("acc_account",account,wnd); + Client::self()->getText("acc_account",account,false,wnd); if (!account) SET_ERR_BREAK("Account name field can't be empty"); - Client::self()->getText("acc_protocol",proto,wnd); + Client::self()->getText("acc_protocol",proto,false,wnd); if (!proto) SET_ERR_BREAK("A protocol must be selected"); break; @@ -1089,10 +1089,10 @@ bool ClientLogic::acceptContact(NamedList* params, Window* wnd) // Check required data while (true) { #define SET_ERR_BREAK(e) { err = e; break; } - Client::self()->getText("abk_name",p,wnd); + Client::self()->getText("abk_name",p,false,wnd); if (p.null()) SET_ERR_BREAK("A contact name must be specified"); - Client::self()->getText("abk_target",target,wnd); + Client::self()->getText("abk_target",target,false,wnd); if (target) p.addParam("target",target); else @@ -1515,7 +1515,7 @@ bool ClientLogic::handleUiAction(Message& msg, bool& stopLogic) ok = Client::self()->delOption(name,msg.getValue("item"),wnd); else if (*action == "get_text") { String text; - ok = Client::self()->getText(name,text,wnd); + ok = Client::self()->getText(name,text,false,wnd); if (ok) msg.retValue() = text; } diff --git a/yatecbase.h b/yatecbase.h index 8422c6cd..99ecedcd 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -258,12 +258,13 @@ public: virtual bool clearTable(const String& name); /** - * Get a control's text + * Get an element's text * @param name Name of the element * @param text The destination string + * @param richText True to get the element's roch text if supported. * @return True if the operation was successfull */ - virtual bool getText(const String& name, String& text) = 0; + virtual bool getText(const String& name, String& text, bool richText = false) = 0; /** * Get the checked state of a checkable control @@ -884,7 +885,18 @@ public: bool getTableRow(const String& name, const String& item, NamedList* data = 0, Window* wnd = 0, Window* skip = 0); bool clearTable(const String& name, Window* wnd = 0, Window* skip = 0); - bool getText(const String& name, String& text, Window* wnd = 0, Window* skip = 0); + + /** + * Get an element's text + * @param name Name of the element + * @param text The destination string + * @param richText True to get the element's roch text if supported. + * @param wnd Optional window owning the element + * @param skip Optional window to skip if wnd is 0 + * @return True if the operation was successfull + */ + bool getText(const String& name, String& text, bool richText = false, Window* wnd = 0, Window* skip = 0); + bool getCheck(const String& name, bool& checked, Window* wnd = 0, Window* skip = 0); bool getSelect(const String& name, String& item, Window* wnd = 0, Window* skip = 0);