Exemplo n.º 1
0
    def setupFormat(self):
        XLogger().debug("Init table format with standard class: %s" % self.config)

        # Init columns
        self.setColumnCount(len(self.config.columns))
        self.setHeaders()
        self.refreshVisibility()
Exemplo n.º 2
0
    def updateConfig(self):
        '''
        '''
        XLogger().debug("Update jobs config")
        for i in xrange(self.list.count()):
            hide = True if (self.list.item(i).checkState() == Qt.Unchecked) else False
            # XLogger().debug( " %1s %s" % ( '' if hide else '*', self.list.item(i).text() ) )

            self.config.columns[i]['hidden']=hide
Exemplo n.º 3
0
    def restoreConfig(self):
        '''
        '''

        XLogger().debug("Restore default columns")
        
        from pulitools.pulimonitor.widgets.jobview import JobConfig

        for i, header in enumerate(JobConfig.defaultColumns):
            hide = header.get('hidden',False)
            # XLogger().debug( " %1s %s" % ( '' if hide else '*', header['field'] ) )

            self.config.columns[i]['hidden']=header.get('hidden', False)
        
        self.refreshList()
Exemplo n.º 4
0
    def setItemValues(self, item, row):
        """
        Set a text, widget or other delegate to each columns of the given item
        The display particularity is defined in each column in the "formula" key.
        A "formula" is a list containing at list 1 element: the name of the method to use.
        Any other element in the list will be send as args to the method.
        The formula can call a method of the current instance or a method of any object defined in the scope
        """

        # Loop over each column of this row
        for i,data in enumerate(self.config.columns[1:]):

            if not('formula' in data):
                # This column has no formula, use "CustomTree.default" method with no args
                method = self.default
                args = []
            else:
                # With a formula attribute, we check if the first item of the list targets a method of the current instance 
                # or the method of another object

                if '.' in data['formula'][0]:
                    # We must identify a class and its method
                    clsName, methodName = data['formula'][0].split('.',1)
                    method = getattr( getattr(sys.modules[__name__],clsName), methodName )
                else:
                    # We call a method of our CustomTree class
                    methodName = data['formula'][0]
                    method = getattr( self, methodName )

                # Create args with remaining elements of the formula list
                args = data['formula'][1:]


            #
            # Actual call for the current item and column
            #
            if not callable(method):
                XLogger().error("Error formula must be a static method of CustomDisplay class")
            else:
                value = row.get(data['field'],'')
                method(item, i+1, value, *args)
Exemplo n.º 5
0
    def loadPrefs(self, prefs):
        ''' Restore the header view state with app settings
        - use the widget 'restoreState's method with given headerViewState
        - update config.column with given visibility array [{'name','hiddenFlag'}]
        - refresh instance's visibility

        @param prefs: QVariant( (headerViewState, visibility) )
        '''

        prefs = prefs.toPyObject()

        if not prefs:
            XLogger().info("No prefs to load for %s" % self.__class__.__name__)
            return
        
        self.header().restoreState( prefs[0] )
    
        for name, hidden in prefs[1]:
            for col in self.config.columns:
                if col["field"]==name:
                    col["hidden"] = hidden

        self.refreshVisibility()
        pass
Exemplo n.º 6
0
 def cancel(self):
     XLogger().debug("Cancel")
     self.close()
     pass
Exemplo n.º 7
0
 def accept(self):
     XLogger().debug("Accept")
     self.updateConfig()
     self.refreshList()
     self.close()
Exemplo n.º 8
0
 def onPrefChanged(self):
     '''
     Slot called when the internal config has been changed. Calls the refreshVisibility method to apply changes for each column
     '''
     XLogger().debug("onPrefChanged received")
     self.refreshVisibility()
 def closeEvent(self, event):
     # update app settings 
     XLogger().debug("Close StandardIconDialog")
     pass
Exemplo n.º 10
0
                <tr><td>PyQt</td><td>%s</td></tr>
                <tr><td>Sip</td><td>%s</td></tr>
            </table>
            ''' % (Config.qt_app_name, Config.version, QT_VERSION_STR,
                   PYQT_VERSION_STR, SIP_VERSION_STR)

        QtGui.QMessageBox.about(self, 'About %s' % Config.qt_app_name, msg)
        pass


#################################################################################
# MAIN
if __name__ == '__main__':

    app = QApplication(sys.argv)

    # Used to create/maintain application settings
    app.setOrganizationName(Config.qt_company_name)
    app.setApplicationName(Config.qt_app_name)
    app.setWindowIcon(QIcon(Config.root_dir + "/rsrc/monitor.png"))

    #
    # Define logs
    # - user log streamed to a widget and stdout
    # - dev log streamed to a stdout
    xlogger = XLogger()

    monitor = PuliMonitor()
    monitor.show()

    app.exec_()