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


C++ QString::compare方法代码示例

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


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

示例1: loadPicture

void QgsComposerPicture::loadPicture( const QFile& file )
{
  if ( !file.exists()
       || ( mUseSourceExpression && mPictureExpr->hasEvalError() ) )
  {
    mMode = Unknown;
  }
  else
  {
    QFileInfo sourceFileInfo( file );
    QString sourceFileSuffix = sourceFileInfo.suffix();
    if ( sourceFileSuffix.compare( "svg", Qt::CaseInsensitive ) == 0 )
    {
      //try to open svg
      mSVG.load( file.fileName() );
      if ( mSVG.isValid() )
      {
        mMode = SVG;
        QRect viewBox = mSVG.viewBox(); //take width/height ratio from view box instead of default size
        mDefaultSvgSize.setWidth( viewBox.width() );
        mDefaultSvgSize.setHeight( viewBox.height() );
      }
      else
      {
        mMode = Unknown;
      }
    }
    else
    {
      //try to open raster with QImageReader
      QImageReader imageReader( file.fileName() );
      if ( imageReader.read( &mImage ) )
      {
        mMode = RASTER;
      }
      else
      {
        mMode = Unknown;
      }
    }
  }

  if ( mMode != Unknown ) //make sure we start with a new QImage
  {
    recalculateSize();
  }
  else if ( !( file.fileName().isEmpty() ) || ( mUseSourceExpression && mPictureExpr && mPictureExpr->hasEvalError() ) )
  {
    //trying to load an invalid file or bad expression, show cross picture
    mMode = SVG;
    QString badFile = QString( ":/images/composer/missing_image.svg" );
    mSVG.load( badFile );
    if ( mSVG.isValid() )
    {
      mMode = SVG;
      QRect viewBox = mSVG.viewBox(); //take width/height ratio from view box instead of default size
      mDefaultSvgSize.setWidth( viewBox.width() );
      mDefaultSvgSize.setHeight( viewBox.height() );
      recalculateSize();
    }
  }

  emit itemChanged();
}
开发者ID:Asjad27,项目名称:QGIS,代码行数:64,代码来源:qgscomposerpicture.cpp

示例2: changeCamera

// 改变相机提示灯
void ImageViewer::changeCamera(QString cameraindex, bool status)
{
    QString img;
    if (status)
        img = ":/image/lightgreen.png";
    else
    {
        img = ":/image/lightyellow.png";
        ui->A1Label_work->setPixmap(QPixmap(img));
        ui->A2Label_work->setPixmap(QPixmap(img));
        ui->B1Label_work->setPixmap(QPixmap(img));
        ui->B2Label_work->setPixmap(QPixmap(img));
        ui->C1Label_work->setPixmap(QPixmap(img));
        ui->C2Label_work->setPixmap(QPixmap(img));
        ui->D1Label_work->setPixmap(QPixmap(img));
        ui->D2Label_work->setPixmap(QPixmap(img));
        ui->E1Label_work->setPixmap(QPixmap(img));
        ui->E2Label_work->setPixmap(QPixmap(img));
        ui->F1Label_work->setPixmap(QPixmap(img));
        ui->F2Label_work->setPixmap(QPixmap(img));
        ui->G1Label_work->setPixmap(QPixmap(img));
        ui->G2Label_work->setPixmap(QPixmap(img));
        ui->H1Label_work->setPixmap(QPixmap(img));
        ui->H2Label_work->setPixmap(QPixmap(img));
        ui->I1Label_work->setPixmap(QPixmap(img));
        ui->I2Label_work->setPixmap(QPixmap(img));
        ui->J1Label_work->setPixmap(QPixmap(img));
        ui->J2Label_work->setPixmap(QPixmap(img));
        ui->K1Label_work->setPixmap(QPixmap(img));
        ui->K2Label_work->setPixmap(QPixmap(img));
        ui->L1Label_work->setPixmap(QPixmap(img));
        ui->L2Label_work->setPixmap(QPixmap(img));
        ui->M1Label_work->setPixmap(QPixmap(img));
        ui->M2Label_work->setPixmap(QPixmap(img));
        ui->N1Label_work->setPixmap(QPixmap(img));
        ui->N2Label_work->setPixmap(QPixmap(img));
        ui->O1Label_work->setPixmap(QPixmap(img));
        ui->O2Label_work->setPixmap(QPixmap(img));
        ui->P1Label_work->setPixmap(QPixmap(img));
        ui->P2Label_work->setPixmap(QPixmap(img));
        ui->Q1Label_work->setPixmap(QPixmap(img));
        ui->Q2Label_work->setPixmap(QPixmap(img));
        ui->R1Label_work->setPixmap(QPixmap(img));
        ui->R2Label_work->setPixmap(QPixmap(img));
        return;
    }
    //qDebug() << cameraindex;
    if (cameraindex.compare("A1") == 0)
        ui->A1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("A2") == 0)
        ui->A2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("B1") == 0)
        ui->B1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("B2") == 0)
        ui->B2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("C1") == 0)
        ui->C1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("C2") == 0)
        ui->C2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("D1") == 0)
        ui->D1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("D2") == 0)
        ui->D2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("E1") == 0)
        ui->E1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("E2") == 0)
        ui->E2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("F1") == 0)
        ui->F1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("F2") == 0)
        ui->F2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("G1") == 0)
        ui->G1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("G2") == 0)
        ui->G2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("H1") == 0)
        ui->H1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("H2") == 0)
        ui->H2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("I1") == 0)
        ui->I1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("I2") == 0)
        ui->I2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("J1") == 0)
        ui->J1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("J2") == 0)
        ui->J2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("K1") == 0)
        ui->K1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("K2") == 0)
        ui->K2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("L1") == 0)
        ui->L1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("L2") == 0)
        ui->L2Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("M1") == 0)
        ui->M1Label_work->setPixmap(QPixmap(img));
    else if (cameraindex.compare("M2") == 0)
        ui->M2Label_work->setPixmap(QPixmap(img));
//.........这里部分代码省略.........
开发者ID:fanxiang090909,项目名称:Railway-Tunnel-Construction-Dlearance-Measure-LanZhou,代码行数:101,代码来源:imageviewer.cpp

示例3: process

void TextDetection::process(Mat &image)
{
	QMutexLocker mutexLocker(&m_mutex);
	try
	{
		if (p_tesseract == NULL)
			initTesseract();

		if (p_tesseract != NULL)
		{
			tesseract::PageSegMode pagesegmode = static_cast<tesseract::PageSegMode>(7); // treat the image as a single text line
			p_tesseract->SetPageSegMode(pagesegmode);

			Mat dst, image_grey, image_grey_blurred, image_grey_res, image_otsu_thresh, image_otsu_thresh_blurred, image_otsu_thresh_smooth;
			Mat element, element2;
			cvtColor(image, image_grey, CV_RGB2GRAY);

			float ratio = (float)image_grey.cols / (float)image_grey.rows;
			// Case where image is a landscape
			if (ratio >= 2)
				resize(image_grey, image_grey, Size(200 * ratio, 200), 0, 0, CV_INTER_CUBIC | CV_WINDOW_KEEPRATIO);

			// Case where image is a square
			else if (ratio < 2)
				resize(image_grey, image_grey, Size(image_grey.cols * ratio * 2, image_grey.rows * ratio * 2), 0, 0, CV_INTER_CUBIC | CV_WINDOW_KEEPRATIO);

			// Case where image is a portrait
			else if (((float)image_grey.rows / (float)image_grey.cols) > 2)
				resize(image_grey, image_grey, Size(image_grey.rows * ratio, 800), 0, 0, CV_INTER_CUBIC | CV_WINDOW_KEEPRATIO);

			cv::GaussianBlur(image_grey, image_grey_res, cv::Size(11, 11), 3);						// Blur to remove noise


			if (m_fontIndex == 0)	// --> English
			{
				// Measure range of greyscale
				double min, max;
				cv::minMaxIdx(image_grey_res, &min, &max);

				if ((max - min) <= 30) // if only one color in image
					threshold(image_grey_res, image_grey_res, max, 255, CV_THRESH_BINARY);		// Threshold to make black all black if image is empty (nothing to read)

				int size2 = 3;
				element2 = getStructuringElement(MORPH_RECT, Size(size2, size2));
				dilate(image_grey_res, image_grey_res, element2);									// Dilate too fill in the edge

				threshold(image_grey_res, dst, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);		// Threshold to make black and white
			}

			else					// --> PR4G
			{
				image_grey_res.convertTo(image_grey_res, -1, 0.3, 70);

				threshold(image_grey_res, image_otsu_thresh, 0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);		// Threshold to make black and white

				int size = 5;
				element = getStructuringElement(MORPH_RECT, Size(size, size));
				erode(image_otsu_thresh, image_otsu_thresh, element);

				Mat img_dilate;
				int size2 = 20;
				element2 = getStructuringElement(MORPH_RECT, Size(size2, size2));
				dilate(image_otsu_thresh, dst, element2);
			}

			if (m_debug)
			{
				imshow("res text", dst);
			}

			p_tesseract->SetImage((uchar*)dst.data, dst.size().width, dst.size().height, dst.channels(), dst.step1());

			// Get OCR result	
			QString res = QString::fromUtf8(p_tesseract->GetUTF8Text());

			res = res.simplified();
			m_currentValue = res;

			res = res.remove(" ");

			if (m_debug)
			{
				qDebug() << "m_currentValue: " << m_currentValue;
				qDebug() << "res txt: " << res;
				qDebug() << "m_text : " << m_text;
			}

			setAlarmValid(true);

			QString temp = m_text;
			if (res.compare(temp.remove(" "), Qt::CaseInsensitive) == 0)
			{
				if (m_alarmOnEquals)
					setAlarm(true);
				else
					setAlarm(false);
			}
			else if (m_alarmOnEquals)
			{
				setAlarm(false);
//.........这里部分代码省略.........
开发者ID:cedric-lemaitre-alyotech,项目名称:survec,代码行数:101,代码来源:TextDetection.cpp

示例4: readExtensionInfo

/*!
    \fn void ExtensionInfoPrivate::readExtensionInfo(QXmlStreamReader &reader)
    \internal
*/
void ExtensionInfoPrivate::readExtensionInfo(QXmlStreamReader &reader)
{
    QString element = reader.name().toString();
    if (element != QString(EXTENSION)) {
        reader.raiseError(QCoreApplication::translate("ExtensionInfo", "Expected element '%1' as top level element").arg(EXTENSION));
        return;
    }
    name = reader.attributes().value(EXTENSION_NAME).toString();
    if (name.isEmpty()) {
        reader.raiseError(msgAttributeMissing(EXTENSION, EXTENSION_NAME));
        return;
    }
    version = reader.attributes().value(EXTENSION_VERSION).toString();
    if (version.isEmpty()) {
        reader.raiseError(msgAttributeMissing(EXTENSION, EXTENSION_VERSION));
        return;
    }
    if (!isValidVersion(version)) {
        reader.raiseError(msgInvalidFormat(EXTENSION_VERSION));
        return;
    }
    compatVersion = reader.attributes().value(EXTENSION_COMPATVERSION).toString();
    if (!compatVersion.isEmpty() && !isValidVersion(compatVersion)) {
        reader.raiseError(msgInvalidFormat(EXTENSION_COMPATVERSION));
        return;
    } else if (compatVersion.isEmpty()) {
        compatVersion = version;
    }
    QString experimentalString = reader.attributes().value(EXTENSION_EXPERIMENTAL).toString();
    experimental = (experimentalString.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0);
    if (!experimentalString.isEmpty() && !experimental
            && experimentalString.compare(QLatin1String("false"), Qt::CaseInsensitive) != 0) {
        reader.raiseError(msgInvalidFormat(EXTENSION_EXPERIMENTAL));
        return;
    }
    enabled = !experimental;
    while (!reader.atEnd()) {
        reader.readNext();
        switch (reader.tokenType()) {
        case QXmlStreamReader::StartElement:
            element = reader.name().toString();
            if (element == VENDOR)
                vendor = reader.readElementText().trimmed();
            else if (element == COPYRIGHT)
                copyright = reader.readElementText().trimmed();
            else if (element == LICENSE)
                license = reader.readElementText().trimmed();
            else if (element == DESCRIPTION)
                description = reader.readElementText().trimmed();
            else if (element == URL)
                url = reader.readElementText().trimmed();
            else if (element == CATEGORY)
                category = reader.readElementText().trimmed();
            else if (element == DEPENDENCYLIST)
                readDependencies(reader);
            else if (element == ARGUMENTLIST)
                readArgumentDescriptions(reader);
            else
                reader.raiseError(msgInvalidElement(name));
            break;
        case QXmlStreamReader::EndDocument:
        case QXmlStreamReader::Comment:
        case QXmlStreamReader::EndElement:
        case QXmlStreamReader::Characters:
            break;
        default:
            reader.raiseError(msgUnexpectedToken());
            break;
        }
    }
}
开发者ID:apathadeus,项目名称:unison,代码行数:75,代码来源:ExtensionInfo.cpp

示例5: on_common_command_clicked

void SxEditor::on_common_command_clicked()
{
	QObject *btn = sender();
	QString name = btn->objectName();

	if(name.compare("selectAll") == 0)
	{
		m_pTextEdit->selectAll();
	}
	if(name.compare("save") == 0)
	{
		m_pTextEdit->save();
	}
	else if(name.compare("copy") == 0)
	{
		m_pTextEdit->copy();
	}
	else if(name.compare("paste") == 0)
	{
		m_pTextEdit->paste();
	}
	else if(name.compare("cut") == 0)
	{
		m_pTextEdit->cut();
	}
	else if(name.compare("redo") == 0)
	{
		m_pTextEdit->redo();
	}
	else if(name.compare("undo") == 0)
	{
		m_pTextEdit->undo();
	}
	else if(name.compare("delete") == 0)
	{
		m_pTextEdit->deleteText();
	}
	else if(name.compare("bold") == 0)
	{
		m_pTextEdit->setFontBold(!m_pTextEdit->fontBold());
	}
	else if(name.compare("italic") == 0)
	{
		m_pTextEdit->setFontItalic(!m_pTextEdit->fontItalic());
	}
	else if(name.compare("underline") == 0)
	{
		m_pTextEdit->setFontUnderline(!m_pTextEdit->fontUnderline());
	}
	else if(name.compare("throughout") == 0)
	{
		m_pTextEdit->setFontStrikeOut(!m_pTextEdit->fontStrikeOut());
	}
	else if(name.compare("alignleft") == 0)
	{
		m_pTextEdit->setTextAlignment(Qt::AlignLeft);
	}
	else if(name.compare("aligncenter") == 0)
	{
		m_pTextEdit->setTextAlignment(Qt::AlignCenter);
	}
	else if(name.compare("alignright") == 0)
	{
		m_pTextEdit->setTextAlignment(Qt::AlignRight);
	}
	else if(name.compare("textcolor") == 0)
	{
		QColor clr = QColorDialog::getColor(m_pTextEdit->textColor(), m_pTextEdit->view());
		m_pTextEdit->setTextColor(clr);
	}
	else if(name.compare("link") == 0)
	{
		m_pUrlInsert = qobject_cast<KDialogBase*>(KXmlUI::windowFromFile("res:/Resources/layout/urlinsert.xml", m_pWindow));
		KPushButton *btnApply = m_pUrlInsert->findChild<KPushButton*>("btnApply");
		KPushButton *btnCancel = m_pUrlInsert->findChild<KPushButton*>("btnCancel");
		QObject::connect(btnApply, SIGNAL(clicked()), this, SLOT("on_urlInsert_button_clicked()"));
		QObject::connect(btnCancel, SIGNAL(clicked()), m_pUrlInsert, SLOT("setRejected()"));
		m_pUrlInsert->doModal(m_pWindow->rootWidget());
	}
	else if(name.compare("replace") == 0)
	{

	}
	else if(name.compare("find") == 0)
	{

	}
}
开发者ID:kxtry,项目名称:sxnote,代码行数:88,代码来源:sxeditor.cpp

示例6: testSettings

bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
{
    // Set nearest to closest settings that do work.
    // See if what is in settings will work (return value).
    int err = 0;
    snd_pcm_t* handle;
    snd_pcm_hw_params_t *params;
    QString dev = device;

    QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput);

    if(dev.compare(QLatin1String("default")) == 0) {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        dev = QLatin1String(devices.first().constData());
#else
        dev = QLatin1String("hw:0,0");
#endif
    } else {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        dev = device;
#else
        int idx = 0;
        char *name;

        QString shortName = device.mid(device.indexOf(QLatin1String("="),0)+1);

        while(snd_card_get_name(idx,&name) == 0) {
            if(shortName.compare(QLatin1String(name)) == 0)
                break;
            idx++;
        }
        dev = QString(QLatin1String("hw:%1,0")).arg(idx);
#endif
    }
    if(mode == QAudio::AudioOutput) {
        err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0);
    } else {
        err=snd_pcm_open( &handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_CAPTURE,0);
    }
    if(err < 0) {
        handle = 0;
        return false;
    }

    bool testChannel = false;
    bool testCodec = false;
    bool testFreq = false;
    bool testType = false;
    bool testSize = false;

    int  dir = 0;

    snd_pcm_nonblock( handle, 0 );
    snd_pcm_hw_params_alloca( &params );
    snd_pcm_hw_params_any( handle, params );

    // set the values!
    snd_pcm_hw_params_set_channels(handle,params,format.channels());
    snd_pcm_hw_params_set_rate(handle,params,format.frequency(),dir);
    switch(format.sampleSize()) {
        case 8:
            if(format.sampleType() == QAudioFormat::SignedInt)
                snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
            else if(format.sampleType() == QAudioFormat::UnSignedInt)
                snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
            break;
        case 16:
            if(format.sampleType() == QAudioFormat::SignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
            } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
            }
            break;
        case 32:
            if(format.sampleType() == QAudioFormat::SignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
            } else if(format.sampleType() == QAudioFormat::UnSignedInt) {
                if(format.byteOrder() == QAudioFormat::LittleEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
                else if(format.byteOrder() == QAudioFormat::BigEndian)
                    snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
            }
    }

    // For now, just accept only audio/pcm codec
    if(!format.codec().startsWith(QLatin1String("audio/pcm"))) {
        err=-1;
    } else
        testCodec = true;

    if(err>=0 && format.channels() != -1) {
//.........这里部分代码省略.........
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:101,代码来源:qaudiodeviceinfo_alsa_p.cpp

示例7: setLanguage

/*!
	\param e target editor
	\param file filename displayed by the editor

	The \a file parameter may actuall be either a filename, an extension or the name of the language,
	checked in that order.

	If it is a filename, complete extension as higher priority than simple extension
	(see QFileInfo suffix() and completeSuffix()).

	Matches are first done case-sensitively.

	If no matching language definition is found for all three possible interpretations of the \a file
	parameter, the same search is done case-insensitively.

	If no matching language is found the previous language definition/completion engine of the editor
	are removed, leaving it blank, and the format scheme of the document is set to the defaultFormatScheme()
*/
void QLanguageFactory::setLanguage(QEditor *e, const QString& file)
{
	QString lang;
	QFileInfo inf(file);
	const QString ext = inf.suffix(),
				cext = inf.completeSuffix();

	//qDebug("suff:%s; compSuff:%s", qPrintable(ext), qPrintable(cext));

	QLanguageDefinition *oldLang = e->languageDefinition();

	if ( file.count() )
	{
		QList<Qt::CaseSensitivity> lcs;
		lcs << Qt::CaseSensitive << Qt::CaseInsensitive;

		foreach ( Qt::CaseSensitivity cs, lcs )
		{
			int n = 0, idx = -1;
			QStringList ext_langs, cext_langs, fcext_langs;

			foreach ( QString lang, m_languages )
			{
				const QStringList& exts = m_data[lang].extensions;

				//qDebug("%s in (%s) ?", qPrintable(ext), qPrintable(exts.join(" ")));

				foreach ( QString x, exts )
				{
					if ( !x.compare(ext, cs) )
						ext_langs << lang;

					if ( !x.compare(cext, cs) )
						cext_langs << lang;

					if ( !x.compare(file, cs) )
						fcext_langs << lang;
				}

				if ( !lang.compare(file, cs) )
					idx = n;

				++n;
			}

			if ( cext_langs.count() )
			{
				// TODO : use MIME types to resolve ambiguity
				lang = cext_langs.first();
			} else if ( ext_langs.count() ) {
				// TODO : use MIME types to resolve ambiguity
				lang = ext_langs.first();
			} else if ( fcext_langs.count() ) {
				// TODO : use MIME types to resolve ambiguity
				lang = fcext_langs.first();
			} else if ( idx != -1 ) {
				lang = m_languages.at(idx);
			}

			if ( lang.count() )
				break;
		}
开发者ID:svn2github,项目名称:texstudio,代码行数:80,代码来源:qlanguagefactory.cpp

示例8: open

bool QAudioOutputPrivate::open()
{
    if(opened)
        return true;

#ifdef DEBUG_AUDIO
    QTime now(QTime::currentTime());
    qDebug()<<now.second()<<"s "<<now.msec()<<"ms :open()";
#endif
    timeStamp.restart();
    elapsedTimeOffset = 0;

    int dir;
    int err = 0;
    int count=0;
    unsigned int freakuency=settings.frequency();

    if (!settings.isValid()) {
        qWarning("QAudioOutput: open error, invalid format.");
    } else if (settings.sampleRate() <= 0) {
        qWarning("QAudioOutput: open error, invalid sample rate (%d).",
                 settings.sampleRate());
    } else {
        err = -1;
    }

    if (err == 0) {
        errorState = QAudio::OpenError;
        deviceState = QAudio::StoppedState;
        emit errorChanged(errorState);
        return false;
    }

    QString dev = QString(QLatin1String(m_device.constData()));
    QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput);
    if(dev.compare(QLatin1String("default")) == 0) {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        if (devices.size() > 0)
            dev = QLatin1String(devices.first());
        else
            return false;
#else
        dev = QLatin1String("hw:0,0");
#endif
    } else {
#if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14)
        dev = QLatin1String(m_device);
#else
        int idx = 0;
        char *name;

        QString shortName = QLatin1String(m_device.mid(m_device.indexOf('=',0)+1).constData());

        while(snd_card_get_name(idx,&name) == 0) {
            if(qstrncmp(shortName.toLocal8Bit().constData(),name,shortName.length()) == 0)
                break;
            idx++;
        }
        dev = QString(QLatin1String("hw:%1,0")).arg(idx);
#endif
    }

    // Step 1: try and open the device
    while((count < 5) && (err < 0)) {
        err=snd_pcm_open(&handle,dev.toLocal8Bit().constData(),SND_PCM_STREAM_PLAYBACK,0);
        if(err < 0)
            count++;
    }
    if (( err < 0)||(handle == 0)) {
        errorState = QAudio::OpenError;
        emit errorChanged(errorState);
        deviceState = QAudio::StoppedState;
        return false;
    }
    snd_pcm_nonblock( handle, 0 );

    // Step 2: Set the desired HW parameters.
    snd_pcm_hw_params_alloca( &hwparams );

    bool fatal = false;
    QString errMessage;
    unsigned int chunks = 8;

    err = snd_pcm_hw_params_any( handle, hwparams );
    if ( err < 0 ) {
        fatal = true;
        errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_any: err = %1").arg(err);
    }
    if ( !fatal ) {
        err = snd_pcm_hw_params_set_rate_resample( handle, hwparams, 1 );
        if ( err < 0 ) {
            fatal = true;
            errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_rate_resample: err = %1").arg(err);
        }
    }
    if ( !fatal ) {
        err = snd_pcm_hw_params_set_access( handle, hwparams, access );
        if ( err < 0 ) {
            fatal = true;
            errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_access: err = %1").arg(err);
//.........这里部分代码省略.........
开发者ID:zccrs,项目名称:qt-mobility,代码行数:101,代码来源:qaudiooutput_alsa_p.cpp

示例9: requestStringToParameterMap

void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters )
{
  parameters.clear();


  //insert key and value into the map (parameters are separated by &)
  Q_FOREACH ( const QString& element, request.split( "&" ) )
  {
    int sepidx = element.indexOf( "=", 0, Qt::CaseSensitive );
    if ( sepidx == -1 )
    {
      continue;
    }

    QString key = element.left( sepidx );
    key = QUrl::fromPercentEncoding( key.toUtf8() ); //replace encoded special characters and utf-8 encodings

    QString value = element.mid( sepidx + 1 );
    value.replace( "+", " " );
    value = QUrl::fromPercentEncoding( value.toUtf8() ); //replace encoded special characters and utf-8 encodings

    if ( key.compare( "SLD_BODY", Qt::CaseInsensitive ) == 0 )
    {
      key = "SLD";
    }
    else if ( key.compare( "SLD", Qt::CaseInsensitive ) == 0 )
    {
      QByteArray fileContents;
      if ( value.startsWith( "http", Qt::CaseInsensitive ) )
      {
        QgsHttpTransaction http( value );
        if ( !http.getSynchronously( fileContents ) )
        {
          continue;
        }
      }
      else if ( value.startsWith( "ftp", Qt::CaseInsensitive ) )
      {
        QgsFtpTransaction ftp;
        if ( !ftp.get( value, fileContents ) )
        {
          continue;
        }
        value = QUrl::fromPercentEncoding( fileContents );
      }
      else
      {
        continue; //only http and ftp supported at the moment
      }
      value = QUrl::fromPercentEncoding( fileContents );

    }
    parameters.insert( key.toUpper(), value );
    QgsMessageLog::logMessage( "inserting pair " + key.toUpper() + " // " + value + " into the parameter map" );
  }

  //feature info format?
  QString infoFormat = parameters.value( "INFO_FORMAT" );
  if ( !infoFormat.isEmpty() )
  {
    mFormat = infoFormat;
  }
  else //capabilities format or GetMap format
  {
    mFormatString = parameters.value( "FORMAT" );
    QString formatString = mFormatString;
    if ( !formatString.isEmpty() )
    {
      QgsMessageLog::logMessage( QString( "formatString is: %1" ).arg( formatString ) );

      //remove the image/ in front of the format
      if ( formatString.contains( "image/png", Qt::CaseInsensitive ) || formatString.compare( "png", Qt::CaseInsensitive ) == 0 )
      {
        formatString = "PNG";
      }
      else if ( formatString.contains( "image/jpeg", Qt::CaseInsensitive ) || formatString.contains( "image/jpg", Qt::CaseInsensitive )
                || formatString.compare( "jpg", Qt::CaseInsensitive ) == 0 )
      {
        formatString = "JPG";
      }
      else if ( formatString.compare( "svg", Qt::CaseInsensitive ) == 0 )
      {
        formatString = "SVG";
      }
      else if ( formatString.contains( "pdf", Qt::CaseInsensitive ) )
      {
        formatString = "PDF";
      }

      mFormat = formatString;
    }
  }

}
开发者ID:Naisha634,项目名称:QGIS,代码行数:94,代码来源:qgshttprequesthandler.cpp

示例10: UpdateCurveUI

void MixerCurve::UpdateCurveUI()
{
    // get the user settings
    QString curveType = m_mixerUI->CurveType->currentText();


    m_mixerUI->CurveStep->setMinimum(0.0);
    m_mixerUI->CurveStep->setMaximum(100.0);
    m_mixerUI->CurveStep->setSingleStep(1.00);

    // set default visible
    m_mixerUI->minLabel->setVisible(true);
    m_mixerUI->CurveMin->setVisible(true);
    m_mixerUI->maxLabel->setVisible(false);
    m_mixerUI->CurveMax->setVisible(false);
    m_mixerUI->stepLabel->setVisible(false);
    m_mixerUI->CurveStep->setVisible(false);

    if (curveType.compare("Flat") == 0) {
        m_mixerUI->minLabel->setVisible(false);
        m_mixerUI->CurveMin->setVisible(false);
        m_mixerUI->stepLabel->setVisible(true);
        m_mixerUI->CurveStep->setVisible(true);
        m_mixerUI->CurveStep->setMinimum(m_mixerUI->CurveMin->minimum());
        m_mixerUI->CurveStep->setMaximum(m_mixerUI->CurveMax->maximum());
        m_mixerUI->CurveStep->setSingleStep(0.01);
        m_mixerUI->CurveStep->setValue(m_mixerUI->CurveMax->value() / 2);
    }
    if (curveType.compare("Linear") == 0) {
        m_mixerUI->maxLabel->setVisible(true);
        m_mixerUI->CurveMax->setVisible(true);
    }
    if (curveType.compare("Step") == 0) {
        m_mixerUI->maxLabel->setVisible(true);
        m_mixerUI->CurveMax->setVisible(true);
        m_mixerUI->stepLabel->setText("Step at");
        m_mixerUI->stepLabel->setVisible(true);
        m_mixerUI->CurveStep->setVisible(true);

        m_mixerUI->CurveStep->setMinimum(1.0);
    }
    if (curveType.compare("Exp") == 0) {
        m_mixerUI->maxLabel->setVisible(true);
        m_mixerUI->CurveMax->setVisible(true);
        m_mixerUI->stepLabel->setText("Power");
        m_mixerUI->stepLabel->setVisible(true);
        m_mixerUI->CurveStep->setVisible(true);

        m_mixerUI->CurveStep->setMinimum(1.0);
    }
    if (curveType.compare("Log") == 0) {
        m_mixerUI->maxLabel->setVisible(true);
        m_mixerUI->CurveMax->setVisible(true);
        m_mixerUI->stepLabel->setText("Power");
        m_mixerUI->stepLabel->setVisible(true);
        m_mixerUI->CurveStep->setVisible(true);
        m_mixerUI->CurveStep->setMinimum(1.0);
    }

    GenerateCurve();
}
开发者ID:nongxiaoming,项目名称:QGroundStation,代码行数:61,代码来源:mixercurve.cpp

示例11: query

QVariant QSystemLocale::query(QueryType type, QVariant in) const
{
    QSystemLocaleData *d = qSystemLocaleData();

    if (type == LocaleChanged) {
        d->readEnvironment();
        return QVariant();
    }

    QReadLocker locker(&d->lock);

    const QLocale &lc_numeric = d->lc_numeric;
    const QLocale &lc_time = d->lc_time;
    const QLocale &lc_monetary = d->lc_monetary;
    const QLocale &lc_messages = d->lc_messages;

    switch (type) {
    case DecimalPoint:
        return lc_numeric.decimalPoint();
    case GroupSeparator:
        return lc_numeric.groupSeparator();
    case ZeroDigit:
        return lc_numeric.zeroDigit();
    case NegativeSign:
        return lc_numeric.negativeSign();
    case DateFormatLong:
        return lc_time.dateFormat(QLocale::LongFormat);
    case DateFormatShort:
        return lc_time.dateFormat(QLocale::ShortFormat);
    case TimeFormatLong:
        return lc_time.timeFormat(QLocale::LongFormat);
    case TimeFormatShort:
        return lc_time.timeFormat(QLocale::ShortFormat);
    case DayNameLong:
        return lc_time.dayName(in.toInt(), QLocale::LongFormat);
    case DayNameShort:
        return lc_time.dayName(in.toInt(), QLocale::ShortFormat);
    case MonthNameLong:
        return lc_time.monthName(in.toInt(), QLocale::LongFormat);
    case MonthNameShort:
        return lc_time.monthName(in.toInt(), QLocale::ShortFormat);
    case StandaloneMonthNameLong:
        return lc_time.standaloneMonthName(in.toInt(), QLocale::LongFormat);
    case StandaloneMonthNameShort:
        return lc_time.standaloneMonthName(in.toInt(), QLocale::ShortFormat);
    case DateToStringLong:
        return lc_time.toString(in.toDate(), QLocale::LongFormat);
    case DateToStringShort:
        return lc_time.toString(in.toDate(), QLocale::ShortFormat);
    case TimeToStringLong:
        return lc_time.toString(in.toTime(), QLocale::LongFormat);
    case TimeToStringShort:
        return lc_time.toString(in.toTime(), QLocale::ShortFormat);
    case DateTimeFormatLong:
        return lc_time.dateTimeFormat(QLocale::LongFormat);
    case DateTimeFormatShort:
        return lc_time.dateTimeFormat(QLocale::ShortFormat);
    case DateTimeToStringLong:
        return lc_time.toString(in.toDateTime(), QLocale::LongFormat);
    case DateTimeToStringShort:
        return lc_time.toString(in.toDateTime(), QLocale::ShortFormat);
    case PositiveSign:
        return lc_numeric.positiveSign();
    case AMText:
        return lc_time.amText();
    case PMText:
        return lc_time.pmText();
    case FirstDayOfWeek:
        return lc_time.firstDayOfWeek();
    case CurrencySymbol:
        return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
    case CurrencyToString: {
        switch (in.type()) {
        case QVariant::Int:
            return lc_monetary.toCurrencyString(in.toInt());
        case QVariant::UInt:
            return lc_monetary.toCurrencyString(in.toUInt());
        case QVariant::Double:
            return lc_monetary.toCurrencyString(in.toDouble());
        case QVariant::LongLong:
            return lc_monetary.toCurrencyString(in.toLongLong());
        case QVariant::ULongLong:
            return lc_monetary.toCurrencyString(in.toULongLong());
        default:
            break;
        }
        return QString();
    }
    case MeasurementSystem: {
        const QString meas_locale = QString::fromLatin1(d->lc_measurement_var.constData(), d->lc_measurement_var.size());
        if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0)
            return QLocale::MetricSystem;
        if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0)
            return QLocale::MetricSystem;
        return QVariant((int)QLocale(meas_locale).measurementSystem());
    }
    case UILanguages: {
        if (!d->uiLanguages.isEmpty())
            return d->uiLanguages;
        QString languages = QString::fromLatin1(qgetenv("LANGUAGE"));
//.........这里部分代码省略.........
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:101,代码来源:qlocale_unix.cpp

示例12: charger

void Tree::charger(QString fileName)
{
    m_file = fileName;
    if (!fileName.endsWith(".ply")){
        qDebug() << "L'objet 3D doit etre defini dans un fichier au format ply";
        return;
    }

    QFile fichier(fileName);
    if (!fichier.open(QIODevice::ReadOnly | QIODevice::Text)){
        qDebug() << "Erreur lors de l'ouveture du fichier";
    }
    QTextStream flux(&fichier);

    int nbVertices = -1, nbFaces = -1;

    while ( !flux.atEnd() ){
        QString data = flux.readLine();
        if (data.section(" ", 0,0).compare("element")==0 || data.section(" ", 1,1).compare("vertex")==0){
            nbVertices = data.section(" ", 2,2).toInt();
            break;
        }
    }

    while ( !flux.atEnd() ){
        QString data = flux.readLine();
        if (data.section(" ", 0,0).compare("element")==0 || data.section(" ", 1,1).compare("face")==0){
            nbFaces = data.section(" ", 2,2).toInt();
            break;
        }
    }

    while ( !flux.atEnd() ){
        QString data = flux.readLine();
        if (data.compare("end_header")==0){
            break;
        }
    }

    if (nbVertices == -1 || nbFaces == -1 || flux.atEnd()){
        qDebug() << "Probleme de lecture du fichier ply";
        return;
    }

    m_nbVertices = nbVertices;

    m_vertices = new point[nbVertices];
    m_normales = new point[nbVertices];

    for (int i=0; i<nbVertices; i++){
        flux >> m_vertices[i].x; flux >> m_vertices[i].y; flux >> m_vertices[i].z;
        flux >> m_normales[i].x; flux >> m_normales[i].y; flux >> m_normales[i].z;
    }

    m_indices = new int[nbFaces*6];
    QString nb, t0, t1, t2, t3;
    int k=0;
    for (int i=0; i<nbFaces; i++){
        flux >> nb;
        //TRIANGLE
        if (nb.toInt() == 3){
            flux >> t0; flux >> t1; flux >> t2;
            m_indices[k] = t0.toInt(); m_indices[k+1] = t1.toInt(); m_indices[k+2] = t2.toInt();
            k+=3;
        }
        //QUAD
        if (nb.toInt() == 4){
            flux >> t0; flux >> t1; flux >> t2; flux >> t3;
            m_indices[k] = t0.toInt(); m_indices[k+1] = t1.toInt(); m_indices[k+2] = t2.toInt();
            m_indices[k+3] = t0.toInt(); m_indices[k+4] = t2.toInt(); m_indices[k+5] = t3.toInt();
            k+=6;
        }
开发者ID:bidonjour,项目名称:TP4,代码行数:72,代码来源:tree.cpp

示例13: saveHeaderData

void UpgradeMessage::saveHeaderData (DbPlugin &db, QString &k, QString &d, QString &sym, DBIndexItem &item)
{
  // is this a co key?
  bool ok = FALSE;
  double t = k.toDouble(&ok);
  if (ok)
  {
    if (t < 10000)
    {
      // its a chart object
      Setting t;
      t.parse(d);
      QString s = "Plugin";
      QString s2;
      t.getData(s,s2);
      if (s2.length())
      {
        t.remove(s);
        s = "Type";
        t.setData(s, s2);
      }

      s = "Plot";
      t.getData(s, s2);
      if (! s2.compare("Main Plot"))
      {
        s2 = "Bars";
        t.setData(s, s2);
      }
      else
        return;

      index.setChartObject(sym, k, t);
      return;
    }
  }

  if (! k.compare("Type"))
  {
    item.setType(d);
    return;
  }

  if (! k.compare("FuturesType"))
  {
    item.setFuturesType(d);
    return;
  }

  if (! k.compare("FuturesMonth"))
  {
    item.setFuturesMonth(d);
    return;
  }

  if (! k.compare("BarType"))
  {
    item.setBarType(d);
    return;
  }

  if (! k.compare("Fundamentals"))
  {
    index.setFundamentals(sym, d);
    return;
  }

  if (! k.compare("LocalIndicators"))
  {
    index.addIndicator(sym, d);
    return;
  }

  if (! k.compare("QuotePlugin"))
  {
    item.setQuotePlugin(d);
    return;
  }

  if (! k.compare("Symbol"))
  {
    item.setSymbol(d);
    return;
  }

  if (! k.compare("Title"))
  {
    item.setTitle(d);
    return;
  }

  if (! k.compare("Path"))
  {
    item.setPath(d);
    return;
  }

  if (! k.compare("SpreadFirstSymbol"))
  {
    int t = d.find("/data0/", 0, TRUE);
//.........这里部分代码省略.........
开发者ID:botvs,项目名称:FinancialAnalytics,代码行数:101,代码来源:UpgradeMessage.cpp

示例14: drv_isSystemFieldName

bool SqliteDriver::drv_isSystemFieldName(const QString& name) const
{
    return    0 == name.compare(QLatin1String("_rowid_"), Qt::CaseInsensitive)
              || 0 == name.compare(QLatin1String("rowid"), Qt::CaseInsensitive)
              || 0 == name.compare(QLatin1String("oid"), Qt::CaseInsensitive);
}
开发者ID:KDE,项目名称:kdb,代码行数:6,代码来源:SqliteDriver.cpp

示例15: supportedOutputCrsList

QStringList QgsServerProjectParser::supportedOutputCrsList() const
{
  QStringList crsList;
  if ( !mXMLDoc )
  {
    return crsList;
  }

  QDomElement qgisElem = mXMLDoc->documentElement();
  if ( qgisElem.isNull() )
  {
    return crsList;
  }
  QDomElement propertiesElem = qgisElem.firstChildElement( "properties" );
  if ( propertiesElem.isNull() )
  {
    return crsList;
  }
  QDomElement wmsCrsElem = propertiesElem.firstChildElement( "WMSCrsList" );
  if ( !wmsCrsElem.isNull() )
  {
    QDomNodeList valueList = wmsCrsElem.elementsByTagName( "value" );
    for ( int i = 0; i < valueList.size(); ++i )
    {
      crsList.append( valueList.at( i ).toElement().text() );
    }
  }
  else
  {
    QDomElement wmsEpsgElem = propertiesElem.firstChildElement( "WMSEpsgList" );
    if ( !wmsEpsgElem.isNull() )
    {
      QDomNodeList valueList = wmsEpsgElem.elementsByTagName( "value" );
      bool conversionOk;
      for ( int i = 0; i < valueList.size(); ++i )
      {
        int epsgNr = valueList.at( i ).toElement().text().toInt( &conversionOk );
        if ( conversionOk )
        {
          crsList.append( QString( "EPSG:%1" ).arg( epsgNr ) );
        }
      }
    }
    else
    {
      //no CRS restriction defined in the project. Provide project CRS, wgs84 and pseudo mercator
      QString projectCrsId = projectCRS().authid();
      crsList.append( projectCrsId );
      if ( projectCrsId.compare( "EPSG:4326", Qt::CaseInsensitive ) != 0 )
      {
        crsList.append( QString( "EPSG:%1" ).arg( 4326 ) );
      }
      if ( projectCrsId.compare( "EPSG:3857", Qt::CaseInsensitive ) != 0 )
      {
        crsList.append( QString( "EPSG:%1" ).arg( 3857 ) );
      }
    }
  }

  return crsList;
}
开发者ID:Naisha634,项目名称:QGIS,代码行数:61,代码来源:qgsserverprojectparser.cpp


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