本文整理汇总了C++中QChar::digitValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::digitValue方法的具体用法?C++ QChar::digitValue怎么用?C++ QChar::digitValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::digitValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pasteLIFE_add
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::pasteLIFE_add (QString line)
{
int cN = 0;
for (QString::const_iterator it = line.constBegin();
it != line.constEnd(); it++) {
QChar c = *it;
if (c.isDigit()) cN = 10*cN + c.digitValue();
else {
if (cN == 0) cN = 1;
switch (c.unicode()) {
case '.':
cX += cN;
cN = 0;
break;
case '*':
case 'O':
while (cN > 0) {
add(cX, cY, elcDefault);
cX++;
cN--;
}
}
}
}
cX = cX0;
cY++;
}
示例2: fromString
FretDiagram* FretDiagram::fromString(Score* score, const QString &s)
{
FretDiagram* fd = new FretDiagram(score);
fd->setStrings(s.size());
fd->setFrets(4);
int offset = 0;
int barreString = -1;
for (int i = 0; i < s.size(); i++) {
QChar c = s.at(i);
if (c == 'X' or c == 'O')
fd->setMarker(i, c.unicode());
else if (c == '-' && barreString == -1) {
fd->setBarre(1);
barreString = i;
}
else {
int fret = c.digitValue();
if (fret != -1) {
fd->setDot(i, fret);
if (fret - 3 > 0 && offset < fret - 3)
offset = fret - 3;
}
}
}
if (offset > 0) {
fd->setOffset(offset);
for (int i = 0; i < fd->strings(); i++)
if (fd->dot(i))
fd->setDot(i, fd->dot(i) - offset);
}
if (barreString >= 0)
fd->setDot(barreString, 1);
return fd;
}
示例3: runtime_error
LevelFile::LevelFile(QString file)
{
// open file
level = new QFile(file);
if(!level->open(QIODevice::ReadOnly)) {
throw runtime_error("Couldn't open file");
}
// create stream
QTextStream in(level);
in.setIntegerBase(10);
// read through file, put into map
QChar l;
int row = 0;
map.append(Row());
while(!in.atEnd()) {
in >> l; // read each letter
if(l == QChar::Space) // ignore space
continue;
else if(l == QChar::LineFeed) { // new row
map.append(Row());
row++;
}
else if(l.isNumber()) { // add number to map
map[row].append(l.digitValue());
}
}
level->close();
}
示例4: applyPatternToColumns
void TagConverter::applyPatternToColumns()
{
QList<int> columns;
//QRegularExpression re = this->generatePattern2(fileToTagLineEdit);
///
QString text = fileToTagLineEdit->text();
text = text.replace(':', '_');
// Remove and convert spaces according to columns
for (int i = fileToTagLineEdit->tags().count() - 1; i >= 0; i--) {
TagButton *tag = fileToTagLineEdit->tags().at(i);
QString substitution = ':' + QString::number(tag->column());
columns.prepend(tag->column());
text.replace(tag->position(), tag->spaceCount(), substitution);
}
QString pattern = "^";
QString characterClass;
// Depending on which detected columns, choose a sub-regex
for (int i = 0; i < text.size(); i++) {
QChar c = text.at(i);
if (c == ':') {
c = text.at(++i);
switch (c.digitValue()) {
case Miam::COL_Track:
case Miam::COL_Year:
case Miam::COL_Disc:
characterClass = "[\\d]+"; // Digits
break;
default:
characterClass = "[\\w\\W]+";
break;
}
pattern += "(" + characterClass + ")";
} else {
pattern += QRegularExpression::escape(text.at(i));
}
}
pattern += "$";
QRegularExpression re(pattern, QRegularExpression::UseUnicodePropertiesOption);
for (QModelIndex index : _tagEditor->selectionModel()->selectedRows()) {
QString filename = index.data().toString();
filename = filename.left(filename.lastIndexOf("."));
QRegularExpressionMatch m = re.match(filename);
if (!m.hasMatch()) {
continue;
}
// The implicit capturing group with index 0 captures the result of the whole match.
for (int i = 0; i < re.captureCount(); i++) {
_tagEditor->updateCellData(index.row(), columns.at(i), m.captured(i + 1));
}
}
this->setVisible(false);
_convertButton->setChecked(false);
}
示例5: if
static int hex2int( QChar hexchar )
{
int v;
if ( hexchar.isDigit() )
v = hexchar.digitValue();
else if ( hexchar >= 'A' && hexchar <= 'F' )
v = hexchar.cell() - 'A' + 10;
else if ( hexchar >= 'a' && hexchar <= 'f' )
v = hexchar.cell() - 'a' + 10;
else
v = -1;
return v;
}
示例6: addDigit
bool PatternFormatter::addDigit(const QChar &rDigit,
int &rValue)
{
if (!rDigit.isDigit())
return false;
int digit_value = rDigit.digitValue();
if (rValue > (INT_MAX - digit_value) / 10)
rValue = INT_MAX;
else
rValue = rValue * 10 + digit_value;
return true;
}
示例7: hexDigitToDecimalValue
uint CSVController::hexDigitToDecimalValue(const QChar& c) const
{
if (c.isDigit())
{
return c.digitValue();
}
else if ('a' <= c && c <= 'f')
{
return c.unicode() - 'a' + 10;
}
else if ('A' <= c && c <= 'F')
{
return c.unicode() - 'A' + 10;
}
return 0;
}
示例8: typified
QString CodeMarker::typified(const QString &string)
{
QString result;
QString pendingWord;
for (int i = 0; i <= string.size(); ++i) {
QChar ch;
if (i != string.size())
ch = string.at(i);
QChar lower = ch.toLower();
if ((lower >= QLatin1Char('a') && lower <= QLatin1Char('z'))
|| ch.digitValue() >= 0 || ch == QLatin1Char('_')
|| ch == QLatin1Char(':')) {
pendingWord += ch;
}
else {
if (!pendingWord.isEmpty()) {
bool isProbablyType = (pendingWord != QLatin1String("const"));
if (isProbablyType)
result += QLatin1String("<@type>");
result += pendingWord;
if (isProbablyType)
result += QLatin1String("</@type>");
}
pendingWord.clear();
switch (ch.unicode()) {
case '\0':
break;
case '&':
result += QLatin1String("&");
break;
case '<':
result += QLatin1String("<");
break;
case '>':
result += QLatin1String(">");
break;
default:
result += ch;
}
}
}
return result;
}
示例9: CheckSum
/////////////////////////////////////////////////////////////////////////////
// CheckSum()
// Calculate the check sum for a given line of TLE data, the last character
// of which is the current checksum. (Although there is no check here,
// the current checksum should match the one we calculate.)
// The checksum algorithm:
// Each number in the data line is summed, modulo 10.
// Non-numeric characters are zero, except minus signs, which are 1.
//
int QTle::CheckSum(const QString str)
{
// The length is "- 1" because we don't include the current (existing)
// checksum character in the checksum calculation.
size_t len = str.length() - 1;
int xsum = 0;
for (size_t i = 0; i < len; i++)
{
QChar ch = str.at(i);
if (ch.isDigit())
xsum += ch.digitValue();
else if (ch == '-')
xsum++;
}
return (xsum % 10);
} // CheckSum()
示例10:
QString Pass2::convertedOperand(QString s) {
Utils *utils= &Singleton<Utils>::Instance();
QString ret = "";
if (s.at(0) == 'C') {
for (int i = 2; i < s.length() -1; ++i) {
QChar c = s.at(i);
ret += utils->intToHexString(c.digitValue());
}
return ret;
}
if (s.at(0).isDigit()) {
return utils->intToHexString(s.toInt());
}
if (s.startsWith("X'") && s.endsWith("'")) {
s = s.replace("'", "");
s = s.replace("X", "");
return s.toLower();
}
return ret;
}
示例11: fnFindSum
int MainWindow::fnFindSum(QString strNumberValue)
{
if(strNumberValue.length()==1)
{
return strNumberValue.toInt();
}
else
{
long lngValue=0;
for(int i=0; i<strNumberValue.length(); i++)
{
//lngValue += QString::toInt(""+strNumberValue.at(i));
QChar c = strNumberValue.at(i);
if(c.isDigit())
{
lngValue += c.digitValue();
}
}
return fnFindSum(QString::number(lngValue));
}
}
示例12: removeArrayItem
/**
* Unfortunately QSettings does not provide a method to remove array elements.
*
* So, we have to read in all keys and values of the named array section, delete
* the whole array section and write it out again, omitting the deleted
* row. We also have to take care to adapt the array indices after the deleted
* row and to write finally the new size entry.
*/
bool Settings::removeArrayItem(const QString& strArrayName, int iIndex) const
{
bool fRet = false;
qSettings()->beginReadArray(strArrayName);
const QStringList keys(qSettings()->allKeys());
QStringList values;
if (iIndex < keys.size())
{
for (int i = 0; i < keys.size(); i++)
values.insert(i, qSettings()->value(keys.at(i)).toString());
qSettings()->endArray();
qSettings()->beginGroup(strArrayName);
qSettings()->remove("");
const QChar cIndex2Remove(iIndex + 1 + 48);
QChar cIndex2Write;
for (int i = 0; i < keys.size(); i++)
{
const QString& strKey = keys.at(i);
const QChar cIndex2Read(strKey.at(0));
if (cIndex2Read.isDigit())
{
if (cIndex2Read != cIndex2Remove)
{
cIndex2Write = cIndex2Read > cIndex2Remove ? QChar(cIndex2Read.digitValue() - 1 + 48) : QChar(cIndex2Read.digitValue() + 48);
qSettings()->setValue(cIndex2Write + strKey.mid(1), values.at(i));
}
}
}
qSettings()->setValue("size", QString(cIndex2Write));
qSettings()->endGroup();
fRet = true;
}
return(fRet);
}
示例13: rankToInt
int CardSuiteUtil::rankToInt(QChar rank){
if (rank == QChar(88)) {
return 0; // X, unknown card
}
if (rank == QChar(65)){
return 14; // ACE
}
if (rank == QChar(75)) {
return 13;// KING
}
if (rank == QChar(81)) {
return 12;// QUEEN
}
if (rank == QChar(74)) {
return 11;// JACKET
}
if (rank.isDigit()) {
return rank.digitValue();
}
qDebug() << "CardSuiteUtil::rankToInt# WARNING imposible rank " << endl;
return 0;
}
示例14: moveToObjectif
int Robot::moveToObjectif(Entrepot *e, Tile objectif)
{
int moveToX = this->getX();
int moveToY = this->getY();
int dx = objectif.getX() - this->getX();
int dy = objectif.getY() - this->getY();
RechercheCheminAStar recherche = RechercheCheminAStar(e);
QString route = recherche.calculChemin(this->getX(), this->getY(), objectif.getX(), objectif.getY());
if(route.length()>0)
{
int j;
QChar c;
c =route.at(0);
j=c.digitValue();
moveToX += recherche.dx[j];
moveToY += recherche.dy[j];
}
this->move(*e, moveToX, moveToY);
if((abs(dx) == 0 && abs(dy) ==1) || (abs(dx) == 1 && abs(dy) ==0)){
if(e->tab[objectif.getX()][objectif.getY()] == MapScene::ARMOIREPLEINE)
{
e->tab[objectif.getX()][objectif.getY()] = MapScene::ARMOIREVIDE;
return MapScene::ARMOIREVIDE;
}
else if(e->tab[objectif.getX()][objectif.getY()] == MapScene::ARMOIREVIDE)
{
e->tab[objectif.getX()][objectif.getY()] = MapScene::ARMOIREPLEINE;
return MapScene::ARMOIREPLEINE;
}
}
return MapScene::VIDE;
}
示例15: extractClassName
/*!
Extract a class name from the type \a string and return it.
*/
QString Node::extractClassName(const QString &string) const
{
QString result;
for (int i=0; i<=string.size(); ++i) {
QChar ch;
if (i != string.size())
ch = string.at(i);
QChar lower = ch.toLower();
if ((lower >= QLatin1Char('a') && lower <= QLatin1Char('z')) ||
ch.digitValue() >= 0 ||
ch == QLatin1Char('_') ||
ch == QLatin1Char(':')) {
result += ch;
}
else if (!result.isEmpty()) {
if (result != QLatin1String("const"))
return result;
result.clear();
}
}
return result;
}