예제 #1
0
    def saveOnChanged(self, cursor, finishedFlag=None):
        """If the text has changed since the last recorded revision,
        save the new version and add it to the revisions list. If
        'finishedFlag' != None, force a save.
        finishedFlag = None, keep as at present
                     = False, set to off
                     = True, set to on
         => True if saved
        """
        lastSaved = self.revisions[-1][0]   # don't need the old cursor
        utext, ci = self.getText(cursor)

        if (finishedFlag == None):
            finishedFlag = self.isFinished()
            if (utext == getReportText(lastSaved)):
                return False

        revN = self.db.getTime()
        if finishedFlag:
            # If the report is flagged as 'finished'
            revN += u"$"

        self.report = self.db.saveReport(self.pupilId, self.subject,
                utext, revN)

        # Save to revisions list
        self.revisions.append((self.report, ci))
        while (len(self.revisions) > UNDOMAX):
            # Delete the second oldest in the list, thus always
            # keeping the initially loaded version.
            del(self.revisions[1])

        return True
예제 #2
0
    def __init__(self, pupilId, subject, db):
        """pupilId: id field of the pupil's database record
        subject: subject tag
        db: database.DB object
        """
        self.db = db
        self.pupilId = pupilId
        self.subject = subject

        self.tlines = None

        self.getReportInfo()

        # Get the frame information as a list of TextFrame objects
        self.frames = []
        i = 0           # The frames are indexed
        for n in self.db.getFrames(self.subject):
            self.frames.append(TextFrame(self.db, n, i, self.subject))
            i += 1
        if not self.printMode:
            self.frames.append(TextFrame(self.db, u"overflowFrame", i,
                    self.subject))

        if self.report:
            self.setText(getReportText(self.report))
예제 #3
0
    def __init__(self, pupilId, subject, db):
        """pupilId: id field of the pupil's database record
        subject: subject tag
        db: database.DB object
        """
        self.db = db
        self.pupilId = pupilId
        self.subject = subject

        self.tlines = None

        self.getReportInfo()

        # Get the frame information as a list of TextFrame objects
        self.frames = []
        i = 0  # The frames are indexed
        for n in self.db.getFrames(self.subject):
            self.frames.append(TextFrame(self.db, n, i, self.subject))
            i += 1
        if not self.printMode:
            self.frames.append(
                TextFrame(self.db, u"overflowFrame", i, self.subject))

        if self.report:
            self.setText(getReportText(self.report))
예제 #4
0
 def undo(self, level):
     """Set the text to a different historical version, from the
     self.revisions list, level being the index (the most recent is
     level 0).
     The 'textChanged' signal is suppressed so that the button
     enabling can work properly.
      => True if report marked as 'finished'
     """
     version = self.revisions[-1 - level]
     self.report, self.cursor = version
     self.setText(getReportText(self.report))
     return getReportVersion(self.report).endswith(u"$")