コード例 #1
0
void PublicHubs::updateList(){
    if (!model)
        return;

    model->clearModel();
    QList<QVariant> data;

    for (auto i = entries.begin(); i != entries.end(); ++i) {
        HubEntry *entry = const_cast<HubEntry*>(&(*i));
        data.clear();

        data << _q(entry->getName())         << _q(entry->getDescription())  << entry->getUsers()
             << _q(entry->getServer())       << _q(entry->getCountry())      << (qlonglong)entry->getShared()
             << (qint64)entry->getMinShare() << (qint64)entry->getMinSlots() << (qint64)entry->getMaxHubs()
             << (qint64)entry->getMaxUsers() << static_cast<double>(entry->getReliability()) << _q(entry->getRating());

        model->addResult(data, entry);
    }
}
コード例 #2
0
bool PublicHubsFrame::matchFilter(const HubEntry& entry, const int& sel, bool doSizeCompare, const FilterModes& mode, const double& size)
{
	if (m_filter.empty())
		return true;
		
	double entrySize = 0;
	string entryString;
	
	switch (sel)
	{
		case COLUMN_NAME:
			entryString = entry.getName();
			doSizeCompare = false;
			break;
		case COLUMN_DESCRIPTION:
			entryString = entry.getDescription();
			doSizeCompare = false;
			break;
		case COLUMN_USERS:
			entrySize = entry.getUsers();
			break;
		case COLUMN_SERVER:
			entryString = entry.getServer();
			doSizeCompare = false;
			break;
		case COLUMN_COUNTRY:
			entryString = entry.getCountry();
			doSizeCompare = false;
			break;
		case COLUMN_SHARED:
			entrySize = (double)entry.getShared();
			break;
		case COLUMN_MINSHARE:
			entrySize = (double)entry.getMinShare();
			break;
		case COLUMN_MINSLOTS:
			entrySize = entry.getMinSlots();
			break;
		case COLUMN_MAXHUBS:
			entrySize = entry.getMaxHubs();
			break;
		case COLUMN_MAXUSERS:
			entrySize = entry.getMaxUsers();
			break;
		case COLUMN_RELIABILITY:
			entrySize = entry.getReliability();
			break;
		case COLUMN_RATING:
			entryString = entry.getRating();
			doSizeCompare = false;
			break;
		default:
			break;
	}
	
	bool insert = false;
	if (doSizeCompare)
	{
		switch (mode)
		{
			case EQUAL:
				insert = (size == entrySize);
				break;
			case GREATER_EQUAL:
				insert = (size <=  entrySize);
				break;
			case LESS_EQUAL:
				insert = (size >=  entrySize);
				break;
			case GREATER:
				insert = (size < entrySize);
				break;
			case LESS:
				insert = (size > entrySize);
				break;
			case NOT_EQUAL:
				insert = (size != entrySize);
				break;
		}
	}
	else
	{
		if (sel >= COLUMN_LAST)
		{
			if (Util::findSubString(entry.getName(), m_filter) != string::npos ||
			        Util::findSubString(entry.getDescription(), m_filter) != string::npos ||
			        Util::findSubString(entry.getServer(), m_filter) != string::npos ||
			        Util::findSubString(entry.getCountry(), m_filter) != string::npos ||
			        Util::findSubString(entry.getRating(), m_filter) != string::npos)
			{
				insert = true;
			}
		}
		if (Util::findSubString(entryString, m_filter) != string::npos)
			insert = true;
	}
	
	return insert;
}