def rebuildHour(self, opt): """ Rebuilds the scale for the minute mode. :param opt | <XGanttRenderOptions> """ self._labels = [] self._hlines = [] self._vlines = [] self._weekendRects = [] self._alternateRects = [] self._topLabels = [] top_format = 'MMM d h:00a' gantt = self.ganttWidget() if gantt.timescale() == gantt.Timescale.Minute: label_format = 'h:mma' else: label_format = 'mm' increment = 1 # minute # generate vertical lines x = 0 i = 0 half = opt.header_height / 2.0 curr = opt.start top_label = opt.start.toString(top_format) top_rect = QRect(0, 0, 0, half) alt_rect = None while curr <= opt.end: # update the top rect new_top_label = curr.toString(top_format) if new_top_label != top_label: top_rect.setRight(x) self._topLabels.append((top_rect, top_label)) top_rect = QRect(x, 0, 0, half) top_label = new_top_label if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) alt_rect = None else: alt_rect = QRect(x, 0, 0, opt.height) # create the line self._hlines.append(QLine(x, 0, x, opt.height)) # create the header label/rect label = nativestring(curr.toString(label_format)) rect = QRect(x, half, opt.cell_width, half) self._labels.append((rect, label)) # increment the dates curr = curr.addSecs(increment * 60) x += opt.cell_width i += 1 # update the top rect top_rect.setRight(x) top_label = opt.end.toString(top_format) self._topLabels.append((top_rect, top_label)) if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) # resize the width to match the last date range new_width = x self.setSceneRect(0, 0, new_width, opt.height) # generate horizontal lines y = 0 h = opt.height width = new_width while y < h: self._vlines.append(QLine(0, y, width, y)) y += opt.cell_height # clear the dirty flag self._dirty = False
def rebuildWeek(self, opt): """ Rebuilds the scale for the week mode. :param opt | <XOrbRenderOptions> """ self._labels = [] self._hlines = [] self._vlines = [] self._weekendRects = [] self._alternateRects = [] self._topLabels = [] top_format = 'MMM' label_format = 'd' increment = 1 # days # generate vertical lines x = 0 i = 0 half = opt.header_height / 2.0 curr = opt.start top_label = opt.start.toString(top_format) top_rect = QRect(0, 0, 0, half) alt_rect = None while curr <= opt.end: # update the month rect new_top_label = curr.toString(top_format) if new_top_label != top_label: top_rect.setRight(x) self._topLabels.append((top_rect, top_label)) top_rect = QRect(x, 0, 0, half) top_label = new_top_label if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) alt_rect = None else: alt_rect = QRect(x, 0, 0, opt.height) # create the line self._hlines.append(QLine(x, 0, x, opt.height)) # create the header label/rect label = nativestring(curr.toString(label_format)) rect = QRect(x, half, opt.cell_width, half) self._labels.append((rect, label)) # store weekend rectangles if curr.dayOfWeek() in (6, 7): rect = QRect(x, 0, opt.cell_width, opt.height) self._weekendRects.append(rect) # increment the dates curr = curr.addDays(increment) x += opt.cell_width i += 1 # update the month rect top_rect.setRight(x) top_label = opt.end.toString(top_format) self._topLabels.append((top_rect, top_label)) if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) # resize the width to match the last date range new_width = x self.setSceneRect(0, 0, new_width, opt.height) # generate horizontal lines y = 0 h = opt.height width = new_width while y < h: self._vlines.append(QLine(0, y, width, y)) y += opt.cell_height # clear the dirty flag self._dirty = False
def rebuildDay(self, opt): """ Rebuilds the scale for the day mode. :param opt | <XGanttRenderOptions> """ self._labels = [] self._hlines = [] self._vlines = [] self._weekendRects = [] self._alternateRects = [] self._topLabels = [] top_format = 'dddd MMMM dd' label_format = 'ha' increment = 60 # hour # generate vertical lines x = 0 i = 0 half = opt.header_height / 2.0 curr = QDateTime(opt.start, QTime(0, 0, 0)) end = QDateTime(opt.end, QTime(23, 0, 0)) top_label = opt.start.toString(top_format) top_rect = QRect(0, 0, 0, half) alt_rect = None while curr <= end: # update the top rect new_top_label = curr.toString(top_format) if new_top_label != top_label: top_rect.setRight(x) self._topLabels.append((top_rect, top_label)) top_rect = QRect(x, 0, 0, half) top_label = new_top_label if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) alt_rect = None else: alt_rect = QRect(x, 0, 0, opt.height) # create the line self._hlines.append(QLine(x, 0, x, opt.height)) # create the header label/rect label = nativestring(curr.toString(label_format))[:-1] rect = QRect(x, half, opt.cell_width, half) self._labels.append((rect, label)) # increment the dates curr = curr.addSecs(increment * 60) x += opt.cell_width i += 1 # update the top rect top_rect.setRight(x) top_label = opt.end.toString(top_format) self._topLabels.append((top_rect, top_label)) if alt_rect is not None: alt_rect.setRight(x) self._alternateRects.append(alt_rect) # resize the width to match the last date range new_width = x self.setSceneRect(0, 0, new_width, opt.height) # generate horizontal lines y = 0 h = opt.height width = new_width while y < h: self._vlines.append(QLine(0, y, width, y)) y += opt.cell_height # clear the dirty flag self._dirty = False