mirror of https://github.com/KLayout/klayout.git
Log model enhanced for extractor messages
This commit is contained in:
parent
93c570a6f9
commit
2fe611a75c
|
|
@ -1134,7 +1134,7 @@ NetlistBrowserPage::setup_trees ()
|
|||
|
||||
if ((lvsdb && lvsdb->cross_ref ()) || (l2ndb && ! l2ndb->log_entries ().empty ())) {
|
||||
|
||||
NetlistLogModel *new_model = new NetlistLogModel (log_view, lvsdb->cross_ref () /*@@@, l2ndb*/);
|
||||
NetlistLogModel *new_model = new NetlistLogModel (log_view, lvsdb->cross_ref (), l2ndb);
|
||||
delete log_view->model ();
|
||||
log_view->setModel (new_model);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,19 +78,20 @@ namespace {
|
|||
|
||||
const std::string var_sep (" \u21D4 ");
|
||||
|
||||
NetlistLogModel::NetlistLogModel (QWidget *parent, const db::NetlistCrossReference *cross_ref)
|
||||
NetlistLogModel::NetlistLogModel (QWidget *parent, const db::NetlistCrossReference *cross_ref, const db::LayoutToNetlist *l2n)
|
||||
: QAbstractItemModel (parent)
|
||||
{
|
||||
tl_assert (cross_ref->netlist_a () != 0);
|
||||
tl_assert (cross_ref->netlist_b () != 0);
|
||||
|
||||
if (! cross_ref->other_log_entries ().empty ()) {
|
||||
m_circuits.push_back (std::make_pair (std::make_pair ((const db::Circuit *)0, (const db::Circuit *)0), &cross_ref->other_log_entries ()));
|
||||
}
|
||||
mp_lvsdb_messages = cross_ref ? &cross_ref->other_log_entries () : 0;
|
||||
mp_l2n_messages = l2n ? &l2n->log_entries () : 0;
|
||||
|
||||
m_global_entries = int ((mp_lvsdb_messages ? mp_lvsdb_messages->size () : 0) + (mp_l2n_messages ? mp_l2n_messages->size () : 0));
|
||||
|
||||
for (auto i = cross_ref->begin_circuits (); i != cross_ref->end_circuits (); ++i) {
|
||||
const db::NetlistCrossReference::PerCircuitData *pcd = cross_ref->per_circuit_data_for (*i);
|
||||
if (pcd && i->first && i->second && ! pcd->log_entries.empty ()) {
|
||||
if (pcd && (i->first || i->second) && ! pcd->log_entries.empty ()) {
|
||||
m_circuits.push_back (std::make_pair (*i, &pcd->log_entries));
|
||||
}
|
||||
}
|
||||
|
|
@ -102,9 +103,11 @@ bool
|
|||
NetlistLogModel::hasChildren (const QModelIndex &parent) const
|
||||
{
|
||||
if (! parent.isValid ()) {
|
||||
return ! m_circuits.empty ();
|
||||
return m_global_entries > 0 || ! m_circuits.empty ();
|
||||
} else if (! parent.parent ().isValid ()) {
|
||||
return parent.row () >= m_global_entries;
|
||||
} else {
|
||||
return ! parent.parent ().isValid ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +117,7 @@ NetlistLogModel::index (int row, int column, const QModelIndex &parent) const
|
|||
if (! parent.isValid ()) {
|
||||
return createIndex (row, column, (void *) (0));
|
||||
} else {
|
||||
return createIndex (row, column, (void *) (& m_circuits [parent.row ()]));
|
||||
return createIndex (row, column, (void *) (& m_circuits [parent.row () - m_global_entries]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +128,7 @@ NetlistLogModel::parent (const QModelIndex &child) const
|
|||
return QModelIndex ();
|
||||
} else {
|
||||
const circuit_entry *ce = (const circuit_entry *) child.internalPointer ();
|
||||
return createIndex (int (ce - & m_circuits.front ()), child.column (), (void *) (0));
|
||||
return createIndex (int (ce - & m_circuits.front ()) + m_global_entries, child.column (), (void *) (0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,12 +136,11 @@ int
|
|||
NetlistLogModel::rowCount (const QModelIndex &parent) const
|
||||
{
|
||||
if (! parent.isValid ()) {
|
||||
return int (m_circuits.size ());
|
||||
return int (m_circuits.size ()) + m_global_entries;
|
||||
} else if (parent.parent ().isValid ()) {
|
||||
return 0;
|
||||
} else if (parent.row () >= 0 && parent.row () < int (m_circuits.size ())) {
|
||||
// @@@ that would crash for "other entries"!
|
||||
return int (m_circuits [parent.row ()].second->size ());
|
||||
} else if (parent.row () >= m_global_entries && parent.row () < int (m_circuits.size ()) + m_global_entries) {
|
||||
return int (m_circuits [parent.row () - m_global_entries].second->size ());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -157,7 +159,14 @@ NetlistLogModel::data (const QModelIndex &index, int role) const
|
|||
if (index.parent ().isValid ()) {
|
||||
const circuit_entry *ce = (const circuit_entry *) index.internalPointer ();
|
||||
if (ce) {
|
||||
le = &(*ce->second) [index.row ()];
|
||||
le = (ce->second->begin () + index.row ()).operator-> ();
|
||||
}
|
||||
} else if (index.row () < m_global_entries) {
|
||||
int n_l2n = int (mp_l2n_messages ? mp_l2n_messages->size () : 0);
|
||||
if (index.row () < n_l2n) {
|
||||
le = (mp_l2n_messages->begin () + index.row ()).operator-> ();
|
||||
} else {
|
||||
le = (mp_lvsdb_messages->begin () + (index.row () - n_l2n)).operator-> ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -175,14 +184,14 @@ NetlistLogModel::data (const QModelIndex &index, int role) const
|
|||
|
||||
} else if (role == Qt::DisplayRole) {
|
||||
|
||||
if (index.parent ().isValid ()) {
|
||||
if (le) {
|
||||
return QVariant (tl::to_qstring (le->msg));
|
||||
}
|
||||
} else if (index.row () >= 0 && index.row () < int (m_circuits.size ())) {
|
||||
const std::pair<const db::Circuit *, const db::Circuit *> &cp = m_circuits [index.row ()].first;
|
||||
if (! cp.first || ! cp.second) {
|
||||
return QVariant (tr ("General"));
|
||||
if (le) {
|
||||
return QVariant (tl::to_qstring (le->msg));
|
||||
} else if (! index.parent ().isValid () && index.row () >= m_global_entries && index.row () < int (m_circuits.size ()) + m_global_entries) {
|
||||
const std::pair<const db::Circuit *, const db::Circuit *> &cp = m_circuits [index.row () - m_global_entries].first;
|
||||
if (! cp.first) {
|
||||
return QVariant (tr ("Circuit ") + tl::to_qstring (std::string ("-") + var_sep + cp.second->name ()));
|
||||
} else if (! cp.second) {
|
||||
return QVariant (tr ("Circuit ") + tl::to_qstring (cp.first->name () + var_sep + std::string ("-")));
|
||||
} else if (cp.first->name () != cp.second->name ()) {
|
||||
return QVariant (tr ("Circuit ") + tl::to_qstring (cp.first->name () + var_sep + cp.second->name ()));
|
||||
} else {
|
||||
|
|
@ -192,13 +201,11 @@ NetlistLogModel::data (const QModelIndex &index, int role) const
|
|||
|
||||
} else if (role == Qt::FontRole) {
|
||||
|
||||
if (index.parent ().isValid ()) {
|
||||
if (le && le->severity == db::Error) {
|
||||
QFont f;
|
||||
f.setBold (true);
|
||||
return QVariant (f);
|
||||
}
|
||||
} else {
|
||||
if (le) {
|
||||
QFont f;
|
||||
f.setBold (le->severity == db::Error);
|
||||
return QVariant (f);
|
||||
} else if (! index.parent ().isValid () && index.row () >= m_global_entries && index.row () < int (m_circuits.size ()) + m_global_entries) {
|
||||
QFont f;
|
||||
f.setBold (true);
|
||||
return QVariant (f);
|
||||
|
|
@ -206,14 +213,12 @@ NetlistLogModel::data (const QModelIndex &index, int role) const
|
|||
|
||||
} else if (role == Qt::ForegroundRole) {
|
||||
|
||||
if (index.parent ().isValid ()) {
|
||||
if (!le) {
|
||||
// ignore
|
||||
} else if (le->severity == db::Error) {
|
||||
return QColor (255, 0, 0);
|
||||
} else if (le->severity == db::Warning) {
|
||||
return QColor (0, 0, 255);
|
||||
}
|
||||
if (! le) {
|
||||
// ignore
|
||||
} else if (le->severity == db::Error) {
|
||||
return QColor (255, 0, 0);
|
||||
} else if (le->severity == db::Warning) {
|
||||
return QColor (0, 0, 255);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "layuiCommon.h"
|
||||
#include "dbNetlistCrossReference.h"
|
||||
#include "dbLayoutToNetlist.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ class LAYUI_PUBLIC NetlistLogModel
|
|||
: public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
NetlistLogModel (QWidget *parent, const db::NetlistCrossReference *cross_ref);
|
||||
NetlistLogModel (QWidget *parent, const db::NetlistCrossReference *cross_ref, const db::LayoutToNetlist *l2n);
|
||||
|
||||
virtual bool hasChildren (const QModelIndex &parent) const;
|
||||
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const;
|
||||
|
|
@ -53,6 +54,9 @@ public:
|
|||
private:
|
||||
typedef std::pair<std::pair<const db::Circuit *, const db::Circuit *>, const db::NetlistCrossReference::PerCircuitData::log_entries_type *> circuit_entry;
|
||||
std::vector<circuit_entry> m_circuits;
|
||||
const db::NetlistCrossReference::PerCircuitData::log_entries_type *mp_lvsdb_messages;
|
||||
const db::LayoutToNetlist::log_entries_type *mp_l2n_messages;
|
||||
int m_global_entries;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue