def __init__(self, model, view): self.id = None self.model = model self.view = view DModule.__init__(self)
def __init__(self, model, view, *args): self.model = model self.view = view self._closed = False self.buttonBox = None DModule.__init__(self) QtWidgets.QDialog.__init__(self, self.view) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.finished.connect(self.on_finished) self.set_up(*args) self.setWindowTitle(self.title()) ok, cancel = self.button_box() if ok or cancel: if ok and cancel: flags = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel elif ok: flags = QtWidgets.QDialogButtonBox.Ok else: flags = QtWidgets.QDialogButtonBox.Cancel self.buttonBox = QtWidgets.QDialogButtonBox( flags, QtCore.Qt.Horizontal) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) QtWidgets.QDialog.layout(self).addWidget(self.buttonBox) self.adjustSize()
def __init__(self, store): self.store = store self._thumbnails = { } # {thumb_filename: path, ...}; thumb_filename = [hashed uri].[ext] DModule.__init__(self)
def __init__(self, model, view, query, relation, table_view): self.model = model self.view = view self.query = query self.relation = relation self.table_view = table_view self.class_name = None self.proxy_model = None DModule.__init__(self) QtCore.QAbstractTableModel.__init__(self) self.icons = dict( obj=self.view.get_icon("object.svg"), geo=self.view.get_icon("geometry.svg"), file=self.view.get_icon("file.svg"), image=self.view.get_icon("image.svg"), georaster=self.view.get_icon("georaster.svg"), remote_file=self.view.get_icon("remote_file.svg"), remote_image=self.view.get_icon("remote_image.svg"), remote_georaster=self.view.get_icon("remote_georaster.svg"), ) if self.query.classes: self.class_name = self.query.classes[0] self.proxy_model = ProxyModel(table_view) self.proxy_model.setSourceModel(self)
def __init__(self, view): self.view = view self.model = view.model self.history = History(self.model.clustering) self._nodes = {} # {node_id: Node, ...} self._edges = [] # [Edge, ...] self._labels = {} # {node_id: label, ...} self._mouse_prev = None self._tool_tip = ToolTip() DModule.__init__(self) QtWidgets.QGraphicsView.__init__(self) scene = QtWidgets.QGraphicsScene(self) scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex) self.setScene(scene) self.setRenderHint(QtGui.QPainter.Antialiasing) self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorUnderMouse) self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorViewCenter) self.setDragMode(QtWidgets.QGraphicsView.NoDrag) self.setMinimumSize(400, 400) scene.selectionChanged.connect(self.on_selected) self.connect_broadcast(Broadcasts.STORE_LOADED, self.on_store_changed) self.connect_broadcast(Broadcasts.STORE_DATA_SOURCE_CHANGED, self.on_store_changed)
def __init__(self, store): self.store = store self._classes = dict([ (cls.__name__, cls) for cls in [DB, DBRel, JSON, Pickle, RDFGraph] ]) # {name: DataSource, ...} DModule.__init__(self)
def __init__(self, parent): self.parent = parent DModule.__init__(self) QtWidgets.QFrame.__init__(self) self.set_up()
def __init__(self, parent): self.parent = parent DModule.__init__(self) self.setAcceptHoverEvents(True) self.setAcceptDrops(True) self.setZValue(0)
def __init__(self, store): self.store = store self.identifier = None self.url = None self.connstr = None self.is_busy = False DModule.__init__(self)
def __init__(self, queryframe): self.queryframe = queryframe self.count_text = None DModule.__init__(self) QtWidgets.QFrame.__init__(self) self.set_up()
def __init__(self, view): self.view = view self.model = view.model self.toolbars = {} # {name: QToolBar, ...} self.actions = {} # {name: QAction, ...} self.tools = {} # {name: Tool, ...} DModule.__init__(self) self.set_up()
def __init__(self, model): self.model = model self.view = self.model.view self._node_obj_lookup = {} # {node_id: obj_id, ...} self._has_clusters = False self._data = [{}, set([]), set([]), {}, {}] # clusters, nodes, edges, labels, positions DModule.__init__(self)
def __init__(self, view): self.view = view self.model = view.model self.dialogs_open = [] self.dialogs = dict([(cls.__name__, cls) for cls in [ # {name: Dialog, ...} Connect, Import, About, ]]) DModule.__init__(self)
def __init__(self, model, view, query): self.model = model self.view = view self.query = query self.descriptors = {} # {type: {srid: [DDescriptor, ...], ...}, ...} self._row_count = 0 DModule.__init__(self) self.set_up()
def __init__(self, view): self.view = view self.model = view.model self.menubar = None self.actions = {} # {name: QAction, ...} self.tools = {} # {name: Tool, ...} self.recent_menu = None DModule.__init__(self) self.set_up()
def __init__(self, model, view, parent): self.model = model self.view = view self.parent = parent DModule.__init__(self) QtWidgets.QFrame.__init__(self, parent) self.setLayout(QtWidgets.QHBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.left = QtWidgets.QFrame() self.left.setLayout(QtWidgets.QVBoxLayout()) self.left.layout().setContentsMargins(0, 0, 0, 0) self.right = QtWidgets.QFrame() self.right.setLayout(QtWidgets.QVBoxLayout()) self.right.layout().setContentsMargins(0, 0, 0, 0) self.recent_list = QtWidgets.QListWidget() for row in self.view.menu.get_recent( ): # [[url], [identifier, connstr], ...] name = None if len(row) == 1: url = row[0] name = url elif len(row) == 2: identifier, connstr = row name = "%s (%s)" % (identifier, os.path.split(connstr)[1]) if not name: continue item = QtWidgets.QListWidgetItem(name) item.setData(QtCore.Qt.UserRole, row) self.recent_list.addItem(item) self.recent_list.setSelectionMode( QtWidgets.QAbstractItemView.SingleSelection) self.recent_list.itemSelectionChanged.connect(self.on_selected) self.recent_list.activated.connect(self.on_connect) self.connect_button = QtWidgets.QPushButton( self.parent.connect_caption()) self.connect_button.clicked.connect(self.on_connect) self.left.layout().addWidget(self.recent_list) self.left.layout().addWidget(self.connect_button) self.layout().addWidget(self.left) logo = self.parent.logo() if logo: self.right.layout().addWidget(logo) self.layout().addWidget(self.right) self.update()
def __init__(self, label, value, view): self.value = value DModule.__init__(self) UserTool.__init__(self, label, view) self.setIcon(view.get_icon("query.svg")) self.setToolTip("Query: %s" % self.label) self.update() self.connect_broadcast(Broadcasts.VIEW_ACTION, self.on_view_action)
def __init__(self, identifier, connstr=None, url=None): self.identifier = identifier self.prefix = os.path.split(self.identifier.strip("#"))[1] self.connstr = connstr self.url = url self.local_folder = None self.classes = [] # [name, ...] self.objects = {} # {local id: linked id, ...} self.object_lookup = {} # {linked id: local id, ...} self.local_resource_uris = [] DModule.__init__(self)
def __init__(self, index, element, icons=None, relation=None, read_only=False): self.index = index self.element = element self.icons = icons self.relation = relation self.read_only = read_only DModule.__init__(self)
def __init__(self, store): self.store = store self.stopped = False self._events = [] # [[time, user, class_name, key, func_name, args], ...] self._last_time = -1 DModule.__init__(self) self.delements_lookup = dict( DObject = self.store.objects, DObjects = self.store.objects, DClass = self.store.classes, DClasses = self.store.classes, )
def __init__(self, model, view, query, list_view, icon_size=256): self.model = model self.view = view self.query = query self.list_view = list_view self.icon_size = icon_size self.images = [] # [DDescriptor, ...] self.icons = [] # [QIcon or None, ...]; for each image self.empty_icon = None self.proxy_model = None self.threads = {} # {row: IconThread, ...} DModule.__init__(self) QtCore.QAbstractListModel.__init__(self) for row in self.threads: self.threads[row].terminate() self.threads[row].wait() self.threads = {} pixmap = QtGui.QPixmap(self.icon_size, self.icon_size) pixmap.fill() self.empty_icon = QtGui.QIcon(pixmap) self.images = [] done = set() for row in self.query: for column in row: descriptor = row[column].descriptor if descriptor is None: continue if descriptor.label.value in done: continue if (descriptor.label.__class__.__name__ == "DResource") and descriptor.label.is_image(): self.images.append(descriptor) done.add(descriptor.label.value) self.icons = [None] * len(self.images) self.proxy_model = ProxyModel(list_view) self.proxy_model.setSourceModel(self) self.proxy_model.sort()
def __init__(self, view): self.view = view self.model = view.model DModule.__init__(self) QtWidgets.QGroupBox.__init__(self, "Clustering") self.setLayout(QtWidgets.QVBoxLayout()) self.cluster_button = Button("Auto Cluster", self.on_cluster) self.n_clusters_combo = Combo(self.on_n_clusters_changed) self.limit_edit = LineEdit("0.68") self.n_samples_label = QtWidgets.QLabel("") self.n_clusters_label = QtWidgets.QLabel("") self.update_tree_button = Button("Update Tree", self.on_update_tree) self.add_cluster_button = Button("Make Cluster", self.on_add_cluster) self.delete_button = Button("Clear Clusters", self.on_delete) form_frame = QtWidgets.QFrame() form_frame.setLayout(QtWidgets.QFormLayout()) form_frame.layout().setContentsMargins(0, 0, 0, 0) form_frame.layout().addRow(QtWidgets.QLabel("N Clusters:"), self.n_clusters_combo) form_frame.layout().addRow(QtWidgets.QLabel("Dist. Limit:"), self.limit_edit) form_frame.layout().addRow(QtWidgets.QLabel("Samples:"), self.n_samples_label) form_frame.layout().addRow(QtWidgets.QLabel("Clusters Found:"), self.n_clusters_label) self.layout().addWidget(self.cluster_button) self.layout().addWidget(form_frame) self.layout().addWidget(self.update_tree_button) self.layout().addWidget(self.add_cluster_button) self.layout().addWidget(self.delete_button) self.update() self.connect_broadcast(Broadcasts.STORE_LOADED, self.on_data_source_changed) self.connect_broadcast(Broadcasts.STORE_DATA_SOURCE_CHANGED, self.on_data_source_changed) self.connect_broadcast(Broadcasts.STORE_DATA_CHANGED, self.on_data_changed)
def __init__(self, model, view, parent): self.model = model self.view = view self.parent = parent DModule.__init__(self) QtWidgets.QFrame.__init__(self, parent) self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) homedir = self.view.registry.get("recent_dir") if not homedir: homedir = str(Path.home()) self.fs_model = QtWidgets.QFileSystemModel() self.fs_model.setRootPath(homedir) self.fs_model.setNameFilters(["*.%s" % self.EXTENSION]) self.fs_model.setNameFilterDisables(False) self.tree = FileTree() self.tree.setModel(self.fs_model) for i in range(1, self.fs_model.columnCount()): self.tree.hideColumn(i) self.tree.setCurrentIndex(self.fs_model.index(homedir)) self.tree.setExpanded(self.fs_model.index(homedir), True) self.tree.setAnimated(False) self.tree.setIndentation(20) self.tree.setSortingEnabled(True) self.tree.selected.connect(self.on_selected) self.path_edit = QtWidgets.QLineEdit() self.path_edit.textChanged.connect(self.on_path_changed) self.connect_button = QtWidgets.QPushButton( self.parent.connect_caption()) self.connect_button.clicked.connect(self.on_connect) self.layout().addWidget(self.tree) self.layout().addWidget(self.path_edit) self.layout().addWidget(self.connect_button) self.update()
def __init__(self, view): self.view = view self.model = view.model DModule.__init__(self) QtWidgets.QGroupBox.__init__(self, "Distance") self.setLayout(QtWidgets.QVBoxLayout()) self.calculate_button = Button("Calculate Distances", self.on_calculate) self.delete_button = Button("Delete Distances", self.on_delete) self.layout().addWidget(self.calculate_button) self.layout().addWidget(self.delete_button) self.update() self.connect_broadcast(Broadcasts.STORE_LOADED, self.on_data_source_changed) self.connect_broadcast(Broadcasts.STORE_DATA_SOURCE_CHANGED, self.on_data_source_changed) self.connect_broadcast(Broadcasts.STORE_DATA_CHANGED, self.on_data_changed)
def __init__(self, model, view, parent): self.model = model self.view = view self.parent = parent DModule.__init__(self) QtWidgets.QFrame.__init__(self, parent) self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(10, 10, 10, 10) self.label = QtWidgets.QLabel("Create a new database in memory.\n\n") self.label.setAlignment(QtCore.Qt.AlignCenter) self.connect_button = QtWidgets.QPushButton("Create") self.connect_button.clicked.connect(self.on_connect) self.layout().addStretch() self.layout().addWidget(self.label) self.layout().addWidget(self.connect_button, alignment=QtCore.Qt.AlignCenter) self.layout().addStretch()
def __init__(self, model, *args): self.model = model self.args = args self.registry = None self.navigator = None self.mdiarea = None self.toolbar = None self.menu = None self.dialogs = None self.querytoolbar = None self.usertools = None self.statusbar = None self._in_parent_thread = False self.broadcast_timer = None DModule.__init__(self) QtWidgets.QMainWindow.__init__(self) self.set_up()
def __init__(self, view): self.view = view self.model = view.model DModule.__init__(self) QtWidgets.QGroupBox.__init__(self, "Class / Descriptors") self.setLayout(QtWidgets.QVBoxLayout()) self.sample_class_combo = Combo(self.on_sample_class_changed) self.cluster_class_combo = Combo(self.on_cluster_class_changed, editable=True) self.node_class_combo = Combo(self.on_node_class_changed, editable=True) classes_frame = QtWidgets.QFrame() classes_frame.setLayout(QtWidgets.QFormLayout()) classes_frame.layout().setContentsMargins(0, 0, 0, 0) classes_frame.layout().addRow(QtWidgets.QLabel("Sample Class:"), self.sample_class_combo) classes_frame.layout().addRow(QtWidgets.QLabel("Cluster Class:"), self.cluster_class_combo) classes_frame.layout().addRow(QtWidgets.QLabel("Node Class:"), self.node_class_combo) self.descriptors_frame = QtWidgets.QFrame() self.descriptors_frame.setLayout(QtWidgets.QFormLayout()) self.descriptors_frame.layout().setContentsMargins(0, 0, 0, 0) self.descriptors_frame.setVisible(False) self.load_data_button = Button("Load Data", self.on_load_data) self.load_descr_button = Button("Load Descriptors...", self.on_load_descriptors) button_frame = QtWidgets.QFrame() button_frame.setLayout(QtWidgets.QHBoxLayout()) button_frame.layout().setContentsMargins(0, 0, 0, 0) button_frame.layout().addWidget(self.load_data_button) button_frame.layout().addWidget(self.load_descr_button) descriptor_box = QtWidgets.QFrame() descriptor_box.setLayout(QtWidgets.QVBoxLayout()) descriptor_box.layout().setContentsMargins(0, 0, 0, 0) self.descriptor_header_button = HeaderButton("Descriptors") descriptor_box.layout().addWidget(self.descriptor_header_button) descriptor_box.layout().addWidget(self.descriptors_frame) self.descriptor_header_button.clicked.connect( self.on_descriptors_clicked) self.layout().addWidget(classes_frame) self.layout().addWidget(descriptor_box) self.layout().addWidget(button_frame) self.load_descriptors() self.update() self.connect_broadcast(Broadcasts.STORE_LOADED, self.on_store_changed) self.connect_broadcast(Broadcasts.STORE_DATA_SOURCE_CHANGED, self.on_store_changed) self.connect_broadcast(Broadcasts.STORE_DATA_CHANGED, self.on_store_changed)
def __init__(self): self.model = None self.registry = None self.mode = None self._loaded = False DModule.__init__(self) QtWidgets.QMainWindow.__init__(self) self.model = Model(self) self.setWindowTitle("CeraMatch") self.setWindowIcon(QtGui.QIcon("res\cm_icon.svg")) self.setStyleSheet("QPushButton {padding: 5px; min-width: 100px;}") self.central_widget = QtWidgets.QWidget(self) self.central_widget.setLayout(QtWidgets.QVBoxLayout()) self.central_widget.layout().setContentsMargins(0, 0, 0, 0) self.setCentralWidget(self.central_widget) self.splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.central_widget.layout().addWidget(self.splitter) self.registry = Registry("Deposit") self.image_view = ImageView(self) self.footer_frame = FooterFrame(self) self.descriptor_group = DescriptorGroup(self) self.sort_group = SortGroup(self) self.cluster_group = ClusterGroup(self) self.menu = Menu(self) self.toolbar = ToolBar(self) self.statusbar = StatusBar(self) self.calculate_button = Button("Calculate Distances", self.on_calculate) self.calculate_button.setEnabled(False) self.left_frame = QtWidgets.QFrame(self) self.left_frame.setLayout(QtWidgets.QVBoxLayout()) self.left_frame.layout().setContentsMargins(10, 10, 0, 10) self.right_frame = QtWidgets.QFrame(self) self.right_frame.setLayout(QtWidgets.QVBoxLayout()) self.right_frame.layout().setContentsMargins(0, 0, 0, 0) self.splitter.addWidget(self.left_frame) self.splitter.addWidget(self.right_frame) self.left_frame.layout().addWidget(self.descriptor_group) group = QtWidgets.QGroupBox("Calculate") group.setLayout(QtWidgets.QVBoxLayout()) group.layout().addWidget(self.calculate_button) self.left_frame.layout().addWidget(group) self.left_frame.layout().addWidget(self.sort_group) self.left_frame.layout().addWidget(self.cluster_group) self.left_frame.layout().addStretch() self.right_frame.layout().addWidget(self.image_view) self.right_frame.layout().addWidget(self.footer_frame) self.setStatusBar(self.statusbar) self._loaded = True self.setGeometry(100, 100, 1024, 768) self.on_samples() self.footer_frame.slider_zoom.setValue(100) self.connect_broadcast(Broadcasts.VIEW_ACTION, self.on_update) self.connect_broadcast(Broadcasts.STORE_LOCAL_FOLDER_CHANGED, self.on_update) self.connect_broadcast(Broadcasts.STORE_SAVED, self.on_update) self.connect_broadcast(Broadcasts.STORE_LOADED, self.on_update) self.connect_broadcast(Broadcasts.STORE_DATA_SOURCE_CHANGED, self.on_update) self.connect_broadcast(Broadcasts.STORE_DATA_CHANGED, self.on_update)
def __init__(self, store): self.store = store self._classes = dict([(cls.__name__, cls) for cls in [CSV, Shapefile, XLSX]]) # {name: DataSource, ...} DModule.__init__(self)
def __init__(self, model, view, parent): self.model = model self.view = view self.parent = parent self._connstr_prev = None self._schemas = defaultdict(lambda: defaultdict( list)) # {server: {db_name: [schema, ...], ...}, ...} self._identifiers = [] DModule.__init__(self) QtWidgets.QFrame.__init__(self, parent) self.form = QtWidgets.QWidget() self.form.setLayout(QtWidgets.QFormLayout()) self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(10, 10, 10, 10) self.server_combo = QtWidgets.QComboBox() self.server_combo.setEditable(True) self.db_name_combo = QtWidgets.QComboBox() self.db_name_combo.setEditable(True) self.schema_name_combo = QtWidgets.QComboBox() self.schema_name_combo.setEditable(True) self.schema_name_combo.setCurrentText("public") self.user_edit = QtWidgets.QLineEdit("") self.user_edit.textChanged.connect(self.update) self.pass_edit = QtWidgets.QLineEdit("") self.pass_edit.setEchoMode(QtWidgets.QLineEdit.Password) self.pass_edit.textChanged.connect(self.update) self.identifier_combo = QtWidgets.QComboBox() self.identifier_combo.setEditable(True) self.local_folder_edit = QtWidgets.QLineEdit("") self.local_folder_edit.textChanged.connect(self.on_local_folder_edit) self.local_folder_edit._edited = False self.lf_browse_button = QtWidgets.QPushButton("Browse...") self.lf_browse_button.clicked.connect(self.on_lf_browse) lf_container = QtWidgets.QWidget() lf_container.setLayout(QtWidgets.QHBoxLayout()) lf_container.layout().setContentsMargins(0, 0, 0, 0) lf_container.layout().addWidget(self.local_folder_edit) lf_container.layout().addWidget(self.lf_browse_button) self.temp_store = Store() self.db = self.temp_store.datasources.DB() servers = [] logins = [] names = {} # {server: [name, ...], ...} for row in self.view.menu.get_recent( ): # [[url], [identifier, connstr], ...] if len(row) == 2: server, name = row[1].split("/")[-2:] schema = "public" if "?" in name: name, schema = name.split("?") schema = schema.split("%3D")[-1] user, server = server.split("@") user, password = user.split(":") if server not in names: names[server] = [] if name not in names[server]: names[server].append(name) if schema not in self._schemas[server][name]: self._schemas[server][name].append(schema) if server not in servers: servers.append(server) logins.append([user, password]) self.server_combo.addItem("") for i in range(len(servers)): self.server_combo.addItem(servers[i], [servers[i]] + logins[i] + [names[servers[i]]]) self.server_combo.editTextChanged.connect(self.on_server_changed) self.db_name_combo.editTextChanged.connect(self.update) self.schema_name_combo.editTextChanged.connect(self.update) self.identifier_combo.editTextChanged.connect( self.on_identifier_changed) self.connect_button = QtWidgets.QPushButton( self.parent.connect_caption()) self.connect_button.clicked.connect(self.on_connect) self.form.layout().addRow("Server[:port]:", self.server_combo) self.form.layout().addRow("Database:", self.db_name_combo) self.form.layout().addRow("Schema:", self.schema_name_combo) self.form.layout().addRow("Username:"******"Password:"******"Identifier:", self.identifier_combo) self.form.layout().addRow("Local Folder:", lf_container) self.layout().addWidget(self.form) self.layout().addWidget(self.connect_button, alignment=QtCore.Qt.AlignCenter) self.layout().addStretch() self.update()