void FormatSettingsPopup::buildPropertyLineEdit(int index, TPropertyGroup *props)
{
	TStringProperty *prop = (TStringProperty *)(props->getProperty(index));
	assert(prop);

	PropertyLineEdit *lineEdit = new PropertyLineEdit(this, prop);
	m_widgets[prop->getName()] = lineEdit;
	lineEdit->setText(tr(toString(prop->getValue()).c_str()));

	int row = m_mainLayout->rowCount();
	m_mainLayout->addWidget(new QLabel(tr(prop->getName().c_str()) + ":", this), row, 0, Qt::AlignRight | Qt::AlignVCenter);
	m_mainLayout->addWidget(lineEdit, row, 1);
}
Beispiel #2
0
//------------------------------------------------
void visitprops(TPropertyGroup &pg, int &index, QTAtomContainer &atoms, QTAtom parent)
{
	int count = pg.getPropertyCount();
	while (index < count) {
		TStringProperty *p = (TStringProperty *)pg.getProperty(index++);
		string str0 = p->getName();
		const char *buf = str0.c_str();
		int atomType, id, sonCount;
		sscanf(buf, "%d %d %d", &atomType, &id, &sonCount);
		QTAtom newAtom;
		if (sonCount == 0) {
			wstring appow = p->getValue();
			string appo = toString(appow);
			const char *str = appo.c_str();

			vector<UCHAR> buf;
			while (strlen(str) > 0) {
				if (str[0] == 'z') {
					int count = atoi(str + 1);
					str += (count < 10) ? 4 : ((count < 100) ? 5 : 6);
					while (count--)
						buf.push_back(0);
				} else {
					int val = atoi(str);
					assert(val >= 0 && val < 256);

					str += (val < 10) ? 2 : ((val < 100) ? 3 : 4);
					buf.push_back(val);
				}
			}
			//const unsigned short*bufs = str1.c_str();
			//UCHAR *bufc = new UCHAR[size];
			//for (int i=0; i<size; i++)
			// {
			//	assert(bufs[i]<257);
			//	bufc[i] = (UCHAR)(bufs[i]-1);
			//	}
			void *ptr = 0;
			if (buf.size() != 0) {
				ptr = &(buf[0]);
			}
			QTInsertChild(atoms, parent, (QTAtomType)atomType, (QTAtomID)id, 0,
						  buf.size(), (void *)ptr, 0);
		} else {
			QTInsertChild(atoms, parent, (QTAtomType)atomType, (QTAtomID)id,
						  0, 0, 0, &newAtom);
			visitprops(pg, index, atoms, newAtom);
		}
	}
}