Exemplo n.º 1
0
    def database(self, accion, dbpath, temporary=False):
        if accion == "M":
            if Code.is_windows:
                os.startfile(self.configuration.folder_databases())
            return

        if accion == "N":
            dbpath = WDB_Games.new_database(self.main_window,
                                            self.configuration)
            if dbpath is None:
                return
            accion = "R"

        if accion == "D":
            resp = QTVarios.select_db(self.main_window, self.configuration,
                                      True, False)
            if resp:
                if QTUtil2.pregunta(
                        self.main_window,
                        "%s\n%s" % (_("Do you want to remove?"), resp)):
                    Util.remove_file(resp)
                    Util.remove_file(resp + ".st1")
            return

        if accion == "R":
            self.configuration.set_last_database(Util.relative_path(dbpath))
            w = WindowDatabase.WBDatabase(self.main_window, self, dbpath,
                                          temporary, False)
            if self.main_window:
                if w.exec_():
                    if w.reiniciar:
                        self.database("R",
                                      self.configuration.get_last_database())
            else:
                w.show()
Exemplo n.º 2
0
 def tw_select_other(self):
     resp = QTVarios.select_db(self, self.configuration, False, True)
     if resp:
         if resp == ":n":
             dbpath = WDB_Games.new_database(self, self.configuration)
             if dbpath is not None:
                 self.configuration.set_last_database(dbpath)
                 self.reinit()
         else:
             self.configuration.set_last_database(resp)
             self.reinit()
Exemplo n.º 3
0
 def gm_save_database(self):
     if self.torneo.num_games_finished() > 0:
         dbpath = QTVarios.select_db(self,
                                     self.configuration,
                                     False,
                                     True,
                                     remove_autosave=True)
         if dbpath is None:
             return
         if dbpath == ":n":
             dbpath = WDB_Games.new_database(self, self.configuration)
             if dbpath is None:
                 return
         um = QTUtil2.unMomento(self, _("Saving..."))
         db = DBgames.DBgames(dbpath)
         for gm in self.torneo.db_games_finished:
             game = Game.Game()
             game.restore(gm.game_save)
             db.insert(game)
         um.final()
         db.close()
         QTUtil2.mensajeTemporal(self, _("Saved"), 1.2)
Exemplo n.º 4
0
    def __init__(self, w_parent, procesador, file_database, is_temporary,
                 si_select):
        self.is_temporary = is_temporary
        icono = Iconos.Database()
        extparam = "databases"
        titulo = _("Temporary database") if self.is_temporary else _(
            "Database")
        QTVarios.WDialogo.__init__(self, w_parent, titulo, icono, extparam)
        self.owner = w_parent

        self.procesador = procesador
        self.configuration = procesador.configuration

        self.reiniciar = False  # lo usamos para cambiar de database

        self.dbGames = DBgames.DBgames(file_database)

        self.dicvideo = self.restore_dicvideo()
        dicVideo = self.dicvideo

        siSummary = not si_select

        self.wplayer = WDB_Players.WPlayer(procesador, self, self.dbGames)
        self.wplayer_active = False

        if siSummary:
            self.wsummary = WDB_Summary.WSummary(procesador,
                                                 self,
                                                 self.dbGames,
                                                 siMoves=False)
            self.register_grid(self.wsummary.grid)

        else:
            self.wsummary = None

        self.wgames = WDB_Games.WGames(procesador, self, self.dbGames,
                                       self.wsummary, si_select)

        self.ultFocus = None

        self.tab = Controles.Tab()
        self.tab.nuevaTab(self.wgames, _("Games"))
        if siSummary:
            self.tab.nuevaTab(self.wsummary, _("Summary"))
            self.tab.dispatchChange(self.tabChanged)
        if not si_select:
            self.tab.nuevaTab(self.wplayer, _("Players"))
        self.tab.ponTipoLetra(puntos=procesador.configuration.x_tb_fontpoints)

        if self.owner and not self.is_temporary:
            liAccionesWork = [(_("Select other"), Iconos.Database(),
                               self.tw_select_other)]
            self.tbWork = QTVarios.LCTB(self, liAccionesWork, icon_size=20)
            self.tbWork.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
            self.tab.setCornerWidget(self.tbWork)

        w = QtWidgets.QWidget(self)
        layoutv = Colocacion.V().control(self.tab).margen(4)
        w.setLayout(layoutv)

        self.infoMove = WDB_InfoMove.WInfomove(self)

        self.splitter = splitter = QtWidgets.QSplitter()
        splitter.addWidget(w)
        splitter.addWidget(self.infoMove)

        layout = Colocacion.H().control(splitter).margen(0)
        self.setLayout(layout)

        self.restore_video(anchoDefecto=1200, altoDefecto=600)
        if not dicVideo:
            dicVideo = {
                "SPLITTER": [800, 380],
                "TREE_1": 25,
                "TREE_2": 25,
                "TREE_3": 50,
                "TREE_4": 661
            }

        if not ("SPLITTER" in dicVideo):
            ancho = self.width()
            ancho_board = self.infoMove.board.width()
            sz = [ancho - ancho_board, ancho_board]
        else:
            sz = dicVideo["SPLITTER"]
        self.splitter.setSizes(sz)

        dic_grid = self.dbGames.read_config("dic_grid")
        if not dic_grid:
            key = "databases_columns_default"
            dic_grid = self.configuration.read_variables(key)
        if dic_grid:
            self.wgames.grid.restore_video(dic_grid)
            self.wgames.grid.releerColumnas()

        self.inicializa()