void EditListTests::testAddEdit()
{
	QList<Patch> list;
	const Edit zeroEdit(this, 0, list);
	const Edit oneEdit(this, 1, list);

	EditList editList(this);

	QVERIFY2(editList.getEdits().count() == 0, "The EditList should not contain edits");

	editList.addEdit(zeroEdit);
	editList.addEdit(oneEdit);

	QVERIFY2( editList.getEdits().count() == 2, "The EditList should contain 2 edits");
	Edit e = editList.getEdits().at(0);
	QVERIFY2( e == zeroEdit, "The EditList first edits object should be zeroEdit");
	e = editList.getEdits().at(1);
	QVERIFY2( e  == oneEdit, "The EditList second edits object should be oneEdit");
}
void EditListTests::testPopEditsUpToLocalVersion()
{
	QList<Patch> list;
	Edit firstEdit(this, 0, list);
	Edit secondEdit(this, 1, list);
	Edit thirdEdit(this, 2, list);

	EditList editList(this);
	editList.addEdit(firstEdit);
	editList.addEdit(secondEdit);
	editList.addEdit(thirdEdit);

	editList.popEditsUpToLocalVersion(5);

	QVERIFY2(firstEdit.getLocalVersion() == 0, "The firstEdit should return 5");
	QVERIFY2(secondEdit.getLocalVersion() == 1, "The secondEdit should return 1");
	QVERIFY2(thirdEdit.getLocalVersion() == 2, "The thirdEdit should return 2");
	QVERIFY2(list.count() == 0, "The list should be empty");
}
void EditListTests::testUpdateToRemoteVersion()
{
	QList<Patch> list;
	Edit zeroEdit(this, 0, list);
	Edit oneEdit(this, 1, list);
	Edit twoEdit(this, 2, list);
	Edit threeEdit(this, 3, list);

	EditList editList(this);
	editList.addEdit(zeroEdit);
	editList.addEdit(oneEdit);
	editList.addEdit(twoEdit);
	editList.addEdit(threeEdit);

	QVERIFY2(editList.getEdits().count() == 4, "The EditList edits count should be 4");

	editList.setRemoteVersion(1);
	QVERIFY2(editList.getRemoteVersion() == 1, "The EditList remote version should be 1");

	editList.setRemoteVersion(2);
	QVERIFY2(editList.getRemoteVersion() == 2, "The EditList remote version should be 2");
}
Exemple #4
0
bool
StdWidgetFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container)
{
	setWidget(w, container);
//	m_container = container;
	if(classname == "KLineEdit")
	{
		KLineEdit *lineedit = static_cast<KLineEdit*>(w);
		createEditor(classname, lineedit->text(), lineedit, container, lineedit->geometry(), lineedit->alignment(), true);
		return true;
	}
	else if(classname == "QLabel")
	{
		QLabel *label = static_cast<QLabel*>(w);
		if(label->textFormat() == RichText)
		{
			//m_widget = w;
//			setWidget(w, container);
			editText();
		}
		else
			createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
		return true;
	}
	else if(classname == "KPushButton")
	{
		KPushButton *push = static_cast<KPushButton*>(w);
		QRect r = w->style().subRect(QStyle::SR_PushButtonContents, w);
		QRect editorRect = QRect(push->x() + r.x(), push->y() + r.y(), r.width(), r.height());
		//r.setX(r.x() + 5);
		//r.setY(r.y() + 5);
		//r.setWidth(r.width()-10);
		//r.setHeight(r.height() - 10);
		createEditor(classname, push->text(), push, container, editorRect, Qt::AlignCenter, false, false, Qt::PaletteButton);
		return true;
	}
	else if(classname == "QRadioButton")
	{
		QRadioButton *radio = static_cast<QRadioButton*>(w);
		QRect r = w->style().subRect(QStyle::SR_RadioButtonContents, w);
		QRect editorRect = QRect(radio->x() + r.x(), radio->y() + r.y(), r.width(), r.height());
		createEditor(classname, radio->text(), radio, container, editorRect, Qt::AlignAuto);
		return true;
	}
	else if(classname == "QCheckBox")
	{
		QCheckBox *check = static_cast<QCheckBox*>(w);
		//QRect r(check->geometry());
		//r.setX(r.x() + 20);
		QRect r = w->style().subRect(QStyle::SR_CheckBoxContents, w);
		QRect editorRect = QRect(check->x() + r.x(), check->y() + r.y(), r.width(), r.height());
		createEditor(classname, check->text(), check, container, editorRect, Qt::AlignAuto);
		return true;
	}
	else if((classname == "KComboBox") || (classname == "KListBox"))
	{
		QStringList list;
		if(classname == "KListBox")
		{
			KListBox *listbox = (KListBox*)w;
			for(uint i=0; i < listbox->count(); i++)
				list.append(listbox->text(i));
		}
		else if(classname == "KComboBox")
		{
			KComboBox *combo = (KComboBox*)w;
			for(int i=0; i < combo->count(); i++)
				list.append(combo->text(i));
		}

		if(editList(w, list))
		{
			if(classname == "KListBox")
			{
				((KListBox*)w)->clear();
				((KListBox*)w)->insertStringList(list);
			}
			else if(classname == "KComboBox")
			{
				((KComboBox*)w)->clear();
				((KComboBox*)w)->insertStringList(list);
			}
		}
		return true;
	}
	else if((classname == "KTextEdit") || (classname == "KDateTimeWidget") || (classname == "KTimeWidget") ||
		(classname == "KDateWidget") || (classname == "KIntSpinBox")) {
		disableFilter(w, container);
		return true;
	}
	return false;
}