def __init__(self, argv):
        QApplication.__init__(self, argv)
        self.setApplicationName('ProfileLogger')
        self.setApplicationVersion('2.0')
        self.setOrganizationName('lochisoft')
        self.setOrganizationDomain('lochisoft.org')

        self.setupActions()
        self.db = Database()
class ProfileLogger(QApplication):
    databaseConnected = pyqtSignal(QString)
    databaseClosed = pyqtSignal(QString)

    def __init__(self, argv):
        QApplication.__init__(self, argv)
        self.setApplicationName('ProfileLogger')
        self.setApplicationVersion('2.0')
        self.setOrganizationName('lochisoft')
        self.setOrganizationDomain('lochisoft.org')

        self.setupActions()
        self.db = Database()
    def setupActions(self):
        self.quitA = QAction(self.tr('&Quit'), self)
        self.quitA.setShortcut(QKeySequence('Ctrl+q'))
        self.quitA.triggered.connect(QApplication.instance().quit);

        self.openDbA = QAction(self.tr('&Open Database...'), self)
        self.openDbA.setShortcut(QKeySequence('Ctrl+o'))
        self.openDbA.triggered.connect(self.onOpenDatabase)

        self.closeDbA = QAction(self.tr('&Close Database...'), self)
        self.closeDbA.triggered.connect(self.onCloseDatabase)

        self.manageProjectsA = QAction(self.tr('&Projects...'), self)
        self.manageProjectsA.triggered.connect(QApplication.instance().onManageProjects)

        self.manageLengthUnitsA = QAction(self.tr('&Length Units...'), self)
        self.manageLengthUnitsA.triggered.connect(QApplication.instance().onManageLengthUnits)

        self.manageSVGItemsA = QAction(self.tr('&SVG Items...'), self)
        self.manageSVGItemsA.triggered.connect(QApplication.instance().onManageSVGItems)
        self.manageLithologicalUnitTypesA = QAction(self.tr('&Lithological Unit Types...'), self)
        self.manageLithologicalUnitTypesA.triggered.connect(QApplication.instance().onManageLithologicalUnitTypes)

        self.manageStratigraphicUnitTypesA = QAction(self.tr('&Stratigraphic Unit Types...'), self)
        self.manageStratigraphicUnitTypesA.triggered.connect(QApplication.instance().onManageStratigraphicUnitTypes)

        self.manageTectonicUnitTypesA = QAction(self.tr('&Tectonic Unit Types...'), self)
        self.manageTectonicUnitTypesA.triggered.connect(QApplication.instance().onManageTectonicUnitTypes)

        self.manageGeologicalMeasurementTypesA = QAction(self.tr('&Geological Measurement Types...'), self)
        self.manageGeologicalMeasurementTypesA.triggered.connect(QApplication.instance().onManageGeologicalMeasurementTypes)
        self.manageGrainSizeTypesA = QAction(self.tr('&Grain Size Types...'), self)
        self.manageGrainSizeTypesA.triggered.connect(QApplication.instance().onManageGrainSizeTypes)    
        self.manageGrainSizesA = QAction(self.tr('&Grain Sizes...'), self)
        self.manageGrainSizesA.triggered.connect(QApplication.instance().onManageGrainSizes)
    def onManageProjects(self):
        dlg = ProjectManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageLengthUnits(self):
        dlg = LengthUnitManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageSVGItems(self):
        dlg = SVGItemManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageLithologicalUnitTypes(self):
        dlg = LithologicalUnitTypeManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageStratigraphicUnitTypes(self):
        dlg = StratigraphicUnitTypeManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageTectonicUnitTypes(self):
        dlg = TectonicUnitTypeManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageGeologicalMeasurementTypes(self):
        dlg = GeologicalMeasurementTypeManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageGrainSizeTypes(self):
        dlg = GrainSizeTypeManagementDialog(self.activeWindow())
        dlg.exec_()
    def onManageGrainSizes(self):
        dlg = GrainSizeManagementDialog(self.activeWindow())
        dlg.exec_()
    def getGlobalManagementActions(self):
        ret = []
        ret.append(self.manageProjectsA)
        ret.append(self.manageLithologicalUnitTypesA)
        ret.append(self.manageStratigraphicUnitTypesA)
        ret.append(self.manageTectonicUnitTypesA)
        ret.append(self.manageGeologicalMeasurementTypesA)
        ret.append(self.manageGrainSizeTypesA)
        ret.append(self.manageGrainSizesA)
        ret.append(self.manageLengthUnitsA)
        ret.append(self.manageSVGItemsA)
        return ret
    def getFileActions(self):
        ret = []
        ret.append(self.quitA)
        return ret
    def getToolActions(self):
        ret = []
        return ret
    def getDatabaseActions(self):
        ret = []
        ret.append(self.openDbA)
        return ret;
    def onOpenDatabase(self):
        cd = Settings().loadConnectionData()
        dlg = DatabaseConnectionDialog(cd, self.activeWindow())
        if QDialog.Accepted == dlg.exec_():
            Settings().saveConnectionData(cd)
            try:
                self.db.open(cd)
                if (cd.insertTemplateData):
                    self.insertTemplateData()
                    self.lengthUnitModel.reload()
                self.databaseConnected.emit(cd.makeInfoString())
            except OperationalError, e:
                dlg = DatabaseExceptionDialog(QApplication.activeWindow(), e)
                dlg.exec_()