当前位置: 首页>>代码示例>>C++>>正文


C++ QString类代码示例

本文整理汇总了C++中QString的典型用法代码示例。如果您正苦于以下问题:C++ QString类的具体用法?C++ QString怎么用?C++ QString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: resultToCode

void QAtResult::resultToCode( const QString& value )
{
    QString val;
    int index;

    // Determine what kind of error report we have.
    if ( value.startsWith( "+CME ERROR:", Qt::CaseInsensitive ) ||
         value.startsWith( "+EXT ERROR:", Qt::CaseInsensitive ) ) {

        // Extended or GPRS error report.
        val = value.mid( 11 ).trimmed();
        index = numeric( val );
        if ( index >= 0 ) {
            d->resultCode = (QAtResult::ResultCode)index;
            d->verbose = false;
            return;
        }

    } else if ( value.startsWith( "+CMS ERROR:", Qt::CaseInsensitive ) ) {

        // Check the SMS codes before the main codes, as there is
        // some overlap in the message names.
        val = value.mid( 11 ).trimmed();
        index = numeric( val );
        if ( index >= 0 ) {
            d->resultCode = (QAtResult::ResultCode)index;
            d->verbose = false;
            return;
        }
        index = 0;
        while ( ext_codes[index].code != QAtResult::MEFailure )
            ++index;
        while ( index < num_ext_codes ) {
            if ( match( val, ext_codes[index].name ) ) {
                d->resultCode = ext_codes[index].code;
                d->verbose = true;
                return;
            }
            ++index;
        }

    } else {

        // Probably something like OK, ERROR, etc.  Scan the basic codes only.
        for ( index = 0; index < num_basic_codes; ++index ) {
            if ( match( value, basic_codes[index].name ) ) {
                d->resultCode = basic_codes[index].code;
                d->verbose = true;
                return;
            }
        }
        d->resultCode = QAtResult::UnknownError;
        d->verbose = true;

    }

    // Scan the extended code list for a match.
    for ( index = 0; index < num_ext_codes; ++index ) {
        if ( match( val, ext_codes[index].name ) ) {
            d->resultCode = ext_codes[index].code;
            d->verbose = true;
            return;
        }
    }
    d->resultCode = QAtResult::UnknownError;
    d->verbose = true;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:67,代码来源:qatresult.cpp

示例2: CEV_show_txt_widget

void cdrop_widget::edit_entry_on_request(quint32 index)
{
    QString original_string_part = this->elements[index]->entry_original_string_part;
    //finding out the mime data and open a suiting dialog formular
    //the event_editor_dialogs folder
    if ( original_string_part.left( 8 ) == "show_txt" )
    {
        //this is a msg box !
        CEV_show_txt_widget* cev = new CEV_show_txt_widget( this->elements[index]->entry_original_string_part,
                                                            this->projectPath );
        QString new_osp = cev->exec2();
        if ( new_osp != this->elements[index]->entry_original_string_part )
        {
            this->elements[index]->entry_original_string_part = new_osp;
            this->elements[index]->entry_text = "\"" + cev->textbox->toPlainText() + "\"";
        }
        delete cev;
    }
    else if ( original_string_part.left(7) == "swi_mod" )
    {
        //this is a SetStuff Command!

    }
    else if ( original_string_part.left(7) == "var_mod" )
    {
        //this is a SetStuff Command!

    }
    else if ( original_string_part.left(7) == "txt_mod" )
    {
        //this is a SetStuff Command!

    }
    else if ( original_string_part.left(9) == "input_swi" )
    {
        //this is a input (switch) Dialog
    }
    else if ( original_string_part.left(9) == "input_var" )
    {
        //this is a input (variables) Dialog
    }
    else if ( original_string_part.left(9) == "input_txt" )
    {
        //this is a input (text) Dialog
    }
    else if ( original_string_part.left(12) == "input_choice" )
    {
        //this is a multiply choice dialog
    }
    else if ( original_string_part.left(4) == "wait" )
    {
        //this is a simple delay command
//        QString s = this->elements[index]->entry_original_string_part;
//        s.remove( "wait" );
//        s.remove( "|" );
//        quint32 w = QInputDialog::getInteger( this,
//                                              tr( "Edit Wait" ),
//                                              tr( "How much milliseconds shall be done nothing?" ),
//                                              s.toInt(),
//                                              100,360000);
    }
    else if ( original_string_part.left(7) == "comment" )
    {
        //this is a simple comment like the c++ "//" ones are
        QString s = QInputDialog::getText( this, tr( "Edit comment" ),
                                           tr( "Type comment's' new text" ),
                                           QLineEdit::Normal,
                                           this->elements[index]->entry_text );
        if ( !s.isEmpty() )
        {
            this->elements[index]->entry_text = s;
            s.prepend( "comment" );
            s.append( "|" );
            this->elements[index]->entry_original_string_part = s;
        }

    }
    else if ( original_string_part.left(15) == "change_matrix_s" )
    {
        //this is brutal function::
        //changing a single value in the matrix
    }
    else if ( original_string_part.left(15) == "change_matrix_m" )
    {
        //this is brutal function::
        //changing a value in the matrix to another given value
    }
    else if ( original_string_part.left(9) == "forrepeat" )
    {
        //this marks the restart of a for-routine
        //** this is NOT EDITABLE
    }
    else if ( original_string_part.left(3) == "for" )
    {
        //this marks the start of a for-routine
    }

    else if ( original_string_part.left(9) == "break_for" )
    {
        //this marks the end of the current for-routine
//.........这里部分代码省略.........
开发者ID:axed,项目名称:gnurpgm,代码行数:101,代码来源:cevent_editor_dialog_cmd_widget.cpp

示例3: questionDialog

 int questionDialog(QWidget *parent, const QString &actionText, const QString &itemText, const QString &templateText, const QString &valueText)
 {
     return QMessageBox::question(parent,titleTemaple.arg(actionText).arg(itemText),templateText.arg(actionText).arg(itemText.toLower()).arg(valueText), QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
 }
开发者ID:2812140729,项目名称:robomongo,代码行数:4,代码来源:DialogUtils.cpp

示例4: DebugMessageHandler

void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
{
    Q_UNUSED(context);
    const char *category = (type == QtDebugMsg) ? "qt" : NULL;
    LogPrint(category, "GUI: %s\n", msg.toStdString());
}
开发者ID:KaSt,项目名称:ekwicoin,代码行数:6,代码来源:ekwicoin.cpp

示例5: matches

bool GerritOptionsPage::matches(const QString &s) const
{
    return s.contains(QLatin1String("gerrit"), Qt::CaseInsensitive);
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:4,代码来源:gerritoptionspage.cpp

示例6: Q_ASSERT

bool QLandmarkFileHandlerLmx::readCoordinates(QLandmark &landmark)
{
    /*
    <xsd:complexType name="coordinatesType">
        <xsd:sequence>
            <xsd:element name="latitude">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:double">
                        <xsd:minInclusive value="-90"/>
                        <xsd:maxInclusive value="90"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="longitude">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:double">
                        <xsd:minInclusive value="-180"/>
                        <xsd:maxExclusive value="180"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="altitude" type="xsd:float" minOccurs="0" />
            <xsd:element name="horizontalAccuracy" minOccurs="0">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:float">
                        <xsd:minInclusive value="0"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="verticalAccuracy" minOccurs="0">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:float">
                        <xsd:minInclusive value="0"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="timeStamp" type="xsd:dateTime" minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>
    */

    Q_ASSERT(m_reader->isStartElement() &&
             (m_reader->name() == "coordinates"));

    if (!m_reader->readNextStartElement()) {
        m_reader->raiseError("The element \"coordinates\" did not have the required child element \"latitude\".");
        return false;
    }

    if (m_reader->name() == "latitude") {
        bool ok = false;
        QString s = m_reader->readElementText();

        if ((s == "INF") || (s == "-INF") || (s == "NaN")) {
            m_reader->raiseError(QString("The element \"latitude\" expected a value convertable to type double (value was \"%1\").").arg(s));
            return false;
        }

        double lat = s.toDouble(&ok);

        if (!ok) {
            m_reader->raiseError(QString("The element \"latitude\" expected a value convertable to type double (value was \"%1\").").arg(s));
            return false;
        }

        if (lat < -90.0 || 90.0 < lat) {
            m_reader->raiseError(QString("The element \"latitude\" fell outside of the bounds -90.0 <= latitude <= 90.0 (value was \"%1\").").arg(s));
            return false;
        }

        QGeoCoordinate coord = landmark.coordinate();
        coord.setLatitude(lat);
        landmark.setCoordinate(coord);

        if (!m_reader->readNextStartElement()) {
            m_reader->raiseError("The element \"coordinates\" did not have the required child element \"longitude\".");
            return false;
        }
    } else {
        m_reader->raiseError("The element \"coordinates\" did not have the required child element \"latitude\".");
        return false;
    }

    if (m_reader->name() == "longitude") {
        bool ok = false;
        QString s = m_reader->readElementText();

        if ((s == "INF") || (s == "-INF") || (s == "NaN")) {
            m_reader->raiseError(QString("The element \"longitude\" expected a value convertable to type double (value was \"%1\").").arg(s));
            return false;
        }

        double lon = s.toDouble(&ok);

        if (!ok) {
            m_reader->raiseError(QString("The element \"longitude\" expected a value convertable to type double (value was \"%1\").").arg(s));
            return false;
        }

        if (lon < -180.0 || 180.0 <= lon) {
//.........这里部分代码省略.........
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:101,代码来源:qlandmarkfilehandler_lmx.cpp

示例7: toHTML

QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
    QString strHTML;

    LOCK2(cs_main, wallet->cs_wallet);
    strHTML.reserve(4000);
    strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";

    int64_t nTime = wtx.GetTxTime();
    int64_t nCredit = wtx.GetCredit();
    int64_t nDebit = wtx.GetDebit();
    int64_t nNet = nCredit - nDebit;

    strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
    int nRequests = wtx.GetRequestCount();
    if (nRequests != -1)
    {
        if (nRequests == 0)
            strHTML += tr(", has not been successfully broadcast yet");
        else if (nRequests > 0)
            strHTML += tr(", broadcast through %n node(s)", "", nRequests);
    }
    strHTML += "<br>";

    strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";

    //
    // From
    //
    if (wtx.IsCoinBase() || wtx.IsCoinStake())
    {
        strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
    }
    else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())
    {
        // Online transaction
        strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
    }
    else
    {
        // Offline transaction
        if (nNet > 0)
        {
            // Credit
            BOOST_FOREACH(const CTxOut& txout, wtx.vout)
            {
                if (wallet->IsMine(txout))
                {
                    CTxDestination address;
                    if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
                    {
                        if (wallet->mapAddressBook.count(address))
                        {
                            strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
                            strHTML += "<b>" + tr("To") + ":</b> ";
                            strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());
                            if (!wallet->mapAddressBook[address].empty())
                                strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";
                            else
                                strHTML += " (" + tr("own address") + ")";
                            strHTML += "<br>";
                        }
                    }
                    break;
                }
            }
        }
    }
开发者ID:403833073,项目名称:egoldcoin,代码行数:68,代码来源:transactiondesc.cpp

示例8: if

QString Serveur::parseCommande(QString comm,bool serveur)
{
    if(comm.startsWith("/"))
    {
        comm.remove(0,1);
        QString pref=comm.split(" ").first();
        QStringList args=comm.split(" ");
        args.removeFirst();
        QString destChan=tab->tabText(tab->currentIndex());
        QString msg=args.join(" ");

        if(pref=="me")
            return "PRIVMSG "+destChan+" ACTION " + msg + "";
        else if(pref=="msg")
            return "MSG "+destChan+" ACTION " + msg + "";
        else if(pref=="join")
        {
            join(msg);
            return " ";
        }
        else if(pref=="quit")
        {
            if(msg == "")
                return "QUIT "+msgQuit;
            else
                return "QUIT "+msg;
        }
        else if(pref=="part")
        {
            tab->removeTab(tab->currentIndex());

            if(msg == "")
            {
                if(msg.startsWith("#"))
                    destChan=msg.split(" ").first();

                if(msgQuit=="")
                    return "PART "+destChan+" using IrcLightClient";
                else
                    return "PART "+destChan+" "+msgQuit;
            }
            else
                return "PART "+destChan+" "+msg;

            conversations.remove(destChan);
        }
        else if(pref=="kick")
        {
            QStringList tableau=msg.split(" ");
            QString c1,c2,c3;
            if(tableau.count() > 0) c1=" "+tableau.first();
            else c1="";
            if(tableau.count() > 1) c2=" "+tableau.at(1);
            else c2="";
            if(tableau.count() > 2) c3=" "+tableau.at(2);
            else c3="";

            if(c1.startsWith("#"))
                return "KICK"+c1+c2+c3;
            else
                return "KICK "+destChan+c1+c2;
        }
        else if(pref=="update")
        {
            updateUsers=true;
            return "WHO "+destChan;
        }
        else if(pref=="ns")
        {
            return "NICKSERV "+msg;
        }
        else if(pref=="nick")
        {
            emit pseudoChanged(msg);
                        ecrire("-> Nickname changed to "+msg);
            return "NICK "+msg;
        }
        else if(pref=="msg")
        {
            return "MSG "+msg;
        }

        else
            return pref+" "+msg;
    }
    else if(!serveur)
	{
        QString destChan=tab->tabText(tab->currentIndex());
                if(comm.endsWith("<br />"))
                    comm=comm.remove(QRegExp("<br />$"));
                ecrire("<b>&lt;"+pseudo+"&gt;</b> "+comm,destChan);

        if(comm.startsWith(":"))
            comm.insert(0,":");

        return "PRIVMSG "+destChan+" "+comm.replace(" ","\t");
    }
	else
	{
		return "";
//.........这里部分代码省略.........
开发者ID:SHNICI,项目名称:Findcoin,代码行数:101,代码来源:serveur.cpp

示例9: setReleaseInformationLink

void CharmNewReleaseDialog::setReleaseInformationLink(const QString &link)
{
    QString hyperlink = m_ui->releaseInfoLabel->text();
    hyperlink.replace(QLatin1String("LINK"), link);
    m_ui->releaseInfoLabel->setText(hyperlink);
}
开发者ID:KDAB,项目名称:Charm,代码行数:6,代码来源:CharmNewReleaseDialog.cpp

示例10: QNetworkReply

QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
    : QNetworkReply(*new QNetworkReplyFileImplPrivate(), parent)
{
    setRequest(req);
    setUrl(req.url());
    setOperation(op);
    setFinished(true);
    QNetworkReply::open(QIODevice::ReadOnly);

    QNetworkReplyFileImplPrivate *d = (QNetworkReplyFileImplPrivate*) d_func();

    QUrl url = req.url();
    if (url.host() == QLatin1String("localhost"))
        url.setHost(QString());

#if !defined(Q_OS_WIN)
    // do not allow UNC paths on Unix
    if (!url.host().isEmpty()) {
        // we handle only local files
        QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
        setError(QNetworkReply::ProtocolInvalidOperationError, msg);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
            Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }
#endif
    if (url.path().isEmpty())
        url.setPath(QLatin1String("/"));
    setUrl(url);


    QString fileName = url.toLocalFile();
    if (fileName.isEmpty()) {
        if (url.scheme() == QLatin1String("qrc")) {
            fileName = QLatin1Char(':') + url.path();
        } else {
#if defined(Q_OS_ANDROID)
            if (url.scheme() == QLatin1String("assets"))
                fileName = QLatin1String("assets:") + url.path();
            else
#endif
                fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery);
        }
    }

    QFileInfo fi(fileName);
    if (fi.isDir()) {
        QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString());
        setError(QNetworkReply::ContentOperationNotPermittedError, msg);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
            Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentOperationNotPermittedError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    d->realFile.setFileName(fileName);
    bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered);

    // could we open the file?
    if (!opened) {
        QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2")
                .arg(d->realFile.fileName(), d->realFile.errorString());

        if (d->realFile.exists()) {
            setError(QNetworkReply::ContentAccessDenied, msg);
            QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied));
        } else {
            setError(QNetworkReply::ContentNotFoundError, msg);
            QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentNotFoundError));
        }
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified());
    d->realFileSize = fi.size();
    setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize);

    QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
        Q_ARG(qint64, d->realFileSize), Q_ARG(qint64, d->realFileSize));
    QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:87,代码来源:qnetworkreplyfileimpl.cpp

示例11: convert

QString DynamicPathConverter::convert(QString const &data) const
{
	QString mutablePath = mPathFromRoot;
	return readTemplate(mutablePath.replace("@@[email protected]@", data));
}
开发者ID:ASabina,项目名称:qreal,代码行数:5,代码来源:dynamicPathConverter.cpp

示例12: printToConsole

void HelpMessageBox::printToConsole()
{
    // On other operating systems, the expected action is to print the message to the console.
    QString strUsage = header + "\n" + coreOptions + "\n" + uiOptions;
    fprintf(stderr, "%s", strUsage.toStdString().c_str());
}
开发者ID:hmtoshi,项目名称:t01,代码行数:6,代码来源:guiutil.cpp

示例13: __tr2qs_ctx

bool KviPerlInterpreter::execute(
    const QString &szCode,
    QStringList &args,
    QString &szRetVal,
    QString &szError,
    QStringList &lWarnings)
{
    if(!m_pInterpreter)
    {
        szError = __tr2qs_ctx("Internal error: perl interpreter not initialized","perl");
        return false;
    }

    g_lWarningList.clear();

    QByteArray szUtf8 = szCode.toUtf8();
    PERL_SET_CONTEXT(m_pInterpreter);

    // clear the _ array
    AV * pArgs = get_av("_",1);
    SV * pArg = av_shift(pArgs);
    while(SvOK(pArg))
    {
        SvREFCNT_dec(pArg);
        pArg = av_shift(pArgs);
    }

    if(args.count() > 0)
    {
        // set the args in the _ arry
        av_unshift(pArgs,(I32)args.count());
        int idx = 0;
        for(QStringList::Iterator it = args.begin(); it != args.end(); ++it)
        {
            QString tmp = *it;
            const char * val = tmp.toUtf8().data();
            if(val)
            {
                pArg = newSVpv(val,tmp.length());
                if(!av_store(pArgs,idx,pArg))
                    SvREFCNT_dec(pArg);
            }
            idx++;
        }
    }

    // call the code
    SV * pRet = eval_pv(szUtf8.data(),false);

    // clear the _ array again
    pArgs = get_av("_",1);
    pArg = av_shift(pArgs);
    while(SvOK(pArg))
    {
        SvREFCNT_dec(pArg);
        pArg = av_shift(pArgs);
    }
    av_undef(pArgs);

    // get the ret value
    if(pRet)
    {
        if(SvOK(pRet))
            szRetVal = svToQString(pRet);
    }

    if(!g_lWarningList.isEmpty())
        lWarnings = g_lWarningList;

    // and the eventual error string
    pRet = get_sv("@",false);
    if(pRet)
    {
        if(SvOK(pRet))
        {
            szError = svToQString(pRet);
            if(!szError.isEmpty())return false;
        }
    }

    return true;
}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:82,代码来源:libkviperlcore.cpp

示例14: LIBMTP_Get_Storage

	void Plugin::UploadTo (LIBMTP_mtpdevice_t *device, const QByteArray& storageId,
			const QString& localPath, const QString& origPath)
	{
		if (!device->storage)
			LIBMTP_Get_Storage (device, 0);

		auto storage = device->storage;

		while (storage)
		{
			qDebug () << "st" << storage->id;
			if (QByteArray::number (storage->id) == storageId)
				break;
			storage = storage->next;
		}

		if (!storage)
		{
			qWarning () << Q_FUNC_INFO
					<< "could not find storage"
					<< storageId;
			emit uploadFinished (localPath,
					QFile::ResourceError,
					tr ("Unable to find the requested storage."));
			return;
		}

		const auto id = storage->id;
		const auto& info = OrigInfos_.take (origPath);

		qDebug () << "uploading" << localPath << "of type" << GetFileType (info.FileFormat_) << "to" << storage->id;

		auto track = LIBMTP_new_track_t ();
		track->storage_id = id;

		auto getStr = [] (const QString& str) { return strdup (str.toUtf8 ().constData ()); };

		track->filename = getStr (QFileInfo (localPath).fileName ());
		track->album = getStr (info.Album_);
		track->title = getStr (info.TrackTitle_);
		track->genre = getStr (info.Genres_.join ("; "));
		track->artist = getStr (info.Artist_);
		track->tracknumber = info.TrackNumber_;
		track->filetype = GetFileType (info.FileFormat_);
		track->filesize = QFileInfo (localPath).size ();
		track->date = getStr (QString::number (info.AlbumYear_) + "0101T0000.0");

		auto watcher = new QFutureWatcher<UploadInfo> ();
		connect (watcher,
				SIGNAL (finished ()),
				this,
				SLOT (handleUploadFinished ()));
		const auto future = QtConcurrent::run ([=] () -> UploadInfo
			{
				const auto cbData = new CallbackData { this, 0 };
				const auto res = LIBMTP_Send_Track_From_File (device,
						localPath.toUtf8 ().constData (), track,
						TransferCallback, cbData);
				delete cbData;
				return { res, device, localPath, track, info };
			});
		watcher->setFuture (future);
	}
开发者ID:zhao07,项目名称:leechcraft,代码行数:63,代码来源:mtpsync.cpp

示例15: switch

void PropertyModel::addProperty(PropertyID propID, EPropertyType propType,
    const QString& propName, const QVariant& value, const QString& uiHint)
{
    if(!_propIdMap.contains(propID))
    {
        Property* prop;

        switch(propType)
        {
        case EPropertyType::Boolean:
            prop = new BooleanProperty(propName, value.toBool());
            break;
        case EPropertyType::Integer:
            prop = new IntegerProperty(propName, value.toInt());
            break;
        case EPropertyType::Double:
            prop = new DoubleProperty(propName, value.toDouble());
            break;
        case EPropertyType::Enum:
            prop = new EnumProperty(propName, value.value<Enum>());
            break;
        case EPropertyType::Matrix:
            prop = new MatrixProperty(propName, value.value<Matrix3x3>());
            break;
        case EPropertyType::Filepath:
            prop = new FilePathProperty(propName, value.value<Filepath>());
            break;
        case EPropertyType::String:
            prop = new StringProperty(propName, value.toString());
            break;
        default:
            /// TODO: throw ??
            return;
        }

        if(!uiHint.isEmpty())
        {
            PropertyHintList uiHintsLists;
            QRegExp re(QString("([^= ]*):{1}([^,]*),?"));
            re.setMinimal(false);
            int pos = 0;

            while((pos = re.indexIn(uiHint, pos)) != -1)
            {
                uiHintsLists.append(qMakePair(re.cap(1), re.cap(2).trimmed()));
                pos += re.matchedLength();
            }

            if(!uiHintsLists.isEmpty())
                prop->setUiHints(uiHintsLists);
        }

        prop->setPropertyID(propID);
        _propIdMap.insert(propID, prop);
        _currentGroup->appendChild(prop);
    }
    else
    {
        /// TODO: throw ??
    }
}
开发者ID:k0zmo,项目名称:mouve,代码行数:61,代码来源:PropertyModel.cpp


注:本文中的QString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。