Кресты / Говнокод #2857 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
void addItem(QStringList &lst, QTreeWidget *ptwg)
{
	bool a0 = false;
	for (int i = 0; i < ptwg->topLevelItemCount(); ++i) {
		if (lst.at(0) == ptwg->topLevelItem(i)->text(0)) {
			a0 = true;
			bool a1 = false;
			QTreeWidgetItem *itm0 = ptwg->topLevelItem(i);
			for (int j = 0; j < itm0->childCount(); ++j) {
				if (lst.at(1) == itm0->child(j)->text(1)) {
					a1 = true;
					bool a2 = false;
					QTreeWidgetItem *itm1 = itm0->child(j);
					for (int k = 0; k < itm1->childCount(); ++k) {
						if (lst.at(2) == itm1->child(k)->text(2)) {
							a2 = true;
							bool a3 = false;
							QTreeWidgetItem *itm2 = itm1->child(k);
							for (int l = 0; l < itm2->childCount(); ++l) {
								if (lst.at(3) == itm2->child(l)->text(3)) {
									a3 = true;
									QTreeWidgetItem *itm3 = itm2->child(l);
									QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
									break;
								}
							}
							if (!a3) {
								QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
								QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
							}
							break;
						}
					}
					if (!a2) {
						QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
						QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
						QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
					}
					break;
				}
			}
			if (!a1) {
				QTreeWidgetItem *itm1 = new QTreeWidgetItem(itm0, QStringList() << "" << lst.at(1));
				QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
				QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
				QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
			}
			break;
		}
	}
	if (!a0) {
		QTreeWidgetItem *itm0 = new QTreeWidgetItem(ptwg, QStringList() << lst.at(0));
		QTreeWidgetItem *itm1 = new QTreeWidgetItem(itm0, QStringList() << "" << lst.at(1));
		QTreeWidgetItem *itm2 = new QTreeWidgetItem(itm1, QStringList() << "" << "" << lst.at(2));
		QTreeWidgetItem *itm3 = new QTreeWidgetItem(itm2, QStringList() << "" << "" << "" << lst.at(3));
		QTreeWidgetItem *itm4 = new QTreeWidgetItem(itm3, QStringList() << "" << "" << "" << "" << lst.at(4));
	}
}

Функция = ) Добавляет в контрол иерархического дерева (5 уровней) элемент, не перерисовывая при этом само дерево, не закрывая никаких открытых веток.

Запостил: JC_NVKZ JC_NVKZ, (Updated )

Комментарии (5) RSS

Добавить комментарий

Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:

    А не использовать ли нам bbcode?


    8