Skip to content

Commit

Permalink
Fixes for Search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
arun3688 authored and adeas31 committed Jan 6, 2018
1 parent 06dcea4 commit d146539
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
19 changes: 3 additions & 16 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -579,6 +579,8 @@ void MainWindow::beforeClosingMainWindow()
GDBAdapter::destroy();
// delete the GitCommands object
GitCommands::destroy();
// delete the searchwidget object to call the destructor, to cancel the search operation running on seperate thread
delete mpSearchWidget;
}

/*!
Expand Down Expand Up @@ -2453,15 +2455,6 @@ void MainWindow::enableReSimulationToolbar(bool visible)
}
}

/*!
* \brief MainWindow::openSearchBrowser
* Open the Search browser Dock Widget using shortcut keys ctrl+h.
*/
void MainWindow::openSearchBrowser()
{
mpSearchDockWidget->show();
}

/*!
* \brief MainWindow::perspectiveTabChanged
* Handles the perspective tab changed case.
Expand Down Expand Up @@ -3157,12 +3150,6 @@ void MainWindow::createActions()
mpTLMCoSimulationAction->setStatusTip(Helper::tlmCoSimulationSetupTip);
mpTLMCoSimulationAction->setEnabled(false);
connect(mpTLMCoSimulationAction, SIGNAL(triggered()), SLOT(TLMSimulate()));
// Search action
mpSearchDockWidgetAction = new QAction(this);
mpSearchDockWidgetAction->setShortcut(QKeySequence("Ctrl+h"));
mpSearchDockWidgetAction->setStatusTip(tr("Open the Search Browser"));
connect(mpSearchDockWidgetAction, SIGNAL(triggered()), SLOT(openSearchBrowser()));

}

//! Creates the menus
Expand Down Expand Up @@ -3264,12 +3251,12 @@ void MainWindow::createMenus()
#endif
pViewWindowsMenu->addAction(mpMessagesDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpSearchDockWidget->toggleViewAction());
mpSearchDockWidget->toggleViewAction()->setShortcut(QKeySequence("Ctrl+h"));
pViewWindowsMenu->addAction(mpStackFramesDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpBreakpointsDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpLocalsDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpTargetOutputDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpGDBLoggerDockWidget->toggleViewAction());
pViewWindowsMenu->addAction(mpSearchDockWidgetAction);
pViewWindowsMenu->addSeparator();
pViewWindowsMenu->addAction(mpCloseWindowAction);
pViewWindowsMenu->addAction(mpCloseAllWindowsAction);
Expand Down
3 changes: 0 additions & 3 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -380,8 +380,6 @@ class MainWindow : public QMainWindow
QAction *mpFetchInterfaceDataAction;
QAction *mpAlignInterfacesAction;
QAction *mpTLMCoSimulationAction;
// Search Actions
QAction * mpSearchDockWidgetAction;
// Toolbars
QMenu *mpRecentFilesMenu;
QMenu *mpLibrariesMenu;
Expand Down Expand Up @@ -468,7 +466,6 @@ public slots:
void toggleAutoSave();
void readInterfaceData(LibraryTreeItem *pLibraryTreeItem);
void enableReSimulationToolbar(bool visible);
void openSearchBrowser();
private slots:
void perspectiveTabChanged(int tabIndex);
void documentationDockWidgetVisibilityChanged(bool visible);
Expand Down
3 changes: 2 additions & 1 deletion OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1010,6 +1010,7 @@ bool LibraryTreeProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
if (mShowOnlyModelica && pLibraryTreeItem && pLibraryTreeItem->getLibraryType() != LibraryTreeItem::Modelica) {
return false;
}
// filter the dummy tree item "All" created for search functionality to be at the top
if (pLibraryTreeItem->getNameStructure().compare("OMEdit.Search.Feature") == 0) {
return false;
}
Expand Down Expand Up @@ -3611,7 +3612,7 @@ LibraryWidget::LibraryWidget(QWidget *pParent)
connect(mpLibraryTreeModel, SIGNAL(rowsInserted(QModelIndex,int,int)), mpLibraryTreeProxyModel, SLOT(invalidate()));
connect(mpLibraryTreeModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), mpLibraryTreeProxyModel, SLOT(invalidate()));
// create a dummy librarytreeItem
mpLibraryTreeModel->createLibraryTreeItem(LibraryTreeItem::Text, "ALL", "OMEdit.Search.Feature", "", true, mpLibraryTreeModel->getRootLibraryTreeItem());
mpLibraryTreeModel->createLibraryTreeItem(LibraryTreeItem::Text, "All", "OMEdit.Search.Feature", "", true, mpLibraryTreeModel->getRootLibraryTreeItem());
// create the layout
QGridLayout *pMainLayout = new QGridLayout;
pMainLayout->setContentsMargins(0, 0, 0, 0);
Expand Down
14 changes: 9 additions & 5 deletions OMEdit/OMEditGUI/Search/SearchWidget.cpp
Expand Up @@ -116,6 +116,7 @@ SearchWidget::SearchWidget(QWidget *pParent)
connect(mpSearchButton, SIGNAL(clicked()), SLOT(searchInFiles()));
connect(pSearchBack, SIGNAL(clicked()), SLOT(switchSearchPage()));
connect(mpCancelButton,SIGNAL(clicked()), SLOT(cancelSearch()));
connect(this,SIGNAL(setCancelSearch()),mpSearch,SLOT(updateCancelSearch()));

QVBoxLayout *pSearchSetStackLayout = new QVBoxLayout;
pSearchSetStackLayout->addWidget(mpSearchStackedWidget);
Expand All @@ -125,6 +126,7 @@ SearchWidget::SearchWidget(QWidget *pParent)

SearchWidget::~SearchWidget()
{
// when the mainwindow closes check whether any ongoing search operation is running emit the stop signal and stop the thread
emit setCancelSearch();
}

Expand Down Expand Up @@ -176,7 +178,6 @@ void SearchWidget::searchInFiles()
*/
void SearchWidget::cancelSearch()
{
connect(this,SIGNAL(setCancelSearch()),mpSearch,SLOT(updateCancelSearch()));
emit setCancelSearch();
}

Expand All @@ -187,6 +188,9 @@ void SearchWidget::cancelSearch()
*/
void SearchWidget::switchSearchPage()
{
/* emit the signal to make sure the thread is stopped if search is not completed fully
and user press the back button */
emit setCancelSearch();
/* switch the search page and clear all the items */
mpSearchStackedWidget->setCurrentIndex(0);
mpProgressBar->setValue(0);
Expand Down Expand Up @@ -289,7 +293,7 @@ SearchFileDetails::SearchFileDetails(QString filename, QMap<int,QString> Linenum
Search::Search(QObject *parent):
QObject(parent)
{
mpStop = false;
mStop = false;
}

/*!
Expand All @@ -299,7 +303,7 @@ Search::Search(QObject *parent):
*/
void Search::run()
{
mpStop = false;
mStop = false;
SearchWidget *mSearchWidget=MainWindow::instance()->getSearchWidget();
LibraryTreeModel *pLibraryTreeModel = MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel();
QStringList filelist;
Expand All @@ -326,7 +330,7 @@ void Search::run()
for (int i = 0; i < filelist.size(); ++i)
{
// check for cancel operation
if(mpStop)
if(mStop)
{
return;
}
Expand Down Expand Up @@ -393,7 +397,7 @@ void Search::getFiles(QString path, QStringList pattern, QStringList &filelist)
*/
void Search::updateCancelSearch()
{
mpStop = true;
mStop = true;
}


Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Search/SearchWidget.h
Expand Up @@ -106,5 +106,5 @@ class Search : public QObject
public slots:
void updateCancelSearch();
private:
bool mpStop;
bool mStop;
};

0 comments on commit d146539

Please sign in to comment.