Example #1
0
    def getColors(self):
        pattern = re.compile(r'^day_([+-]\d+)([+-]\d+)$')
        retCol = {'default': '', 'ranges': []}
        for color in self.options("colors"):
            if color == "default":
                retCol['default'] = self.get("colors", "default")
            else:
                match = pattern.match(color)
                if match:
                    col = (int(match.group(1)), int(match.group(2)),
                           self.get("colors", color))
                    retCol['ranges'].append(col)

        retCol['ranges'] = tools.sortColorsByRange(retCol['ranges'])
        return retCol
Example #2
0
    def getColors(self):
        pattern = re.compile( r'^day_([+-]\d+)([+-]\d+)$' )
        retCol = { 'default' : '',
                   'ranges'  : [] }
        for color in self.options("colors"):
            if color == "default":
                retCol['default'] = self.get("colors", "default")
            else:
                match = pattern.match(color)
                if match:
                    col = ( int( match.group(1) ), int( match.group(2) ), self.get("colors", color) )
                    retCol['ranges'].append( col )

        retCol['ranges'] = tools.sortColorsByRange( retCol['ranges'] )
        return retCol
Example #3
0
    def addToMyColors(self):
        if self.ui.radioSingleDay.isChecked():
            rangeStart = self.ui.spinColorsSingleDay.value()
            rangeStop = rangeStart
        else:
            rangeStart = self.ui.spinColorsFrom.value()
            rangeStop = self.ui.spinColorsTo.value()

        # Just keep the ranges (excluding color names)
        chkRanges = [(range[0], range[1]) for range in self.myColors['ranges']]
        # Append our new range
        chkRanges.append((rangeStart, rangeStop))

        # if True, ranges are overlapping (baaaad)
        if tools.checkRangeOverlap(chkRanges):
            if rangeStop == rangeStart:
                message = u"Overlapping detected.\nCannot add color for that day."
            else:
                message = u"Overlapping ranges detected (%d → %d).\nCannot add color for the specified range." % (
                    rangeStart, rangeStop)
            QMessageBox().information(self, "Information", message,
                                      QMessageBox.Ok)
            return

        # Looks like everything went fine... Adding new color...
        self.myColors['ranges'].append(
            (rangeStart, rangeStop, self.lastColorUsed))

        # ...and sort everything
        self.myColors['ranges'] = tools.sortColorsByRange(
            self.myColors['ranges'])

        # Display colors
        self.displayMyColors()

        # Need to save
        self.saveRequired()
Example #4
0
    def addToMyColors(self):
        if self.ui.radioSingleDay.isChecked():
            rangeStart = self.ui.spinColorsSingleDay.value()
            rangeStop  = rangeStart
        else:
            rangeStart = self.ui.spinColorsFrom.value()
            rangeStop  = self.ui.spinColorsTo.value()

        # Just keep the ranges (excluding color names)
        chkRanges = [ (range[0],range[1]) for range in self.myColors['ranges'] ]
        # Append our new range
        chkRanges.append( ( rangeStart, rangeStop ) )

        # if True, ranges are overlapping (baaaad)
        if tools.checkRangeOverlap( chkRanges ):
            if rangeStop == rangeStart:
                message = u"Overlapping detected.\nCannot add color for that day."
            else:
                message = u"Overlapping ranges detected (%d → %d).\nCannot add color for the specified range." % (rangeStart ,rangeStop)
            QMessageBox().information(self,
                                      "Information",
                                      message,
                                      QMessageBox.Ok)
            return

        # Looks like everything went fine... Adding new color...
        self.myColors['ranges'].append( ( rangeStart, rangeStop, self.lastColorUsed ) )

        # ...and sort everything
        self.myColors['ranges'] = tools.sortColorsByRange( self.myColors['ranges'] )

        # Display colors
        self.displayMyColors()

        # Need to save
        self.saveRequired()