def new_phrasebook(self):
     offer_list = []
     for ix in localsettings.activedent_ixs + localsettings.activehyg_ixs:
         if not PHRASEBOOKS.has_book(ix):
             offer_list.append(localsettings.ops[ix])
     if offer_list == []:
         self.advise(_("Everyone has a phrasebook already!"), 2)
         return
     dl = QtGui.QInputDialog(self)
     choice, result = dl.getItem(self, _("Choose"), _("A phrasebook for which clinician?"), sorted(offer_list))
     if result:
         ix = localsettings.ops_reverse[str(choice.toAscii())]
         PHRASEBOOKS.create_book(ix)
         self.load_phrasebooks()
Beispiel #2
0
 def new_phrasebook(self):
     offer_list = []
     for ix in localsettings.activedent_ixs + localsettings.activehyg_ixs:
         if not PHRASEBOOKS.has_book(ix):
             offer_list.append(localsettings.ops[ix])
     if offer_list == []:
         self.advise(_("Everyone has a phrasebook already!"), 2)
         return
     dl = QtGui.QInputDialog(self)
     choice, result = dl.getItem(self, _("Choose"),
                                 _("A phrasebook for which clinician?"),
                                 sorted(offer_list))
     if result:
         ix = localsettings.ops_reverse[str(choice.toAscii())]
         PHRASEBOOKS.create_book(ix)
         self.load_phrasebooks()
Beispiel #3
0
    def __init__(self, parent=None, id=0):
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle(_("Phrase Book"))

        layout = QtGui.QVBoxLayout(self)
        self.tabWidget = MockTabWidget()

        self.buttonBox = QtGui.QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(
            QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setCenterButtons(True)
        self.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), self.accept)
        self.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.reject)

        layout.addWidget(self.tabWidget)
        layout.addWidget(self.buttonBox)

        self.dict = OrderedDict()

        self.xml = minidom.parseString(PHRASEBOOKS.book(id).xml)
        sections = self.xml.getElementsByTagName("section")

        for section in sections:
            header = section.getElementsByTagName("header")[0]
            header_text = header.firstChild.data
            icon_loc = header.getAttribute("icon")
            if icon_loc:
                icon = QtGui.QIcon(icon_loc)
            else:
                icon = QtGui.QIcon(":icons/pencil.png")
            page = QtGui.QWidget(self)
            layout = QtGui.QVBoxLayout(page)
            phrases = section.getElementsByTagName("phrase")
            for phrase in phrases:

                if phrase.hasAttribute("spacer"):
                    layout.addStretch()
                elif phrase.hasAttribute("sub_heading"):
                    text = phrase.firstChild.data
                    label = QtGui.QLabel(u"<b>%s</b>" % text)
                    layout.addWidget(label)
                else:
                    text = phrase.firstChild.data
                    cb = QtGui.QCheckBox(page)
                    cb.setText(text)
                    layout.addWidget(cb)
                    self.dict[cb] = text
            widgets = section.getElementsByTagName("widget")
            for widget in widgets:
                if widget.firstChild.data == "choose_shade":
                    sp = shadePicker(self)
                    layout.addWidget(sp)
                    self.dict[sp.cb] = sp.result

            spacerItem = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Minimum,
                                           QtGui.QSizePolicy.Expanding)
            layout.addItem(spacerItem)

            self.tabWidget.addTab(page, icon, header_text)
Beispiel #4
0
 def apply_changes(self):
     if QtGui.QMessageBox.question(self, _("confirm"),
     _("commit all local files to database?"),
     QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel
     ) == QtGui.QMessageBox.Ok:
         no_ = 0
         for te in self.text_editors:
             if not te.is_dirty:
                 continue
             new_xml = te.text()
             result, message = self.check_xml_validity(new_xml)
             if not result:
                 self.advise("%s %s %s"% (
                 _("Phrasebook"), te.db_index, _("is not valid")), 2)
                 continue
             result = PHRASEBOOKS.update_database(new_xml, te.db_index)
             if result:
                 te.setText(new_xml)
                 no_ += 1
         self.advise("%s %d %s"% (_("Updated"), no_, _("Books")), 1)
Beispiel #5
0
 def apply_changes(self):
     if QtGui.QMessageBox.question(
             self, _("confirm"), _("commit all local files to database?"),
             QtGui.QMessageBox.Ok
             | QtGui.QMessageBox.Cancel) == QtGui.QMessageBox.Ok:
         no_ = 0
         for te in self.text_editors:
             if not te.is_dirty:
                 continue
             new_xml = te.text()
             result, message = self.check_xml_validity(new_xml)
             if not result:
                 self.advise(
                     "%s %s %s" %
                     (_("Phrasebook"), te.db_index, _("is not valid")), 2)
                 continue
             result = PHRASEBOOKS.update_database(new_xml, te.db_index)
             if result:
                 te.setText(new_xml)
                 no_ += 1
         self.advise("%s %d %s" % (_("Updated"), no_, _("Books")), 1)
    def load_phrasebooks(self):
        self.loading = True
        while self.tab_widget.count():
            self.tab_widget.removeTab(0)
        for editor in self.text_editors:
            editor.setParent(None)
        self.text_editors = []
        for book in PHRASEBOOKS.get_all_books():
            editor = XMLEditor(self)
            editor.editor_settings()
            editor.setText(book.xml)
            editor.db_index = book.ix
            editor.textChanged.connect(self.text_changed)
            editor.cursorPositionChanged.connect(self.cursor_position_changed)

            if book.ix == 0:
                title = _("Global Phrasebook")
            else:
                title = localsettings.ops[book.ix]
            self.text_editors.append(editor)

            self.tab_widget.addTab(editor, title)

        self.loading = False
Beispiel #7
0
    def load_phrasebooks(self):
        self.loading = True
        while self.tab_widget.count():
            self.tab_widget.removeTab(0)
        for editor in self.text_editors:
            editor.setParent(None)
        self.text_editors = []
        for book in PHRASEBOOKS.get_all_books():
            editor = XMLEditor(self)
            editor.editor_settings()
            editor.setText(book.xml)
            editor.db_index = book.ix
            editor.textChanged.connect(self.text_changed)
            editor.cursorPositionChanged.connect(self.cursor_position_changed)

            if book.ix == 0:
                title = _("Global Phrasebook")
            else:
                title = localsettings.ops[book.ix]
            self.text_editors.append(editor)

            self.tab_widget.addTab(editor, title)

        self.loading = False