# Path: gsdview/mdi.py
# class MdiMainWindow(QtWidgets.QMainWindow):
#     """Base class for MDI applications.
# 
#     :SIGNALS:
# 
#         * :attr:`subWindowClosed`
# 
#     """
# 
#     # @TODO: should the subWindowClosed signal be emitted by mdiarea?
#     #: SIGNAL: it is emitted when an MDI subwindow is closed
#     #:
#     #: :C++ signature: `void subWindowClosed()`
#     subWindowClosed = QtCore.Signal()
# 
#     def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):
#         super().__init__(parent, flags, **kwargs)
# 
#         #: MDI area instance (QMdiArea)
#         self.mdiarea = QtWidgets.QMdiArea()
#         self.setCentralWidget(self.mdiarea)
#         self.mdiarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
#         self.mdiarea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
# 
#         #: sub-windows menu
#         self.windowmenu = QtWindowListMenu(self.menuBar())
#         self.windowmenu.attachToMdiArea(self.mdiarea)
# 
# Path: gsdview/qtsupport.py
# def geticon(name, package=None):
#     """Build and return requested icon.
# 
#     It is assumed that icon files are located in the "images" subfolder
#     of the package.
# 
#     .. seealso:: :func:`gsdview.utils.getresource`
# 
#     """
# 
#     iconfile = utils.getresource(os.path.join('images', name), package)
# 
#     return QtGui.QIcon(iconfile)


import os
import sys
    import sys
from qtpy import QtCore, QtWidgets
from gsdview.mdi import MdiMainWindow
from gsdview.qtsupport import geticon
        self.createMenus()
        self.createToolBars()
        self.updateActions()

        self.setWindowTitle(self.tr('MDI'))
        self.statusBar().showMessage(self.tr('Ready'))

    def closeEvent(self, event):
        self.mdiarea.closeAllSubWindows()
        if self.mdiarea.activeSubWindow():
            event.ignore()
        else:
            event.accept()

    def activeMdiChild(self):
        subwindow = self.mdiarea.activeSubWindow()
        if subwindow:
            return subwindow.widget()
        return None

    @QtCore.Slot()
    def newFile(self):
        child = self.createMdiChild()
        child.newFile()
        child.show()

    @QtCore.Slot()
    def open(self):
        fileName = QtWidgets.QFileDialog.getOpenFileName(self)
        if not fileName.isEmpty():

# Path: gsdview/mdi.py
# class MdiMainWindow(QtWidgets.QMainWindow):
#     """Base class for MDI applications.
# 
#     :SIGNALS:
# 
#         * :attr:`subWindowClosed`
# 
#     """
# 
#     # @TODO: should the subWindowClosed signal be emitted by mdiarea?
#     #: SIGNAL: it is emitted when an MDI subwindow is closed
#     #:
#     #: :C++ signature: `void subWindowClosed()`
#     subWindowClosed = QtCore.Signal()
# 
#     def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):
#         super().__init__(parent, flags, **kwargs)
# 
#         #: MDI area instance (QMdiArea)
#         self.mdiarea = QtWidgets.QMdiArea()
#         self.setCentralWidget(self.mdiarea)
#         self.mdiarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
#         self.mdiarea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
# 
#         #: sub-windows menu
#         self.windowmenu = QtWindowListMenu(self.menuBar())
#         self.windowmenu.attachToMdiArea(self.mdiarea)
# 
# Path: gsdview/qtsupport.py
# def geticon(name, package=None):
#     """Build and return requested icon.
# 
#     It is assumed that icon files are located in the "images" subfolder
#     of the package.
# 
#     .. seealso:: :func:`gsdview.utils.getresource`
# 
#     """
# 
#     iconfile = utils.getresource(os.path.join('images', name), package)
# 
#     return QtGui.QIcon(iconfile)


# Path: tests/test_mdi.py
import os
import sys
    import sys
from qtpy import QtCore, QtWidgets
from gsdview.mdi import MdiMainWindow
from gsdview.qtsupport import geticon

        self.createMenus()
        self.createToolBars()
        self.updateActions()

        self.setWindowTitle(self.tr('MDI'))
        self.statusBar().showMessage(self.tr('Ready'))

    def closeEvent(self, event):
        self.mdiarea.closeAllSubWindows()
        if self.mdiarea.activeSubWindow():
            event.ignore()
        else:
            event.accept()

    def activeMdiChild(self):
        subwindow = self.mdiarea.activeSubWindow()
        if subwindow:
            return subwindow.widget()
        return None

    @QtCore.Slot()
    def newFile(self):
        child = self.createMdiChild()
        child.newFile()
        child.show()

    @QtCore.Slot()
    def open(self):
        fileName = QtWidgets.QFileDialog.getOpenFileName(self)
        if not fileName.isEmpty():

            existing = self.findMdiChild(fileName)