コード例 #1
0
 def appointment_clicked(self, start, finish, serialno):
     for appt in self.appts:
         if (appt.serialno == serialno
                 and start == localsettings.wystimeToHumanTime(appt.start)
                 and finish == localsettings.wystimeToHumanTime(appt.end)):
             self.pWidget.appt_clicked_signal.emit(appt)
             break
コード例 #2
0
 def appointment_clicked(self, start, finish, serialno):
     for appt in self.appts:
         if (appt.serialno == serialno and
                 start == localsettings.wystimeToHumanTime(appt.start) and
                 finish == localsettings.wystimeToHumanTime(appt.end)):
             self.pWidget.appt_clicked_signal.emit(appt)
             break
コード例 #3
0
    def print_(self):
        dialog = QtPrintSupport.QPrintDialog(self.printer, self.parent)
        if not dialog.exec_():
            return
        self.printer.setPaperSize(QtPrintSupport.QPrinter.A5)
        painter = QtGui.QPainter(self.printer)
        pageRect = self.printer.pageRect()
        painter.setPen(QtCore.Qt.black)

        font = QtGui.QFont("Times", 11)
        fm = QtGui.QFontMetrics(font)
        fontLineHeight = fm.height()

        painter.setFont(font)

        rect = QtCore.QRectF(pageRect.width() / 6,
                             pageRect.height() / 20,
                             pageRect.width() * 5 / 6,
                             pageRect.height() / 3)

        text = "%s %s %s\n%s\n" % (self.pt.title, self.pt.fname, self.pt.sname,
                                   self.pt.address)
        text += "Our ref %d\n\n" % self.pt.serialno
        painter.drawText(rect, text)

        option = QtGui.QTextOption(QtCore.Qt.AlignCenter)
        option.setWrapMode(QtGui.QTextOption.WordWrap)

        y = pageRect.height() / 3
        painter.drawLine(0, int(y), int(pageRect.width()), int(y))

        y += fontLineHeight * 1.5

        font.setBold(True)
        painter.setFont(font)
        rect = QtCore.QRectF(0, y, pageRect.width(), fontLineHeight * 1.5)
        painter.drawText(rect, "You have the following appointments with us",
                         option)
        font.setBold(False)
        painter.setFont(font)

        for appt in self.appts:
            y += fontLineHeight * 1.5
            atime = localsettings.wystimeToHumanTime(appt.atime)
            adate = localsettings.longDate(appt.date)

            text = "%s - %s with %s" % (atime, adate, appt.dent_inits)

            rect = QtCore.QRectF(0, y, pageRect.width(), fontLineHeight * 1.5)

            painter.drawText(rect, text, option)

        y = pageRect.height() * 2 / 3

        painter.drawLine(0, int(y), int(pageRect.width()), int(y))
        font.setItalic(True)
        painter.setFont(font)

        rect = QtCore.QRectF(0, y, pageRect.width(), pageRect.height() * 1 / 3)
        painter.drawText(rect, localsettings.APPOINTMENT_CARD_FOOTER, option)
コード例 #4
0
ファイル: apptcardPrint.py プロジェクト: jdzla/openmolar1
    def print_(self):
        dialog = QtGui.QPrintDialog(self.printer)
        if not dialog.exec_():
            return
        self.printer.setPaperSize(QtGui.QPrinter.A5)
        painter = QtGui.QPainter(self.printer)
        pageRect = self.printer.pageRect()
        painter.setPen(QtCore.Qt.black)

        font = QtGui.QFont("Times", 11)
        fm = QtGui.QFontMetrics(font)
        fontLineHeight = fm.height()

        painter.setFont(font)

        rect = QtCore.QRectF(pageRect.width()/6, pageRect.height()/20,
            pageRect.width()*5/6, pageRect.height()/3)

        text = "%s %s %s\n%s\n"%(
            self.pt.title, self.pt.fname, self.pt.sname, self.pt.address)
        text += "Our ref %d\n\n"% self.pt.serialno
        painter.drawText(rect, text)

        option = QtGui.QTextOption(QtCore.Qt.AlignCenter)
        option.setWrapMode(QtGui.QTextOption.WordWrap)

        y = pageRect.height()/3
        painter.drawLine(0,int(y),int(pageRect.width()),int(y))

        y += fontLineHeight*1.5

        font.setBold(True)
        painter.setFont(font)
        rect = QtCore.QRectF(0, y, pageRect.width(), fontLineHeight*1.5)
        painter.drawText(rect, "You have the following appointments with us",
            option)
        font.setBold(False)
        painter.setFont(font)

        for appt in self.appts:
            y += fontLineHeight*1.5
            atime = localsettings.wystimeToHumanTime(appt.atime)
            adate = localsettings.longDate(appt.date)

            text = "%s - %s with %s"%(atime, adate, appt.dent_inits)

            rect = QtCore.QRectF(0, y, pageRect.width(), fontLineHeight*1.5)

            painter.drawText(rect, text, option)



        y = pageRect.height() *2/3

        painter.drawLine(0,int(y),int(pageRect.width()),int(y))
        font.setItalic(True)
        painter.setFont(font)

        rect = QtCore.QRectF(0, y, pageRect.width(), pageRect.height()*1/3)
        painter.drawText(rect, localsettings.APPOINTMENT_CARD_FOOTER, option)
コード例 #5
0
 def __init__(self, category, appointment, parent=None, index=0):
     self.appointment = appointment
     self.isAppointment = True
     try:
         if appointment.date:
             self.headerCol = (
                 localsettings.wystimeToHumanTime(appointment.atime) + "\t" +
                 localsettings.readableDate(appointment.date))
         else:
             self.headerCol = "TBA"  # used to be "TBA"
     except AttributeError:
         self.headerCol = category
         self.isAppointment = False
     self.parentItem = parent
     self.myindex = index
     self.childItems = []
コード例 #6
0
 def __init__(self, category, appointment, parent=None, index=0):
     self.appointment = appointment
     self.isAppointment = True
     try:
         if appointment.date:
             self.headerCol = "%s\t%s" % (
                 localsettings.wystimeToHumanTime(appointment.atime),
                 localsettings.readableDate(appointment.date))
         else:
             self.headerCol = "TBA"  # used to be "TBA"
     except AttributeError:
         self.headerCol = category
         self.isAppointment = False
     self.parentItem = parent
     self.myindex = index
     self.childItems = []
コード例 #7
0
ファイル: appointments.py プロジェクト: OOmblik/openmolar1
 def getStart(self):
     '''
     returns the day start in format set by localsettings Human Time
     '''
     return localsettings.wystimeToHumanTime(self.start)
コード例 #8
0
ファイル: appointments.py プロジェクト: OOmblik/openmolar1
 def readableTime(self):
     return localsettings.wystimeToHumanTime(self.atime)
コード例 #9
0
ファイル: appointments.py プロジェクト: claudioger/openmolar1
 def getStart(self):
     '''
     returns the day start in format set by localsettings Human Time
     '''
     return localsettings.wystimeToHumanTime(self.start)
コード例 #10
0
ファイル: appointments.py プロジェクト: claudioger/openmolar1
 def readableTime(self):
     return localsettings.wystimeToHumanTime(self.atime)
コード例 #11
0
ファイル: calendars.py プロジェクト: claudioger/openmolar1
    def paintEvent(self, event=None):
        '''
        draws the widget - recalled at any point by instance.update()
        '''
        self.setFont()
        self.setMinimumWidth(self.minimumWidth())
        painter = QtGui.QPainter(self)
        painter.setFont(self.font)

        rowHeight = self.height() / (self.rowNo)

        # HEADER ROW - the month and year, highlighted
        painter.setBrush(self.palette().highlight())
        rect = QtCore.QRectF(0, 0, self.width(), rowHeight)
        painter.drawRect(rect)
        painter.setPen(self.palette().color(self.palette().HighlightedText))
        self.font.setBold(True)
        painter.setFont(self.font)

        c_date = datetime.date(self.year, self.month, 1)
        my_text = "%s %s" % (localsettings.monthName(c_date), self.year)
        painter.drawText(rect, my_text, CENTRE)

        self.font.setBold(False)
        painter.setFont(self.font)

        for day in range(0, self.rowNo - 1):
            rect = QtCore.QRectF(0, (day + 1) * rowHeight, self.vheaderwidth,
                                 rowHeight)

            painter.setPen(self.palette().color(self.palette().WindowText))
            brush = self.palette().base()

            if day == 0:
                option = CENTRE
                my_text = _("DATE")
                c_date = datetime.date(1900, 1, 1)
                brush = self.palette().button()

            else:
                option = RIGHT
                c_date = datetime.date(self.year, self.month, day)
                my_text = "%s %2s " % (localsettings.dayName(c_date), day)

                brush = self.palette().base()
                if c_date.isoweekday() > 5:
                    brush = self.palette().alternateBase()
                if c_date == self.selectedDate:
                    brush = self.palette().highlight()
                elif c_date == self.highlightedDate:
                    brush = self.mouseBrush

            painter.setBrush(brush)

            painter.save()
            painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
            painter.drawRect(rect)
            painter.restore()
            if c_date in (self.selectedDate, self.highlightedDate):
                painter.setPen(self.palette().color(
                               self.palette().HighlightedText))
                painter.drawText(rect, my_text, option)

            elif c_date.isoweekday() < 6:
                painter.setPen(self.palette().color(
                               self.palette().WindowText))
                painter.drawText(rect, my_text, option)

            else:
                painter.save()
                painter.setPen(QtCore.Qt.red)
                painter.drawText(rect, my_text, option)
                painter.restore()

            rect = rect.adjusted(self.vheaderwidth, 0, self.bankHolColwidth,
                                 0)

            painter.save()
            painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
            painter.drawRect(rect)
            painter.restore()

            key = "%d%02d" % (self.month, day)
            if key in self.headingdata:
                my_text = str(self.headingdata.get(key))
                self.font.setItalic(True)
                painter.setFont(self.font)
                painter.drawText(rect, my_text, CENTRE)
                self.font.setItalic(False)
                painter.setFont(self.font)

            #- text column
            x = self.bankHolColwidth + self.vheaderwidth
            rect = rect.adjusted(self.bankHolColwidth, 0, 0, 0)

            for col in range(self.colNo):
                dentix = self.dents[col]
                my_text = ""

                colWidth = self.dentColWidths[dentix]
                rect = rect.adjusted(0, 0, colWidth, 0)

                painter.save()
                painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
                painter.drawRect(rect)
                painter.restore()
                option = LEFT
                if day == 0:
                    my_text = "%s" % localsettings.apptix_reverse.get(dentix,
                                                                      "all")
                    option = CENTRE
                elif key in self.data:
                    dent = self.data[key].get(dentix)
                    if dent:
                        if dentix == 0:
                            my_text = dent.memo.upper()
                        else:
                            if not dent.flag:
                                times = ""
                            else:
                                times = "%s - %s " % (
                                    localsettings.wystimeToHumanTime(
                                        dent.start),
                                    localsettings.wystimeToHumanTime(dent.end))
                            my_text = "%s%s" % (times, dent.memo)

                if my_text:
                    painter.drawText(
                        rect.adjusted(2,
                                      0,
                                      0,
                                      0),
                        my_text,
                        option)

                rect = rect.adjusted(colWidth, 0, 0, 0)
        painter.setPen(QtGui.QColor("black"))

        painter.drawLine(self.bankHolColwidth + self.vheaderwidth, rowHeight,
                         self.bankHolColwidth + self.vheaderwidth, self.height())
コード例 #12
0
ファイル: calendars.py プロジェクト: vomae/openmolar1
    def paintEvent(self, event=None):
        '''
        draws the widget - recalled at any point by instance.update()
        '''
        self.setFont()
        self.setMinimumWidth(self.minimumWidth())
        painter = QtGui.QPainter(self)
        painter.setFont(self.font)

        rowHeight = self.height() / (self.rowNo)

        # HEADER ROW - the month and year, highlighted
        painter.setBrush(self.palette().highlight())
        rect = QtCore.QRectF(0, 0, self.width(), rowHeight)
        painter.drawRect(rect)
        painter.setPen(self.palette().color(self.palette().HighlightedText))
        self.font.setBold(True)
        painter.setFont(self.font)

        c_date = datetime.date(self.year, self.month, 1)
        my_text = "%s %s" % (localsettings.monthName(c_date), self.year)
        painter.drawText(rect, my_text, CENTRE)

        self.font.setBold(False)
        painter.setFont(self.font)

        for day in range(0, self.rowNo - 1):
            rect = QtCore.QRectF(0, (day + 1) * rowHeight, self.vheaderwidth,
                                 rowHeight)

            painter.setPen(self.palette().color(self.palette().WindowText))
            brush = self.palette().base()

            if day == 0:
                option = CENTRE
                my_text = _("DATE")
                c_date = datetime.date(1900, 1, 1)
                brush = self.palette().button()

            else:
                option = RIGHT
                c_date = datetime.date(self.year, self.month, day)
                my_text = "%s %2s " % (localsettings.dayName(c_date), day)

                brush = self.palette().base()
                if c_date.isoweekday() > 5:
                    brush = self.palette().alternateBase()
                if c_date == self.selectedDate:
                    brush = self.palette().highlight()
                elif c_date == self.highlightedDate:
                    brush = self.mouseBrush

            painter.setBrush(brush)

            painter.save()
            painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
            painter.drawRect(rect)
            painter.restore()
            if c_date in (self.selectedDate, self.highlightedDate):
                painter.setPen(self.palette().color(
                    self.palette().HighlightedText))
                painter.drawText(rect, my_text, option)

            elif c_date.isoweekday() < 6:
                painter.setPen(self.palette().color(self.palette().WindowText))
                painter.drawText(rect, my_text, option)

            else:
                painter.save()
                painter.setPen(QtCore.Qt.red)
                painter.drawText(rect, my_text, option)
                painter.restore()

            rect = rect.adjusted(self.vheaderwidth, 0, self.bankHolColwidth, 0)

            painter.save()
            painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
            painter.drawRect(rect)
            painter.restore()

            key = "%d%02d" % (self.month, day)
            if key in self.headingdata:
                my_text = str(self.headingdata.get(key))
                self.font.setItalic(True)
                painter.setFont(self.font)
                painter.drawText(rect, my_text, CENTRE)
                self.font.setItalic(False)
                painter.setFont(self.font)

            # text column
            rect = rect.adjusted(self.bankHolColwidth, 0, 0, 0)

            for col in range(self.colNo):
                dentix = self.dents[col]
                my_text = ""

                colWidth = self.dentColWidths[dentix]
                rect = rect.adjusted(0, 0, colWidth, 0)

                painter.save()
                painter.setPen(QtGui.QPen(QtCore.Qt.gray, 1))
                painter.drawRect(rect)
                painter.restore()
                option = LEFT
                if day == 0:
                    my_text = "%s" % localsettings.apptix_reverse.get(
                        dentix, "all")
                    option = CENTRE
                elif key in self.data:
                    dent = self.data[key].get(dentix)
                    if dent:
                        if dentix == 0:
                            my_text = dent.memo.upper()
                        else:
                            if not dent.flag:
                                times = ""
                            else:
                                times = "%s - %s " % (
                                    localsettings.wystimeToHumanTime(
                                        dent.start),
                                    localsettings.wystimeToHumanTime(dent.end))
                            my_text = "%s%s" % (times, dent.memo)

                if my_text:
                    painter.drawText(rect.adjusted(2, 0, 0, 0), my_text,
                                     option)

                rect = rect.adjusted(colWidth, 0, 0, 0)
        painter.setPen(QtGui.QColor("black"))

        painter.drawLine(self.bankHolColwidth + self.vheaderwidth,
                         rowHeight, self.bankHolColwidth + self.vheaderwidth,
                         self.height())