Example #1
0
Login::Login(QWidget *parent):
QDialog(parent)
{
	QString labelString("Twitch User Name:");
	twitchNameLabel = new QLabel(this);

	assert(twitchNameLabel != NULL);

	twitchNameLabel->setText(labelString);
	twitchNameLabel->setGeometry(QRect(50,30,120,15));
	twitchNameLabel->show();

	loginButton = new QPushButton(this);

	assert(loginButton != NULL);

	QString buttonText("Login");
	loginButton->setText(buttonText);
	loginButton->setGeometry(QRect(50,90,90,25));
	connect(loginButton, SIGNAL( released()),this, SLOT(GetFollowingList()));
	loginButton->show();

	edit = new QTextEdit(this);

	assert(edit != NULL);

	edit->setGeometry(QRect(50,50,140,20));
	edit->show();
}
Example #2
0
uint32	LabelHash::checkLabel( char const * const domain, char const * const label, uint32 hashValue )
{
	// First things first - make sure the label actually hashes to the given value

	uint32 actualHash = Crc::calculate(label);

	FATAL(actualHash != hashValue, ("LabelHash::checkLabel - Label [%s] hashes to [%d] and not [%d]\n",label,actualHash,hashValue));

	// ----------

	std::string domainString(domain);
	std::string labelString(label);

	// Find the hash-to-label map for the given domain, or 
	// create a new one if there isn't one already.
	
	TDomainMap::iterator domainIt = gs_allDomains.find(domainString);

	if(domainIt == gs_allDomains.end())
	{
		// Domain not found, create entry for it containing the label

		THashToStringMap newDomainMap;

		newDomainMap.insert( THashEntry(hashValue,labelString) );

		gs_allDomains.insert( TDomainEntry(domainString,newDomainMap) );
	}
	else
	{
		// Domain found, check for existing hash value

		THashToStringMap & domainLabels = (*domainIt).second;

		THashToStringMap::iterator labelIt = domainLabels.find(hashValue);

		if(labelIt == domainLabels.end())
		{
			// Hash value not found, add it to the domain

			domainLabels.insert( THashEntry(hashValue,labelString) );
		}
		else
		{
			// Hash value found, fatal if the string mapped to it doesn't match 
			// the given string

			std::string & currentLabel = (*labelIt).second;

			FATAL( currentLabel != labelString, ("LabelHash::checkLabel - Found a hash collision for domain [%s], label [%s] - two labels hashed to the same value\n",domain,label));
		}
	}

	// All is good, hash is OK.

	return hashValue;
};
QwtText ScaleDraw::label(double value) const
{
	QString s = labelString(value);
	if (s.isEmpty())
		return QwtText();

	s.replace("-", QChar(0x2212));
	return QwtText(d_prefix + s + d_suffix);
}
Example #4
0
bool ScriptModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	if(!index.isValid())
		return false;

	if(role == ActionIdRole)
	{
		mScript->setAction(index.row(), mActionFactory->newActionInstance(value.toString()));

		emit dataChanged(index, index);
		emit scriptEdited();

		return true;
	}

	ActionTools::ActionInstance *actionInstance = mScript->actionAt(index.row());
	if(!actionInstance)
		return false;

	if(role == ActionDataRole)
	{
		actionInstance->copyActionDataFrom(value.value<ActionTools::ActionInstance>());

		emit dataChanged(index, index);
		emit scriptEdited();

		return true;
	}

	if(index.column() == ColumnLabel)
	{
		switch(role)
		{
		case Qt::CheckStateRole:
			mUndoStack->push(new ChangeEnabledCommand(QList<int>() << index.row(), value.toBool(), this));

			emit scriptEdited();
			return true;
		case Qt::EditRole:
			QString lineNumber(QString("%1").arg(index.row() + 1, 3, 10, QChar('0')));
			QString labelString(value.toString());
			QString finalValue;

			if(!labelString.isEmpty() && lineNumber != labelString)
			{
				int labelLine = mScript->labelLine(labelString);
				if(labelLine == -1 || labelLine == index.row())
					finalValue = labelString;
			}

			if(labelString == actionInstance->label() || labelString == lineNumber)
				return true;

			mUndoStack->push(new ChangeLabelCommand(finalValue, index.row(), this));

			emit scriptEdited();
			return true;
		}
	}
	else if(index.column() == ColumnComment)
	{
		if(value.toString() == actionInstance->comment())
			return true;

		mUndoStack->push(new ChangeCommentCommand(value.toString(), index.row(), this));

		emit scriptEdited();
		return true;
	}

	return false;
}