mirror of https://github.com/KLayout/klayout.git
WIP: refactoring for more comfortable net browser
This commit is contained in:
parent
03bf0a557e
commit
f4495274ab
|
|
@ -2271,6 +2271,7 @@ NetlistBrowserModel::data (const QModelIndex &index, int role) const
|
||||||
return QVariant ();
|
return QVariant ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @@@
|
||||||
static QString build_url (void *id, const std::string &tag, const std::string &title)
|
static QString build_url (void *id, const std::string &tag, const std::string &title)
|
||||||
{
|
{
|
||||||
if (id == no_id) {
|
if (id == no_id) {
|
||||||
|
|
@ -2594,10 +2595,13 @@ NetlistBrowserModel::flags (const QModelIndex & /*index*/) const
|
||||||
bool
|
bool
|
||||||
NetlistBrowserModel::hasChildren (const QModelIndex &parent) const
|
NetlistBrowserModel::hasChildren (const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
NetlistModelItemData *d = (NetlistModelItemData *) (parent.internalPointer ());
|
NetlistModelItemData *d = 0;
|
||||||
if (! d) {
|
if (parent.isValid ()) {
|
||||||
return false;
|
d = (NetlistModelItemData *) (parent.internalPointer ());
|
||||||
} else {
|
} else {
|
||||||
|
d = mp_root.get ();
|
||||||
|
}
|
||||||
|
if (d) {
|
||||||
d->ensure_children (const_cast<NetlistBrowserModel *> (this));
|
d->ensure_children (const_cast<NetlistBrowserModel *> (this));
|
||||||
return d->begin () != d->end ();
|
return d->begin () != d->end ();
|
||||||
}
|
}
|
||||||
|
|
@ -2635,15 +2639,17 @@ QModelIndex
|
||||||
NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) const
|
NetlistBrowserModel::index (int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
NetlistModelItemData *d = 0;
|
NetlistModelItemData *d = 0;
|
||||||
if (parent.isValid ()) {
|
if (! parent.isValid ()) {
|
||||||
|
d = mp_root.get ();
|
||||||
|
} else {
|
||||||
d = (NetlistModelItemData *) (parent.internalPointer ());
|
d = (NetlistModelItemData *) (parent.internalPointer ());
|
||||||
}
|
}
|
||||||
if (! d) {
|
if (d) {
|
||||||
d = mp_root.get ();
|
d->ensure_children (const_cast<NetlistBrowserModel *> (this));
|
||||||
|
return createIndex (row, column, (void *) d->child (size_t (row)));
|
||||||
|
} else {
|
||||||
|
return QModelIndex ();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->ensure_children (const_cast<NetlistBrowserModel *> (this));
|
|
||||||
return createIndex (row, column, (void *) d->child (size_t (row)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -2748,10 +2754,14 @@ NetlistBrowserModel::parent (const QModelIndex &index) const
|
||||||
int
|
int
|
||||||
NetlistBrowserModel::rowCount (const QModelIndex &parent) const
|
NetlistBrowserModel::rowCount (const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
NetlistModelItemData *d = (NetlistModelItemData *) (parent.internalPointer ());
|
NetlistModelItemData *d = 0;
|
||||||
if (! d) {
|
if (parent.isValid ()) {
|
||||||
return 0;
|
d = (NetlistModelItemData *) (parent.internalPointer ());
|
||||||
} else {
|
} else {
|
||||||
|
d = mp_root.get ();
|
||||||
|
}
|
||||||
|
if (d) {
|
||||||
|
d->ensure_children (const_cast<NetlistBrowserModel *> (this));
|
||||||
return int (d->child_count ());
|
return int (d->child_count ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue