예제 #1
0
InfoList get_info_list(const payment_address& payaddr,
    EntryMultimap& map)
{
    InfoList info;
    auto iter_pair = map.equal_range(payaddr);
    for (auto it = iter_pair.first; it != iter_pair.second; ++it)
        info.push_back(it->second);
    return info;
}
예제 #2
0
InfoList InfoReader::convertListToInfoList(QStringList l) {
	InfoList r;
	for (int n = 0; n < l.count(); n++) {
		QStringList s = l[n].split("|");
		if (s.count() >= 2) {
			r.append(InfoData(s[0], s[1]));
		}
	}
	return r;
}
예제 #3
0
Installer::InfoList Installer::get_all_installs() const
{
    InfoList result;

    for ( InfoMap::const_iterator it = info_map.begin(); it != info_map.end(); ++it )
    {
        result.push_back( it->second );
    }

    return result;
}
int FilePropertiesDialog::find(QString s, InfoList &list) {
	qDebug("FilePropertiesDialog::find");

	int n=0;
	InfoList::iterator it;

	for ( it = list.begin(); it != list.end(); ++it ) {
		//qDebug(" * item: '%s', s: '%s'", (*it).name().toUtf8().data(), s.toUtf8().data());
		if ((*it).name() == s) return n;
		n++;
	}
	return -1;
}
예제 #5
0
QStringList InfoReader::convertInfoListToList(InfoList l) {
	QStringList r;
	for (int n = 0; n < l.count(); n++) {
		r << l[n].name() + "|" + l[n].desc();
	}
	return r;
}
예제 #6
0
파일: Worker.cpp 프로젝트: Suneal/qt
void Worker::threadFinished()
{
    ++m_finishedCount;
    Q_ASSERT(m_finishedCount == 1 || m_finishedCount == 2);

    const ResultThreader *const handler = static_cast<ResultThreader *>(sender());
    Q_ASSERT(handler);

    switch(handler->type())
    {
        case ResultThreader::Baseline:
        {
            m_baseline = handler->result();
            break;
        }
        case ResultThreader::Result:
            m_result = handler->result();
    }

    if(m_finishedCount == 1) /* One thread's missing. */
        return;

    /* Ok, both threads have now finished, and we got their results in m_result and m_baseline. */

    /* No matter how this function exits, we want to delete this Worker. */
    deleteLater();

    ResultThreader::Hash::const_iterator itA(m_result.constBegin());
    ResultThreader::Hash::const_iterator itB(m_baseline.constBegin());
    const ResultThreader::Hash::const_iterator endA(m_result.constEnd());
    const ResultThreader::Hash::const_iterator endB(m_baseline.constEnd());
    const int baselineCount = m_baseline.count();
    const int resultCount = m_result.count();

    /* If you want useful output, change the QTextStream to use stderr. */
    //QTextStream err(stderr);
    QByteArray out;
    QTextStream err(&out);

    if(resultCount < baselineCount)
    {
        err << qPrintable(QString(QLatin1String("WARNING: Test result contains %1 reports, "
                                                "but the baseline contains %2, a DECREASE "
                                                "of %3 tests.\n"))
                                  .arg(resultCount)
                                  .arg(baselineCount)
                                  .arg(resultCount - baselineCount));
    }
    else if(resultCount > baselineCount)
    {
        err << qPrintable(QString(QLatin1String("NOTE: The number of tests run is more than what "
                                                "the baseline specifies. Run was %1 test cases, the "
                                                "baseline specifies %2; an increase of %3 tests.\n"))
                                  .arg(resultCount)
                                  .arg(baselineCount)
                                  .arg(resultCount - baselineCount));
    }

    for(; itA != endA; ++itA)
    {
        const TestResult::Status result = itA.value();
        const TestResult::Status baseline = m_baseline.value(itA.key());

        if(result == baseline) /* We have no change. */
        {
            if(result == TestResult::NotTested)
                m_notTested.append(itA.key());
            else
                continue;
        }
        else if(baseline == TestResult::Pass && result == TestResult::Fail)
            m_unexpectedFailures.append(itA.key());
        else if(baseline == TestResult::Fail && result == TestResult::Pass)
            m_unexpectedPasses.append(itA.key());
    }

    list(err, QLatin1String("Not tested"),           m_notTested);
    list(err, QLatin1String("Unexpected failures"),  m_unexpectedFailures);
    list(err, QLatin1String("Unexpected passes"),    m_unexpectedPasses);

    err << "SUMMARY:\n";
    typedef QPair<QString, int> Info;
    typedef QList<Info> InfoList;
    InfoList info;

    const int totFail       = count(m_result, TestResult::Fail);
    const int totPass       = count(m_result, TestResult::Pass);
    const int total         = resultCount;
    const int notTested     = m_notTested.count();
    const int percentage    = total==0 ? 0 : int((static_cast<double>(totPass) / total) * 100);

    Q_ASSERT_X(percentage >= 0 && percentage <= 100, Q_FUNC_INFO,
               qPrintable(QString(QLatin1String("Percentage was: %1")).arg(percentage)));

    info.append(Info(QLatin1String("Total"),                total));
    info.append(Info(QLatin1String("Failures"),             totFail));
    info.append(Info(QLatin1String("Passes"),               totPass));
    info.append(Info(QLatin1String("Not tested"),           notTested));
    info.append(Info(QLatin1String("Pass percentage(%)"),   percentage));
    info.append(Info(QLatin1String("Unexpected failures"),  m_unexpectedFailures.count()));
    info.append(Info(QLatin1String("Unexpected passes"),    m_unexpectedPasses.count()));

    const InfoList::const_iterator end(info.constEnd());
    InfoList::const_iterator it(info.constBegin());

    /* List the statistics nicely in a row with padded columns. */
    for(; it != end; ++it)
    {
        const QString result((((*it).first) + QLatin1Char(':')).leftJustified(22, QLatin1Char(' ')));
        err << m_indent << qPrintable(result) << (*it).second << '\n';
    }

    if(!m_unexpectedFailures.isEmpty())
    {
        err << "FAILURE: Regressions discovered, baseline was not updated.\n";
        err.flush();
        QTextStream(stderr) << out;
        m_eventLoop.exit(ExitCode::Regression);
        return;
    }
    else if(m_unexpectedPasses.isEmpty() && baselineCount == resultCount)
    {
        err << "Result was identical to the baseline, baseline was not updated.\n";
        m_eventLoop.exit(ExitCode::Success);
        return;
    }

    /* Ok, we got unexpected successes and no regressions: let's update the baseline. */

    QFile resultFile(m_resultFile.absoluteFilePath());

    /* Remove the old file, otherwise QFile::copy() will fail. */
    QDir baselineDir(m_baselineFile.absolutePath());
    baselineDir.remove(m_baselineFile.fileName());

    if(resultFile.copy(m_baselineFile.absoluteFilePath()))
    {
        /* Give a detailed message of what's going on. */
        if(resultCount > baselineCount)
            err << "More tests was run than specified in the baseline, updating the baseline.\n";
        else
            err << "Improvement, the baseline was updated.\n";

        /* We actually flag this as an error, because the new baseline must be submitted. */
        err.flush();
        QTextStream(stderr) << out;
        m_eventLoop.exit(ExitCode::Regression);
        return;
    }
    else
    {
        err << qPrintable(QString(QLatin1String("Encountered error when updating "
                                                "the baseline: %1\n"))
                                  .arg(resultFile.errorString()));
        err.flush();
        QTextStream(stderr) << out;
        m_eventLoop.exit(ExitCode::WriteError);
        return;
    }
}
예제 #7
0
/** Lists the bus configuration.
 */
void CommandConfig::listConfigs(
        MasterDevice &m,
        const ConfigList &configList,
        bool doIndent
        )
{
    ConfigList::const_iterator configIter;
    stringstream str;
    Info info;
    typedef list<Info> InfoList;
    InfoList list;
    InfoList::const_iterator iter;
    unsigned int maxAliasWidth = 0, maxPosWidth = 0,
                 maxSlavePosWidth = 0, maxStateWidth = 0;
    ec_ioctl_slave_t slave;
    string indent(doIndent ? "  " : "");

    for (configIter = configList.begin();
            configIter != configList.end();
            configIter++) {

        str << dec << configIter->alias;
        info.alias = str.str();
        str.clear();
        str.str("");

        str << configIter->position;
        info.pos = str.str();
        str.clear();
        str.str("");

        str << hex << setfill('0')
            << "0x" << setw(8) << configIter->vendor_id
            << "/0x" << setw(8) << configIter->product_code;
        info.ident = str.str();
        str.clear();
        str.str("");

        if (configIter->slave_position != -1) {
            m.getSlave(&slave, configIter->slave_position);

            str << dec << configIter->slave_position;
            info.slavePos = str.str();
            str.clear();
            str.str("");

            info.state = alStateString(slave.al_state);
        } else {
            str << "-";
            info.slavePos = str.str();
            str.clear();
            str.str("");

            str << "-";
            info.state = str.str();
            str.clear();
            str.str("");
        }

        list.push_back(info);

        if (info.alias.length() > maxAliasWidth)
            maxAliasWidth = info.alias.length();
        if (info.pos.length() > maxPosWidth)
            maxPosWidth = info.pos.length();
        if (info.slavePos.length() > maxSlavePosWidth)
            maxSlavePosWidth = info.slavePos.length();
        if (info.state.length() > maxStateWidth)
            maxStateWidth = info.state.length();
    }

    for (iter = list.begin(); iter != list.end(); iter++) {
        cout << indent << setfill(' ') << right
            << setw(maxAliasWidth) << iter->alias
            << ":" << left
            << setw(maxPosWidth) << iter->pos
            << "  "
            << iter->ident
            << "  "
            << setw(maxSlavePosWidth) << iter->slavePos << "  "
            << setw(maxStateWidth) << iter->state << "  "
            << endl;
    }
}
예제 #8
0
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
	: BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK,
		B_FLOATING_SUBSET_WINDOW_FEEL,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE)
{
	AddToSubset(parent);

	typedef pair<string, string> Item;
	typedef vector<Item> InfoList;

	char name[B_PATH_NAME_LENGTH];
	strcpy(name, f->ref.name);
	strcat(name, " info");
	SetTitle(name);

	InfoList info;
	Item item;

	// Size
	size_to_string(f->size, name);
	if (f->count > 0) {
		// This is a directory.
		char str[64];
		sprintf(str, kInfoInFiles, f->count);
		strcat(name, str);
	}
	info.push_back(Item(kInfoSize, name));

	// Created & modified dates
	BEntry entry(&f->ref);
	time_t t;
	entry.GetCreationTime(&t);
	strftime(name, 64, kInfoTimeFmt, localtime(&t));
	info.push_back(Item(kInfoCreated, name));
	entry.GetModificationTime(&t);
	strftime(name, 64, kInfoTimeFmt, localtime(&t));
	info.push_back(Item(kInfoModified, name));

	// Kind
	BMimeType* type = f->Type();
	type->GetShortDescription(name);
	info.push_back(Item(kInfoKind, name));
	delete type;

	// Path
	string path;
	f->GetPath(path);
	info.push_back(Item(kInfoPath, path));

	// Icon
	BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
	entry_ref ref;
	entry.GetRef(&ref);
	BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);

	// Compute the window size and add the views.
	BFont smallFont(be_plain_font);
	smallFont.SetSize(floorf(smallFont.Size() * 0.95));

	struct font_height fh;
	smallFont.GetHeight(&fh);
	float fontHeight = fh.ascent + fh.descent + fh.leading;

	float leftWidth = 32.0;
	float rightWidth = 0.0;
	InfoList::iterator i = info.begin();
	while (i != info.end()) {
		float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin;
		leftWidth = max_c(leftWidth, w);
		w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
		rightWidth = max_c(rightWidth, w);
		i++;
	}

	float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin);
	float winWidth = leftWidth + rightWidth;
	ResizeTo(winWidth, winHeight);

	LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon);
	BView *rightView = new BView(
		BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
		B_FOLLOW_NONE, B_WILL_DRAW);

	AddChild(leftView);
	AddChild(rightView);

	BStringView *sv = new BStringView(
		BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0),
		NULL, f->ref.name, B_FOLLOW_ALL);

	BFont largeFont(be_plain_font);
	largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
	sv->SetFont(&largeFont);
	rightView->AddChild(sv);

	float y = 32.0 + 4.0 * kSmallVMargin;
	i = info.begin();
	while (i != info.end()) {
		sv = new BStringView(
			BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight),
			NULL, (*i).first.c_str());
		sv->SetFont(&smallFont);
		sv->SetAlignment(B_ALIGN_RIGHT);
		sv->SetHighColor(kBasePieColor[1]); // arbitrary
		leftView->AddChild(sv);

		sv = new BStringView(
			BRect(kSmallHMargin, y, rightView->Bounds().Width(), y + fontHeight),
			NULL, (*i).second.c_str());
		sv->SetFont(&smallFont);
		rightView->AddChild(sv);

		y += fontHeight + kSmallVMargin;
		i++;
	}

	Show();
}
예제 #9
0
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
	: BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK,
		B_FLOATING_SUBSET_WINDOW_FEEL,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE)
{
	AddToSubset(parent);

	typedef pair<string, string> Item;
	typedef vector<Item> InfoList;

	BString stringTitle("%refName% info");
	stringTitle.ReplaceFirst("%refName%", f->ref.name);
	SetTitle(stringTitle.String());

	InfoList info;
	Item item;

	// Size
	BString name;
	if (f->count > 0) {
		// This is a directory, include file count information
		static BMessageFormat format(B_TRANSLATE(
		"%size% in {0, plural, one{# file} other{# files}}"));

		format.Format(name, f->count);
	} else
		name = "%size%";

	char tmp[B_PATH_NAME_LENGTH] = { 0 };
	string_for_size(f->size, tmp, sizeof(tmp));
	name.ReplaceFirst("%size%", tmp);

	info.push_back(Item(B_TRANSLATE_MARK("Size"), name.String()));

	// Created & modified dates
	BEntry entry(&f->ref);
	time_t t;
	entry.GetCreationTime(&t);
	strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
	info.push_back(Item(B_TRANSLATE("Created"), tmp));
	entry.GetModificationTime(&t);
	strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
	info.push_back(Item(B_TRANSLATE("Modified"), tmp));

	// Kind
	BMimeType* type = f->Type();
	type->GetShortDescription(tmp);
	info.push_back(Item(B_TRANSLATE("Kind"), tmp));
	delete type;

	// Path
	string path;
	f->GetPath(path);
	info.push_back(Item(B_TRANSLATE("Path"), path));

	// Icon
	BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
	entry_ref ref;
	entry.GetRef(&ref);
	BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);

	// Compute the window size and add the views.
	BFont smallFont(be_plain_font);
	smallFont.SetSize(floorf(smallFont.Size() * 0.95));

	struct font_height fh;
	smallFont.GetHeight(&fh);
	float fontHeight = fh.ascent + fh.descent + fh.leading;

	float leftWidth = 32.0;
	float rightWidth = 0.0;
	InfoList::iterator i = info.begin();
	while (i != info.end()) {
		float w = smallFont.StringWidth((*i).first.c_str())
			+ 2.0 * kSmallHMargin;
		leftWidth = max_c(leftWidth, w);
		w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
		rightWidth = max_c(rightWidth, w);
		i++;
	}

	float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
		+ kSmallVMargin);
	float winWidth = leftWidth + rightWidth;
	ResizeTo(winWidth, winHeight);

	LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight),
		icon);
	BView *rightView = new BView(
		BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
		B_FOLLOW_NONE, B_WILL_DRAW);

	AddChild(leftView);
	AddChild(rightView);

	BStringView *sv = new BStringView(
		BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(),
		kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL);

	BFont largeFont(be_plain_font);
	largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
	sv->SetFont(&largeFont);
	rightView->AddChild(sv);

	float y = 32.0 + 4.0 * kSmallVMargin;
	i = info.begin();
	while (i != info.end()) {
		sv = new BStringView(
			BRect(kSmallHMargin, y, leftView->Bounds().Width(),
			y + fontHeight), NULL, (*i).first.c_str());
		sv->SetFont(&smallFont);
		sv->SetAlignment(B_ALIGN_RIGHT);
		sv->SetHighColor(kBasePieColor[1]); // arbitrary
		leftView->AddChild(sv);

		sv = new BStringView(
			BRect(kSmallHMargin, y, rightView->Bounds().Width(),
			y + fontHeight), NULL, (*i).second.c_str());
		sv->SetFont(&smallFont);
		rightView->AddChild(sv);

		y += fontHeight + kSmallVMargin;
		i++;
	}

	Show();
}