__init__.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. /***************************************************************************
  3. Name : Versioning plugin for DB Manager
  4. Description : Set up versioning support for a table
  5. Date : Mar 12, 2012
  6. copyright : (C) 2012 by Giuseppe Sucameli
  7. email : brush.tyler@gmail.com
  8. ***************************************************************************/
  9. /***************************************************************************
  10. * *
  11. * This program is free software; you can redistribute it and/or modify *
  12. * it under the terms of the GNU General Public License as published by *
  13. * the Free Software Foundation; either version 2 of the License, or *
  14. * (at your option) any later version. *
  15. * *
  16. ***************************************************************************/
  17. """
  18. from qgis.PyQt.QtCore import Qt
  19. from qgis.PyQt.QtWidgets import QAction, QApplication
  20. from qgis.PyQt.QtGui import QIcon
  21. # The load function is called when the "db" database or either one of its
  22. # children db objects (table o schema) is selected by the user.
  23. # @param db is the selected database
  24. # @param mainwindow is the DBManager mainwindow
  25. def load(db, mainwindow):
  26. # add the action to the DBManager menu
  27. action = QAction(QIcon(), QApplication.translate("DBManagerPlugin", "&Change Logging…"), db)
  28. mainwindow.registerAction(action, QApplication.translate("DBManagerPlugin", "&Table"), run)
  29. # The run function is called once the user clicks on the action TopoViewer
  30. # (look above at the load function) from the DBManager menu/toolbar.
  31. # @param item is the selected db item (either db, schema or table)
  32. # @param action is the clicked action on the DBManager menu/toolbar
  33. # @param mainwindow is the DBManager mainwindow
  34. def run(item, action, mainwindow):
  35. from .dlg_versioning import DlgVersioning
  36. dlg = DlgVersioning(item, mainwindow)
  37. QApplication.restoreOverrideCursor()
  38. try:
  39. dlg.exec_()
  40. finally:
  41. QApplication.setOverrideCursor(Qt.WaitCursor)