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


C++ QTextCodec::name方法代码示例

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


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

示例1: accept

void PreviewForm::accept() {
    int mib = encodingComboBox->itemData(
                      encodingComboBox->currentIndex()).toInt();
    QTextCodec *codec = QTextCodec::codecForMib(mib);
    qDebug () << " PreviewForm::accept() returning codec name " << codec->name();
    emit userCodec(fileName, codec->name(), format);
    QDialog::accept();

}
开发者ID:Iownnoname,项目名称:qt,代码行数:9,代码来源:previewform.cpp

示例2: foreach

/// The codecmanager constructs
/// This method registeres all codecs available in Qt
TextCodecManager::TextCodecManager()
{
    // append all special encodings
    QList<QByteArray> encList;
    encList << "UTF-8" << "UTF-16" << "UTF-16BE" << "UTF-16LE" << "UTF-32" << "UTF-32BE" << "UTF-32LE";
    foreach( QByteArray enc, encList ) {
        QTextCodec* codec = QTextCodec::codecForName(enc);
        giveTextCodec( new TextCodec( QString(codec->name()), codec, QTextCodec::IgnoreHeader ) );
        giveTextCodec( new TextCodec( QStringLiteral("%1 with BOM").arg( QString(codec->name()) ), codec, QTextCodec::DefaultConversion ) );
    }
开发者ID:edbee,项目名称:edbee-lib,代码行数:12,代码来源:textcodec.cpp

示例3: newDocument

Document* FileManager::newDocument() {
    const QString filenameScheme = QObject::tr("New File %0");
    static int counter = 0;

    QString filename;
    bool findNewFilename = false;
    do {
        filename = filenameScheme.arg(++counter);
        foreach(Document* d, m_documents) {
            if(d->documentInfo()->fileName() == filename) {
                findNewFilename = true;
                break;
            }
        }
    }while(findNewFilename);

    QTextCodec* codec = ApplicationManager::settings()->defaultEncoding();
    DocumentInfo docinfo(filename,codec->name(),0);

    Document* doc = new Document(docinfo, QString());

    m_documents.append(doc);
    m_documentMap.insert(filename, doc);

    emit documentOpened(doc);
    return doc;
}
开发者ID:BackupTheBerlios,项目名称:lprojector-svn,代码行数:27,代码来源:FileManager.cpp

示例4: staticCharset

static
const char * staticCharset(int i)
{
    static QCString localcharset;

    switch ( i ) {
      case 0:
	return "UTF-8";
      case 1:
	return "ISO-10646-UCS-2";
      case 2:
	return ""; // in the 3rd place - some Xdnd targets might only look at 3
      case 3:
	if ( localcharset.isNull() ) {
	    QTextCodec *localCodec = QTextCodec::codecForLocale();
	    if ( localCodec ) {
		localcharset = localCodec->name();
		localcharset = localcharset.lower();
		stripws(localcharset);
	    } else {
		localcharset = "";
	    }
	}
	return localcharset;
    }
    return 0;
}
开发者ID:kthxbyte,项目名称:QT2-Linaro,代码行数:27,代码来源:qdragobject.cpp

示例5: doParseHeader

TWScript::ParseHeaderResult TWScript::doParseHeader(const QStringList & lines)
{
	QString line, key, value;
	QFileInfo fi(m_Filename);
	
	m_FileSize = fi.size();
	m_LastModified = fi.lastModified();
	
	foreach (line, lines) {
		key = line.section(':', 0, 0).trimmed();
		value = line.section(':', 1).trimmed();
		
		if (key == "Title") m_Title = value;
		else if (key == "Description") m_Description = value;
		else if (key == "Author") m_Author = value;
		else if (key == "Version") m_Version = value;
		else if (key == "Script-Type") {
			if (value == "hook") m_Type = ScriptHook;
			else if (value == "standalone") m_Type = ScriptStandalone;
			else m_Type = ScriptUnknown;
		}
		else if (key == "Hook") m_Hook = value;
		else if (key == "Context") m_Context = value;
		else if (key == "Shortcut") m_KeySequence = QKeySequence(value);
		else if (key == "Encoding") {
			QTextCodec * codec = QTextCodec::codecForName(value.toUtf8());
			if (codec) {
				if (!m_Codec || codec->name() != m_Codec->name()) {
					m_Codec = codec;
					return ParseHeader_CodecChanged;
				}
			}
		}
	}
开发者ID:stloeffler,项目名称:TeXworks-sharpie,代码行数:34,代码来源:TWScript.cpp

示例6: populateCharacterEncodingMenu

void Menu::populateCharacterEncodingMenu()
{
	if (!m_actionGroup)
	{
		QList<int> textCodecs;
		textCodecs << 106 << 1015 << 1017 << 4 << 5 << 6 << 7 << 8 << 82 << 10 << 85 << 12 << 13 << 109 << 110 << 112 << 2250 << 2251 << 2252 << 2253 << 2254 << 2255 << 2256 << 2257 << 2258 << 18 << 39 << 17 << 38 << 2026;

		m_actionGroup = new QActionGroup(this);
		m_actionGroup->setExclusive(true);

		QAction *defaultAction = QMenu::addAction(tr("Auto Detect"));
		defaultAction->setData(-1);
		defaultAction->setCheckable(true);

		m_actionGroup->addAction(defaultAction);

		addSeparator();

		for (int i = 0; i < textCodecs.count(); ++i)
		{
			QTextCodec *codec = QTextCodec::codecForMib(textCodecs.at(i));

			if (!codec)
			{
				continue;
			}

			QAction *textCodecAction = QMenu::addAction(Utils::elideText(codec->name(), this));
			textCodecAction->setData(textCodecs.at(i));
			textCodecAction->setCheckable(true);

			m_actionGroup->addAction(textCodecAction);
		}
	}

	MainWindow *mainWindow = MainWindow::findMainWindow(parent());
	const QString encoding = (mainWindow ? mainWindow->getWindowsManager()->getOption(QLatin1String("Content/DefaultCharacterEncoding")).toString().toLower() : QString());

	for (int i = 2; i < actions().count(); ++i)
	{
		QAction *action = actions().at(i);

		if (!action)
		{
			continue;
		}

		action->setChecked(encoding == action->text().toLower());

		if (action->isChecked())
		{
			break;
		}
	}

	if (!m_actionGroup->checkedAction() && !actions().isEmpty())
	{
		actions().first()->setChecked(true);
	}
}
开发者ID:sietse,项目名称:otter-browser,代码行数:60,代码来源:Menu.cpp

示例7:

/*!
 *\en
 *
 *\_en \ru
 *
 *\_ru
 */
QString
AExtText::getCodec() const
{
	QTextCodec *codec = text->codec();
	if ( codec ) return codec->name();
	return "";
}
开发者ID:K-Be,项目名称:ananas-labs-qt4,代码行数:14,代码来源:aexttext.cpp

示例8: openDocument

Document* FileManager::openDocument(const QString& filename, QString* error) {
    QFileInfo fi(filename);
    QFile file(filename);

    if (!(fi.exists() && fi.isFile())){
        if(error)
            *error = tr("The file <br>\"%0\" <br>does not "
                        "exist or is no file.")
                        .arg(fi.absolutePath());
        return 0;
    }

    if (!file.open(QIODevice::ReadOnly|QIODevice::Text)){
        if(error)
            *error = tr("Unable to open the file<br>\"%0\" <br>"
                        "Check permissions or wether other programs "
                        "are locking the file.")
                        .arg(fi.absolutePath());
        return 0;
    }

    QByteArray contents = file.readAll();
    EncodingDetector detector(contents);
    QTextCodec* codec = detector.GetFontEncoding();//TODO:Delete?
    DocumentInfo docinfo(cleanPath(filename),codec->name(),fi.size());

    Document* doc = new Document(docinfo, codec->toUnicode(contents));
    file.close();

    m_documents.append(doc);
    m_documentMap.insert(cleanPath(filename), doc);

    emit documentOpened(doc);
    return doc;
}
开发者ID:BackupTheBerlios,项目名称:lprojector-svn,代码行数:35,代码来源:FileManager.cpp

示例9: openDocUrl

KTextEditor::Document* KateApp::openDocUrl (const KUrl &url, const QString &encoding, bool isTempFile)
{
  KateMainWindow *mainWindow = activeMainWindow ();

  if (!mainWindow)
    return 0;

  QTextCodec *codec = encoding.isEmpty() ? 0 : QTextCodec::codecForName(encoding.toLatin1());

  // this file is no local dir, open it, else warn
  bool noDir = !url.isLocalFile() || !QFileInfo (url.toLocalFile()).isDir();

  KTextEditor::Document *doc=0;
  
  if (noDir)
  {
    // show no errors...
    documentManager()->setSuppressOpeningErrorDialogs (true);

    // open a normal file
    if (codec)
      doc=mainWindow->viewManager()->openUrl( url, codec->name(), true, isTempFile);
    else
      doc=mainWindow->viewManager()->openUrl( url, QString(), true, isTempFile );
    
    // back to normal....
    documentManager()->setSuppressOpeningErrorDialogs (false);
  }
  else
    KMessageBox::sorry( mainWindow,
                        i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.url()) );

  return doc;
}
开发者ID:dividedmind,项目名称:kate,代码行数:34,代码来源:kateapp.cpp

示例10: setEncoding

bool Terminal::setEncoding(const QString& encoding)
{
    // Since there can be multiple names for the same codec (i.e., "utf8" and
    // "utf-8"), we need to get the codec in the system first and use its
    // canonical name
    QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
    if (!codec) {
        return false;
    }

    // Check whether encoding actually needs to be changed
    const QString encodingBeforeUpdate(m_encoding.getName());
    if (0 == encodingBeforeUpdate.compare(QString(codec->name()), Qt::CaseInsensitive)) {
        return false;
    }

    m_encoding.setEncoding(encoding);

    // Emit the signal only if the encoding actually was changed
    const QString encodingAfterUpdate(m_encoding.getName());
    if (0 == encodingBeforeUpdate.compare(encodingAfterUpdate, Qt::CaseInsensitive)) {
        return false;
    }

    emit encodingChanged(encoding);

    return true;
}
开发者ID:DeviaVir,项目名称:phantomjs,代码行数:28,代码来源:terminal.cpp

示例11: cancel

/*!
	\brief Reset the subcontrols to reflect the current settings
	
	The name can be a bit misleading at first, it has been chosen
	because it directly maps to the effect a "cancel" button would
	have on the widget
*/
void QEditConfig::cancel()
{
	// reload the current config
	
	bool oldDir = m_direct;
	
	m_direct = false;
	
	cbFont->setFont(QDocument::font());
	spnFontSize->setValue(QDocument::font().pointSize());
	
	spnTabWidth->setValue(QDocument::tabStop());
	
	QDocument::WhiteSpaceMode ws = QDocument::showSpaces();
	chkShowTabsInText->setChecked(ws & QDocument::ShowTabs);
	chkShowLeadingWhitespace->setChecked(ws & QDocument::ShowLeading);
	chkShowTrailingWhitespace->setChecked(ws & QDocument::ShowTrailing);
	
	QDocument::LineEnding le = QDocument::defaultLineEnding();
	chkDetectLE->setChecked(le == QDocument::Conservative);
	cbLineEndings->setCurrentIndex(le ? le - 1 : 0);
	
	int flags = QEditor::defaultFlags();
	chkReplaceTabs->setChecked(flags & QEditor::ReplaceTabs);
	chkAutoRemoveTrailingWhitespace->setChecked(flags & QEditor::RemoveTrailing);
	chkPreserveTrailingIndent->setChecked(flags & QEditor::PreserveTrailingIndent);
	
	QTextCodec *c = QEditor::defaultCodec();
	cbEncoding->setCurrentIndex(cbEncoding->findText(c ? c->name() : QTextCodec::codecForLocale()->name()));
	
	m_direct = oldDir;
}
开发者ID:TheProjecter,项目名称:pockemul,代码行数:39,代码来源:qeditconfig.cpp

示例12: createCodecComboBox

void TransferTab::createCodecComboBox()
{
    QMap<QString, QString> codecMap;
    QRegExp iso8859RegExp("ISO[- ]8859-([0-9]+).*");

    foreach (QByteArray name, QTextCodec::availableCodecs()) {
        QTextCodec *codec = QTextCodec::codecForName(name);

        QString sortKey = codec->name().toUpper();
        int rank;

        if (sortKey.startsWith("UTF-8")) {
            rank = 1;
        } else if (sortKey.startsWith("UTF-16")) {
            rank = 2;
        } else if (iso8859RegExp.exactMatch(sortKey)) {
            if (iso8859RegExp.cap(1).size() == 1)
                rank = 3;
            else
                rank = 4;
        } else {
            rank = 5;
        }
        sortKey.prepend(QChar('0' + rank));

        codecMap.insert(sortKey, QString(name));
    }
开发者ID:foxwolf,项目名称:qipmsg,代码行数:27,代码来源:setup_window.cpp

示例13: saveProperties

void KviWindow::saveProperties(KviConfigurationFile * pCfg)
{
	// store only the non-default text encoding.
	QString szCodec = m_szTextEncoding;
	QTextCodec * pCodec = defaultTextCodec();
	if(pCodec && m_pTextCodec)
	{
		if(KviQString::equalCI(szCodec, pCodec->name().data()))
			szCodec = KviQString::Empty; // store "default"
	}

	if(!szCodec.isEmpty())
		pCfg->writeEntry("TextEncoding", szCodec);
	if(m_pInput)
	{
		pCfg->writeEntry("inputToolButtonsHidden", m_pInput->isButtonsHidden());
		pCfg->writeEntry("commandLineIsUserFriendly", m_pInput->isUserFriendly());
	}

	/*
	if(m_pIrcView && m_eType == KviWindow::Channel)
	if(m_pIrcView->isLogging())
		pCfg->writeEntry("LoggingEnabled",m_pIrcView->isLogging());
	*/
}
开发者ID:Cizzle,项目名称:KVIrc,代码行数:25,代码来源:KviWindow.cpp

示例14: showTextEncoding

void MainWindow::showTextEncoding(QWidget* viewer)
{
    QTextCodec* textCodec = LOGVIEWERMANAGER()->textCodec(viewer);
    Q_ASSERT(textCodec);

    QString name = textCodec->name();
    static_cast<StatusBar*>(statusBar())->setTextCodec(name);
}
开发者ID:joonhwan,项目名称:monkeylogviewer,代码行数:8,代码来源:MainWindow.cpp

示例15: main

int main( int argc, char ** argv )
{
  QApplication a( argc, argv );
  a.setOrganizationName(ORGNAME);
  a.setOrganizationDomain(ORGDOMAIN);
  a.setApplicationName(APPNAME);

  MyPasswordSafe myps;

  QTextCodec *codec = QTextCodec::codecForLocale();
  QTranslator qt(0);
#ifdef DEBUG
  cout << "Using locale: " << (const char *)codec->name() << endl;
#endif
  qt.load(QString("qt_") + codec->name(), locale_dir);
  a.installTranslator(&qt);
  QTranslator myapp(0);
  if(!myapp.load(QString("mypasswordsafe_") + codec->name(),
		 locale_dir)) {
#ifdef DEBUG
    cout << "No locale file for " << (const char *)codec->name()
	 << " found in " << locale_dir << endl;
#endif
  }
  else {
    a.installTranslator(&myapp);
  }

  if(myps.firstTime()) {
    myps.helpAbout(1); // show license
  }

  if(!doStartupDialog(&myps, argc, argv)) {
    return 0;
  }

  myps.show();
  //a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
  a.connect(&myps, SIGNAL(quit()), &a, SLOT(quit()));
  return a.exec();
}
开发者ID:SemanticGap,项目名称:mypasswordsafe,代码行数:41,代码来源:main.cpp


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