Esempio n. 1
0
void CC3GLSLVariable::populateFromProgram()
{
	_semantic = kCC3SemanticNone;
	_semanticIndex = 0;
	_isGLStateKnown = false;
	CC3OpenGL::sharedGL()->populateShaderProgramVariable( this );
	normalizeName();
}
Esempio n. 2
0
std::vector<std::string> ModuleRegistry::moduleNames() {
  std::vector<std::string> names;
  for (size_t i = 0; i < modules_.size(); i++) {
    std::string name = normalizeName(modules_[i]->getName());
    modulesByName_[name] = i;
    names.push_back(std::move(name));
  }
  return names;
}
Esempio n. 3
0
void AuthorEditWidget::addAuthor(const QString& name)
{
    QString normName = normalizeName(name);

    if(!authorExists(normName)) {

        authorList->addItem(normName);
        authorComboBox->setEditText(QString());
    }
}
Esempio n. 4
0
CreateAccount::CreateAccount(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CreateAccount)
{
    ui->setupUi(this);

    setMaxLengths();
    setupValidators();
    setupCards();

    ui->btnSubmit->setEnabled(false);
    ui->cardBox->setVisible(false);
    ui->dummyBox->setMinimumSize(ui->cardBox->sizeHint());

    ui->editEmail->setMinimumSize(ui->editEmail->sizeHint());
    createImageLabel(ui->lblTick, ":/tick.png");
    ui->lblTick->setVisible(false);
    ui->lblTick->setMinimumSize(ui->lblTick->sizeHint());

    // signals and slots

    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editMiddlename, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editProfession, SIGNAL(editingFinished()), this, SLOT(normalizeName()));

    // connect required fields to submit
    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editEmail, SIGNAL(editingFinished()), this, SLOT(checkEmail()));
    connect(ui->editContact, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editAttachment, SIGNAL(textChanged(QString)), this, SLOT(enableSubmit()));
    connect(ui->editAmount, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));

    connect(ui->btnAttachment, SIGNAL(clicked(bool)), this, SLOT(addAttachment()));
    connect(ui->btnReset, SIGNAL(clicked(bool)), this, SLOT(resetForm()));
}
Esempio n. 5
0
void ModuleRegistry::callNativeMethod(ExecutorToken token, unsigned int moduleId, unsigned int methodId,
                                      folly::dynamic&& params, int callId) {
  if (moduleId >= modules_.size()) {
    throw std::runtime_error(
      folly::to<std::string>("moduleId ", moduleId,
                             " out of range [0..", modules_.size(), ")"));
  }

#ifdef WITH_FBSYSTRACE
  if (callId != -1) {
    fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
  }
#endif

  // TODO mhorowitz: systrace
  std::string what;
  try {
    modules_[moduleId]->invoke(token, methodId, std::move(params));
    return;
  } catch (const std::exception& e) {
    what = e.what();
    // fall through;
  } catch (...) {
    // fall through;
  }

  std::string moduleName = normalizeName(modules_[moduleId]->getName());
  auto descs = modules_[moduleId]->getMethods();
  std::string methodName;
  if (methodId < descs.size()) {
    methodName = descs[methodId].name;
  } else {
    methodName = folly::to<std::string>("id ", methodId, " (out of range [0..",
                                        descs.size(), "))");
  }

  if (what.empty()) {
    throw std::runtime_error(
      folly::to<std::string>("Unknown native exception in module '", moduleName,
                             "' method '", methodName, "'"));
  } else {
    throw std::runtime_error(
      folly::to<std::string>("Native exception in module '", moduleName,
                             "' method '", methodName, "': ", what));
  }
}
Esempio n. 6
0
QList<ZealSearchResult> ZealDocsetsRegistry::getRelatedLinks(QString name, QString path)
{
    QList<ZealSearchResult> results;
    // Get the url without the #anchor.
    QUrl mainUrl(path);
    mainUrl.setFragment(NULL);
    QString pageUrl(mainUrl.toString());
    docsetEntry entry = docs[name];

    // Prepare the query to look up all pages with the same url.
    QString query;
    if (entry.type == DASH) {
        query = QString("SELECT name, type, path FROM searchIndex WHERE path LIKE \"%1%%\"").arg(pageUrl);
    } else if (entry.type == ZDASH) {
        query = QString("SELECT ztoken.ztokenname, ztokentype.ztypename, zfilepath.zpath, ztokenmetainformation.zanchor "
                        "FROM ztoken "
                        "JOIN ztokenmetainformation ON ztoken.zmetainformation = ztokenmetainformation.z_pk "
                        "JOIN zfilepath ON ztokenmetainformation.zfile = zfilepath.z_pk "
                        "JOIN ztokentype ON ztoken.ztokentype = ztokentype.z_pk "
                        "WHERE zfilepath.zpath = \"%1\"").arg(pageUrl);
    } else if (entry.type == ZEAL) {
        query = QString("SELECT name type, path FROM things WHERE path LIKE \"%1%%\"").arg(pageUrl);
    }

    QSqlQuery result = entry.db.exec(query);
    while (result.next()) {
        QString sectionName = result.value(0).toString();
        QString sectionPath = result.value(2).toString();
        QString parentName;
        if (entry.type == ZDASH) {
            sectionPath.append("#");
            sectionPath.append(result.value(3).toString());
        }

        normalizeName(sectionName, parentName, "");

        results.append(ZealSearchResult(sectionName, "", sectionPath, name, QString()));
    }

    return results;
}
Esempio n. 7
0
void ZealDocsetsRegistry::_runQuery(const QString& rawQuery, int queryNum)
{
    if(queryNum != lastQuery) return; // some other queries pending - ignore this one

    QList<ZealSearchResult> results;
    ZealSearchQuery query(rawQuery);

    QString preparedQuery = query.getSanitizedQuery();
    bool hasDocsetFilter = query.hasDocsetFilter();

    for (const ZealDocsetsRegistry::docsetEntry docset : docsets()) {
        if(hasDocsetFilter && !query.docsetPrefixMatch(docset.prefix)) {
            // Filter out this docset as the names don't match the docset prefix
            continue;
        }

        QString qstr;
        QSqlQuery q;
        QList<QList<QVariant> > found;
        bool withSubStrings = false;
        // %.%1% for long Django docset values like django.utils.http
        // %::%1% for long C++ docset values like std::set
        // %/%1% for long Go docset values like archive/tar
        QString subNames = QString(" or %1 like '%.%2%' escape '\\'");
        subNames += QString(" or %1 like '%::%2%' escape '\\'");
        subNames += QString(" or %1 like '%/%2%' escape '\\'");
        while(found.size() < 100) {
            auto curQuery = preparedQuery;
            QString notQuery; // don't return the same result twice
            QString parentQuery;
            if(withSubStrings) {
                // if less than 100 found starting with query, search all substrings
                curQuery = "%"+preparedQuery;
                // don't return 'starting with' results twice
                if(docset.type == ZDASH) {
                    notQuery = QString(" and not (ztokenname like '%1%' escape '\\' %2) ").arg(preparedQuery, subNames.arg("ztokenname", preparedQuery));
                } else {
                    if(docset.type == ZEAL) {
                        notQuery = QString(" and not (t.name like '%1%' escape '\\') ").arg(preparedQuery);
                        parentQuery = QString(" or t2.name like '%1%' escape '\\' ").arg(preparedQuery);
                    } else { // DASH
                        notQuery = QString(" and not (t.name like '%1%' escape '\\' %2) ").arg(preparedQuery, subNames.arg("t.name", preparedQuery));
                    }
                }
            }
            int cols = 3;
            if(docset.type == ZEAL) {
                qstr = QString("select t.name, t2.name, t.path from things t left join things t2 on t2.id=t.parent where "
                               "(t.name like '%1%' escape '\\'  %3) %2 order by length(t.name), lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery, parentQuery);

            } else if(docset.type == DASH) {
                qstr = QString("select t.name, null, t.path from searchIndex t where (t.name "
                               "like '%1%' escape '\\' %3)  %2 order by length(t.name), lower(t.name) asc, t.path asc limit 100").arg(curQuery, notQuery, subNames.arg("t.name", curQuery));
            } else if(docset.type == ZDASH) {
                cols = 4;
                qstr = QString("select ztokenname, null, zpath, zanchor from ztoken "
                                "join ztokenmetainformation on ztoken.zmetainformation = ztokenmetainformation.z_pk "
                                "join zfilepath on ztokenmetainformation.zfile = zfilepath.z_pk where (ztokenname "

                               "like '%1%' escape '\\' %3) %2 order by length(ztokenname), lower(ztokenname) asc, zpath asc, "
                               "zanchor asc limit 100").arg(curQuery, notQuery, subNames.arg("ztokenname", curQuery));
            }
            q = db(docset.name).exec(qstr);
            while(q.next()) {
                QList<QVariant> values;
                for(int i = 0; i < cols; ++i) {
                    values.append(q.value(i));
                }
                found.append(values);
            }

            if(withSubStrings) break;
            withSubStrings = true;  // try again searching for substrings
        }
        for(auto &row : found) {
            QString parentName;
            if(!row[1].isNull()) {
                parentName = row[1].toString();
            }
            auto path = row[2].toString();
            // FIXME: refactoring to use common code in ZealListModel and ZealDocsetsRegistry
            if(docset.type == ZDASH) {
                path += "#" + row[3].toString();
            }
            auto itemName = row[0].toString();
            normalizeName(itemName, parentName, row[1].toString());
            results.append(ZealSearchResult(itemName, parentName, path, docset.name, preparedQuery));
        }
    }
    qSort(results);
    if(queryNum != lastQuery) return; // some other queries pending - ignore this one

    queryResults = results;
    emit queryCompleted();
}
Esempio n. 8
0
static int findFile(const char * file, u32 lba, u32 dir_size, u32 is_dir, Iso9660DirectoryRecord *result_record)
{
	u32 pos;
	int ret;
	Iso9660DirectoryRecord *rec;
	char name[32];
	int re;

	pos = isoLBA2Pos(lba, 0);
	re = lba = 0;

	while ( re < dir_size ) {
		if (isoPos2LBA(pos) != lba) {
			lba = isoPos2LBA(pos);
			ret = readSector(lba, g_sector_buffer);

			if (ret < 0) {
				return ret;
			}
		}

		rec = (Iso9660DirectoryRecord*)&g_sector_buffer[isoPos2OffsetInSector(pos)];

		if(rec->len_dr == 0) {
			u32 remaining;

			remaining = isoPos2RestSize(pos);
			pos += remaining;
			re += remaining;
			continue;
		}
		
		if(rec->len_dr < rec->len_fi + sizeof(*rec)) {
			printf("%s: Corrupt directory record found in %s, LBA %d\n", __func__, g_filename, lba);

			return -12;
		}

		if(rec->len_fi > 32) {
			return -11;
		}

		if(rec->len_fi == 1 && rec->fi == 0) {
			if (0 == strcmp(file, ".")) {
				memcpy(result_record, rec, sizeof(*result_record));

				return 0;
			}
		} else if(rec->len_fi == 1 && rec->fi == 1) {
			if (0 == strcmp(file, "..")) {
				// didn't support ..
				return -19;
			}
		} else {
			memset(name, 0, sizeof(name));
			memcpy(name, &rec->fi, rec->len_fi);
			normalizeName(name);

			if (0 == strcmp(name, file)) {
				if (is_dir) {
					if(!rec->fileFlags & ISO9660_FILEFLAGS_DIR) {
						return -14;
					}
				}

				memcpy(result_record, rec, sizeof(*result_record));

				return 0;
			}
		}

		pos += rec->len_dr;
		re += rec->len_dr;
	}

	return -18;
}
Esempio n. 9
0
Tag::Tag(QObject *parent, int _id, const QString& _name) : QObject(parent), id(_id), name(_name)
{
	normalizedName = normalizeName(name);
}