Skip to content

Commit

Permalink
Removed all references to _otherwindows on MainWindow, so all subwind…
Browse files Browse the repository at this point in the history
…ows (except BusinessEditor) will belong to MDI Area
  • Loading branch information
j2sg committed Jul 19, 2015
1 parent 7722938 commit a8428b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
4 changes: 0 additions & 4 deletions include/view/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define MAINWINDOW_H

#include <QMainWindow>
#include <QList>
#include <QDate>
#include "types.h"

Expand Down Expand Up @@ -106,7 +105,6 @@ namespace View
void invoiceSaved(const Model::Domain::Invoice &invoice);
void invoiceDeleted(const Model::Domain::Invoice &invoice);
void invoiceHasAddedNewEntity(const Model::Domain::Invoice &invoice);
void updateOtherWindows(QObject *object);
private:
void createWidgets();
void createCentralWidget();
Expand All @@ -128,7 +126,6 @@ namespace View
const QDate &endDate = QDate::currentDate());
View::Report::UnpaidsReport *createUnpaidsReport();
void closeAllEditors();
void closeOtherWindows();
void deleteAllEditors();
void setStorageConnected(bool connected = true);
void setCompanyOpen(bool open = true);
Expand Down Expand Up @@ -189,7 +186,6 @@ namespace View

View::Management::EntityEditor *_companyEditor;
View::Management::BusinessEditor *_businessEditor;
QList<QWidget *> _otherWindows;
};
}

Expand Down
31 changes: 5 additions & 26 deletions src/view/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void View::MainWindow::closeEvent(QCloseEvent *event)
event -> accept();
else if(verifyExit()) {
closeAllEditors();
closeOtherWindows();
_mdiArea -> closeAllSubWindows();
if(!_mdiArea -> currentSubWindow())
event -> accept();
Expand Down Expand Up @@ -181,7 +180,6 @@ void View::MainWindow::disconnectStorage()

closeAllEditors();
deleteAllEditors();
closeOtherWindows();
}

void View::MainWindow::importStorage()
Expand Down Expand Up @@ -283,8 +281,6 @@ void View::MainWindow::closeCompany()
return;
}

closeOtherWindows();

statusBar() -> showMessage(tr("Closed Company %1").arg(_company -> name()), 5000);

delete _company;
Expand Down Expand Up @@ -385,6 +381,7 @@ void View::MainWindow::searchInvoice()
View::Invoicing::InvoiceSearchResult *result = createInvoiceSearchResult(dialog.type(), dialog.searchMode(),
dialog.beginDate(), dialog.endDate(), dialog.entityId(),
dialog.minTotal(), dialog.maxTotal(), dialog.paid());
_mdiArea -> addSubWindow(result);
result -> show();
}
}
Expand Down Expand Up @@ -449,6 +446,7 @@ void View::MainWindow::volumeBuy()
Model::Management::SearchByDateRange :
Model::Management::SearchByTypeOnly,
dialog.beginDate(), dialog.endDate());
_mdiArea -> addSubWindow(volumeReport);
volumeReport -> show();
}
}
Expand All @@ -466,6 +464,7 @@ void View::MainWindow::volumeSale()
Model::Management::SearchByDateRange :
Model::Management::SearchByTypeOnly,
dialog.beginDate(), dialog.endDate());
_mdiArea -> addSubWindow(volumeReport);
volumeReport -> show();
}
}
Expand All @@ -477,6 +476,7 @@ void View::MainWindow::unpaidInvoices()

View::Report::UnpaidsReport *unpaidsReport = createUnpaidsReport();

_mdiArea -> addSubWindow(unpaidsReport);
unpaidsReport -> show();
}

Expand Down Expand Up @@ -556,13 +556,6 @@ void View::MainWindow::invoiceHasAddedNewEntity(const Model::Domain::Invoice &in

}

void View::MainWindow::updateOtherWindows(QObject *object)
{
QWidget *window = qobject_cast<QWidget *>(object);
window -> close();
_otherWindows.removeAll(window);
}

void View::MainWindow::createWidgets()
{
createCentralWidget();
Expand Down Expand Up @@ -889,7 +882,7 @@ View::Invoicing::InvoiceEditor *View::MainWindow::findInvoiceEditor(Model::Domai
{
foreach(QMdiSubWindow *subWindow, _mdiArea -> subWindowList()) {
View::Invoicing::InvoiceEditor *editor = qobject_cast<View::Invoicing::InvoiceEditor *>(subWindow -> widget());
if(editor -> id() == invoice -> id())
if(editor && editor -> id() == invoice -> id())
return editor;
}

Expand All @@ -905,8 +898,6 @@ View::Invoicing::InvoiceSearchResult *View::MainWindow::createInvoiceSearchResul
View::Invoicing::InvoiceSearchResult *result = new View::Invoicing::InvoiceSearchResult(invoices, type);

connect(result, SIGNAL(loaded(Model::Domain::Invoice*)), this, SLOT(loadInvoice(Model::Domain::Invoice*)));
connect(result, SIGNAL(destroyed(QObject*)), this, SLOT(updateOtherWindows(QObject*)));
_otherWindows.push_back(result);

return result;
}
Expand All @@ -928,9 +919,6 @@ View::Report::VolumeReport *View::MainWindow::createVolumeReport(Model::Domain::
View::Report::VolumeReport *volumeReport = new View::Report::VolumeReport(type, reportByDate, reportByEntity,
reportByProduct, statistics);

connect(volumeReport, SIGNAL(destroyed(QObject *)), this, SLOT(updateOtherWindows(QObject *)));
_otherWindows.push_back(volumeReport);

delete invoices;

return volumeReport;
Expand All @@ -949,9 +937,6 @@ View::Report::UnpaidsReport *View::MainWindow::createUnpaidsReport()

View::Report::UnpaidsReport *unpaidsReport = new View::Report::UnpaidsReport(buyInvoices, saleInvoices, buyStatistics, saleStatistics);

connect(unpaidsReport, SIGNAL(destroyed(QObject *)), this, SLOT(updateOtherWindows(QObject *)));
_otherWindows.push_back(unpaidsReport);

return unpaidsReport;
}

Expand All @@ -964,12 +949,6 @@ void View::MainWindow::closeAllEditors()
_businessEditor -> close();
}

void View::MainWindow::closeOtherWindows()
{
foreach(QWidget *window, _otherWindows)
window -> close();
}

void View::MainWindow::deleteAllEditors()
{
if(_companyEditor) {
Expand Down

0 comments on commit a8428b6

Please sign in to comment.