class CSVTableController(AbstractTableController): """ Implements AbstractTableController class for *.CSV files tables """ def __init__(self): """ Default constructor """ AbstractTableController.__init__(self) self._user = None self._userRights = UserRights() self._model = None self._application = None self._mainWindow = None def start(self, loginFilePath): """ Reimplemented from AbstractTableController """ self._application = QtGui.QApplication(sys.argv) self._mainWindow = MainWindow(self) self._mainWindow.setVisible(False) loginDialog = LoginDialog(loginFilePath) QtCore.QObject.connect(loginDialog, QtCore.SIGNAL("userLoggedIn(QObject)"), self.userLoggedIn) loginDialog.setModal(True) loginDialog.show() sys.exit(self._application.exec_()) def userLoggedIn(self, user): """ Reimplemented from AbstractTableController """ if user == None or (user.login() == "" and user.password() == ""): self._application.exit() return self._user = user self._userRights = user.rights() self._mainWindow.setVisible(True) def openTable(self, tablePath): """ Reimplemented from AbstractTableController """ try: with open(tablePath) as testingObject: pass except IOError, exception: return OperationResult(False, None, "File error: " + exception.message) try: self._model = CSVTableModel(tablePath) except Exception, exception: return OperationResult(False, None, "Model error: " + exception.message)