From 4f8d238de71502c761f49aeed85d74d681f392b9 Mon Sep 17 00:00:00 2001 From: in3otd Date: Tue, 30 Jun 2015 19:17:25 +0200 Subject: [PATCH 1/7] Correct Components Tab behavior when searching. When using the Component Search in the Components Tab the component category shown in the top combo box was not changed, but still showed the last used category. Now when searching, the category text shown is changed to "Search results" and restored to the last used category when exiting the search. --- qucs/qucs/qucs.cpp | 37 ++++++++++++++++++++++++++++++++----- qucs/qucs/qucs.h | 1 + 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/qucs/qucs/qucs.cpp b/qucs/qucs/qucs.cpp index c038383598..15868821aa 100644 --- a/qucs/qucs/qucs.cpp +++ b/qucs/qucs/qucs.cpp @@ -610,15 +610,26 @@ void QucsApp::fillComboBox (bool setAll) // Component IconView with the appropriate components. void QucsApp::slotSetCompView (int index) { -// qDebug() << "QucsApp::slotSetCompView (int index)"; + //qDebug() << "QucsApp::slotSetCompView(" << index << ")"; editText->setHidden (true); // disable text edit of component property - CompSearch->clear(); QList Comps; CompComps->clear (); // clear the IconView if (CompChoose->count () <= 0) return; + // was in "search mode" ? + if (CompChoose->itemText(0) == tr("Search results")) { + if (index == 0) // user selected "Search results" item + return; + CompChoose->removeItem(0); + CompSearch->clear(); + --index; // adjust requested index since item 0 was removed + } + + // make sure the right index is selected + // (might have been called by a cleared search and not by user action) + CompChoose->setCurrentIndex(index); QString item = CompChoose->itemText (index); Comps = Category::getModules(item); @@ -689,6 +700,15 @@ void QucsApp::slotSearchComponent(const QString &searchText) { qDebug() << "User search: " << searchText; CompComps->clear (); // clear the IconView + + // not already in "search mode" + if (CompChoose->itemText(0) != tr("Search results")) { + ccCurIdx = CompChoose->currentIndex(); // remember current panel + // insert "Search results" at the beginning, so that it is visible + CompChoose->insertItem(-1, tr("Search results")); + CompChoose->setCurrentIndex(0); + } + if (searchText.isEmpty()) { slotSetCompView(CompChoose->currentIndex()); } else { @@ -757,8 +777,14 @@ void QucsApp::slotSearchComponent(const QString &searchText) // ------------------------------------------------------------------ void QucsApp::slotSearchClear() { - CompSearch->clear(); - slotSetCompView(CompChoose->currentIndex()); + // was in "search mode" ? + if (CompChoose->itemText(0) == tr("Search results")) { + CompChoose->removeItem(0); // remove the added "Search results" item + CompSearch->clear(); + // go back to the panel selected before search started + slotSetCompView(ccCurIdx); + // the added "Search results" panel text will be removed by slotSetCompView() + } } // ------------------------------------------------------------------ @@ -820,8 +846,9 @@ void QucsApp::slotSelectComponent(QListWidgetItem *item) if (mod->info) { (*mod->info)(CompName, CompFile_cptr, false); if (CompName == name) { - CompChoose->setCurrentIndex(i); + //CompChoose->setCurrentIndex(i); view->selElem = (*mod->info) (CompName, CompFile_cptr, true); + // TODO: component found, exit the loops now... } } } diff --git a/qucs/qucs/qucs.h b/qucs/qucs/qucs.h index 47907780be..e8385a9852 100644 --- a/qucs/qucs/qucs.h +++ b/qucs/qucs/qucs.h @@ -196,6 +196,7 @@ private slots: QString QucsFileFilter; QFileSystemModel *m_homeDirModel; QFileSystemModel *m_projModel; + int ccCurIdx; // CompChooser current index (used during search) // ********** Methods *************************************************** void initView(); From 926263a322c23e6004b439cde0c37e87c8704fe2 Mon Sep 17 00:00:00 2001 From: in3otd Date: Tue, 30 Jun 2015 19:20:45 +0200 Subject: [PATCH 2/7] Translated ToolTip for the "verilog-a user devices" icons The ToolTip for the "verilog-a user devices" icons was not using the translated string. --- qucs/qucs/qucs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qucs/qucs/qucs.cpp b/qucs/qucs/qucs.cpp index 15868821aa..a7ae9ec3b1 100644 --- a/qucs/qucs/qucs.cpp +++ b/qucs/qucs/qucs.cpp @@ -767,7 +767,7 @@ void QucsApp::slotSearchComponent(const QString &searchText) // Add icon an name tag to dock QListWidgetItem *icon = new QListWidgetItem(vaIcon, Name); - icon->setToolTip("verilog-a user devices: " + Name); + icon->setToolTip(tr("verilog-a user devices") + ": " + Name); CompComps->addItem(icon); } } From d0f9edc0e0edfcd079bce4004df8903c13864011 Mon Sep 17 00:00:00 2001 From: in3otd Date: Tue, 7 Jul 2015 23:30:07 +0200 Subject: [PATCH 3/7] Make the library search like the Qucs Component search The Library Tool was using a somewhat cumbersome search, forcing the user to open a separate dialog for searching. A search box is now included in the main Library Tool window and provides an 'instant search' feature, like the main Qucs window does for the standard component search. The old Search Dialog widget files are removed. --- qucs/qucs-lib/CMakeLists.txt | 4 +- qucs/qucs-lib/Makefile.am | 6 +- qucs/qucs-lib/qucslib.cpp | 148 +++++++++++++++++++++++------- qucs/qucs-lib/qucslib.h | 6 +- qucs/qucs-lib/searchdialog.cpp | 160 --------------------------------- qucs/qucs-lib/searchdialog.h | 45 ---------- 6 files changed, 124 insertions(+), 245 deletions(-) delete mode 100644 qucs/qucs-lib/searchdialog.cpp delete mode 100644 qucs/qucs-lib/searchdialog.h diff --git a/qucs/qucs-lib/CMakeLists.txt b/qucs/qucs-lib/CMakeLists.txt index ee2a16ac35..66063210dd 100644 --- a/qucs/qucs-lib/CMakeLists.txt +++ b/qucs/qucs-lib/CMakeLists.txt @@ -49,11 +49,11 @@ INCLUDE( ${QT_USE_FILE} ) ADD_DEFINITIONS(${QT_DEFINITIONS}) SET(QUCSLIB_SRCS -main.cpp qucslib.cpp displaydialog.cpp symbolwidget.cpp searchdialog.cpp librarydialog.cpp +main.cpp qucslib.cpp displaydialog.cpp symbolwidget.cpp librarydialog.cpp ) SET(QUCSLIB_MOC_HDRS -qucslib.h displaydialog.h symbolwidget.h searchdialog.h librarydialog.h +qucslib.h displaydialog.h symbolwidget.h librarydialog.h ) QT4_WRAP_CPP( QUCSLIB_MOC_SRCS ${QUCSLIB_MOC_HDRS} ) diff --git a/qucs/qucs-lib/Makefile.am b/qucs/qucs-lib/Makefile.am index 63f6bbe64b..36a7caeb84 100644 --- a/qucs/qucs-lib/Makefile.am +++ b/qucs/qucs-lib/Makefile.am @@ -28,13 +28,13 @@ bin_PROGRAMS = qucslib dist_man_MANS = qucslib.1 -MOCHEADERS = qucslib.h displaydialog.h symbolwidget.h searchdialog.h \ - librarydialog.h qucslib_common.h +MOCHEADERS = qucslib.h displaydialog.h symbolwidget.h librarydialog.h \ + qucslib_common.h MOCFILES = $(MOCHEADERS:.h=.moc.cpp) qucslib_SOURCES = main.cpp qucslib.cpp displaydialog.cpp symbolwidget.cpp \ - searchdialog.cpp librarydialog.cpp qrc_qucslib.cpp + librarydialog.cpp qrc_qucslib.cpp qrc_qucslib.cpp: qucslib.qrc $(RCC) -o $@ $< diff --git a/qucs/qucs-lib/qucslib.cpp b/qucs/qucs-lib/qucslib.cpp index ccbf43cb6e..1403fc2be5 100644 --- a/qucs/qucs-lib/qucslib.cpp +++ b/qucs/qucs-lib/qucslib.cpp @@ -40,13 +40,13 @@ #include #include #include +#include #include "qucslib.h" #include "qucslib_common.h" #include "librarydialog.h" #include "displaydialog.h" #include "symbolwidget.h" -#include "searchdialog.h" /* Constructor setups the GUI. */ @@ -84,6 +84,12 @@ QucsLib::QucsLib() helpMenu->addAction(helpAbout); connect(helpAbout, SIGNAL(activated()), SLOT(slotAbout())); + // use Escape key to clear search + QAction *escape = new QAction(this); + escape->setShortcut(Qt::Key_Escape); + connect(escape, SIGNAL(triggered()), SLOT(slotSearchClear())); + this->addAction(escape); + // setup menu bar menuBar()->addMenu(fileMenu); menuBar()->addSeparator(); @@ -106,12 +112,19 @@ QucsLib::QucsLib() CompList = new QListWidget(); connect(CompList, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*))); connect(CompList,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),SLOT(slotShowComponent(QListWidgetItem*))); - QPushButton *SearchButton = new QPushButton (tr("Search...")); - connect(SearchButton, SIGNAL(clicked()), SLOT(slotSearchComponent())); + + CompSearch = new QLineEdit(this); + CompSearch->setPlaceholderText(tr("Search Lib Components")); + QPushButton *CompSearchClear = new QPushButton(tr("Clear")); + connect(CompSearch, SIGNAL(textEdited(const QString &)), SLOT(slotSearchComponent(const QString &))); + connect(CompSearchClear, SIGNAL(clicked()), SLOT(slotSearchClear())); LibGroupLayout->addWidget(Library); LibGroupLayout->addWidget(CompList); - LibGroupLayout->addWidget(SearchButton); + QHBoxLayout *CompSearchLayout = new QHBoxLayout(); + LibGroupLayout->addLayout(CompSearchLayout); + CompSearchLayout->addWidget(CompSearch); + CompSearchLayout->addWidget(CompSearchClear); LibGroup->setLayout(LibGroupLayout); @@ -171,21 +184,24 @@ void QucsLib::putLibrariesIntoCombobox() UserLibCount = 0; QStringList LibFiles; QStringList::iterator it; + if(UserLibDir.cd(".")) // user library directory exists ? { //LibFiles = UserLibDir.entryList("*.lib", QDir::Files, QDir::Name); LibFiles = UserLibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); + UserLibCount = LibFiles.count(); for(it = LibFiles.begin(); it != LibFiles.end(); it++) { Library->addItem(QPixmap(":/bitmaps/home.png"), (*it).left((*it).length()-4)); } - } - - // add a separator to distinguish between user libraries and system libs - Library->insertSeparator(LibFiles.size()); + if (UserLibCount > 0) { + // add a separator to distinguish between user libraries and system libs + Library->insertSeparator(LibFiles.size()); + } + } QDir LibDir(QucsSettings.LibDir); LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); @@ -237,6 +253,7 @@ void QucsLib::slotManageLib() { (new LibraryDialog(this))->exec(); putLibrariesIntoCombobox(); + CompSearch->clear(); // in case "search mode" was previously active } // ---------------------------------------------------- @@ -283,27 +300,19 @@ void QucsLib::slotShowModel() // ---------------------------------------------------- void QucsLib::slotSelectLibrary(int Index) { - int End; - - End = Library->count ()-1; - - if(Library->itemText (End) == tr("Search result")) - { - if(Index < End) - { - // if search result still there -> remove it - Library->removeItem (End); - } - else - { - return; - } + // was in "search mode" ? + if (Library->itemText(0) == tr("Search results")) { + if (Index == 0) // user selected "Search results" item + return; + Library->removeItem(0); // remove the added "Search results" item + CompSearch->clear(); + --Index; // adjust requested index since item 0 was removed } - if(Library->itemText (0) == "") - { - Library->removeItem (0); - } + // make sure the right index is selected + // (might have been called by a cleared search and not by user action) + Library->setCurrentIndex(Index); + CompList->clear (); LibraryComps.clear (); DefaultSymbol = ""; @@ -351,15 +360,88 @@ void QucsLib::slotSelectLibrary(int Index) } // ---------------------------------------------------- -void QucsLib::slotSearchComponent() +void QucsLib::slotSearchComponent(const QString &searchText) { - SearchDialog *d = new SearchDialog(this); - d->setWindowTitle(tr("Search Library Component")); - if(d->exec() == QDialog::Accepted) - QMessageBox::information(this, tr("Result"), - tr("No appropriate component found.")); + // clear the components view + // (search restarts anew at every keypress) + CompList->clear (); + + if (Library->itemText(0) != tr("Search results")) { + // not already in "search mode" + libCurIdx = Library->currentIndex(); // remember current selected item + // insert "Search results" at the beginning, so that it is visible + Library->insertItem(-1, tr("Search results")); + Library->setCurrentIndex(0); + } + + if(searchText.isEmpty()) { + return; + } + + bool findComponent = false; + QDir LibDir(QucsSettings.LibDir); + QStringList LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); + + QFile File; + QTextStream ReadWhole; + QString LibraryString, LibName, CompName; + QStringList::iterator it; + int Start, End, NameStart, NameEnd; + for(it = LibFiles.begin(); it != LibFiles.end(); it++) { // all library files + File.setFileName(QucsSettings.LibDir + (*it)); + if(!File.open(QIODevice::ReadOnly)) continue; + + ReadWhole.setDevice(&File); + LibraryString = ReadWhole.readAll(); + File.close(); + + Start = LibraryString.indexOf("', Start); + if(End < 0) continue; + LibName = LibraryString.mid(Start, End-Start).section('"', 1, 1); + + // check all components of the current library + while((Start=LibraryString.indexOf("\n 0) { + Start++; + NameStart = Start + 11; + NameEnd = LibraryString.indexOf('>', NameStart); + if(NameEnd < 0) continue; + CompName = LibraryString.mid(NameStart, NameEnd-NameStart); + + End = LibraryString.indexOf("\n", NameEnd); + if(End < 0) continue; + End += 13; + + // does search criterion match ? + if(CompName.indexOf(searchText, 0, Qt::CaseInsensitive) >= 0) { + if(!findComponent) { + DefaultSymbol = ""; + CompList->clear(); + LibraryComps.clear(); + } + findComponent = true; + CompList->addItem(CompName); + LibraryComps.append(LibName+'\n'+LibraryString.mid(Start, End-Start)); + } + Start = End; + } + } +} + + +void QucsLib::slotSearchClear() +{ + // was in "search mode" ? + if (Library->itemText(0) == tr("Search results")) { + Library->removeItem(0); // remove the added "Search results" item + CompSearch->clear(); + // go back to the panel selected before search started + slotSelectLibrary(libCurIdx); + } } + // ---------------------------------------------------- void QucsLib::slotShowComponent(QListWidgetItem *Item) { diff --git a/qucs/qucs-lib/qucslib.h b/qucs/qucs-lib/qucslib.h index ec23954dde..1c3f828a44 100644 --- a/qucs/qucs-lib/qucslib.h +++ b/qucs/qucs-lib/qucslib.h @@ -64,7 +64,8 @@ private slots: void slotCopyToClipBoard(); void slotShowModel(); void slotSelectLibrary(int); - void slotSearchComponent(); + void slotSearchComponent(const QString &); + void slotSearchClear(); void slotShowComponent(QListWidgetItem*); void slotManageLib(); @@ -76,10 +77,11 @@ private slots: QMenu *fileMenu, *helpMenu; int UserLibCount; + int libCurIdx; SymbolWidget *Symbol; QTextEdit *CompDescr; QVBoxLayout *all; - + QLineEdit *CompSearch; }; #endif /* QUCSLIB_H */ diff --git a/qucs/qucs-lib/searchdialog.cpp b/qucs/qucs-lib/searchdialog.cpp deleted file mode 100644 index 6b62095337..0000000000 --- a/qucs/qucs-lib/searchdialog.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************** - searchdialog.cpp - ------------------ - begin : Sat Jun 11 2005 - copyright : (C) 2005 by Michael Margraf - email : michael.margraf@alumni.tu-berlin.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "searchdialog.h" -#include "qucslib.h" - - - -SearchDialog::SearchDialog(QucsLib *parent) - // QDialog(parent, 0, false, Qt::WDestructiveClose) - : QDialog(parent) -{ - ParentDialog = parent; - - all = new QVBoxLayout(this); - all->setMargin(5); - all->setSpacing(5); - - all->addWidget( - new QLabel(tr("The search result contains all components whose\n" - "name contains the search string. All libraries\n" - "are included in the search."), this) ); - - QLabel *SearchString = new QLabel(tr("Search string:")); - SearchEdit = new QLineEdit(); - connect(SearchEdit, SIGNAL(returnPressed()), SLOT(slotSearch())); - - QGroupBox *h1 = new QGroupBox(this); - QHBoxLayout *h1Layout = new QHBoxLayout(); - h1Layout->addWidget(SearchString); - h1Layout->addWidget(SearchEdit); - h1->setLayout(h1Layout); - - - QPushButton *ButtonSearch = new QPushButton(tr("Search")); - connect(ButtonSearch, SIGNAL(clicked()), SLOT(slotSearch())); - QPushButton *ButtonClose = new QPushButton(tr("Close")); - connect(ButtonClose, SIGNAL(clicked()), SLOT(slotClose())); - ButtonSearch->setFocus(); - - SearchEdit->setFocus(); - - QGroupBox *h2 = new QGroupBox(this); - QHBoxLayout *h2Layout = new QHBoxLayout(); - h2Layout->addWidget(ButtonSearch); - h2Layout->addWidget(ButtonClose); - h2->setLayout(h2Layout); - - all->addWidget(h1); - all->addWidget(h2); - -} - -SearchDialog::~SearchDialog() -{ - delete all; -} - -// ************************************************************ -void SearchDialog::slotClose() -{ - reject(); -} - -// ************************************************************ -void SearchDialog::slotSearch() -{ - if(SearchEdit->text().isEmpty()) { - reject(); - return; - } - - bool findComponent = false; - QDir LibDir(QucsSettings.LibDir); - QStringList LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); - - QFile File; - QTextStream ReadWhole; - QString LibraryString, LibName, CompName; - QStringList::iterator it; - int Start, End, NameStart, NameEnd; - for(it = LibFiles.begin(); it != LibFiles.end(); it++) { // all library files - File.setFileName(QucsSettings.LibDir + (*it)); - if(!File.open(QIODevice::ReadOnly)) continue; - - ReadWhole.setDevice(&File); - LibraryString = ReadWhole.readAll(); - File.close(); - - Start = LibraryString.indexOf("', Start); - if(End < 0) continue; - LibName = LibraryString.mid(Start, End-Start).section('"', 1, 1); - - // check all components of the current library - while((Start=LibraryString.indexOf("\n 0) { - Start++; - NameStart = Start + 11; - NameEnd = LibraryString.indexOf('>', NameStart); - if(NameEnd < 0) continue; - CompName = LibraryString.mid(NameStart, NameEnd-NameStart); - - End = LibraryString.indexOf("\n", NameEnd); - if(End < 0) continue; - End += 13; - - // does search criterion match ? - if(CompName.indexOf(SearchEdit->text(), 0, Qt::CaseInsensitive) >= 0) { - if(!findComponent) { - ParentDialog->DefaultSymbol = ""; - ParentDialog->CompList->clear(); - ParentDialog->LibraryComps.clear(); - } - findComponent = true; - ParentDialog->CompList->addItem(CompName); - ParentDialog->LibraryComps.append( - LibName+'\n'+LibraryString.mid(Start, End-Start)); - } - Start = End; - } - } - - if(findComponent) { - End = ParentDialog->Library->count(); - if(ParentDialog->Library->itemText(End-1) != tr("Search result")) - ParentDialog->Library->addItem(tr("Search result")); - ParentDialog->Library->setCurrentIndex(End); - reject(); - } - else accept(); -} diff --git a/qucs/qucs-lib/searchdialog.h b/qucs/qucs-lib/searchdialog.h deleted file mode 100644 index b8fe65eec6..0000000000 --- a/qucs/qucs-lib/searchdialog.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - searchdialog.h - ---------------- - begin : Sat Jun 11 2005 - copyright : (C) 2005 by Michael Margraf - email : michael.margraf@alumni.tu-berlin.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef SEARCHDIALOG_H -#define SEARCHDIALOG_H - -#include -#include -#include - -#include "qucslib.h" - - - -class SearchDialog : public QDialog { - Q_OBJECT -public: - SearchDialog(QucsLib *parent); - ~SearchDialog(); - -private slots: - void slotClose(); - void slotSearch(); - -private: - QVBoxLayout *all; - QLineEdit *SearchEdit; - QucsLib *ParentDialog; -}; - -#endif From 913db8936d8622aeb747242b277b87317a3e5ba6 Mon Sep 17 00:00:00 2001 From: in3otd Date: Sun, 26 Jul 2015 15:15:39 +0200 Subject: [PATCH 4/7] Include user libraries in search Previously the user libraries were shown in the selection list but not actually used when searching for a component. Now the list of searched libraries includes also the user libraries. --- qucs/qucs-lib/qucslib.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qucs/qucs-lib/qucslib.cpp b/qucs/qucs-lib/qucslib.cpp index 1403fc2be5..fe1f079139 100644 --- a/qucs/qucs-lib/qucslib.cpp +++ b/qucs/qucs-lib/qucslib.cpp @@ -362,6 +362,7 @@ void QucsLib::slotSelectLibrary(int Index) // ---------------------------------------------------- void QucsLib::slotSearchComponent(const QString &searchText) { + QStringList LibFiles; // clear the components view // (search restarts anew at every keypress) CompList->clear (); @@ -379,8 +380,17 @@ void QucsLib::slotSearchComponent(const QString &searchText) } bool findComponent = false; + + // user libraries + QStringList UserLibFiles = UserLibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); + foreach(QString s, UserLibFiles) // build list with full path + LibFiles += (UserLibDir.absoluteFilePath(s)); + + // system libraries QDir LibDir(QucsSettings.LibDir); - QStringList LibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); + QStringList SysLibFiles = LibDir.entryList(QStringList("*.lib"), QDir::Files, QDir::Name); + foreach(QString s, SysLibFiles) // build list with full path + LibFiles += (LibDir.absoluteFilePath(s)); QFile File; QTextStream ReadWhole; @@ -388,7 +398,7 @@ void QucsLib::slotSearchComponent(const QString &searchText) QStringList::iterator it; int Start, End, NameStart, NameEnd; for(it = LibFiles.begin(); it != LibFiles.end(); it++) { // all library files - File.setFileName(QucsSettings.LibDir + (*it)); + File.setFileName((*it)); if(!File.open(QIODevice::ReadOnly)) continue; ReadWhole.setDevice(&File); From 4ebfdbcd683bf7b6a1039d01868a422b87a4a61c Mon Sep 17 00:00:00 2001 From: in3otd Date: Sun, 26 Jul 2015 22:30:30 +0200 Subject: [PATCH 5/7] Make search show the selected component category --- qucs/qucs/qucs.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qucs/qucs/qucs.cpp b/qucs/qucs/qucs.cpp index a7ae9ec3b1..2ebafe55d5 100644 --- a/qucs/qucs/qucs.cpp +++ b/qucs/qucs/qucs.cpp @@ -846,7 +846,12 @@ void QucsApp::slotSelectComponent(QListWidgetItem *item) if (mod->info) { (*mod->info)(CompName, CompFile_cptr, false); if (CompName == name) { - //CompChoose->setCurrentIndex(i); + // change currently selected category, so the user will + // learn where the component comes from + CompChoose->setCurrentIndex(i+1); // +1 due to the added "Search Results" item + ccCurIdx = i; // remember the category to select when exiting search + //!! comment out the above two lines if you would like that the search + //!! returns back to the last selected category instead view->selElem = (*mod->info) (CompName, CompFile_cptr, true); // TODO: component found, exit the loops now... } From d7788976edc1e937fd7e5a7fe0a641550f5d06c9 Mon Sep 17 00:00:00 2001 From: in3otd Date: Sun, 26 Jul 2015 22:31:14 +0200 Subject: [PATCH 6/7] Make search show the selected component library --- qucs/qucs-lib/qucslib.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qucs/qucs-lib/qucslib.cpp b/qucs/qucs-lib/qucslib.cpp index fe1f079139..b5a8571ed7 100644 --- a/qucs/qucs-lib/qucslib.cpp +++ b/qucs/qucs-lib/qucslib.cpp @@ -218,6 +218,7 @@ void QucsLib::slotAbout() QMessageBox::about(this, tr("About..."), "QucsLib Version " PACKAGE_VERSION "\n"+ tr("Library Manager for Qucs\n")+ + tr("Copyright (C) 2011-2015 Qucs Team\n")+ tr("Copyright (C) 2005 by Michael Margraf\n")+ "\nThis is free software; see the source for copying conditions." "\nThere is NO warranty; not even for MERCHANTABILITY or " @@ -465,6 +466,9 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item) CompDescr->append("Library: " + LibName); CompDescr->append("----------------------------"); + // FIXME: here we assume that LibName is the same as the actual filename... + int i = Library->findText(LibName); + if(Library->currentIndex() < UserLibCount) LibName = UserLibDir.absolutePath() + QDir::separator() + LibName; @@ -509,6 +513,14 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item) else if(!DefaultSymbol.isEmpty()) // has library a default symbol ? Symbol->setSymbol(DefaultSymbol, LibName, Item->text()); + // change currently selected category, so the user will + // learn where the component comes from + Library->setCurrentIndex(i); + // remove 1 to find the actual index (when in Search Mode ther is one more + // item due to the added "Search Results" item) + libCurIdx = i-1; // remember the category to select when exiting search + //!! comment out the above two lines if you would like that the search + //!! returns back to the last selected category instead } From c8f6ae68faf65b234e3a0a8ff8f54b9c272e9683 Mon Sep 17 00:00:00 2001 From: in3otd Date: Mon, 27 Jul 2015 22:30:30 +0200 Subject: [PATCH 7/7] Use QucsHomeDir as base path for User Libs Corrected location of User Libs: now 'user_lib/' is assumed to be located in QucsSettings.QucsHomeDir instead of homePath() + '.qucs/', so that it will be correctly found even if the user changed the default Qucs home (user) directory. --- qucs/qucs-lib/main.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/qucs/qucs-lib/main.cpp b/qucs/qucs-lib/main.cpp index 099f746713..c78181db34 100644 --- a/qucs/qucs-lib/main.cpp +++ b/qucs/qucs-lib/main.cpp @@ -42,12 +42,17 @@ QDir UserLibDir; bool loadSettings() { QSettings settings("qucs","qucs"); + // Qucs Library Tool specific settings settings.beginGroup("QucsLib"); if(settings.contains("x"))QucsSettings.x=settings.value("x").toInt(); if(settings.contains("y"))QucsSettings.y=settings.value("y").toInt(); if(settings.contains("dx"))QucsSettings.dx=settings.value("dx").toInt(); if(settings.contains("dy"))QucsSettings.dy=settings.value("dy").toInt(); settings.endGroup(); + // Qucs general settings + if(settings.contains("QucsHomeDir")) + if(settings.value("QucsHomeDir").toString() != "") + QucsSettings.QucsHomeDir.setPath(settings.value("QucsHomeDir").toString()); if(settings.contains("font"))QucsSettings.font.fromString(settings.value("font").toString()); if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString(); @@ -85,23 +90,24 @@ int main(int argc, char *argv[]) QucsSettings.dx = 600; QucsSettings.dy = 350; QucsSettings.font = QFont("Helvetica", 12); + QucsSettings.QucsHomeDir.setPath(QDir::homePath() + "/.qucs"); // is application relocated? char * var = getenv ("QUCSDIR"); + QDir QucsDir; if (var != NULL) { - QDir QucsDir = QDir (var); - QString QucsDirStr = QucsDir.canonicalPath (); - QucsSettings.LangDir = - QDir::convertSeparators (QucsDirStr + "/share/qucs/lang/"); - QucsSettings.LibDir = - QDir::convertSeparators (QucsDirStr + "/share/qucs/library/"); + QucsDir = QDir(QString(var)); + QucsSettings.LangDir = QucsDir.canonicalPath() + "/share/qucs/lang/"; + QucsSettings.LibDir = QucsDir.canonicalPath() + "/share/qucs/library/"; } else { QucsSettings.LangDir = LANGUAGEDIR; QucsSettings.LibDir = LIBRARYDIR; } - UserLibDir.setPath (QDir::homePath()+QDir::convertSeparators ("/.qucs/user_lib")); + loadSettings(); + UserLibDir.setPath(QucsSettings.QucsHomeDir.canonicalPath() + "/user_lib/"); + QApplication a(argc, argv); a.setFont(QucsSettings.font);