Coverage for modules/org/openteacher/interfaces/qt/enterers/topo/topo : 66%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#! /usr/bin/env python3 # -*- coding: utf-8 -*-
# Copyright 2011, Milan Boers # Copyright 2011-2013, Marten de Vries # # This file is part of OpenTeacher. # # OpenTeacher is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenTeacher is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
global EnterMapChooser, EnterPlaceByName, EnterPlacesWidget, EnterWidget
"""List widget of all the places"""
self.clear()
# Add all the places to the list for place in self.enterWidget.list["items"]: self.addItem(place["name"] + " (" + str(place["x"]) + "," + str(place["y"]) + ")")
"""The dropdown menu for choosing the map"""
# Fill the MapChooser with the maps # Change the map
#update the last combobox item
#the from harddisk item (retranslated)
#custom map def onSuccess(path): name = os.path.splitext(os.path.basename(path))[0]
self.insertItem(0, name, str({'mapPath': path, 'knownPlaces': ''})) self.prevIndex += 1 self.setCurrentIndex(0) #start the process over again. self._otherMap() def onError(): self.setCurrentIndex(self.prevIndex) _fileDialogsMod = base._modules.default("active", type="fileDialogs") _fileDialogsMod.getLoadPath( onSuccess, QtCore.QDir.homePath(), [("gif", ""), ("jpg", ""), ("jpeg", ""), ("png", ""), ("bmp", ""), ("svg", "")], fileType=_("Images"), onError=onError, ) #non-empty current map #Show warning warningD = QtWidgets.QMessageBox() warningD.setIcon(QtWidgets.QMessageBox.Warning) warningD.setWindowTitle(_("Warning")) warningD.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok) warningD.setText(_("Are you sure you want to use another map? This will remove all your places!")) feedback = warningD.exec_() if feedback != QtWidgets.QMessageBox.Ok: self.setCurrentIndex(self.prevIndex) return
# Clear the entered items self.enterWidget.list = { "items": list(), "tests": list() } # Update the list self.enterWidget.currentPlaces.update() self.mapWidget.setMap(self.currentMap["mapPath"]) self.enterWidget.addPlaceEdit.updateKnownPlaces(self.currentMap["knownPlaces"]) self.prevIndex = self.currentIndex() #empty current map else:
def currentMap(self):
"""The add-place-by-name edit"""
"""Gets list of names from the knownPlaces dict list"""
"""Updates the list of names"""
"""The enter tab"""
"items": list(), "tests": list() }
#create the GUI
#left side
#left side - top
#left side - middle
#left side - top
#left side - bottom
#left side
#right side
#right side - top
#right side - middle
#right side - bottom
#right side
#total layout
"""Updates the widgets on the EnterWidget after the list of places has changed
""" self.enterMap.update() self.currentPlaces.update()
"""Add a place to the list"""
self.list["items"].append(place) self.lesson.changed = True self.updateWidgets()
"""Add a place by looking at the list of known places"""
for placeDict in self.mapChooser.currentMap["knownPlaces"]: if name in placeDict["names"]: try: id = self.list["items"][-1]["id"] + 1 except IndexError: id = 0 self.list["items"].append({ "name": name, "x": placeDict["x"], "y": placeDict["y"], "id": id }) self.updateWidgets() return else: QtWidgets.QMessageBox( QtWidgets.QMessageBox.Warning, _("Place not found"), _("Sorry, this place is not in the list of known places. Please add it manually by doubleclicking on the right location in the map.") ).exec_()
self.addPlaceEdit.setText("") self.addPlaceEdit.setFocus()
self.lesson.changed = True
"""Remove a place from the list"""
for placeItem in self.currentPlaces.selectedItems(): for place in self.list["items"]: if placeItem.text() == place["name"] + " (" + str(place["x"]) + "," + str(place["y"]) + ")": self.list["items"].remove(place) self.lesson.changed = True self.updateWidgets()
global base
"default": 640, }
self._mm.mods(type="translator"), self._mm.mods(type="map"), ) self._mm.mods(type="topoMaps"), self._mm.mods(type="fileDialogs"), self._mm.mods(type="ui"), )
global QtCore, QtWidgets except ImportError: return
#setup translation except IndexError: pass else:
global _ global ngettext
except IndexError: _, ngettext = str, lambda a, b, n: a if n == 1 else b else: self._mm.resourcePath("translations") )
|