void MainWindow::onTextChanged() { // force the length to always be 1 QTextEdit *textEdit = reinterpret_cast<QTextEdit*>(sender()); if (textEdit->toPlainText().length() > 1) textEdit->setPlainText(textEdit->toPlainText().at(0)); }
bool MainWindow::tryEnableInjectionButtons() { QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit"); QString pathToSave = savePathTextField->toPlainText(); QFile saveFile(pathToSave); if(!saveFile.exists() || !pathToSave.endsWith(".sfs")) { setInjectionEnabled(false); return false; } QTextEdit* injectPathTextField = this->findChild<QTextEdit*>("fileToInjectTextEdit"); QString pathToInjectFrom = injectPathTextField->toPlainText(); QFile injectFile(pathToInjectFrom); if(!injectFile.exists() || !pathToInjectFrom.endsWith(".sfs")) { setInjectionEnabled(false); return false; } setInjectionEnabled(true); return true; }
void WrapTextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { qWarning( "WrapTextDelegate::setModelData called" ); QTextEdit * textEdit = static_cast<QTextEdit*>(editor); if ( index.column() == BachAssetItem::Column_Info ) { BachAsset ba = ((RecordSuperModel*)model)->getRecord(index); ba.setTags( textEdit->toPlainText() ); ba.commit(); model->setData(index, QVariant(textEdit->toPlainText()), Qt::EditRole ); } }
/** * Gets the conversation corresponding to the * currently selected tab, and sends whatever's in its * message text-box to all participants of the conversation. * @brief MainWindow::sendConvoMessage */ void MainWindow::sendConvoMessage() { Conversation *cdata = convos->at(ui->tabgrpConversations->currentIndex()-1); QTextEdit* txtMsg = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_MSG_ID); QTextEdit* txtConv = ui->tabgrpConversations->currentWidget()->findChild<QTextEdit*>(CONVO_TAB_TXT_ID); if(txtMsg->toPlainText().length() > 0) { controller->sendConvoMessage(cdata, txtMsg->toPlainText()); addTextToConvo(txtConv, controller->myName() + "|" + txtMsg->toPlainText()); txtMsg->clear(); } }
void BasicSurface::updateShader() { QTextEdit* text = window()->findChild<QTextEdit*>("fragText"); QString frag = text->toPlainText(); text = window()->findChild<QTextEdit*>("vertText"); QString vert = text->toPlainText(); program.removeAllShaders(); program.addShaderFromSourceCode(QOpenGLShader::Vertex, vert); program.addShaderFromSourceCode(QOpenGLShader::Fragment, frag); program.link(); program.bind(); update(); }
void DesignerFields::save( DesignerFields::Storage *storage ) { QMap<QString, QWidget*>::Iterator it; for ( it = mWidgets.begin(); it != mWidgets.end(); ++it ) { QString value; if ( it.value()->inherits( "QLineEdit" ) ) { QLineEdit *wdg = static_cast<QLineEdit*>( it.value() ); value = wdg->text(); } else if ( it.value()->inherits( "QSpinBox" ) ) { QSpinBox *wdg = static_cast<QSpinBox*>( it.value() ); value = QString::number( wdg->value() ); } else if ( it.value()->inherits( "QCheckBox" ) ) { QCheckBox *wdg = static_cast<QCheckBox*>( it.value() ); value = ( wdg->isChecked() ? "true" : "false" ); } else if ( it.value()->inherits( "QDateTimeEdit" ) ) { Q3DateTimeEdit *wdg = static_cast<Q3DateTimeEdit*>( it.value() ); value = wdg->dateTime().toString( Qt::ISODate ); } else if ( it.value()->inherits( "KDateTimeWidget" ) ) { KDateTimeWidget *wdg = static_cast<KDateTimeWidget*>( it.value() ); value = wdg->dateTime().toString( Qt::ISODate ); } else if ( it.value()->inherits( "KDatePicker" ) ) { KDatePicker *wdg = static_cast<KDatePicker*>( it.value() ); value = wdg->date().toString( Qt::ISODate ); } else if ( it.value()->inherits( "QComboBox" ) ) { QComboBox *wdg = static_cast<QComboBox*>( it.value() ); value = wdg->currentText(); } else if ( it.value()->inherits( "QTextEdit" ) ) { QTextEdit *wdg = static_cast<QTextEdit*>( it.value() ); value = wdg->toPlainText(); } storage->write( it.key(), value ); } }
void PageItem::slotSetFormData() { QTextEdit *textEdit = qobject_cast<QTextEdit*>(sender()); if (textEdit) // textEdit == 0 if the above cast fails { slotSetFormData(textEdit->toPlainText()); return; } QListWidget *listWidget = qobject_cast<QListWidget*>(sender()); if (listWidget) { QList<int> choices; for (int i = 0; i < listWidget->count(); ++i) { if (listWidget->item(i)->isSelected()) choices << i; } QString objectName = sender()->objectName(); if (!objectName.startsWith(QLatin1String("PageItem::formField"))) return; int which = objectName.remove(QLatin1String("PageItem::formField")).toInt(); Poppler::FormFieldChoice *formField = static_cast<Poppler::FormFieldChoice*>(m_formFields.at(which).field); formField->setCurrentChoices(choices); return; } }
const char *getCharProperty(GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue) { QTextEdit *qw; QString str; qw=(QTextEdit*) GWEN_Widget_GetImplData(_widget, QT4_DIALOG_WIDGET_REAL); assert(qw); switch(prop) { case GWEN_DialogProperty_Value: str=qw->toPlainText(); if (str.isEmpty()) return defaultValue; else { GWEN_Widget_SetText(_widget, QT4_DIALOG_STRING_TITLE, str.toUtf8()); return GWEN_Widget_GetText(_widget, QT4_DIALOG_STRING_TITLE); } break; default: break; } DBG_WARN(GWEN_LOGDOMAIN, "Function is not appropriate for this type of widget (%s)", GWEN_Widget_Type_toString(GWEN_Widget_GetType(_widget))); return defaultValue; };
/** * We get a new Message from a chat participant * * - Ignore Messages from muted chat participants */ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info) { QDateTime sendTime = QDateTime::fromTime_t(info.sendTime); QDateTime recvTime = QDateTime::fromTime_t(info.recvTime); QString message = QString::fromStdWString(info.msg); QString name = QString::fromUtf8(info.peer_nickname.c_str()); QString rsid = QString::fromUtf8(info.rsid.c_str()); std::cerr << "message from rsid " << info.rsid.c_str() << std::endl; if(!isParticipantMuted(name)) { ui.chatWidget->addChatMsg(true, name, sendTime, recvTime, message, ChatWidget::TYPE_NORMAL); emit messageReceived(id()) ; } // This is a trick to translate HTML into text. QTextEdit editor; editor.setHtml(message); QString notifyMsg = name + ": " + editor.toPlainText(); if(notifyMsg.length() > 30) MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg.left(30) + QString("...")); else MainWindow::displayLobbySystrayMsg(tr("Lobby chat") + ": " + _lobby_name, notifyMsg); // also update peer list. time_t now = time(NULL); if (now > lastUpdateListTime) { lastUpdateListTime = now; updateParticipantsList(); } }
void Test2Test::testCase4() { TextEdit txt; QTextEdit mytxt; QTest::keyClicks(&mytxt, "Pavlova Viktoria is student of BNTU"); QCOMPARE(mytxt.toPlainText(), QString("Pavlova Viktoria is student of BNTU")); }
void ChatWidget::sendChat() { QTextEdit *chatWidget = ui->chatTextEdit; if (chatWidget->toPlainText().isEmpty()) { // nothing to send return; } QString text; RsHtml::optimizeHtml(chatWidget, text); std::wstring msg = text.toStdWString(); if (msg.empty()) { // nothing to send return; } #ifdef CHAT_DEBUG std::cout << "ChatWidget:sendChat " << std::endl; #endif if (rsMsgs->sendPrivateChat(peerId, msg)) { QDateTime currentTime = QDateTime::currentDateTime(); addChatMsg(false, name, currentTime, currentTime, QString::fromStdWString(msg), TYPE_NORMAL); } chatWidget->clear(); // workaround for Qt bug - http://bugreports.qt.nokia.com/browse/QTBUG-2533 // QTextEdit::clear() does not reset the CharFormat if document contains hyperlinks that have been accessed. chatWidget->setCurrentCharFormat(QTextCharFormat ()); }
QString QTextEditProto::toString() const { QTextEdit *item = qscriptvalue_cast<QTextEdit*>(thisObject()); if (item) return QString("[ QTextEdit starting: %1... ]").arg(item->toPlainText().left(50)); return QString("QTextEdit(unknown)"); }
void MainWindow::on_exportSavePushButton_clicked() { QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView"); QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit"); QString pathToSave = savePathTextField->toPlainText(); QFile saveFile(pathToSave); if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly)) { QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened."); } QString saveText(saveFile.readAll()); std::size_t headerEnd = saveText.indexOf("VESSEL"); QString header = saveText.left(headerEnd); saveFile.close(); saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate); m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n")); std::stringstream stringBuilder; for(int i = 0; i < savesList->count(); i++) { VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i); stringBuilder << item->GetVesselData()->AccessFullText()->toStdString(); } stringBuilder << "}\n}"; saveFile.write(header.toLocal8Bit()); saveFile.write(stringBuilder.str().c_str()); saveFile.close(); }
/** Get a message node element, extrapolate its type (public msg, private msg, channelEnter, etc.) and emit the specific signal */ void AJAXChat::emitChatData(const QDomElement &message) { QString messageText = message.firstChildElement("text").text(); // decode html entities from the message text and simplify it QTextEdit t; t.setHtml(messageText); messageText = t.toPlainText().simplified(); if (messageText.startsWith("/")) { QStringList messageParts = messageText.split(" "); if (messageText.startsWith("/privmsg")) { const int userID = message.attribute("userID").toInt(); emit newPrivateMessage(messageParts.at(1), getUser(userID).text()); } else if (messageText.startsWith("/login")) { emit userLoggedIn(messageParts.at(1)); } else if (messageText.startsWith("/logout")) { emit userLoggedOut(messageParts.at(1)); qDebug("Logged out: " + getUser(messageParts.at(1)).text().toUtf8()); } else if (messageText.startsWith("/channelEnter")) { emit userJoinChannel(messageParts.at(1)); } else if (messageText.startsWith("/channelLeave")) { emit userLeaveChannel(messageParts.at(1)); } else if (messageText.startsWith("/kick")) { emit userKicked(messageParts.at(1)); } else if (messageText.startsWith("/nick")) { emit userChangeNick(messageParts.at(1), messageParts.at(2)); } } else { const int userID = message.attribute("userID").toInt(); emit newPublicMessage(messageText, getUser(userID).text()); } }
void ConsoleImpl::typeWriterFontChanged() { QTextEdit* te = textEditOutput; te->setFont(QGit::TYPE_WRITER_FONT); te->setPlainText(te->toPlainText()); te->moveCursor(QTextCursor::End); }
void MainWindow::onWatchEditChanged() { watchList.clear(); QTextEdit* watchEdit = ui->watchEdit; QStringList lines = watchEdit->toPlainText().split("\n"); bool valid = true; QStringList validList; QString str; for(auto line:lines) { line = line.trimmed(); QFileInfo check(line); if(check.isFile() || check.isDir()) validList.push_back(line); else { valid = false; this->statusBar()->showMessage("监视路径错误:" + line); } } if(valid) { this->statusBar()->clearMessage(); watchList.swap(validList); } updateBtn(); }
void EditStyle::editTextClicked(int id) { QTextEdit* e = 0; switch (id) { case 0: e = evenHeaderL; break; case 1: e = evenHeaderC; break; case 2: e = evenHeaderR; break; case 3: e = oddHeaderL; break; case 4: e = oddHeaderC; break; case 5: e = oddHeaderR; break; case 6: e = evenFooterL; break; case 7: e = evenFooterC; break; case 8: e = evenFooterR; break; case 9: e = oddFooterL; break; case 10: e = oddFooterC; break; case 11: e = oddFooterR; break; } if (e == 0) return; bool styled = id < 6 ? headerStyled->isChecked() : footerStyled->isChecked(); if (styled) e->setPlainText(editPlainText(e->toPlainText(), tr("Edit Plain Text"))); else e->setHtml(editHtml(e->toHtml(), tr("Edit HTML Text"))); }
/**funcion que valida numeros ingresados*/ void sudoku::correccionInGame(){ QTextEdit *numberTextTemp = ( QTextEdit *) sender(); int contador=0; long inputNumber = numberTextTemp->toPlainText().toLong(); if ((inputNumber>9 || inputNumber<1)&& inputNumber!=NULL){ QMessageBox::information(this, "Advertencia", "El numero ingresado no es valido esta fuera del rango"); numberTextTemp->setText(""); } for(int i = 0; i < 9; i++){ for(int j = 0; j < 9; j++){ if(getDisplayValue(i,j)!=0){ contador++; } if(contador==81){ on_comprobar_clicked(); } if(((getDisplayValue(i,j)!=0) && numbertext[i][j]->isEnabled())){ CorreccionFila(i,j); CorreccionColumna(i,j); CorreccionCuadrante(i,j); } } } }
void FriendsDialog::sendMsg() { QTextEdit *lineWidget = ui.lineEdit; if (lineWidget->toPlainText().isEmpty()) { // nothing to send return; } QString text; RsHtml::optimizeHtml(lineWidget, text); std::wstring message = text.toStdWString(); #ifdef FRIENDS_DEBUG std::string msg(message.begin(), message.end()); std::cerr << "FriendsDialog::sendMsg(): " << msg << std::endl; #endif rsMsgs->sendPublicChat(message); ui.lineEdit->clear(); // workaround for Qt bug - http://bugreports.qt.nokia.com/browse/QTBUG-2533 // QTextEdit::clear() does not reset the CharFormat if document contains hyperlinks that have been accessed. ui.lineEdit->setCurrentCharFormat(QTextCharFormat ()); /* redraw send list */ insertSendList(); }
void MainWindow::onExceptEditChanged() { exceptList.clear(); QTextEdit* exceptEdit = ui->exceptEdit; QStringList lines = exceptEdit->toPlainText().split("\n"); bool valid = true; QStringList validList; QString str; for(auto line:lines) { line = line.trimmed(); QFileInfo check(line); if(check.isFile() || check.isDir()) validList.push_back(line); else { valid = false; this->statusBar()->showMessage("排除路径出错" + line); } } if(valid) { this->statusBar()->clearMessage(); exceptList.swap(validList); } }
void MainWindow::on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) { if (currentRow >= 0) { widget.tableWidget->selectRow(currentRow); QTextEdit *st = qobject_cast<QTextEdit*>(widget.tableWidget->cellWidget(currentRow, 3)); widget.textEdit->setText(st->toPlainText()); } else { } }
void ItemWidget::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QTextEdit *textEdit = qobject_cast<QTextEdit*>(editor); if (textEdit != NULL) { model->setData(index, textEdit->toPlainText()); textEdit->document()->setModified(false); } }
void CColumnDelegate::setModelData(QWidget *editor_widg, QAbstractItemModel *model,const QModelIndex &index) const { if (columnindex==ContentIndex) { QTextEdit* editor = qobject_cast<QTextEdit*>(editor_widg); model->setData(index,qVariantFromValue(editor->toPlainText())); } else return QStyledItemDelegate::setModelData(editor_widg,model,index); }
void PopupChatDialog::checkChat() { /* if <return> at the end of the text -> we can send it! */ QTextEdit *chatWidget = ui.chattextEdit; std::string txt = chatWidget->toPlainText().toStdString(); if ('\n' == txt[txt.length()-1] && txt.length()-1 == txt.find('\n')) /* only if on first line! */ sendChat(); else updateStatusTyping() ; }
void FriendsDialog::insertChat() { std::list<ChatInfo> newchat; if (!rsMsgs->getPublicChatQueue(newchat)) { #ifdef FRIENDS_DEBUG std::cerr << "no chat available." << std::endl ; #endif return; } #ifdef FRIENDS_DEBUG std::cerr << "got new chat." << std::endl; #endif std::list<ChatInfo>::iterator it; /* add in lines at the bottom */ for(it = newchat.begin(); it != newchat.end(); it++) { /* are they private? */ if (it->chatflags & RS_CHAT_PRIVATE) { /* this should not happen */ continue; } QDateTime sendTime = QDateTime::fromTime_t(it->sendTime); QDateTime recvTime = QDateTime::fromTime_t(it->recvTime); QString name = QString::fromUtf8(rsPeers->getPeerName(it->rsid).c_str()); QString msg = QString::fromStdWString(it->msg); #ifdef FRIENDS_DEBUG std::cerr << "FriendsDialog::insertChat(): " << msg.toStdString() << std::endl; #endif bool incoming = false; // notify with a systray icon msg if(it->rsid != rsPeers->getOwnId()) { incoming = true; // This is a trick to translate HTML into text. QTextEdit editor; editor.setHtml(msg); QString notifyMsg = name + ": " + editor.toPlainText(); if(notifyMsg.length() > 30) emit notifyGroupChat(tr("New group chat"), notifyMsg.left(30) + QString("...")); else emit notifyGroupChat(tr("New group chat"), notifyMsg); } addChatMsg(incoming, false, name, sendTime, recvTime, msg); } }
//static void body_view::rich_to_plain(QString& s) { QTextEdit tmp; /* hack: remove <br /> or the conversion to plaintext will insert question marks at line break positions. <p> on the other hand is correctly replaced by '\n' */ s.replace("<br />", "<p>"); tmp.setText(s); s = tmp.toPlainText(); }
void QgsStringRelay::changeText() { QObject* sObj = QObject::sender(); QTextEdit *te = qobject_cast<QTextEdit *>( sObj ); QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( sObj ); if ( te ) changeText( te->toPlainText() ); if ( pte ) changeText( pte->toPlainText() ); }
void MainWindow::selectRow(int i) { // widget.tableWidget. if (i >= 0) { widget.tableWidget->selectRow(i); QTextEdit *st = qobject_cast<QTextEdit*>(widget.tableWidget->cellWidget(i, 3)); widget.textEdit->setText(st->toPlainText()); } else { QTextEdit *st = qobject_cast<QTextEdit*>(widget.tableWidget->cellWidget(i, 3)); widget.textEdit->setText(""); } }
QVariant ItemHandlerMultiLine::GetObjectValue (QObject *object) const { QTextEdit *edit = qobject_cast<QTextEdit*> (object); if (!edit) { qWarning () << Q_FUNC_INFO << "not a QTextEdit" << object; return QVariant (); } return edit->toPlainText ().split ('\n', QString::SkipEmptyParts); }
void NewTransferDlg::addLinks(QString links) { QTextEdit* target; target = /*radioDownload->isChecked() ?*/ textURIs /*: textFiles*/; QStringList sl = links.split('\n'); foreach (QString s, sl) { s = s.trimmed(); if (!target->toPlainText().contains(s)) target->append(s); }