Skip to content

Commit

Permalink
[ConcertSearch] Remove singleton for dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
bugwelle committed May 13, 2020
1 parent 081a0b6 commit 68ce425
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 31 deletions.
23 changes: 1 addition & 22 deletions src/ui/concerts/ConcertSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,13 @@ ConcertSearch::~ConcertSearch()
delete ui;
}

/**
* @brief Returns an instance of the class
* @param parent Parent widget
* @return Instance of ConcertSearch
*/
ConcertSearch* ConcertSearch::instance(QWidget* parent)
{
static ConcertSearch* m_instance = nullptr;
if (m_instance == nullptr) {
m_instance = new ConcertSearch(parent);
}
return m_instance;
}

/**
* @brief Executes the search dialog
* @param searchString Concert name/search string
* @return Result of QDialog::exec
* @see ConcertSearch::search
*/
int ConcertSearch::exec(QString searchString)
int ConcertSearch::execWithSearch(QString searchString)
{
QSize newSize;
newSize.setHeight(parentWidget()->size().height() - 200);
Expand All @@ -55,13 +41,6 @@ int ConcertSearch::exec(QString searchString)
return QDialog::exec();
}

int ConcertSearch::exec()
{
return 0;
}

/*** GETTER ***/

/**
* @brief ConcertSearch::scraperNo
* @return Current scraper number
Expand Down
4 changes: 2 additions & 2 deletions src/ui/concerts/ConcertSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ConcertSearch : public QDialog
~ConcertSearch() override;

public slots:
int exec() override;
int exec(QString searchString);
int execWithSearch(QString searchString);

static ConcertSearch* instance(QWidget* parent = nullptr);
int scraperNo();
TmdbId scraperId();
Expand Down
18 changes: 12 additions & 6 deletions src/ui/concerts/ConcertWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,20 @@ void ConcertWidget::onStartScraperSearch()
}
emit setActionSearchEnabled(false, MainWidgets::Concerts);
emit setActionSaveEnabled(false, MainWidgets::Concerts);
ConcertSearch::instance()->exec(m_concert->name());
if (ConcertSearch::instance()->result() == QDialog::Accepted) {

auto* searchWidget = new ConcertSearch(this);
searchWidget->execWithSearch(m_concert->name());

if (searchWidget->result() == QDialog::Accepted) {
setDisabledTrue();
ConcertSearch::instance()->scraperId();
m_concert->controller()->loadData(ConcertSearch::instance()->scraperId(),
Manager::instance()->concertScrapers().at(ConcertSearch::instance()->scraperNo()),
ConcertSearch::instance()->infosToLoad());
searchWidget->scraperId();
m_concert->controller()->loadData(searchWidget->scraperId(),
Manager::instance()->concertScrapers().at(searchWidget->scraperNo()),
searchWidget->infosToLoad());
searchWidget->deleteLater();

} else {
searchWidget->deleteLater();
emit setActionSearchEnabled(true, MainWidgets::Concerts);
emit setActionSaveEnabled(true, MainWidgets::Concerts);
}
Expand Down
1 change: 0 additions & 1 deletion src/ui/main/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
TvShowSearch::instance(this);
ImageDialog::instance(this);
MovieListDialog::instance(this);
ConcertSearch::instance(this);
NameFormatter::instance(this);
MovieMultiScrapeDialog::instance(this);
MusicMultiScrapeDialog::instance(this);
Expand Down

0 comments on commit 68ce425

Please sign in to comment.