Skip to content

Commit

Permalink
Fix for issues #550 and #553
Browse files Browse the repository at this point in the history
This PR fixes both issues #550 and #553. It was found that QucsLib tool
didn't update neither the default symbol nor the name/library of the
selected component
  • Loading branch information
andresmmera committed Aug 15, 2016
1 parent 9d924ca commit 1ab5488
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qucs-core/src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# include <config.h>
#endif

#include <stdio.h>

#include <stdlib.h>
#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion qucs-core/src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define LOG_ERROR 0
#define LOG_STATUS 1

#include <stdio.h>
__BEGIN_DECLS

void logprint (int, const char *, ...);
Expand Down
35 changes: 33 additions & 2 deletions qucs/qucs-lib/qucslib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "displaydialog.h"
#include "symbolwidget.h"


/* Constructor setups the GUI. */
QucsLib::QucsLib()
{
Expand Down Expand Up @@ -112,6 +111,7 @@ QucsLib::QucsLib()
CompList = new QListWidget();
connect(CompList, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));

CompSearch = new QLineEdit(this);
CompSearch->setPlaceholderText(tr("Search Lib Components"));
Expand Down Expand Up @@ -455,10 +455,32 @@ void QucsLib::slotSearchClear()
}


void QucsLib::LoadDefaultSymbol(QString libpath)
{
ComponentLibrary parsedlib;

int result = parseComponentLibrary (libpath, parsedlib);

switch (result)
{
case QUCS_COMP_LIB_IO_ERROR:
QMessageBox::critical(0, tr ("Error"), tr("Cannot open \"%1\".").arg (libpath));
return;
case QUCS_COMP_LIB_CORRUPT:
QMessageBox::critical(0, tr("Error"), tr("Library is corrupt."));
return;
default:
break;
}

// copy the contents of default symbol section to a string
DefaultSymbol = parsedlib.defaultSymbol;

}

// ----------------------------------------------------
void QucsLib::slotShowComponent(QListWidgetItem *Item)
{

if(!Item) return;

//QString CompString = LibraryComps.at(CompList->index(Item));
Expand All @@ -468,6 +490,9 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
CompDescr->append("Library: " + LibName);
CompDescr->append("----------------------------");

//Load the default symbol for the current Qucs library
LoadDefaultSymbol(QucsSettings.LibDir + LibName + ".lib");

// FIXME: here we assume that LibName is the same as the actual filename...
int i = Library->findText(LibName);

Expand Down Expand Up @@ -510,11 +535,17 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
QMessageBox::critical(this, tr("Error"), tr("Library is corrupt."));
return;
}

if(!content.isEmpty())
Symbol->setSymbol(content, LibName, Item->text());
else if(!DefaultSymbol.isEmpty()) // has library a default symbol ?
Symbol->setSymbol(DefaultSymbol, LibName, Item->text());


// Update component's name and library
Symbol->LibraryName = LibName;
Symbol->ComponentName = Item->text();

// change currently selected category, so the user will
// learn where the component comes from
Library->setCurrentIndex(i);
Expand Down
1 change: 1 addition & 0 deletions qucs/qucs-lib/qucslib.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private slots:
void slotSearchClear();
void slotShowComponent(QListWidgetItem*);
void slotManageLib();
void LoadDefaultSymbol(QString);

private:
void closeEvent(QCloseEvent*);
Expand Down

0 comments on commit 1ab5488

Please sign in to comment.