Example #1
0
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)

        self.diary_control = DiaryControl()
        self.diary_widget = DiaryWidget()

        self.model = DiaryDataModel()

        self.diary_widget.setModel(self.model)

        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addWidget(self.diary_control)
        layout.addWidget(self.diary_widget)
        self.connect_signals()
Example #2
0
class DiaryInterface(QtGui.QWidget):
    '''
    A composite widget containing all elements for viewing a patient record
    '''
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)

        self.diary_control = DiaryControl()
        self.diary_widget = DiaryWidget()

        self.model = DiaryDataModel()

        self.diary_widget.setModel(self.model)

        layout = QtGui.QHBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addWidget(self.diary_control)
        layout.addWidget(self.diary_widget)
        self.connect_signals()

    def sizeHint(self):
        return QtCore.QSize(500, 400)

    def connect_signals(self):
        self.diary_control.date_changed.connect(self.diary_widget.set_date)
        self.diary_control.view_changed.connect(self.diary_widget.setViewStyle)

    def refresh(self):
        '''
        usually called when the database has connected/changed
        '''
        QtGui.QApplication.instance().setOverrideCursor(QtCore.Qt.WaitCursor)
        self.diary_control.refresh()
        self.model.load()
        self.diary_control.set_limits(self.model.start_date,
            self.model.end_date)
        QtGui.QApplication.instance().restoreOverrideCursor()

    def Advise(self, *args):
        if __name__ == "__main__":
            print args
        self.emit(QtCore.SIGNAL("Advise"), *args)
Example #3
0
            painter.drawRect(rect)
            x += colwidth

        year_rect = QtCore.QRectF(0, 0, self._offset, bottom_y)
        painter.drawText(year_rect, str(self.date.year()), option)


if __name__ == "__main__":

    from lib_openmolar.client.db_orm.diary import DiaryDataModel
    from lib_openmolar.client.connect import DemoClientConnection
    app = QtGui.QApplication([])

    cc = DemoClientConnection()
    cc.connect()
    model = DiaryDataModel()
    model.load()

    mw = QtGui.QMainWindow()

    obj = DiaryWidget()
    obj.setModel(model)
    obj.set_date(QtCore.QDate.currentDate().addDays(1))

    cb = QtGui.QComboBox()
    cb.addItems([
        "Day", "4 day", "week", "fortnight", "month", "year", "agenda", "tasks"
    ])
    cb.currentIndexChanged.connect(obj.setViewStyle)

    frame = QtGui.QFrame()