예제 #1
0
파일: FLFormDB.py 프로젝트: deavid/pineboo
    def loadControls(self):
        if self.pushButtonCancel:
            self.pushButtonCancel.hide()

        if self.bottomToolbar:
            self.toolButtonClose.hide()
        self.bottomToolbar = QtWidgets.QFrame()
        self.bottomToolbar.setMinimumSize(self.iconSize)

        self.bottomToolbar.layout = QtWidgets.QHBoxLayout()
        self.bottomToolbar.setLayout(self.bottomToolbar.layout)
        self.bottomToolbar.layout.setContentsMargins(0, 0, 0, 0)
        self.bottomToolbar.layout.setSpacing(0)
        self.bottomToolbar.layout.addStretch()
        self.bottomToolbar.setFocusPolicy(QtCore.Qt.NoFocus)
        self.layout.addWidget(self.bottomToolbar)
        # if self.layout:
        #    self.layout = None
        # Limpiamos la toolbar

        sizePolicy = QtWidgets.QSizePolicy(
            QtWidgets.QSizePolicy.Policy(0), QtWidgets.QSizePolicy.Policy(0))
        sizePolicy.setHeightForWidth(True)

        pbSize = self.iconSize
        settings = FLSettings()
        if settings.readBoolEntry("application/isDebuggerMode", False):

            pushButtonExport = QtWidgets.QToolButton()
            pushButtonExport.setObjectName("pushButtonExport")
            pushButtonExport.setSizePolicy(sizePolicy)
            pushButtonExport.setMinimumSize(pbSize)
            pushButtonExport.setMaximumSize(pbSize)
            pushButtonExport.setIcon(QtGui.QIcon(filedir("../share/icons", "gtk-properties.png")))
            pushButtonExport.setShortcut(QKeySequence(self.tr("F3")))
            pushButtonExport.setWhatsThis("Exportar a XML(F3)")
            pushButtonExport.setToolTip("Exportar a XML(F3)")
            pushButtonExport.setFocusPolicy(QtCore.Qt.NoFocus)
            self.bottomToolbar.layout.addWidget(pushButtonExport)
            pushButtonExport.clicked.connect(self.exportToXml)
            spacer = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
            self.bottomToolbar.layout.addItem(spacer)

        if not self.pushButtonCancel:
            self.pushButtonCancel = QtWidgets.QToolButton()
            self.pushButtonCancel.setObjectName("pushButtonCancel")
            self.pushButtonCancel.clicked.connect(self.close)

        self.pushButtonCancel.setSizePolicy(sizePolicy)
        self.pushButtonCancel.setMaximumSize(pbSize)
        self.pushButtonCancel.setMinimumSize(pbSize)
        self.pushButtonCancel.setIcon(
            QtGui.QIcon(filedir("../share/icons", "gtk-stop.png")))
        # self.pushButtonCancel.setFocusPolicy(QtCore.Qt.StrongFocus)
        # self.pushButtonCancel.setFocus()
        self.pushButtonCancel.setShortcut(QKeySequence(self.tr("Esc")))
        self.pushButtonCancel.setWhatsThis("Cerrar formulario (Esc)")
        self.pushButtonCancel.setToolTip("Cerrar formulario (Esc)")
        self.bottomToolbar.layout.addWidget(self.pushButtonCancel)
        self.setFocusPolicy(QtCore.Qt.NoFocus)
예제 #2
0
    def __init__(self, parent=None, name=None, popup=False):
        super(FLDataTable, self).__init__(parent)

        if parent:
            self._parent = parent

        if not name:
            self.setName("FLDataTable")

        self.pixOk_ = filedir("../share/icons", "unlock.png")
        self.pixNo_ = filedir("../share/icons", "lock.png")
        self.paintFieldMtd_ = None
        self.refreshing_ = False

        self._v_header = self.verticalHeader()
        self._v_header.setDefaultSectionSize(22)
        self._h_header = self.horizontalHeader()
        self._h_header.setDefaultSectionSize(120)
        self._h_header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive)
        self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.setAlternatingRowColors(True)
        self.setSortingEnabled(True)
        self.sortByColumn(0, QtCore.Qt.AscendingOrder)

        self.popup_ = popup
예제 #3
0
    def __init__(self, DGI):

        from pineboolib.plugins.kugar.pnkugarplugins import PNKugarPlugins
        self._DGI = DGI
        self.tree = None
        self.root = None
        self.dbserver = None
        self.dbauth = None
        self.dbname = None
        self.apppath = None
        self.tmpdir = None
        self.parser = None
        self.version = 0.8
        self.main_form_name = "eneboo" if not self._DGI.mobilePlatform() else "mobile"
        pineboolib.project = self
        self.deleteCache = False
        self.parseProject = False
        self.translator_ = []
        self.actions = {}
        self.tables = {}
        self.files = {}
        self.apppath = filedir("..")
        self.tmpdir = FLSettings().readEntry("ebcomportamiento/kugar_temp_dir", filedir("../tempdata"))
        if not os.path.exists(self.tmpdir):
            os.mkdir(self.tmpdir)
        self.kugarPlugin = PNKugarPlugins()

        if not self._DGI.localDesktop():
            self._DGI.extraProjectInit()
        
        self.init_time()
예제 #4
0
    def __init__(self, parent=None, name=None, popup=False):
        super(FLDataTable, self).__init__(parent)

        if parent:
            self._parent = parent

        if not name:
            self.setName("FLDataTable")

        self.pixOk_ = filedir("../share/icons", "unlock.png")
        self.pixNo_ = filedir("../share/icons", "lock.png")
        self.paintFieldMtd_ = None
        self.refreshing_ = False

        self._v_header = self.verticalHeader()
        self._v_header.setDefaultSectionSize(22)
        self._h_header = self.horizontalHeader()
        self._h_header.setDefaultSectionSize(120)
        self._h_header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive)
        self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.setAlternatingRowColors(True)
        self.setSortingEnabled(True)
        self.sortByColumn(0, QtCore.Qt.AscendingOrder)

        self.popup_ = popup
예제 #5
0
    def contentCached(self, n, shaKey=None):
        if not shaKey:
            query = "SELECT sha FROM flfiles WHERE nombre='%s'" % n
            cursor = self.db_.cursor()
            try:
                cursor.execute(query)
            except:
                return None

            for contenido in cursor:
                shaKey = contenido[0]

        data = None
        modId = self._prj.conn.managerModules().idModuleOfFile(n)
        name_ = n[:n.index(".")]
        ext_ = n[n.index(".") + 1:]
        if (os.path.exists(
                filedir("../tempdata/cache/%s/%s/file.%s/%s" %
                        (self._prj.dbname, modId, ext_, name_)))):
            data = self.contentFS(
                filedir(
                    "../tempdata/cache/%s/%s/file.%s/%s/%s.%s" %
                    (self._prj.dbname, modId, ext_, name_, shaKey[:16], ext_)))
        else:
            data = self.content(n)
        return data
예제 #6
0
    def conectar(self):
        folder_ = None

        if self.leFolder.text():
            folder_ = self.leFolder.text()
        else:
            folder_ = filedir("../projects")

        self.ruta = filedir(str(folder_), str(self.leName.text()))
        self.username = self.leUserName.text()
        self.password = self.lePassword.text()
        self.hostname = self.leHostName.text()
        self.portnumber = self.lePort.text()
        self.database = self.leDBName.text()
        self.driveralias = self.cBDrivers.currentText()
        self.deleteCache = self.ui.cBDeleteCache.isChecked()
        self.parseProject = self.ui.cBParseProject.isChecked()
        """
        if not self.leName.text():
            self.ruta = ""
        elif not self.ruta.endswith(".xml"):
            self.ruta += ".xml"
        if not os.path.isfile(self.ruta) and self.leName.text():
            QtWidgets.QMessageBox.information(self, "AVISO", "El proyecto \n" + self.ruta +" no existe")
            self.ruta = None
        else:
            self.close()
        """
        self.dbProjects_.close()
        self.close()
예제 #7
0
    def load(self):
        dlg_ = filedir('forms/dlg_connect.ui')
        try:
            self.ui = uic.loadUi(dlg_, self)
        except Exception:
            print(traceback.format_exc())
            QtWidgets.QMessageBox.information(self, "AVISO",
                                              "No encuentro %s :(" % dlg_)
            sys.exit(32)
        frameGm = self.frameGeometry()
        screen = QtWidgets.QApplication.desktop().screenNumber(
            QtWidgets.QApplication.desktop().cursor().pos())
        centerPoint = QtWidgets.QApplication.desktop().screenGeometry(
            screen).center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

        self.ui.pbnStart.clicked.connect(self.on_click)
        self.ui.pbnSearchFolder.clicked.connect(self.findPathProject)

        # MODIFICACION 4 PARA CONECTOR SQLITE : DEFINIMOS LO QUE HACEN LOS BOTONES nuevos
        self.ui.pbnCargarDatos.clicked.connect(self.loadProject)
        self.tableWidget.doubleClicked.connect(self.on_click)
        # self.ui.pbnMostrarProyectos.clicked.connect(self.ShowTable)
        self.ui.pbnBorrarProyecto.clicked.connect(self.deleteProject)
        self.ui.pbnGuardarProyecto.clicked.connect(self.saveProject)
        self.ui.pbnProyectoEjemplo.clicked.connect(self.saveProjectExample)
        self.ui.pbnEnebooImportButton.clicked.connect(self.saveEnebooImport)
        # hasta aqui la modificación 4
        self.ui.leFolderSQLITE.setText(filedir("../projects"))

        self.leName = self.ui.leName
        self.leDBName = self.ui.leDBName
        self.leUserName = self.ui.leUserName
        self.lePassword = self.ui.lePassword
        self.lePort = self.ui.lePort
        # MODIFICACION 6 PARA CONECTOR SQLITE : DEFINIMOS los NUEVOS CAMPOS DEL UI:
        self.leFolder = self.ui.leFolderSQLITE
        # self.leDBType = self.ui.leDBType
        self.leHostName = self.ui.leHostName

        # hasta aqui la modificación 6
        self.cBDrivers = self.ui.cBDrivers

        DV = PNSqlDrivers()
        list = DV.aliasList()
        self.cBDrivers.addItems(list)

        i = 0
        while i < self.cBDrivers.count():
            if DV.aliasToName(
                    self.cBDrivers.itemText(i)) == DV.defaultDriverName:
                self.cBDrivers.setCurrentIndex(i)
                break

            i = i + 1
        self.loadPreferences()
        self.openDB()
        self.ShowTable()
예제 #8
0
    def load(self):
        # DEFINIMOS LO QUE HACEN LOS BOTONES
        self.ui = uic.loadUi(filedir('forms/dlg_connect.ui'), self)
        self.ui.pbnStart.clicked.connect(self.conectar)
        self.ui.pbnSearchFolder.clicked.connect(self.findPathProject)
        self.ui.pbnSearchFolder_2.clicked.connect(self.findProject)
        self.ui.pbnCargarDatos.clicked.connect(self.ChargeProject)
        self.ui.pbnMostrarProyectos.clicked.connect(self.ShowTable)
        self.ui.pbnBorrarProyecto.clicked.connect(self.DeleteProject)
        self.ui.pbnGuardarProyecto.clicked.connect(self.SaveProject)

        # Creates or opens a file called mydb with a SQLite3 DB
        db = sqlite3.connect('./projects/pinebooconectores.sqlite')

        # Get a cursor object para crear la tabla "proyectos"
        cursor = db.cursor()
        cursor.execute('''
            CREATE TABLE IF NOT EXISTS proyectos(id INTEGER PRIMARY KEY, name TEXT, dbname TEXT, dbtype TEXT, dbhost TEXT, dbport TEXT, username TEXT, password TEXT)
''')
        db.commit()

        # Get a cursor object  para AÑADIR CAMPOS
        cursor = db.cursor()
        name1 = 'A'
        dbname1 = 'B'
        dbtype1 = 'C'
        dbhost1 = 'D'
        dbport1 = 'E'
        username1 = 'F'
        password1 = 'G'

        with db:
            cursor.execute(
                '''
        INSERT INTO proyectos(name, dbname, dbtype, dbhost, dbport, username, password) VALUES (?,?,?,?,?,?,?)''',
                (name1, dbname1, dbtype1, dbhost1, dbport1, username1,
                 password1))
        db.commit()
        print("PROYECTO GRABADO")

        # When we are done working with the DB we need to close the connection:
        db.close()

        dlg = QtGui.QDialog()

        DlgConnect.leFolder = self.ui.leFolderSQLITE
        DlgConnect.leFolder_2 = self.ui.leProyElegID
        DlgConnect.leID = self.ui.leID
        DlgConnect.leName = self.ui.leName
        DlgConnect.leDBName = self.ui.leDBName
        DlgConnect.leDBType = self.ui.leDBType
        DlgConnect.leHost = self.ui.leHost
        DlgConnect.lePort = self.ui.lePort
        DlgConnect.leUserName = self.ui.leUserName
        DlgConnect.lePassword = self.ui.lePassword

        # muestra tabla
        DlgConnect.TABLEVIEW = self.ui.tableView
        ui = uic.loadUi(filedir('forms/dlg_connect.ui'), DlgConnect.TABLEVIEW)
예제 #9
0
    def loadControls(self):

        self.bottomToolbar = QtGui.QFrame()
        self.bottomToolbar.setMaximumHeight(64)
        self.bottomToolbar.setMinimumHeight(16)
        self.bottomToolbar.layout = QtGui.QHBoxLayout()
        self.bottomToolbar.setLayout(self.bottomToolbar.layout)
        self.bottomToolbar.layout.setMargin(0)
        self.bottomToolbar.layout.setSpacing(0)
        self.bottomToolbar.layout.addStretch()
        self.bottomToolbar.setFocusPolicy(QtCore.Qt.NoFocus)
        self.layout.addWidget(self.bottomToolbar)

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(0),
                                       QtGui.QSizePolicy.Policy(0))
        sizePolicy.setHeightForWidth(True)

        pbSize = QtCore.QSize(22, 22)

        if not self.pushButtonAccept:
            self.pushButtonAccept = QtGui.QToolButton()
            self.pushButtonAccept.clicked.connect(self.accept)

        self.pushButtonAccept.setSizePolicy(sizePolicy)
        self.pushButtonAccept.setMaximumSize(pbSize)
        self.pushButtonAccept.setMinimumSize(pbSize)
        self.pushButtonAccept.setIcon(
            QtGui.QIcon(filedir("icons", "gtk-save.png")))
        #pushButtonAccept->setAccel(QKeySequence(Qt::Key_F10)); FIXME
        self.pushButtonAccept.setFocus()
        self.pushButtonAccept.setWhatsThis(
            "Seleccionar registro actual y cerrar formulario (F10)")
        self.pushButtonAccept.setToolTip(
            "Seleccionar registro actual y cerrar formulario (F10)")
        self.pushButtonAccept.setFocusPolicy(QtCore.Qt.NoFocus)
        self.bottomToolbar.layout.addWidget(self.pushButtonAccept)
        self.pushButtonAccept.show()

        if not self.pushButtonCancel:
            self.pushButtonCancel = QtGui.QToolButton()
            self.pushButtonCancel.clicked.connect(self.reject)

        self.pushButtonCancel.setSizePolicy(sizePolicy)
        self.pushButtonCancel.setMaximumSize(pbSize)
        self.pushButtonCancel.setMinimumSize(pbSize)
        self.pushButtonCancel.setIcon(
            QtGui.QIcon(filedir("icons", "gtk-stop.png")))
        self.pushButtonCancel.setFocusPolicy(QtCore.Qt.NoFocus)
        #pushButtonCancel->setAccel(Esc); FIXME
        self.pushButtonCancel.setWhatsThis(
            "Cerrar formulario sin seleccionar registro (Esc)")
        self.pushButtonCancel.setToolTip(
            "Cerrar formulario sin seleccionar registro (Esc)")
        self.bottomToolbar.layout.addWidget(self.pushButtonCancel)
        self.pushButtonCancel.show()

        self.cursor_.setEdition(False)
        self.cursor_.setBrowse(False)
        self.cursor_.recordChoosed.connect(self.accept)
예제 #10
0
    def loadControls(self):
        
        self.bottomToolbar = QtGui.QFrame()
        self.bottomToolbar.setMaximumHeight(64)
        self.bottomToolbar.setMinimumHeight(16)
        self.bottomToolbar.layout = QtGui.QHBoxLayout()
        self.bottomToolbar.setLayout(self.bottomToolbar.layout)
        self.bottomToolbar.layout.setMargin(0)
        self.bottomToolbar.layout.setSpacing(0)
        self.bottomToolbar.layout.addStretch()
        self.bottomToolbar.setFocusPolicy(QtCore.Qt.NoFocus)
        self.layout.addWidget(self.bottomToolbar)

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(0) ,QtGui.QSizePolicy.Policy(0))
        sizePolicy.setHeightForWidth(True)
        
        pbSize = QtCore.QSize(22,22)

  
                
                
            
        if not self.pushButtonAccept:
            self.pushButtonAccept = QtGui.QToolButton()
            self.pushButtonAccept.clicked.connect(self.accept)
                
        self.pushButtonAccept.setSizePolicy(sizePolicy)
        self.pushButtonAccept.setMaximumSize(pbSize)
        self.pushButtonAccept.setMinimumSize(pbSize)
        self.pushButtonAccept.setIcon(QtGui.QIcon(filedir("icons","gtk-save.png")))
        #pushButtonAccept->setAccel(QKeySequence(Qt::Key_F10)); FIXME
        self.pushButtonAccept.setFocus()
        self.pushButtonAccept.setWhatsThis("Seleccionar registro actual y cerrar formulario (F10)")
        self.pushButtonAccept.setToolTip("Seleccionar registro actual y cerrar formulario (F10)")
        self.pushButtonAccept.setFocusPolicy(QtCore.Qt.NoFocus)
        self.bottomToolbar.layout.addWidget(self.pushButtonAccept)
        self.pushButtonAccept.show()
                
            
        if not self.pushButtonCancel:
            self.pushButtonCancel = QtGui.QToolButton()
            self.pushButtonCancel.clicked.connect(self.reject)
                
        self.pushButtonCancel.setSizePolicy(sizePolicy)
        self.pushButtonCancel.setMaximumSize(pbSize)
        self.pushButtonCancel.setMinimumSize(pbSize)
        self.pushButtonCancel.setIcon(QtGui.QIcon(filedir("icons","gtk-stop.png")))
        self.pushButtonCancel.setFocusPolicy(QtCore.Qt.NoFocus)  
        #pushButtonCancel->setAccel(Esc); FIXME
        self.pushButtonCancel.setWhatsThis("Cerrar formulario sin seleccionar registro (Esc)")
        self.pushButtonCancel.setToolTip("Cerrar formulario sin seleccionar registro (Esc)")
        self.bottomToolbar.layout.addWidget(self.pushButtonCancel)
        self.pushButtonCancel.show()
        
        self.cursor_.setEdition(False)
        self.cursor_.setBrowse(False)
        self.cursor_.recordChoosed.connect(self.accept)                
예제 #11
0
    def __init__(self):

        # Cargamos los parsers avalibles
        dirlist = os.listdir(filedir("plugins/kugar"))
        for f in dirlist:
            if not f[0:2] == "__" and not os.path.isfile(filedir("plugins/kugar", f)):
                self.avalibleParsers_.append(f)

        self.defaultParser_ = "kut2fpdf"
예제 #12
0
    def load_db(self, dbname, host, port, user, passwd):
        self.dbserver = DBServer()
        self.dbserver.host = host
        self.dbserver.port = port
        self.dbauth = DBAuth()
        self.dbauth.username = user
        self.dbauth.password = passwd
        self.dbname = dbname
        self.apppath = filedir("..")
        self.tmpdir = filedir("../tempdata")

        self.actions = {}
        self.tables = {}
        pineboolib.project = self
예제 #13
0
    def load_db(self, dbname, host, port, user, passwd):
        self.dbserver = DBServer()
        self.dbserver.host = host
        self.dbserver.port = port
        self.dbauth = DBAuth()
        self.dbauth.username = user
        self.dbauth.password = passwd
        self.dbname = dbname
        self.apppath = filedir("..")
        self.tmpdir = filedir("../tempdata")

        self.actions = {}
        self.tables = {}
        pineboolib.project = self
예제 #14
0
 def load(self):
     self.ui = uic.loadUi(filedir('forms/mainform.ui'), self)
     self.areasTab = self.ui.areasTab
     self.areasTab.removeItem(0)  #Borramos tab de ejemplo.
     self.formTab = self.ui.formTab
     self.formTab.setTabsClosable(True)
     self.connect(self.formTab, QtCore.SIGNAL('tabCloseRequested(int)'),
                  self.closeFormTab)
     self.formTab.removeTab(0)
     app_icon = QtGui.QIcon()
     app_icon.addFile(filedir('icons/pineboo-logo-16.png'),
                      QtCore.QSize(16, 16))
     app_icon.addFile(filedir('icons/pineboo-logo-24.png'),
                      QtCore.QSize(24, 24))
     app_icon.addFile(filedir('icons/pineboo-logo-32.png'),
                      QtCore.QSize(32, 32))
     app_icon.addFile(filedir('icons/pineboo-logo-48.png'),
                      QtCore.QSize(48, 48))
     app_icon.addFile(filedir('icons/pineboo-logo-64.png'),
                      QtCore.QSize(64, 64))
     app_icon.addFile(filedir('icons/pineboo-logo-128.png'),
                      QtCore.QSize(128, 128))
     app_icon.addFile(filedir('icons/pineboo-logo-256.png'),
                      QtCore.QSize(256, 256))
     self.setWindowIcon(app_icon)
     self.setWindowTitle("Pineboo")
예제 #15
0
    def openDB(self):
        if self.dbProjects_:
            self.dbProjects_.close()

        self.dbProjects_ = sqlite3.connect(
            filedir(self.ui.leFolderSQLITE.text()) +
            '/pinebooconectores.sqlite')
예제 #16
0
    def cargarConfiguracion(self):
        w = self.w_

        w.child(u"cbFLTableDC").checked = self.leerValorLocal("FLTableDoubleClick")
        w.child(u"cbFLTableSC").checked = self.leerValorLocal("FLTableShortCut")
        w.child(u"cbFLTableCalc").checked = self.leerValorLocal("FLTableExport2Calc")
        w.child(u"cbDebuggerMode").checked = self.leerValorLocal("isDebuggerMode")
        w.child(u"cbSLConsola").checked = self.leerValorLocal("SLConsola")
        w.child(u"cbSLInterface").checked = self.leerValorLocal("SLInterface")
        w.child(u"leCallFunction").text = self.leerValorLocal("ebCallFunction")
        w.child(u"leMaxPixImages").text = self.leerValorLocal("maxPixImages")
        w.child(u"leNombreVertical").text = self.leerValorGlobal("verticalName")
        w.child(u"cbFLLarge").checked = (self.leerValorGlobal("FLLargeMode") == 'True')
        w.child(u"cbPosInfo").checked = (self.leerValorGlobal("PosInfo") == 'True')
        w.child(u"cbMobile").checked = self.leerValorLocal("mobileMode")
        w.child(u"cbDeleteCache").checked = self.leerValorLocal("deleteCache")
        w.child(u"cbParseProject").checked = self.leerValorLocal("parseProject")
        w.child(u"cbActionsMenuRed").checked = self.leerValorLocal("ActionsMenuRed")
        w.child(u"cbKugarParser").addItems(pineboolib.project.kugarPlugin.listAvalibles())
        w.child(u"cbKugarParser").setCurrentText(self.leerValorLocal("kugarParser") if not "" else pineboolib.project.kugarPlugin.defaultParser())
        w.child(u"cbSpacerLegacy").checked = self.leerValorLocal("spacerLegacy")
        w.child(u"cbParseModulesOnLoad").checked = self.leerValorLocal("parseModulesOnLoad")
        w.child(u"cb_traducciones").checked = self.leerValorLocal("translations_from_qm")
        w.child("le_kut_temporales").text = self.leerValorLocal("kugar_temp_dir")
        w.child("cb_kut_debug").checked = self.leerValorLocal("kugar_debug_mode")
        w.child("cb_no_borrar_cache").checked = self.leerValorLocal("keep_general_cache")
        w.child("cb_clean_no_python").checked = self.leerValorLocal("clean_no_python")
        w.child("cb_snapshot").checked = self.leerValorLocal("show_snaptshop_button")
        autoComp = self.leerValorLocal("autoComp")
        if not autoComp or autoComp == "OnDemandF4":
            autoComp = "Bajo Demanda (F4)"
        elif autoComp == "NeverAuto":
            autoComp = "Nunca"
        else:
            autoComp = "Siempre"
        w.child(u"cbAutoComp").setCurrentText(autoComp)

        w.child(u"leCO").hide()
        self.colorActual_ = self.leerValorLocal("colorObligatorio")
        if self.colorActual_ is "":
            self.colorActual_ = "#FFE9AD"

        w.child(u"leCO").setStyleSheet('background-color:' + self.colorActual_)
        
        #Actualizaciones.
        
        if os.path.exists(filedir("../.git")):
            w.child("cb_git_activar").checked = self.leerValorLocal("git_updates_enabled")
            ruta = self.leerValorLocal("git_updates_repo")
            if ruta is False:
                ruta = 'https://github.com/Aulla/pineboo.git'
            w.child("le_git_ruta").text = ruta
            connect(w.child("pb_git_test"), u"clicked()", self, "search_git_updates")
        else:
            w.child("tbwLocales").setTabEnabled("tab_updates", False)
               
        
        
        
        w.child(u"leCO").show()
예제 #17
0
    def load(self, filename):
        # self.parser = etree.XMLParser(
        #    ns_clean=True,
        #    encoding="UTF-8",
        #    remove_blank_text=True,
        #)
        self.tree = etree.ElementTree.parse(filename)
        self.root = self.tree.getroot()
        self.dbserver = DBServer(one(self.root.find("database-server")))
        self.dbauth = DBAuth(one(self.root.find("database-credentials")))
        self.dbname = one(self.root.find("database-name").text)
        self.apppath = one(self.root.find("application-path").text)
        self.tmpdir = filedir("../tempdata")
        if not getattr(self.dbserver, "host", None):
            self.dbserver.host = None

        if not getattr(self.dbserver, "port", None):
            self.dbserver.port = None

        if not getattr(self.dbserver, "type", None):
            self.dbserver.type = None

        if not self.dbauth:
            self.dbauth.username = None
            self.dbauth.password = None

        self.actions = {}
        self.tables = {}
        pineboolib.project = self
예제 #18
0
def create_app(DGI):
    """Create a MainForm using the DGI or the core."""
    from PyQt5 import QtGui, QtWidgets
    from pineboolib.utils import filedir
    import pineboolib
    app = QtWidgets.QApplication(sys.argv)
    if DGI.localDesktop():

        noto_fonts = [
            "NotoSans-BoldItalic.ttf", "NotoSans-Bold.ttf",
            "NotoSans-Italic.ttf", "NotoSans-Regular.ttf"
        ]
        for fontfile in noto_fonts:
            QtGui.QFontDatabase.addApplicationFont(
                filedir("../share/fonts/Noto_Sans", fontfile))

        QtWidgets.QApplication.setStyle("QtCurve")
        font = QtGui.QFont('Noto Sans', 9)
        font.setBold(False)
        font.setItalic(False)
        QtWidgets.QApplication.setFont(font)

        # Es necesario importarlo a esta altura, QApplication tiene que ser
        # construido antes que cualquier widget
        mainForm = importlib.import_module(
            "pineboolib.plugins.mainform.%s.%s" %
            (pineboolib.main.Project.mainFormName.lower(),
             pineboolib.main.Project.mainFormName.lower()))
    else:
        mainForm = DGI.mainForm()
    # mainForm = getattr(module_, "MainForm")()
    # from pineboolib import mainForm
    return app, mainForm
예제 #19
0
    def setMainWidgetQWidget(self, *w):

        if not self.cursor_ and not w:
            return

        if self.showed:
            if self.mainWidget_ and not self.mainWidget_ == w:
                self.initMainWidget(w)
            else:
                w.hide()

            if self.layout:
                del self.Layout

            #w.setFont(qApp.font()) #FIXME
            self.layout = QtGui.QVBoxLayout(self, 2, 3, "vlay" + self.name_)
            self.layout.add(w)
            self.layoutButtons = QtGui.QHBoxLayout(self.layout, 3,
                                                   "hlay" + self.name_)

            self.layoutButtons.addItem(QtGui.QSpacerItem())
            self.pushButtonCancel = QtGui.QPushButton(self, "pushButtonCancel")
            #self.pushButtonCancel.set_size(QtGui.QSizePolicy) #FIXME
            self.pushButtonCancel.setMinimumSize(22, 22)
            self.pushButtonCancel.setMaximumSize(22, 22)
            self.pushButtonCancel.setIcon(
                QtGui.QIcon(filedir("icons", "gtk-cancel.png")))
            #pushButtonCancel->setFocusPolicy(QWidget::NoFocus);
            #pushButtonCancel->setAccel(QKeySequence(tr("Esc")));
            #QToolTip::add(pushButtonCancel, tr("Cerrar formulario (Esc)"));
            #QWhatsThis::add(pushButtonCancel, tr("Cerrar formulario (Esc)"));
            self.layoutButtons.addWidget(self.pushButtonCancel)
            self.pushButtonCancel.clicked.connect(self.close)
            self.pushButtonCancel.show()
            self.mainWidget_ = w
예제 #20
0
    def createSystemTable(self, n):
        util = FLUtil()
        if not self.existsTable(n):
            doc = QDomDocument()
            _path = filedir("..", "share", "pineboo", "tables")
            dir = qsatype.Dir(_path)
            _tables = dir.entryList("%s.mtd" % n)

            for f in _tables:
                path = "%s/%s" % (_path, f)
                _file = QtCore.QFile(path)
                _file.open(QtCore.QIODevice.ReadOnly)
                _in = QtCore.QTextStream(_file)
                _data = _in.readAll()
                if not util.domDocumentSetContent(doc, _data):
                    print(
                        "FLManager::createSystemTable :",
                        util.tr(
                            "Error al cargar los metadatos para la tabla %1").
                        arg(n))
                    return False
                else:
                    docElem = doc.documentElement()

                    mtd = self.createTable(self.metadata(docElem, True))
                    return mtd

                f.close()

        return False
예제 #21
0
    def load(self):
        """
        Carga el form dlgconnect
        """
        from pineboolib.fllegacy.flmanagermodules import FLManagerModules
        mM = FLManagerModules()
        dlg_ = filedir('dlgconnect/dlgconnect.ui')

        self.ui = mM.createUI(dlg_, None, self)
        del mM

        # Centrado en pantalla
        frameGm = self.frameGeometry()
        screen = QtWidgets.QApplication.desktop().screenNumber(QtWidgets.QApplication.desktop().cursor().pos())
        centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())
        
        
        self.ui.pbLogin.clicked.connect(self.open)
        self.ui.tbOptions.clicked.connect(self.showOptions)
        self.ui.pbSaveConnection.clicked.connect(self.saveProfile)
        self.ui.tbDeleteProfile.clicked.connect(self.deleteProfile)
        self.ui.tbEditProfile.clicked.connect(self.editProfile)
        self.cleanProfileForm()
        self.ui.cbDBType.currentIndexChanged.connect(self.updatePort)
        self.ui.cbProfiles.currentIndexChanged.connect(self.enablePassword)
        self.ui.cbAutoLogin.stateChanged.connect(self.enableProfilePassword)
        self.ui.le_profiles.setText(self.profile_dir)
        self.ui.tb_profiles.clicked.connect(self.change_profile_dir)
        self.showOptions()
        self.loadProfiles()
        self.ui.leDescription.textChanged.connect(self.updateDBName)
예제 #22
0
파일: flsqlite.py 프로젝트: deavid/pineboo
    def connect(self, db_name, db_host, db_port, db_userName, db_password):

        checkDependencies({"sqlite3": "sqlite3"})
        self.db_filename = db_name
        db_is_new = not os.path.exists(filedir("../%s" % self.db_filename))

        import sqlite3

        import pineboolib
        if self.db_filename == getattr(pineboolib.project.conn, "db_name", None):
            self.conn_ = pineboolib.project.conn.conn
        else:
            self.conn_ = sqlite3.connect(self.db_filename)
            self.conn_.isolation_level = None

            if db_is_new:
                self.logger.warn("La base de datos %s no existe", self.db_filename)

        if self.conn_:
            self.open_ = True

        if self.parseFromLatin:
            self.conn_.text_factory = lambda x: str(x, 'latin1')

        return self.conn_
예제 #23
0
 def __init__(self, parent, action, load=False):
     try:
         assert (self.__class__,action) not in self.known_instances
     except AssertionError:
         print("WARN: Clase %r ya estaba instanciada, reescribiendo!. " % ((self.__class__,action),)
             + "Puede que se estén perdiendo datos!" )
     self.known_instances[(self.__class__,action)] = self
     QtGui.QWidget.__init__(self, parent)
     self.action = action
     self.prj = action.prj
     self.mod = action.mod
     self.layout = QtGui.QVBoxLayout()
     self.layout.setMargin(2)
     self.layout.setSpacing(2)
     self.setLayout(self.layout)
     # self.widget = QtGui.QWidget()
     # self.layout.addWidget(self.widget)
     self.bottomToolbar = QtGui.QFrame()
     self.bottomToolbar.setMaximumHeight(64)
     self.bottomToolbar.setMinimumHeight(16)
     self.bottomToolbar.layout = QtGui.QHBoxLayout()
     self.bottomToolbar.setLayout(self.bottomToolbar.layout)
     self.bottomToolbar.layout.setMargin(0)
     self.bottomToolbar.layout.setSpacing(0)
     self.bottomToolbar.layout.addStretch()
     self.toolButtonClose = QtGui.QToolButton()
     self.toolButtonClose.setIcon(QtGui.QIcon(filedir("icons","gtk-cancel.png")))
     self.toolButtonClose.clicked.connect(self.close)
     self.bottomToolbar.layout.addWidget(self.toolButtonClose) 
     self.layout.addWidget(self.bottomToolbar)
     self.setWindowTitle(action.alias)
     self.loaded = False
     
         
     if load: self.load()
예제 #24
0
 def setMainWidgetQWidget(self, *w):
     
     if not self.cursor_ and not w:
         return
     
     if self.showed:
         if self.mainWidget_ and not self.mainWidget_ == w:
             self.initMainWidget(w)
         else:
             w.hide()
         
         if self.layout:
             del self.Layout
         
         #w.setFont(qApp.font()) #FIXME
         self.layout = QtGui.QVBoxLayout(self, 2,3,"vlay" + self.name_)
         self.layout.add(w)
         self.layoutButtons = QtGui.QHBoxLayout(self.layout , 3, "hlay" + self.name_)
         
         self.layoutButtons.addItem(QtGui.QSpacerItem())
         self.pushButtonCancel = QtGui.QPushButton(self, "pushButtonCancel")
         #self.pushButtonCancel.set_size(QtGui.QSizePolicy) #FIXME
         self.pushButtonCancel.setMinimumSize(22, 22)
         self.pushButtonCancel.setMaximumSize(22, 22)
         self.pushButtonCancel.setIcon(QtGui.QIcon(filedir("icons","gtk-cancel.png")))
         #pushButtonCancel->setFocusPolicy(QWidget::NoFocus);
         #pushButtonCancel->setAccel(QKeySequence(tr("Esc")));
         #QToolTip::add(pushButtonCancel, tr("Cerrar formulario (Esc)"));
         #QWhatsThis::add(pushButtonCancel, tr("Cerrar formulario (Esc)"));
         self.layoutButtons.addWidget(self.pushButtonCancel)
         self.pushButtonCancel.clicked.connect(self.close)
         self.pushButtonCancel.show()
         self.mainWidget_ = w
예제 #25
0
        def addRowToReportData(self, l):
            if not self.qry_.isValid():
                return
            row = QtXml.QDomElement(self.q_.rptXmlData().createElement("Row"))
            row.setAttribute("level", l)

            imgFieldsBack = []
            i = 0
            for it in self.qFieldList_:
                strVal = str(self.qry_.value(i, False))
                if self.qImgFields_ and self.qImgFields_[len(self.qImgFields_) - 1] == i:
                    imgFieldsBack.append(self.qImgFields_.pop())
                    if strVal in ["", "None"]:
                        row.setAttribute(it, strVal)
                        continue
                    imgFile = filedir("../tempdata")
                    imgFile += "/%s.png" % strVal
                    if not os.path.exists(imgFile):
                        #print("Creando", imgFile)
                        #print(self.qry_.value(i, True))
                        pix = QtGui.QPixmap(self.qry_.value(i, True))
                        if not pix.save(imgFile):
                            print("FLReportEngine::No se ha podido guardar", imgFile)
                    row.setAttribute(it, imgFile)
                else:
                    row.setAttribute(it, strVal)
                i += 1

            self.rows_.appendChild(row)
            self.qImgFields_ = imgFieldsBack
예제 #26
0
    def contentCached(self, n, shaKey=None):

        data = None
        modId = None
        name_ = n[:n.index(".")]
        ext_ = n[n.index(".") + 1:]

        if not shaKey and not self._prj.conn.manager().isSystemTable(name_):
            query = "SELECT sha FROM flfiles WHERE nombre='%s'" % n
            try:
                cursor = self.db_.cursor()
            except Exception:
                cursor = self._prj.conn.cursor()
            try:
                cursor.execute(query)
            except Exception:
                print("ERROR: FLManagerModules.contentCached",
                      traceback.format_exc())
                # cursor.execute("ROLLBACK")
                cursor.close()
                return None

            for contenido in cursor:
                shaKey = contenido[0]

        if self._prj.conn.manager().isSystemTable(name_):
            modId = "sys"
        else:
            modId = self._prj.conn.managerModules().idModuleOfFile(n)
        if os.path.exists(
                filedir("../tempdata/cache/%s/%s/file.%s/%s" %
                        (self._prj.dbname, modId, ext_, name_))):
            utf8_ = False
            if ext_ == "kut":
                utf8_ = True
            data = self.contentFS(
                filedir("../tempdata/cache/%s/%s/file.%s/%s/%s.%s" %
                        (self._prj.dbname, modId, ext_, name_, shaKey, ext_)),
                utf8_)
        elif os.path.exists(
                filedir("../share/pineboo/tables/%s.%s" % (name_, ext_))):
            data = self.contentFS(
                filedir("../share/pineboo/tables/%s.%s" % (name_, ext_)))
        else:
            data = self.content(n)

        return data
예제 #27
0
 def load(self):
     self.ui = uic.loadUi(filedir('forms/dlg_connect.ui'), self)
     self.connect(self.ui.pbnStart, QtCore.SIGNAL("clicked()"),
                  self.conectar)
     self.connect(self.ui.pbnSearchFolder, QtCore.SIGNAL("clicked()"),
                  self.findPathProject)
     DlgConnect.leFolder = self.ui.leFolder
     DlgConnect.leName = self.ui.leName
예제 #28
0
 def conectar(self):
     DlgConnect.ruta = filedir(str(DlgConnect.leFolder.text()), str(DlgConnect.leName.text()))
     if not DlgConnect.ruta.endswith(".xml"):
         DlgConnect.ruta += ".xml"
     if not os.path.isfile(DlgConnect.ruta):
         QtGui.QMessageBox.information(self, "AVISO", "El proyecto \n" + DlgConnect.ruta +" no existe")
         DlgConnect.ruta = None
     else:
         self.close()
예제 #29
0
    def loadTsContent(self, key):
        if self.idM_ == "sys":
            tsFile = filedir("../share/pineboo/translations/%s.%s" %
                             (self.idM_, self.lang_))
        else:
            tsFile = filedir("../tempdata/cache/%s/%s/file.ts/%s.%s/%s" %
                             (self._prj.conn.database(), self.idM_, self.idM_,
                              self.lang_, key))
        # qmFile = self.AQ_DISKCACHE_DIRPATH + "/" + key + ".qm"
        qmFile = "%s.qm" % tsFile

        if os.path.exists(qmFile):
            if tsFile in (None, ""):
                return False

        trans = FLTranslations()
        trans.lrelease("%s.ts" % tsFile, qmFile, not self.mulTiLang_)
        return self.load(qmFile)
예제 #30
0
 def content_cached(self, tmp_folder, db_name, module_id, file_ext, file_name, sha_key):
     from pineboolib.utils import filedir
     from pineboolib.pncontrolsfactory import aqApp
     data_ = None
     if module_id == "sys" and file_name in self.sys_mtds():
         path_ = filedir("./plugins/dgi/dgi_aqnext/system_files/%s/%s.%s" % (file_ext, file_name, file_ext))
         if os.path.exists(path_):
             data_ = aqApp.db().managerModules().contentFS(path_, False)
     
     return data_ 
예제 #31
0
def create_app(DGI):
    """Create a MainForm using the DGI or the core."""
    from PyQt5 import QtGui, QtWidgets, QtCore
    from pineboolib.utils import filedir
    import pineboolib
    app = DGI.create_app()
    pineboolib.base_dir = filedir(".")  # Almacena base_dir para luego usarlo sobre filedir
    pineboolib._DGI = DGI  # Almacenamos de DGI seleccionado para futuros usos

    if DGI.localDesktop():

        noto_fonts = [
            "NotoSans-BoldItalic.ttf",
            "NotoSans-Bold.ttf",
            "NotoSans-Italic.ttf",
            "NotoSans-Regular.ttf"]
        for fontfile in noto_fonts:
            QtGui.QFontDatabase.addApplicationFont(
                filedir("../share/fonts/Noto_Sans", fontfile))

        from pineboolib.fllegacy.flsettings import FLSettings
        sett_ = FLSettings()

        styleA = sett_.readEntry("application/style", None)
        if styleA is None:
            styleA = "Fusion"

        app.setStyle(styleA)

        fontA = sett_.readEntry("application/font", None)
        if fontA is None:
            if DGI.mobilePlatform():
                font = QtGui.QFont('Noto Sans', 14)
            else:
                font = QtGui.QFont('Noto Sans', 9)
            font.setBold(False)
            font.setItalic(False)
        else:
            font = QtGui.QFont(fontA[0], int(fontA[1]), int(fontA[2]), fontA[3] == "true")

        app.setFont(font)
    return app
예제 #32
0
def load_model( nombre ):
    
    if nombre is None:
        return
    
    #if nombre in processed_: 
    #    return None
    
    #processed_.append(nombre)
    
    
    from pineboolib import qsa as qsa_dict_modules
    
    
    nombre_qsa = nombre.replace("_model", "")
    model_name = nombre_qsa[0].upper() + nombre_qsa[1:]
    
    #mod = getattr(qsa_dict_modules, model_name, None)
    #if mod is None:
    #    mod = base_model(nombre)
    #    if mod:
    #        setattr(qsa_dict_modules, model_name, mod)
    
    
    
    db_name = pineboolib.project.conn.DBName()
    
    mod = None
    file_path = filedir("..", "tempdata", "cache", db_name, "models", "%s_model.py" % nombre)
    
    if os.path.exists(file_path):
        module_path = "tempdata.cache.%s.models.%s_model" % (db_name, nombre)
        if module_path in sys.modules:
            #print("Recargando", module_path)
            try:
                mod = importlib.reload(sys.modules[module_path])
            except Exception as exc:
                logger.warning("Error recargando módulo:\n%s\n%s", exc, traceback.format_exc())
                pass 
        else:
            #print("Cargando", module_path)
            try:
                mod = importlib.import_module(module_path)
            except Exception as exc:
                logger.warning("Error cargando módulo:\n%s\n%s", exc, traceback.format_exc())
                pass 
            #models_[nombre] = mod
    
    
    #if mod:
    #    setattr(qsa_dict_modules, model_name, mod)
    
    #print(3, nombre, mod)
    return mod
예제 #33
0
 def load(self):
     self.ui = uic.loadUi(filedir('forms/dlg_connect.ui'), self)
     self.ui.pbnStart.clicked.connect(self.conectar)
     self.ui.pbnSearchFolder.clicked.connect(self.findPathProject)
     DlgConnect.leFolder = self.ui.leFolder
     DlgConnect.leName = self.ui.leName
     DlgConnect.leUserName = self.ui.leUserName
     DlgConnect.lePassword = self.ui.lePassword
     DlgConnect.leHostName = self.ui.leHostName
     DlgConnect.lePort = self.ui.lePort
     DlgConnect.leDBName = self.ui.leDBName
예제 #34
0
    def getExistingDirectory(basedir=None, caption=None):
        if not basedir:
            basedir = filedir("..")

        if pineboolib.project._DGI.localDesktop():
            parent = pineboolib.project.main_window.ui
            ret = QtWidgets.QFileDialog.getExistingDirectory(parent, caption, basedir, QtWidgets.QFileDialog.ShowDirsOnly)
            if ret:
                ret = ret + "/"

            return ret
예제 #35
0
파일: pineboo.py 프로젝트: deavid/pineboo
def show_splashscreen(project):
    """Show a splashscreen to inform keep the user busy while Pineboo is warming up."""
    from PyQt5 import QtGui, QtCore, QtWidgets
    from pineboolib.utils import filedir
    splash_path = filedir("../share/splashscreen/splash_%s.png" % project.dbname)
    if not os.path.exists(splash_path):
        splash_path = filedir("../share/splashscreen/splash.png")

    splash_pix = QtGui.QPixmap(splash_path)
    splash = QtWidgets.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()

    frameGm = splash.frameGeometry()
    screen = QtWidgets.QApplication.desktop().screenNumber(
        QtWidgets.QApplication.desktop().cursor().pos())
    centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
    frameGm.moveCenter(centerPoint)
    splash.move(frameGm.topLeft())
    return splash
예제 #36
0
    def renderReport(self, initRow=0, initCol=0, fRec=False, pages=None):
        if self.rt.find("KugarTemplate") > -1:
            parser = kut2rml()
            self.rt = parser.parse(self.d_.template_, self.rt, self.rd.toString(1))
            if self.rt:
                pdfname = filedir("../tempdata")
                pdfname += "/%s.pdf" % datetime.datetime.now().strftime("%Y%m%d%H%M%S")
                parser_ = parsepdf()
                parser_.parse(self.rt, pdfname)

            # print(self.rd.toString(1))
        """
예제 #37
0
 def conectar(self):
     DlgConnect.ruta = filedir(str(DlgConnect.leFolder.text()),
                               str(DlgConnect.leName.text()))
     if not DlgConnect.ruta.endswith(".xml"):
         DlgConnect.ruta += ".xml"
     if not os.path.isfile(DlgConnect.ruta):
         QtGui.QMessageBox.information(
             self, "AVISO",
             "El proyecto \n" + DlgConnect.ruta + " no existe")
         DlgConnect.ruta = None
     else:
         self.close()
예제 #38
0
    def __init__(self):

        self.driversdict = {}

        dirlist = os.listdir(filedir("../pineboolib/plugins/sql"))
        for f in dirlist:
            if not f[0:2] == "__":
                f = f[:f.find(".py")]
                mod_ = importlib.import_module("pineboolib.plugins.sql.%s" % f)
                driver_ = getattr(mod_, f)()
                self.driversdict[f] = driver_.alias_

        self.defaultDriverName = "FLQPSQL"
예제 #39
0
    def initScript(self):
        from pineboolib.utils import filedir

        mw = mainWindow
        mw.createUi(filedir('plugins/mainform/mobile/mainform.ui'))

        mw.init()

        mw.updateMenuAndDocks()
        mw.initModule("sys")
        mw.show()

        mw.readState()
예제 #40
0
 def __init__(self, _DGI):
     """
     Constructor
     @param _DGI. DGI cargado.
     """
     super(DlgConnect, self).__init__()
     self._DGI = _DGI
     self.optionsShowed = True
     self.minSize = QSize(350, 140)
     self.maxSize = QSize(350, 495)
     self.profileDir = filedir("../profiles")
     import pineboolib
     self.pNSqlDrivers = pineboolib.project.sql_drivers_manager
예제 #41
0
    def __init__(self, parent=None, name=None, popup=False):
        super(FLDataTable, self).__init__(parent)

        if parent:
            self._parent = parent

        if not name:
            self.setName("FLDataTable")

        self.pixOk_ = filedir("icons", "unlock.png")
        self.pixNo_ = filedir("icons", "lock.png")

        self._v_header = self.verticalHeader()
        self._v_header.setDefaultSectionSize(22)
        self._h_header = self.horizontalHeader()
        self._h_header.setDefaultSectionSize(120)
        self._h_header.setResizeMode(QtGui.QHeaderView.Interactive)
        self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.setAlternatingRowColors(True)

        self.popup_ = popup
예제 #42
0
 def existsTable(self,  n, cache = True):
     
     if cache:
         modId = self.db_.managerModules().idModuleOfFile(n +".mtd")
         return os.path.exists(filedir("../tempdata/cache/%s/file.mtd/%s" %(modId, n)))
     
     
     q = FLSqlQuery()
     sql_query = "SELECT * FROM %s WHERE 1 = 1" % n
     q.setTablesList(n)
     q.setSelect("*")
     q.setFrom(n)
     q.setWhere("1 = 1 LIMIT 1")
     return q.exec_()
예제 #43
0
    def existsTable(self, n, cache=True):

        if cache:
            modId = self.db_.managerModules().idModuleOfFile(n + ".mtd")
            return os.path.exists(
                filedir("../tempdata/cache/%s/file.mtd/%s" % (modId, n)))

        q = FLSqlQuery()
        sql_query = "SELECT * FROM %s WHERE 1 = 1" % n
        q.setTablesList(n)
        q.setSelect("*")
        q.setFrom(n)
        q.setWhere("1 = 1 LIMIT 1")
        return q.exec_()
예제 #44
0
 def __init__(self, parent = None, name = None, popup = False):
     super(FLDataTable, self).__init__(parent)
     
     if parent: 
         self._parent = parent
     
     if not name:
         self.setName("FLDataTable")
     
     self.pixOk_ = filedir("icons","unlock.png")
     self.pixNo_ = filedir("icons","lock.png")
     
     self._v_header = self.verticalHeader()
     self._v_header.setDefaultSectionSize(18)
     self._h_header = self.horizontalHeader()
     self._h_header.setDefaultSectionSize(70)
     self._h_header.setResizeMode(QtGui.QHeaderView.Interactive)
     self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
     self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
     self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
     self.setAlternatingRowColors(True)
     
     self.popup_ = popup
예제 #45
0
파일: dgi_qt.py 프로젝트: deavid/pineboo
    def getExistingDirectory(basedir=None, caption=None):
        if not basedir:
            from pineboolib.utils import filedir
            basedir = filedir("..")

        import pineboolib
        if pineboolib.project._DGI.localDesktop():
            parent = pineboolib.project.main_window.ui_
            ret = QtWidgets.QFileDialog.getExistingDirectory(
                parent, caption, basedir, QtWidgets.QFileDialog.ShowDirsOnly)
            if ret:
                ret = ret + "/"

            return ret
예제 #46
0
    def loadTsContent(self, key):
        if self.idM_ == "sys":
            ts_file = filedir("../share/pineboo/translations/%s.%s" %
                             (self.idM_, self.lang_))
        else:
            from pineboolib.pncontrolsfactory import aqApp
            ts_file = filedir("%s/cache/%s/%s/file.ts/%s.%s/%s" %
                             (aqApp.tmp_dir(), aqApp.db().database(), self.idM_, self.idM_, self.lang_, key))
        # qmFile = self.AQ_DISKCACHE_DIRPATH + "/" + key + ".qm"
        
        
        ret_ = None
        if not self.translation_from_qm:
            ret_ = self.load_ts("%s.ts" % ts_file)
            if not ret_:
                self.logger.warning("For some reason, i cannot load '%s.ts'", ts_file)
        else:
            
            qm_file = "%s.qm" % ts_file
            if os.path.exists(qm_file):
                if ts_file in (None, ""):
                    return False

            else:

                trans = FLTranslations()
                trans.lrelease("%s.ts" % ts_file, qm_file, not self.mulTiLang_)
            
            
            
            
            
            ret_ = self.load(qm_file)
            if not ret_:
                self.logger.warning("For some reason, i cannot load '%s'", qm_file)
        
        return ret_
예제 #47
0
    def setMainWidget(self, w=None):
        if not w:
            if not self.cursor_:
                self.setMainWidget(self.prj.conn.managerModules().createForm(
                    self.action_, self))
                return
            else:
                self.setMainWidget(
                    self.cursor_.db().managerModules().createForm(
                        self.action_.name, self))
                return
        elif isinstance(w, str):
            if not self.cursor_:
                self.setMainWidget(self.prj.conn.managerModules().createUI(
                    self.action_, self))
                return
            else:
                self.setMainWidget(self.cursor_.db().managerModules().createUI(
                    self.action_.name, self))
                return
        else:

            print("Creamos la ventana")

            if self.showed:
                if self.mainWidget_ and not self.mainWidget_ == w:
                    self.initMainWidget(w)
            else:
                w.hide()

            if self.layoutButtons:
                del self.layoutButtons

            if self.layout:
                del self.layout

            w.setFont(QtWidgets.QApplication.font())
            self.layout = QtWidgets.QVBoxLayout()
            self.layout.addWidget(w)
            self.layoutButtons = QtWidgets.QHBoxLayout()

            # pbSize = Qt.QSize(22,22)

            wt = QtWidgets.QToolButton.whatsThis()
            wt.setIcon(QtGui.QIcon(filedir("../share/icons", "gtk-find.png")))
            self.layoutButtons.addWidget(wt)
            wt.show()

            self.mainWidget_ = w
예제 #48
0
    def contentCached(self, n, shaKey=None):

        data = None
        modId = None
        name_ = n[:n.index(".")]
        ext_ = n[n.index(".") + 1:]

        if not shaKey and not self._prj.conn.manager().isSystemTable(name_):
            query = "SELECT sha FROM flfiles WHERE nombre='%s'" % n
            cursor = self.db_.cursor()
            try:
                cursor.execute(query)
            except:
                return None

            for contenido in cursor:
                shaKey = contenido[0]

        if self._prj.conn.manager().isSystemTable(name_):
            modId = "sys"
        else:
            modId = self._prj.conn.managerModules().idModuleOfFile(n)
        if os.path.exists(
                filedir("../tempdata/cache/%s/%s/file.%s/%s" %
                        (self._prj.dbname, modId, ext_, name_))):
            data = self.contentFS(
                filedir("../tempdata/cache/%s/%s/file.%s/%s/%s.%s" %
                        (self._prj.dbname, modId, ext_, name_, shaKey, ext_)))
        elif os.path.exists(
                filedir("../share/pineboo/tables/%s.%s" % (name_, ext_))):
            data = self.contentFS(
                filedir("../share/pineboo/tables/%s.%s" % (name_, ext_)))
        else:
            data = self.content(n)

        return data
예제 #49
0
 def load(self):
     self.ui = uic.loadUi(filedir('forms/mainform.ui'), self)
     self.areasTab = self.ui.areasTab
     self.areasTab.removeItem(0) #Borramos tab de ejemplo.
     self.formTab = self.ui.formTab
     self.formTab.setTabsClosable(True)
     self.connect(self.formTab, QtCore.SIGNAL('tabCloseRequested(int)'), self.closeFormTab)
     self.formTab.removeTab(0)
     app_icon = QtGui.QIcon()
     app_icon.addFile(filedir('icons/pineboo-logo-16.png'), QtCore.QSize(16,16))
     app_icon.addFile(filedir('icons/pineboo-logo-24.png'), QtCore.QSize(24,24))
     app_icon.addFile(filedir('icons/pineboo-logo-32.png'), QtCore.QSize(32,32))
     app_icon.addFile(filedir('icons/pineboo-logo-48.png'), QtCore.QSize(48,48))
     app_icon.addFile(filedir('icons/pineboo-logo-64.png'), QtCore.QSize(64,64))
     app_icon.addFile(filedir('icons/pineboo-logo-128.png'), QtCore.QSize(128,128))
     app_icon.addFile(filedir('icons/pineboo-logo-256.png'), QtCore.QSize(256,256))
     self.setWindowIcon(app_icon)
     self.setWindowTitle("Pineboo")
예제 #50
0
def create_app(DGI):
    """Create a MainForm using the DGI or the core."""
    from PyQt5 import QtGui, QtWidgets
    from pineboolib.utils import filedir
    import pineboolib
    app = QtWidgets.QApplication(sys.argv)
    if DGI.localDesktop():

        noto_fonts = [
            "NotoSans-BoldItalic.ttf",
            "NotoSans-Bold.ttf",
            "NotoSans-Italic.ttf",
            "NotoSans-Regular.ttf"]
        for fontfile in noto_fonts:
            QtGui.QFontDatabase.addApplicationFont(
                filedir("../share/fonts/Noto_Sans", fontfile))

        sett_ = FLSettings()

        styleA = sett_.readEntry("application/style", None)
        if styleA is None:
            styleA = "Fusion"

        QtWidgets.QApplication.setStyle(styleA)

        fontA = sett_.readEntry("application/font", None)
        if fontA is None:
            font = QtGui.QFont('Noto Sans', 9)
            font.setBold(False)
            font.setItalic(False)
        else:
            font = QtGui.QFont(fontA[0], int(fontA[1]), int(fontA[2]), fontA[3] == "true")

        QtWidgets.QApplication.setFont(font)

        if DGI.mobilePlatform():
            pineboolib.main.Project.mainFormName = "Mobile"

        # Es necesario importarlo a esta altura, QApplication tiene que ser
        # construido antes que cualquier widget
        mainForm = importlib.import_module("pineboolib.plugins.mainform.%s.%s" % (
            pineboolib.main.Project.mainFormName.lower(), pineboolib.main.Project.mainFormName.lower()))
    else:
        mainForm = DGI.mainForm()
    # mainForm = getattr(module_, "MainForm")()
    # from pineboolib import mainForm
    return app, mainForm
예제 #51
0
 def load(self):
     from PyQt5 import uic
 
     import pineboolib
     from pineboolib.fllegacy.flmanagermodules import FLManagerModules
     from pineboolib.utils import filedir
     mng_mod = FLManagerModules()
 
     dlg_ = filedir('dlgabout/about_pineboo.ui')
     version_ = pineboolib.project.version
     self.ui = mng_mod.createUI(dlg_, None, self)
     self.ui.lbl_version.setText("Pineboo v%s" % str(version_))
     self.ui.btn_close.clicked.connect(self.ui.close)
     self.ui.btn_clipboard.clicked.connect(self.to_clipboard)
     self.ui.show()
     
     self.ui.lbl_librerias.setText(self.load_components())
예제 #52
0
    def load(self, filename):
        self.parser = etree.XMLParser(
                        ns_clean=True,
                        encoding="UTF-8",
                        remove_blank_text=True,
                        )
        self.tree = etree.parse(filename, self.parser)
        self.root = self.tree.getroot()
        self.dbserver = DBServer(one(self.root.xpath("database-server")))
        self.dbauth = DBAuth(one(self.root.xpath("database-credentials")))
        self.dbname = one(self.root.xpath("database-name/text()"))
        self.apppath = one(self.root.xpath("application-path/text()"))
        self.tmpdir = filedir("../tempdata")

        self.actions = {}
        self.tables = {}
        pineboolib.project = self
예제 #53
0
    def conectar(self):
        DlgConnect.ruta = filedir(str(DlgConnect.leFolder.text()), str(DlgConnect.leName.text()))
        DlgConnect.username = DlgConnect.leUserName.text()
        DlgConnect.password = DlgConnect.lePassword.text()
        DlgConnect.hostname = DlgConnect.leHostName.text()
        DlgConnect.portnumber = DlgConnect.lePort.text()
        DlgConnect.database = DlgConnect.leDBName.text()

        if not DlgConnect.leName.text():
            DlgConnect.ruta = ""
        elif not DlgConnect.ruta.endswith(".xml"):
            DlgConnect.ruta += ".xml"
        if not os.path.isfile(DlgConnect.ruta) and DlgConnect.leName.text():
            QtGui.QMessageBox.information(self, "AVISO", "El proyecto \n" + DlgConnect.ruta +" no existe")
            DlgConnect.ruta = None
        else:
            self.close()
예제 #54
0
    def loadProfiles(self):
        """
        Actualiza el ComboBox de los perfiles
        """
        self.ui.cbProfiles.clear()
        if not os.path.exists(self.profileDir):
            os.mkdir(filedir(self.profileDir))

        files = [f for f in os.listdir(self.profileDir) if os.path.isfile(os.path.join(self.profileDir, f))]
        for file in files:
            fileName = file.split(".")[0]
            self.ui.cbProfiles.addItem(fileName)

        settings = FLSettings()
        last_profile = settings.readEntry("DBA/last_profile", None)
        if last_profile:
            self.ui.cbProfiles.setCurrentText(last_profile)
예제 #55
0
    def setMainWidget(self, w = None):
        if not w:
            if not self.cursor_:
                self.setMainWidget(self.prj.conn.managerModules().createForm(self.action_, self))
                return
            else:
                self.setMainWidget(self.cursor_.db().managerModules().createForm(self.action_.name, self))
                return
        elif isinstance(w,str):
            if not self.cursor_:
                self.setMainWidget(self.prj.conn.managerModules().createUI(self.action_, self))
                return
            else:
                self.setMainWidget(self.cursor_.db().managerModules().createUI(self.action_.name, self))
                return
        else:
            
        
            print("Creamos la ventana")

            if self.showed:
                if self.mainWidget_ and not self.mainWidget_ == w:
                    self.initMainWidget(w)
            else:
                w.hide()

            if self.layoutButtons:
                del self.layoutButtons

            if self.layout:
                del self.layout


            w.setFont(QtGui.qApp.font())
            self.layout = QtGui.QVBoxLayout()
            self.layout.addWidget(w)
            self.layoutButtons = QtGui.QHBoxLayout()

        #pbSize = Qt.QSize(22,22)

            wt = QtGui.QToolButton.whatsThis()
            wt.setIcon(QtGui.QIcon(filedir("icons","gtk-find.png")))
            self.layoutButtons.addWidget(wt)
            wt.show()

            self.mainWidget_ = w
예제 #56
0
    def load(self, filename):
        self.parser = etree.XMLParser(
            ns_clean=True,
            encoding="UTF-8",
            remove_blank_text=True,
        )
        self.tree = etree.parse(filename, self.parser)
        self.root = self.tree.getroot()
        self.dbserver = DBServer(one(self.root.xpath("database-server")))
        self.dbauth = DBAuth(one(self.root.xpath("database-credentials")))
        self.dbname = one(self.root.xpath("database-name/text()"))
        self.apppath = one(self.root.xpath("application-path/text()"))
        self.tmpdir = filedir("../tempdata")

        self.actions = {}
        self.tables = {}
        pineboolib.project = self
예제 #57
0
    def __init__(self):

        self.driversdict = {}
        # if not os.path.exists("pineboolib/plugins"):
        #    os.makedirs("pineboolib/plugins")
        if not os.path.exists("pineboolib/plugins/sql"):
            os.makedirs("pineboolib/plugins/sql")

        dirlist = os.listdir(filedir("plugins/sql"))
        for f in dirlist:
            if not f[0:2] == "__":
                f = f[:f.find(".py")]
                mod_ = importlib.import_module("pineboolib.plugins.sql.%s" % f)
                driver_ = getattr(mod_, f.upper())()
                self.driversdict[f] = driver_.alias_

        self.defaultDriverName = "FLsqlite"
예제 #58
0
def load_models():
    #print(1, "load_models!!")
    
    db_name = pineboolib.project.conn.DBName()
    tables = pineboolib.project.conn.tables()
    #models_ = {}
    from pineboolib.pncontrolsfactory import aqApp
    from pineboolib import qsa as qsa_dict_modules
    Base = aqApp.db().declarative_base()
    
    setattr(qsa_dict_modules, "Base", aqApp.db().declarative_base())
    setattr(qsa_dict_modules, "session", aqApp.db().session())
    setattr(qsa_dict_modules, "engine", aqApp.db().engine())
    
    for t in tables:
        #print(t, "*")
        try:
            mod = base_model(t)
        except Exception:
            mod = None
        #print(t, mod)
        if mod is not None:
            model_name = "%s%s" % (t[0].upper(), t[1:])
            class_ = getattr(mod, model_name, None)
            if class_ is not None:
                #print("Registrando", model_name)
                setattr(qsa_dict_modules, model_name, class_)
    
    

    
    for root, dirs, files in os.walk(filedir(".." , "tempdata" , "cache", db_name, "models")):
        for nombre in files: #Buscamos los presonalizados
            if nombre.endswith("pyc"):
                continue
            
            nombre = nombre.replace("_model.py", "")
            mod = load_model(nombre)
            if mod is not None:
                model_name = "%s%s" % (nombre[0].upper(), nombre[1:])
                
                class_ = getattr(mod, model_name, None)
                if class_ is not None:
                    #print("Registro 2", model_name)
                    setattr(qsa_dict_modules, model_name, class_)
예제 #59
0
def show_splashscreen(project):
    """Show a splashscreen to inform keep the user busy while Pineboo is warming up."""
    from PyQt5 import QtGui, QtCore, QtWidgets
    from pineboolib.utils import filedir
    splash_pix = QtGui.QPixmap(
        filedir("../share/splashscreen/splash_%s.png" % project.dbname))
    splash = QtWidgets.QSplashScreen(
        splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    splash.setMask(splash_pix.mask())
    splash.show()

    frameGm = splash.frameGeometry()
    screen = QtWidgets.QApplication.desktop().screenNumber(
        QtWidgets.QApplication.desktop().cursor().pos())
    centerPoint = QtWidgets.QApplication.desktop().screenGeometry(screen).center()
    frameGm.moveCenter(centerPoint)
    splash.move(frameGm.topLeft())
    return splash