Hi,
I have a though question. On which way tables can be nested? I am busy with an xml editor and it would be nice if the tables could be nested.
Any thoughts?
Cheers,
Jeroen
Printable View
Hi,
I have a though question. On which way tables can be nested? I am busy with an xml editor and it would be nice if the tables could be nested.
Any thoughts?
Cheers,
Jeroen
Here you find a tree structure on a mysql sample...
Link on comment... && http://www.klempert.de/nested_sets/artikel/
IMO: much work to get it running.
Code:
#define TREEQUERY "SELECT n.*, round((n.rgt-n.lft-1)/2,0) AS childs, count(*)+(n.lft>1) AS level, ((min(p.rgt)-n.rgt-(n.lft>1))/2) > 0 AS lower, (( (n.lft-max(p.lft)>1) )) AS upper FROM PCMS_CAT n, PCMS_CAT p WHERE n.lft BETWEEN p.lft AND p.rgt AND (p.root_id = n.root_id) AND (p.id != n.id OR n.lft = 1) GROUP BY n.root_id,n.id ORDER BY n.root_id,n.lft" /* download query from http://www.klempert.de/nested_sets/ demo http://www.klempert.de/nested_sets/demo/ CREATE TABLE `PCMS_CAT` ( `id` int(12) NOT NULL auto_increment, `root_id` int(12) NOT NULL default '0', `name` varchar(35) NOT NULL default 'Category-Name-New', `lft` int(12) NOT NULL default '0', `rgt` int(12) NOT NULL default '0', `xmlattribute` longblob NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `id_2` (`id`), KEY `root_id` (`root_id`), KEY `lft` (`lft`), KEY `rgt` (`rgt`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=152 ; */ void Panel::GoTree() { QString teme,imageicon,toolssett; QIcon defic; itecats.clear(); /* clear attributes !!! */ bool have = query.exec(TREEQUERY); //////db->SqlLog(TREEQUERY,have); TOTsumrowCAT = query.numRowsAffected(); if (TOTsumrowCAT == 0) { QMessageBox::warning(this, tr("Error"),tr("Null item Found, Now table are ready. \nReopen application.").arg(TREETABLE)); return; } QList<QStandardItem *> sub3; /* flat rowlines level x */ QList<QStandardItem *> sub4; /* flat rowlines */ QList<QStandardItem *> sub5; /* flat rowlines */ QList<QStandardItem *> sub6; /* flat rowlines */ QList<QStandardItem *> rootlines; /* flat rowlines */ bool aoappend; QList<QStandardItem *> inerows; ////////////qDebug() << "summ category " << TOTsumrowCAT; while (query.next()) { /* data */ int dbid = query.value(0).toInt(); int level = query.value(7).toInt(); int moveup = direct_int(query.value(9).toString()); int movedown = direct_int(query.value(8).toString()); int childer = direct_int(query.value(6).toString()); DataAttributes motor; motor.Setup(precode,langs); motor.SetValue("name",name); motor.SetValue("level",level); motor.SetValue("child",childer); motor.SetValue("goup",moveup); motor.SetValue("dbnummer",dbid); motor.init(); CateAttribute *CatAttXML = new CateAttribute(motor,dbid,langs); CatAttXML->SetDbConnection(db); connect(CatAttXML, SIGNAL(PLoad()), this , SLOT(Reload())); itecats.append(CatAttXML); aoappend = true; inerows.clear(); s0->setFlags ( Qt::ItemIsEnabled ); s1->setFlags ( Qt::ItemIsEnabled ); s2->setFlags ( Qt::ItemIsUserCheckable ); s0->setToolTip ( motor.GetToolTips() ); inerows.append(s0); inerows.append(s1); inerows.append(s2); qDebug() << "name-> " << name; /* */ if (level == 2) { rootlines.append(s0); parentItem->appendRow(inerows); } else if (level > 2) { if (level == 3) { before = rootlines.last(); sub3.append(s0); } else if (level == 4) { before = sub3.last(); sub4.append(s0); } else if (level == 5) { before = sub4.last(); sub5.append(s0); } else if (level == 6) { before = sub5.last(); sub6.append(s0); } else { aoappend = false; } if (aoappend) { before->appendRow(inerows); } } /* if level 1 end */ } /* while sql */ categorie->setModel(model); categorie->expandAll(); categorie->resizeColumnToContents (0); categorie->resizeColumnToContents (1); categorie->resizeColumnToContents (2); }
my dream are to become an answer on Thread http://www.qtcentre.org/forum/f-qt-p...ovie-7403.html
as exchange :o