Result StoragePoolControlThread::getAllStoragePoolDataList()
{
    Result result;
    QStringList storagePoolDataList;
    if ( task.srcConnPtr!=NULL && keep_alive ) {
        virStoragePoolPtr *storagePool = NULL;
        unsigned int flags = VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE |
                             VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE;
        int ret = virConnectListAllStoragePools(
                    *task.srcConnPtr, &storagePool, flags);
        if ( ret<0 ) {
            result.err = sendConnErrors();
            result.result = false;
            result.msg = storagePoolDataList;
            return result;
        };

        // therefore correctly to use for() command, because storagePool[0] can not exist.
        for (int i = 0; i < ret; i++) {
            QStringList currentAttr;
            QString type, source, target;
            char *Returns = (virStoragePoolGetXMLDesc(storagePool[i], VIR_STORAGE_XML_INACTIVE));
            if ( Returns!=NULL ) {
                QDomDocument doc;
                QString s;
                QTextStream str;
                str.setString(&s);
                doc.setContent(QString(Returns));
                QDomElement _pool, _el;
                _pool= doc.firstChildElement("pool");
                type = _pool.attribute("type");
                _el = _pool.firstChildElement("source");
                _el.save(str, 4);
                source = str.readAll();
                _el = _pool.firstChildElement("target");
                _el.save(str, 4);
                target = str.readAll();
                free(Returns);
            };
            currentAttr<< QString::fromUtf8( virStoragePoolGetName(storagePool[i]) )
                       << type << source << target;
            storagePoolDataList.append(currentAttr.join(DFR));
            //qDebug()<<currentAttr;
            virStoragePoolFree(storagePool[i]);
        };
        free(storagePool);
        result.result = true;
    } else {
        result.result = false;
    };
    result.msg = storagePoolDataList;
    return result;
}
Exemplo n.º 2
0
void About::aboutInit()
{
  setModal(true);
  resize(400, 400);
  setWindowTitle("About");
  setWindowIcon(QIcon("icons/backupsoft.png"));

  QWidget *icon = new QWidget(this);
  icon->setStyleSheet("background-image: url(icons/backupsoft.png)");
  icon->setGeometry(250 , 10, 100, 100);

  QLabel *title = new QLabel("BackupSoft", this);
  title->setFont(QFont("Helvetica", 25, 10, false));
  title->setGeometry(10, 10, 200, 30);

  QLabel *version = new QLabel("Copyright 2010 by\nMichael Kohler and Fabian Gammenthaler\n\nVersion: 1.0", this);
  version->setFont(QFont("Helvetica", 8, 2, false));
  version->setGeometry(10, 70, 200, 55);

  QTextEdit *licence = new QTextEdit(this);
  licence->setGeometry(10, 160, 380, 230);
  licence->setReadOnly(true);

  QFile *file = new QFile("licence.txt");
  if (file->open(QIODevice::ReadOnly)) {
    QTextStream *stream = new QTextStream(file);
    licence->setText(stream->readAll());
  }
  else {
    QString errorMsg = "Could not open licence.txt.. Please make sure it is existent and readable.";
    AlertWindow *alertWin = new AlertWindow("ERROR", "", errorMsg);
    alertWin->show();
  }
}
Exemplo n.º 3
0
bool loadTPL(Translator &translator, QIODevice &dev, ConversionData &cd)
{
    // Hack: Check if the template is utf8
    QTextStream testStream;
    testStream.setDevice( &dev );
    QString testContent = testStream.readAll();
    if ( ( testContent.startsWith( QLatin1String("{*?template charset="), Qt::CaseInsensitive ) &&
           ( testContent.startsWith( QLatin1String("{*?template charset=utf8?*}"), Qt::CaseInsensitive ) ||
             testContent.startsWith( QLatin1String("{*?template charset=utf-8?*}"), Qt::CaseInsensitive ) ) ) ||
         cd.m_assumeUtf8 )
    {
        stream.setCodec( QTextCodec::codecForName("UTF-8") );
        stream.setAutoDetectUnicode( true );
    }
    else
    {
        stream.setCodec( QTextCodec::codecForLocale() );
        stream.setAutoDetectUnicode( false );
    }
    stream.setDevice( &dev );
    stream.seek( 0 ); // we need to rewind it because the testStream has read all data on the QIODevice

    parse( &translator, cd.m_sourceDir.path() + QDir::separator() + cd.m_sourceFileName );

    return true;
}
Exemplo n.º 4
0
QTextDocument* KateProject::notesDocument ()
{
  /**
   * already there?
   */
  if (m_notesDocument)
    return m_notesDocument;
  
  /**
   * else create it
   */
  m_notesDocument = new QTextDocument (this);
  m_notesDocument->setDocumentLayout (new QPlainTextDocumentLayout (m_notesDocument));
  
  /**
   * and load text if possible
   */
  if (QFile *inFile = projectLocalFile ("notes.txt")) {
    {
      QTextStream inStream (inFile);
      inStream.setCodec ("UTF-8");
      m_notesDocument->setPlainText (inStream.readAll ());
    }
    delete inFile;
  }

  /**
   * and be done
   */
  return m_notesDocument;
}
Exemplo n.º 5
0
bool TextManager::openFile(const QString &filePath, const QString &generatorName, const text::LanguageInfo &language)
{
	QFile file(filePath);
	QTextStream *inStream = nullptr;

	if (!file.isOpen() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
		inStream = new QTextStream(&file);
		inStream->setCodec(QTextCodec::codecForName("UTF-8"));

		QScintillaTextEdit *area = new QScintillaTextEdit();

		area->setCurrentLanguage(language);
		area->setText(inStream->readAll());
		mText.insert(filePath, area);
		mPath.insert(area, filePath);
		mPathType.insert(filePath, true);
		mModified.insert(filePath, QPair<bool, bool>(false, false));
		mGeneratorName.insert(filePath, generatorName);
		mCodeBlockManager.addNewCode(filePath);

		connect(area, SIGNAL(textWasModified(text::QScintillaTextEdit*))
				, this, SLOT(setModified(text::QScintillaTextEdit*)));

		return true;
	}
Exemplo n.º 6
0
QScriptValue loadJS(QScriptContext *context, QScriptEngine *engine)
{
	QString result;
	for ( int i = 0; i < context->argumentCount(); ++i ) {
		if ( i > 0 ) {
			result.append(" ");
		}
		result.append(context->argument(i).toString());
	}
	QFile scriptFile(result);

	// check file is exited or not
	if ( !scriptFile.open(QIODevice::ReadOnly) ) {
		return QScriptValue();
	}

	// load file
	QTextStream stream (&scriptFile);
	QString s = stream.readAll();
	scriptFile.close();

	// set ScriptContext
	QScriptContext *parent = context->parentContext();
	if( parent != 0 ) {
		context->setActivationObject(context->parentContext()->activationObject());
		context->setThisObject(context->parentContext()->thisObject());
	}
	// execute script
	return engine->evaluate(s, result);
}
Exemplo n.º 7
0
help::prelude_t help::build_prelude () {
  help::prelude_t ret;

  QStringList args = QCoreApplication::arguments ();

  QString ver ("X2Go Client " + QString (VERSION));

  if (QFile::exists (":/txt/git-info")) {
    QFile file (":/txt/git-info");

    if (file.open (QIODevice::ReadOnly | QIODevice::Text)) {
      QTextStream stream (&file);

      QString git_info (stream.readAll ().trimmed ());
      git_info = git_changelog_extract_commit_sha (git_info);

      if (!(git_info.isEmpty ())) {
        ver.append (" (Git information: " + git_info + ")");
      }
    }
  }

  ret.append (ver);
  ret.append ("Usage: " + QString (args.at (0)) + " [OPTION]...");
  ret.append ("Options:");
  ret.append ("");

  return (ret);
}
Exemplo n.º 8
0
void MainWindow::aboutLicense() {
    QDialog *dialog = new QDialog( this );

    QFile file( ":/GPL" );
    if(!file.open( QIODevice::ReadOnly | QIODevice::Text ))
        qCritical( "GPL LicenseFile not found" );

    QTextStream out ( &file );
    out.setFieldAlignment ( QTextStream::AlignCenter );

    QTextEdit *qteLicense = new QTextEdit ( dialog );
        qteLicense->setText ( out.readAll ());
        qteLicense->setReadOnly ( 1 );
    QPushButton *qpbClose = new QPushButton ( IconLoader::Load( "window-close" ), tr( "&Close" ), dialog );
        connect( qpbClose, SIGNAL( clicked()), dialog, SLOT( deleteLater()));

    qglDialog = new QGridLayout( dialog );
        qglDialog->addWidget( qteLicense, 0, 0 );
        qglDialog->addWidget( qpbClose, 1, 0, Qt::AlignRight );

        dialog->setLayout( qglDialog);
        dialog->setWindowTitle( "GNU General Public License" );
        dialog->setFixedSize( 550, 400 );
        dialog->exec();
}
Exemplo n.º 9
0
QString Plik::odczyt_z_pliku()
{
    qDebug() << "[Plik::odczyt_z_pliku()]";
    QFile plik(sciezka);
    tekst="";

    if(!plik.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        qDebug() << "Nie można było otworzyc pliku do odczytu\n";

//        QMessageBox::warning(
//                    this,
//                    QObject::tr("Hello World"),
//                    "Wystąpił błąd w dostępie do pliku"
//                    );
        return tekst;
    }

    QTextStream in (&plik);
    tekst = in.readAll();

    qDebug() << "Wczytano Następujące Dane z Pliku:\n";
    qDebug() << tekst << "\n";

    plik.flush();
    plik.close();

    return tekst;
}
void
WarrantyWidget::initialize ()
{
    QSettings content (configFile, QSettings::IniFormat);

    m_warrantyTimer =
        content.value ("warrantytimer", true).toBool ();
    m_warrantyText =
        content.value ("warrantytext", "qtn_warr_terms").toString ();

    SYS_DEBUG ("show warranty timer = %s", SYS_BOOL (m_warrantyTimer));
    SYS_DEBUG ("warranty_text = %s", SYS_STR (m_warrantyText));

    if (! m_warrantyText.isEmpty ())
    {
        if (m_warrantyText.contains ("qtn_"))
            m_warrantyText = qtTrId (m_warrantyText.toAscii ().constData ());
        else
        {
            QFile warrantyFile (configPath + m_warrantyText);
            if (warrantyFile.open (QIODevice::ReadOnly | QIODevice::Text))
            {
                QTextStream inStream (&warrantyFile);
                m_warrantyText = inStream.readAll ();
            }
            else
            {
                SYS_WARNING ("Warranty text cannot be loaded!");
                m_warrantyText = "";
            }
        }
    }
}
int TableContendor::readFileIntoContendor (QString ifilename)
{
bool res;

QFile infile(ifilename);

if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
{
    qDebug()<<"Error while opening file";
    return 1;
}





QTextStream str (&infile);
QStringList listOfLines = str.readAll().split("\n");
QStringList namesLst = listOfLines.at(0).trimmed().split("\t");
int gnumberOfColumns  = namesLst.count();
int gnumberOfRows = listOfLines.count();

setSizes(gnumberOfColumns,gnumberOfRows-1);





int i=0;
foreach (QString name, namesLst)
{
    setColumnName(i, name);
    i++;
}
Exemplo n.º 12
0
void processInput(QTextStream& in, QList<Streamable>* streamables) {
    Class clazz;
    Streamable currentStreamable;

    QRegExp exp(
        "(/\\*.*\\*/)|" // multi-line comments
        "(//.*\n)|" // single-line comments
        "(\\s*#.*\n)|" // preprocessor definitions
        "(\\s*STREAMABLE\\s+)|" // STREAMABLE tag for classes
        "(\\s*STREAM\\s+.*;)|" // STREAM tag for fields
        "(\\s*class\\s+[^;]+\\{)" // class definition
    );
    exp.setMinimal(true);

    QRegExp classExp("class (\\w+) ?:?([^:]*)\\{");

    // read in the entire input and look for matches with our expression
    QString all = in.readAll();
    for (int off = 0; (off = exp.indexIn(all, off)) != -1; off += exp.matchedLength()) {
        QString match = exp.cap().simplified();
        if (match.startsWith("/*") || match.startsWith("//") || match.startsWith('#')) {
            continue; // comment, preprocessor definition
        }
        if (match.startsWith("STREAMABLE")) {
            if (clazz.name.isEmpty()) {
                cerr << "Found STREAMABLE marker before class definition." << endl;
                continue;
            }
            if (!currentStreamable.clazz.name.isEmpty()) {
                streamables->append(currentStreamable);
            }
            currentStreamable.clazz = clazz;
            currentStreamable.fields.clear();

        } else if (match.startsWith("STREAM")) {
            match.chop(1); // get rid of the semicolon
            match = match.mid(match.indexOf(' ') + 1).trimmed(); // and STREAM, and any space before it
            int index = match.lastIndexOf(' ');
            Field field = { match.left(index).simplified(), match.mid(index + 1) };
            currentStreamable.fields.append(field);

        } else { // match.startsWith("class")
            classExp.exactMatch(match);
            clazz.name = classExp.cap(1);
            clazz.bases.clear();
            foreach (const QString& bstr, classExp.cap(2).split(',')) {
                QString base = bstr.trimmed();
                if (!base.isEmpty() && base.startsWith("STREAM")) {
                    clazz.bases.append(base.mid(base.lastIndexOf(' ') + 1));
                }
            }
        }
    }
    if (!currentStreamable.clazz.name.isEmpty()) {
        streamables->append(currentStreamable);
    }
}
Exemplo n.º 13
0
void DebugView::nodeCreated(const ModelNode &createdNode)
{
    if (isDebugViewEnabled()) {
        QTextStream message;
        QString string;
        message.setString(&string);
        message << createdNode;
        log(tr("Node created:"), message.readAll());
    }
}
Exemplo n.º 14
0
void IWindow::loadFile(QString &file)
{
	FILE *fh = fopen(file.toAscii().data(), "r");
	if (fh == 0)
		return;
	QTextStream *ts = new QTextStream(fh, QIODevice::ReadOnly);
	m_input->document()->setPlainText(ts->readAll());
	delete ts;
	fclose(fh);
}
Exemplo n.º 15
0
void TicketQToolButton::click()
{
    BL_FUNC_DEBUG
    QString txt = "";

    /// Copiamos el archivo.
    QString archivo = g_confpr->value( CONF_DIR_OPENREPORTS ) + "etiquetas.rml";
    QString archivod = g_confpr->value( CONF_DIR_USER ) + "etiquetas.rml";
    blCopyFile(archivo,archivod);

    BlFile file;
    file.setFileName ( archivod );
    file.open ( QIODevice::ReadOnly );
    QTextStream stream ( &file );
    QString buff = stream.readAll();
    file.close();
    QString fitxersortidatxt = "";


    /// Hacemos el texto de las etiquetas.
    m_companyact = m_albaranProveedorView->mainCompany();

    QString query = "SELECT * , ceil(cantlalbaranp) AS cantidad FROM lalbaranp NATURAL LEFT JOIN articulo WHERE idalbaranp = " + m_albaranProveedorView->dbValue ( "idalbaranp" );
    BlDbRecordSet *cur = m_companyact->loadQuery ( query );
    while ( !cur->eof() ) {
        int i = 0;
        while ( i < cur->value( "cantidad" ).toInt() ) {
            fitxersortidatxt += "<blockTable><tr><td>";
            fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "nomarticulo" ) + "</font></para>\n";
            fitxersortidatxt += "<barCode code=\"code128\" height=\"0.60cm\">" + cur->value( "codigocompletoarticulo" ) + "</barCode>\n";
            fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "codigocompletoarticulo" ) + " - (" + m_albaranProveedorView->dbValue ( "fechaalbaranp" ).left ( 10 ) + ")</font></para>\n";
//     if (cur->numcampo("lotelalbaranp") != -1)
//             fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\"> Lote: " + cur->value("lotelalbaranp") + "</font></para>\n";
            fitxersortidatxt += "</td></tr></blockTable>";
            fitxersortidatxt += "<spacer length=\"0.5cm\"/>\n";
            i++;
        } // end while
        cur->nextRecord();
    } // end while
    delete cur;


    buff.replace ( "[story]", fitxersortidatxt );

    if ( file.open ( QIODevice::WriteOnly ) ) {
        QTextStream stream ( &file );
        stream << buff;
        file.close();
    } // end if
    blCreateAndLoadPDF ( "etiquetas" );



    
}
Exemplo n.º 16
0
bool HttpDaemon::Private::initialize()
{
  QScriptEngine engine;
   
  QFile file(configScript);
  if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
    qDebug() << file.errorString();
    return false;
  }

  QTextStream stream (&file);

  auto globalObject = engine.globalObject();
  auto configObject = engine.newObject();
  auto typesObject  = engine.newObject();
  auto actionObject = engine.newObject();
  auto handlerObject= engine.newObject();
  auto addTypeFn    = engine.newFunction(addType);
  auto setPortFn    = engine.newFunction(setPort);
  auto addReqHdrFn  = engine.newFunction(addRequestHeader);
  auto setDocRootFn = engine.newFunction(setDocumentRoot);
  auto setServNamFn = engine.newFunction(setServerName);
  auto setServAdmFn = engine.newFunction(setServerAdmin);
  auto setErrLogFn  = engine.newFunction(setErrorLog);
  auto actionFn     = engine.newFunction(action);
  auto addHandlerFn = engine.newFunction(addHandler);
  
  configObject.setProperty(settings_types, typesObject);
  configObject.setProperty(settings_action, actionObject);
  configObject.setProperty(settings_handler, handlerObject);
  globalObject.setProperty(settings_conf, configObject);
  configObject.setProperty("action", actionFn);
  configObject.setProperty("addHandler", addHandlerFn);
  configObject.setProperty("addType", addTypeFn);
  configObject.setProperty("setListenPort", setPortFn);
  configObject.setProperty("addRequestHeader", addReqHdrFn);
  configObject.setProperty("setDocumentRoot", setDocRootFn);
  configObject.setProperty("setServerName", setServNamFn);
  configObject.setProperty("setServerAdmin", setServAdmFn);
  configObject.setProperty("setErrorLog", setErrLogFn);
  
  auto const program = stream.readAll();
  auto const result = engine.evaluate(program, file.fileName(), 1);
  if (engine.hasUncaughtException()) {
    auto line = engine.uncaughtExceptionLineNumber();
    qDebug() << "uncaught exception at line" << line << ":" << result.toString();
    return false;
  }
  auto configValue = engine.evaluate("(function(){return (JSON.stringify(configure));})();");
  serverSettings = QJsonDocument::fromJson(configValue.toString().toLocal8Bit());
  //  qDebug () << serverSettings.toJson();
  return true;
}
Exemplo n.º 17
0
    void TailEditor::_parseFile ()
    {
        QFile file (_tailedFilename.c_str());

        if (file.open (QIODevice::ReadOnly)) {
            QTextStream stream (&file);

            _content = stream.readAll();
        }

        file.close();
    }
Exemplo n.º 18
0
void dlgNotepad::restore()
{
    QString directoryFile = QDir::homePath()+"/.config/mudlet/profiles/"+mpHost->getName();
    QString fileName = directoryFile + "/notes.txt";
    QDir dirFile;
    QFile file;
    file.setFileName( fileName );
    file.open( QIODevice::ReadOnly );
    QTextStream fileStream;
    fileStream.setDevice( &file );
    QString txt = fileStream.readAll();
    notesEdit->setPlainText(txt);
}
Exemplo n.º 19
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);setFixedSize(600,400);
    if(!file.open(QFile::ReadOnly | QFile::Text))
    {   ui->textBrowser->setText("ERROR");
        exit(-1);
    }
    str=point.readAll();
ui->textBrowser->setText(str);
   file.close();
}
Exemplo n.º 20
0
QString adjustGosmoreVersion( QTextStream &stream, WaypointParser &parser )
{
    QString content = stream.readAll();
    if ( !QCoreApplication::instance()->arguments().contains( "--routino" ) ) {
        QStringList lines = content.split( '\r' );
        if ( lines.size() > 2 ) {
            QStringList fields = lines.at( lines.size()-2 ).split(',');
            parser.setFieldIndex( WaypointParser::RoadType, fields.size()-3 );
            parser.setFieldIndex( WaypointParser::TotalSecondsRemaining, fields.size()-2 );
            parser.setFieldIndex( WaypointParser::RoadName, fields.size()-1 );
        }
    }
    return content;
}
Subtitle Subtitle::Parser::parse(const QString &fileName) {
	Subtitle sub;
	QFile file(fileName);
	if (!file.open(QFile::ReadOnly))
		return sub;
	QTextStream in;
	in.setDevice(&file);
	in.setCodec(m_enc.toLocal8Bit());
	m_all = in.readAll();
	m_name = fileName;
	m_pos = 0;
	_parse(sub);
	return sub;
}
Exemplo n.º 22
0
FileTemplates::FileTemplates(QObject *parent) :
    QObject(parent)
{
    m_menu.setTitle(tr("New"));
    templateDir = QCoreApplication::applicationDirPath()+QDir::toNativeSeparators("/templates/");
    QFile file(templateDir + "file.json");
    file.open(QIODevice::ReadOnly);
    QTextStream stream ( &file );
    JsonReader reader;
    reader.parse(stream.readAll());
    if(reader.errorString().isEmpty())
        buildMenu(reader.result());

}
Exemplo n.º 23
0
void DebugView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
    if (isDebugViewEnabled()) {
        QTextStream message;
        QString string;
        message.setString(&string);
        message << removedNode << lineBreak;
        foreach (const ModelNode &modelNode, removedNode.allSubModelNodes()) {
            message << tr("Child node:") << modelNode << lineBreak;
        }

        log(tr("Node about to be removed:"), message.readAll());
    }
}
Exemplo n.º 24
0
QString InFile::readAll(QString const &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		throw qReal::Exception((fileName + " - file open operation failed").toUtf8());
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	QString text = input.readAll();
	file.close();
	return text;
}
Exemplo n.º 25
0
QString FileUtils::readFromFile(const QString &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		throw FailedToOpenFileException(file);
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	const QString result = input.readAll();
	file.close();

	return result;
}
Exemplo n.º 26
0
QString FileUtils::readFromFile(QString const &fileName)
{
	QFile file(fileName);
	file.open(QIODevice::ReadOnly | QIODevice::Text);
	if (!file.isOpen()) {
		qDebug() << "Failed to open file" << fileName;
		throw "Failed to open file";
	}

	QTextStream input;
	input.setDevice(&file);
	input.setCodec("UTF-8");
	QString const result = input.readAll();
	file.close();

	return result;
}
Exemplo n.º 27
0
	void Plugin::Init (ICoreProxy_ptr)
	{
		QFile embedderJS (":/plugins/azoth/plugins/embedmedia/resources/scripts/embedder.js");

		if (!embedderJS.open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open script file"
					<< embedderJS.errorString ();
			return;
		}

		QTextStream content (&embedderJS);

		content.setCodec (QTextCodec::codecForName ("UTF-8"));
		ScriptContent_ = content.readAll ();
	}
Exemplo n.º 28
0
void QGoogleTranslator::finishedSlot(QNetworkReply* reply)
{
    // Reathising attributes of the reply
    // e.g. the HTTP    QTextStream stream ( &file );

    QVariant statusCodV =
            reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    // Or the target URL if it was a rethisirect:
    QVariant redirectionTargetUrl =
            reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    QTextStream stream ( reply );
    stream.setCodec("UTF-8");
    QString strTmp;
    strTmp =  stream.readAll();
    QVariant response = Json::parse(strTmp);
    emit translationFinished(response.toMap ().value ("responseData")
                             .toMap ().value ("translatedText").toString ());
}
Exemplo n.º 29
0
void Dialog::on_comboBox_activated(const QString &arg1)
{
  str =  ui->comboBox->currentText();
  QFile   mFile(str);
  if(!mFile.open(QFile::ReadOnly | QFile::Text))
  {
          QMessageBox msgBox;

          msgBox.setText("Error.");

          msgBox.exec();
          return;
}
  QTextStream stream (&mFile);


  str=stream.readAll();
  ui->label_2->setText(str);
}
Exemplo n.º 30
0
bool Editor::loadFile (QString &fileName){
    QFile file (fileName);

    if (!file.open (QFile::ReadOnly | QFile::Text) ) {
        QMessageBox::warning (this, tr("Application"), 
                              tr("Cannot write file %1: \n %2.") 
                               .arg(fileName)
                               .arg(file.errorString() ) );
        return false;
    }

    QTextStream in (&file);

    QApplication::setOverrideCursor(Qt::WaitCursor);
    setPlainText (in.readAll() );
    QApplication::restoreOverrideCursor();

    setCurrentFile (fileName);
    return true;
}