Skip to content

Commit

Permalink
Introduce optional netlisting to console
Browse files Browse the repository at this point in the history
-Implemented conditional netlisting to console for CDL
-forced using trailing a_ for class attributes instead ms-style m_ for
 class QucsApp
-removed unused attribute m_projModel from class QucsApp

Signed-off-by: ThomasZecha <zecha@ihp-microelectronics.com>
  • Loading branch information
ThomasZecha committed Jan 9, 2025
1 parent 5458ff7 commit 5da8ebd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 57 deletions.
2 changes: 1 addition & 1 deletion qucs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ int main(int argc, char *argv[])
}
}

QucsMain = new QucsApp();
QucsMain = new QucsApp(netlist2Console);
//1a.setMainWidget(QucsMain);

QucsMain->show();
Expand Down
106 changes: 54 additions & 52 deletions qucs/qucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
//#include "extsimkernels/codemodelgen.h"
#include "symbolwidget.h"

QucsApp::QucsApp()
QucsApp::QucsApp(bool netlist2Console) :
a_netlist2Console(netlist2Console)
{

windowTitle = misc::getWindowTitle();
setWindowTitle(windowTitle);

Expand Down Expand Up @@ -575,11 +575,11 @@ void QucsApp::initView()
messageDock = new MessageDock(this);

// initial projects directory model
m_homeDirModel = new QucsFileSystemModel(this);
m_proxyModel = new QucsSortFilterProxyModel();
//m_proxyModel->setDynamicSortFilter(true);
a_homeDirModel = new QucsFileSystemModel(this);
a_proxyModel = new QucsSortFilterProxyModel();
//a_proxyModel->setDynamicSortFilter(true);
// show all directories (project and non-project)
m_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
a_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);

// ............................................
QString path = QucsSettings.qucsWorkspaceDir.absolutePath();
Expand Down Expand Up @@ -1386,21 +1386,21 @@ void QucsApp::readProjects()

if (path == homepath) {
// in Qucs Home, disallow further up in the dirs tree
m_homeDirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
a_homeDirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
} else {
m_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
a_homeDirModel->setFilter(QDir::NoDot | QDir::AllDirs);
}

// set the root path
QModelIndex rootModelIndex = m_homeDirModel->setRootPath(path);
QModelIndex rootModelIndex = a_homeDirModel->setRootPath(path);
// assign the model to the proxy and the proxy to the view
m_proxyModel->setSourceModel(m_homeDirModel);
m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
a_proxyModel->setSourceModel(a_homeDirModel);
a_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
// sort by first column (file name, only column show in the QListView)
m_proxyModel->sort(0);
Projects->setModel(m_proxyModel);
a_proxyModel->sort(0);
Projects->setModel(a_proxyModel);
// fix the listview on the root path of the model
Projects->setRootIndex(m_proxyModel->mapFromSource(rootModelIndex));
Projects->setRootIndex(a_proxyModel->mapFromSource(rootModelIndex));
}

// ----------------------------------------------------------
Expand Down Expand Up @@ -3524,53 +3524,55 @@ void QucsApp::slotSaveCdlNetlist()
Schematic* schematic = dynamic_cast<Schematic*>(DocumentTab->currentWidget());
Q_ASSERT(schematic != nullptr);

#ifdef NETLIST_CDL_TO_CONSOLE // for fast testing purposes
QString netlistString;
if (a_netlist2Console)
{
QTextStream netlistStream(&netlistString);
CdlNetlistWriter cdlWriter(netlistStream, schematic);
if (!cdlWriter.write())
QString netlistString;
{
QMessageBox::critical(
this,
tr("Save CDL netlist"),
tr("Save CDL netlist failed!"),
QMessageBox::Ok);
QTextStream netlistStream(&netlistString);
CdlNetlistWriter cdlWriter(netlistStream, schematic);
if (!cdlWriter.write())
{
QMessageBox::critical(
this,
tr("Save CDL netlist"),
tr("Save CDL netlist failed!"),
QMessageBox::Ok);
}
printf("\nCDL netlist:\n%s\n", netlistString.toUtf8().constData());
Content->refresh();
}
printf("\nCDL netlist:\n%s\n", netlistString.toUtf8().constData());
Content->refresh();
}
#else
QFileInfo inf(schematic->getDocName());
QString filename = QFileDialog::getSaveFileName(
this,
tr("Save CDL netlist"),
inf.path() + QDir::separator() + "netlist.cdl",
"CDL netlist (*.cdl)");

if (filename.isEmpty())
else
{
return;
}
QFileInfo inf(schematic->getDocName());
QString filename = QFileDialog::getSaveFileName(
this,
tr("Save CDL netlist"),
inf.path() + QDir::separator() + "netlist.cdl",
"CDL netlist (*.cdl)");

if (filename.isEmpty())
{
return;
}

QFile netlistFile(filename);
if (netlistFile.open(QIODevice::WriteOnly))
{
QTextStream netlistStream(&netlistFile);
CdlNetlistWriter cdlWriter(netlistStream, schematic);
if (!cdlWriter.write())
QFile netlistFile(filename);
if (netlistFile.open(QIODevice::WriteOnly))
{
QMessageBox::critical(
this,
tr("Save CDL netlist"),
tr("Save CDL netlist failed!"),
QMessageBox::Ok);
QTextStream netlistStream(&netlistFile);
CdlNetlistWriter cdlWriter(netlistStream, schematic);
if (!cdlWriter.write())
{
QMessageBox::critical(
this,
tr("Save CDL netlist"),
tr("Save CDL netlist failed!"),
QMessageBox::Ok);
}
netlistFile.close();
Content->refresh();
}
netlistFile.close();
Content->refresh();
}
#endif

}
}

Expand Down
8 changes: 4 additions & 4 deletions qucs/qucs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Q_OBJECT
class QucsApp : public QMainWindow {
Q_OBJECT
public:
QucsApp();
QucsApp(bool netlist2Console);
~QucsApp();
bool closeAllFiles();
bool gotoPage(const QString&); // to load a document
Expand Down Expand Up @@ -251,10 +251,10 @@ private slots:
// ********** Properties ************************************************
QStack<QString> HierarchyHistory; // keeps track of "go into subcircuit"
QString QucsFileFilter;
QFileSystemModel *m_homeDirModel;
QucsSortFilterProxyModel *m_proxyModel;
QFileSystemModel *m_projModel;
QFileSystemModel *a_homeDirModel;
QucsSortFilterProxyModel *a_proxyModel;
int ccCurIdx; // CompChooser current index (used during search)
bool a_netlist2Console;

// ********** Methods ***************************************************
void initView();
Expand Down

0 comments on commit 5da8ebd

Please sign in to comment.