Beispiel #1
0
    def __init__(self, parent=None, **kwargs):
        FramelessWindow.__init__(self, parent, **kwargs)
        self.setWindowFlags(Qt.Popup)

        self.__filterFunc = None

        self.__setupUi()

        self.__loop = None
        self.__model = QStandardItemModel()
        self.__triggeredAction = None
    def __init__(self, tableType, parent):
        # generate a model based on orb columns
        items = {}
        model = QStandardItemModel(parent)

        if tableType:
            self.__populate(tableType.schema().columns(), model)

        self._tableType = tableType

        super(XOrbColumnCompleter, self).__init__(model, parent)
Beispiel #3
0
    def __init__(self, parent=None, **kwargs):
        super(AddonManagerWidget, self).__init__(parent, **kwargs)

        self.setLayout(QVBoxLayout())

        self.__header = QLabel(
            wordWrap=True,
            textFormat=Qt.RichText
        )
        self.__search = QLineEdit(
            placeholderText=self.tr("Filter")
        )

        self.layout().addWidget(self.__search)

        self.__view = view = QTreeView(
            rootIsDecorated=False,
            editTriggers=QTreeView.NoEditTriggers,
            selectionMode=QTreeView.SingleSelection,
            alternatingRowColors=True
        )
        self.__view.setItemDelegateForColumn(0, TristateCheckItemDelegate())
        self.layout().addWidget(view)

        self.__model = model = QStandardItemModel()
        model.setHorizontalHeaderLabels(["", "Name", "Version", "Action"])
        model.dataChanged.connect(self.__data_changed)
        proxy = QSortFilterProxyModel(
            filterKeyColumn=1,
            filterCaseSensitivity=Qt.CaseInsensitive
        )
        proxy.setSourceModel(model)
        self.__search.textChanged.connect(proxy.setFilterFixedString)

        view.setModel(proxy)
        view.selectionModel().selectionChanged.connect(
            self.__update_details
        )
        header = self.__view.header()
        header.setResizeMode(0, QHeaderView.Fixed)
        header.setResizeMode(2, QHeaderView.ResizeToContents)

        self.__details = QTextBrowser(
            frameShape=QTextBrowser.NoFrame,
            readOnly=True,
            lineWrapMode=QTextBrowser.WidgetWidth,
            openExternalLinks=True,
        )

        self.__details.setWordWrapMode(QTextOption.WordWrap)
        palette = QPalette(self.palette())
        palette.setColor(QPalette.Base, Qt.transparent)
        self.__details.setPalette(palette)
        self.layout().addWidget(self.__details)
Beispiel #4
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.train_data = None
        self.test_data = None

        #: An Ordered dictionary with current inputs and their testing
        #: results.
        self.learners = OrderedDict()

        sbox = gui.widgetBox(self.controlArea, "Sampling")
        rbox = gui.radioButtons(
            sbox, self, "resampling", callback=self._param_changed
        )
        gui.appendRadioButton(rbox, "Cross validation")
        ibox = gui.indentedBox(rbox)
        gui.spin(ibox, self, "k_folds", 2, 50, label="Number of folds:",
                 callback=self.kfold_changed)
        gui.appendRadioButton(rbox, "Leave one out")
        gui.appendRadioButton(rbox, "Random sampling")
        ibox = gui.indentedBox(rbox)
        gui.spin(ibox, self, "n_repeat", 2, 50, label="Repeat train/test",
                 callback=self.bootstrap_changed)
        gui.widgetLabel(ibox, "Relative training set size:")
        gui.hSlider(ibox, self, "sample_p", minValue=1, maxValue=100,
                    ticks=20, vertical=False, labelFormat="%d %%",
                    callback=self.bootstrap_changed)

        gui.appendRadioButton(rbox, "Test on train data")
        gui.appendRadioButton(rbox, "Test on test data")

        rbox.layout().addSpacing(5)
        gui.button(rbox, self, "Apply", callback=self.apply)

        gui.rubber(self.controlArea)

        self.view = QTreeView(
            rootIsDecorated=False,
            uniformRowHeights=True,
            wordWrap=True,
            editTriggers=QTreeView.NoEditTriggers
        )
        header = self.view.header()
        header.setResizeMode(QHeaderView.ResizeToContents)
        header.setDefaultAlignment(Qt.AlignCenter)
        header.setStretchLastSection(False)

        self.result_model = QStandardItemModel()
        self.view.setModel(self.result_model)
        self.view.setItemDelegate(ItemDelegate())
        self._update_header()
        box = gui.widgetBox(self.mainArea, "Evaluation Results")
        box.layout().addWidget(self.view)
    def _configure_model(self):
        model = QStandardItemModel(0, 3, self)

        # Set headers
        headers = [
            self.tr('Name'),
            self.tr('Data Type'),
            self.tr('Description')
        ]
        model.setHorizontalHeaderLabels(headers)

        self.setModel(model)
Beispiel #6
0
    def __init__(self, name='', desc='', survey_date=None, run_no=''):
        self.name = name
        self.desc = desc
        self.survey_date = survey_date
        self.run_no = run_no

        self.model = QStandardItemModel()
        #self.model=route_model.route_model()

        self.model.setColumnCount(len(cols))

        [self.model.setHeaderData(cols[c], Qt.Horizontal, c) for c in cols]
Beispiel #7
0
    def __init__(self, parent=None):
        super(FormWidget, self).__init__(parent)
        self.setupUi(self)
        self.form = None

        self.fieldsmodel = QgsFieldModel()
        self.widgetmodel = WidgetsModel()
        self.possiblewidgetsmodel = QStandardItemModel()
        self.formlayersmodel = QgsLayerModel(watchregistry=True)
        self.formlayers = CaptureLayerFilter()
        self.formlayers.setSourceModel(self.formlayersmodel)

        self.layerCombo.setModel(self.formlayers)
        self.useablewidgets.setModel(self.possiblewidgetsmodel)
        self.fieldList.setModel(self.fieldsmodel)

        self.userwidgets.setModel(self.widgetmodel)
        self.userwidgets.selectionModel().currentChanged.connect(self.load_widget)
        self.widgetmodel.rowsRemoved.connect(self.setwidgetconfigvisiable)
        self.widgetmodel.rowsInserted.connect(self.setwidgetconfigvisiable)
        self.widgetmodel.modelReset.connect(self.setwidgetconfigvisiable)

        self.addWidgetButton.pressed.connect(self.newwidget)
        self.removeWidgetButton.pressed.connect(self.removewidget)

        self.formfolderLabel.linkActivated.connect(self.openformfolder)
        self.expressionButton.clicked.connect(self.opendefaultexpression)

        self.fieldList.currentIndexChanged.connect(self.updatewidgetname)
        self.fieldwarninglabel.hide()
        self.formtab.currentChanged.connect(self.formtabchanged)

        for item, data in readonlyvalues:
            self.readonlyCombo.addItem(item, data)

        self.loadwidgettypes()

        self.formLabelText.textChanged.connect(self.form_name_changed)
        self.layerCombo.currentIndexChanged.connect(self.layer_updated)

        self.fieldList.currentIndexChanged.connect(self._save_current_widget)
        self.nameText.textChanged.connect(self._save_current_widget)
        self.useablewidgets.currentIndexChanged.connect(self._save_current_widget)
        self.useablewidgets.currentIndexChanged.connect(self.swapwidgetconfig)

        menu = QMenu("Field Actions")
        action = menu.addAction("Auto add all fields")
        action.triggered.connect(self.auto_add_fields)

        self.addWidgetButton.setMenu(menu)
        self.addWidgetButton.setPopupMode(QToolButton.MenuButtonPopup)

        self.defaultLayerCombo.layerChanged.connect(self.default_layer_changed)
Beispiel #8
0
    def __init__(self):
        super().__init__()

        self.data = None
        self.results = None
        self.learners = []
        self.headers = []

        box = gui.widgetBox(self.controlArea, "Learners")

        self.learners_box = gui.listBox(
            box, self, "selected_learner", "learners",
            callback=self._learner_changed
        )
        box = gui.widgetBox(self.controlArea, "Show")

        gui.comboBox(box, self, "selected_quantity", items=self.quantities,
                     callback=self._update)

        box = gui.widgetBox(self.controlArea, "Select")

        gui.button(box, self, "Correct",
                   callback=self.select_correct, autoDefault=False)
        gui.button(box, self, "Misclassified",
                   callback=self.select_wrong, autoDefault=False)
        gui.button(box, self, "None",
                   callback=self.select_none, autoDefault=False)

        self.outputbox = box = gui.widgetBox(self.controlArea, "Output")
        gui.checkBox(box, self, "append_predictions",
                     "Predictions", callback=self._invalidate)
        gui.checkBox(box, self, "append_probabilities",
                     "Probabilities",
                     callback=self._invalidate)

        gui.auto_commit(self.controlArea, self, "autocommit",
                        "Send Data", "Auto send is on")

        grid = QGridLayout()

        self.tablemodel = QStandardItemModel(self)
        view = self.tableview = QTableView(
            editTriggers=QTableView.NoEditTriggers)
        view.setModel(self.tablemodel)
        view.horizontalHeader().hide()
        view.verticalHeader().hide()
        view.horizontalHeader().setMinimumSectionSize(60)
        view.selectionModel().selectionChanged.connect(self._invalidate)
        view.setShowGrid(False)
        view.clicked.connect(self.cell_clicked)
        grid.addWidget(view, 0, 0)
        self.mainArea.layout().addLayout(grid)
Beispiel #9
0
    def __init__(self, iface, spatial_unit_dock):

        """
        The method initializes the dockwidget.
        :param iface: QGIS user interface class
        :type class qgis.utils.iface
        :param plugin: The STDM plugin
        :type class
        :return: None
        """
        from stdm.ui.entity_browser import _EntityDocumentViewerHandler
        DetailsDockWidget.__init__(self, iface, spatial_unit_dock)

        DetailsDBHandler.__init__(self)

        self.spatial_unit_dock = spatial_unit_dock

        self.view = QTreeView()
        self.view.setSelectionBehavior(
            QAbstractItemView.SelectRows
        )
        #self.feature_ids = []
        self.layer_table = None
        self.entity = None
        self.feature_models = {}
        self.party_models = {}
        self.STR_models = {}
        self.feature_STR_model = {}
        self.removed_feature = None
        self.selected_root = None
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        self.view.setUniformRowHeights(True)
        self.view.setRootIsDecorated(True)
        self.view.setAlternatingRowColors(True)
        self.view.setWordWrap(True)
        self.view.setHeaderHidden(True)
        self.view.setEditTriggers(
            QAbstractItemView.NoEditTriggers
        )
        self.current_profile = current_profile()
        self.social_tenure = self.current_profile.social_tenure
        self.spatial_unit = self.social_tenure.spatial_unit
        self.party = self.social_tenure.party
        self.view.setMinimumWidth(250)
        self.doc_viewer_title = QApplication.translate(
            'EntityBrowser',
            'Document Viewer'
        )
        self.doc_viewer = _EntityDocumentViewerHandler(
            self.doc_viewer_title, self.iface.mainWindow()
        )
Beispiel #10
0
 def update_commands(self, meas_prog_list_byname):
     global Regexprogramfile
     Regexprogramfile = "(" + "|".join(meas_prog_list_byname) + ")"
     self.valid_list_of_commands = self.get_list_of_commands()
     #initiate syntax highlighting for the macro editor
     self.highlighter = MacroHighlighter(self.ui.macro_textbox.document(),
                                         self.valid_list_of_commands)
     #update the list of available macro commands in the user interface
     model = QStandardItemModel()
     parentItem = model.invisibleRootItem()
     for command in self.valid_list_of_commands:
         parentItem.appendRow(QStandardItem(command.label))
     self.ui.macrocommandtree.setModel(model)
Beispiel #11
0
    def __init__(self):
        super(PrvTreeviewNest, self).__init__()

        loadUi('treeview_nest.ui')

        # row can be 0 even when it's more than 0.
        self._datamodel = QStandardItemModel(0, 2)
        self.setModel(self._datamodel)

        for i in range(4):
            self.add_widget(i + 1)

        self.show()
    def __init__(self, parent):
        QDockWidget.__init__(self, parent)
        self.parent = parent

        self.setupUi(self)

        self.block_model = QStandardItemModel()
        self.segment_model = QStandardItemModel()
        self.channelgroup_model = QStandardItemModel()
        self.channel_model = QStandardItemModel()
        self.unit_model = QStandardItemModel()

        self.neoBlockList.setModel(self.block_model)
        self.neoSegmentList.setModel(self.segment_model)
        self.neoChannelGroupList.setModel(self.channelgroup_model)
        self.neoChannelList.setModel(self.channel_model)
        self.neoUnitList.setModel(self.unit_model)

        self.neoBlockList.doubleClicked.connect(
            lambda x: self._edit_item_annotations(x, self.block_model))
        self.neoSegmentList.doubleClicked.connect(
            lambda x: self._edit_item_annotations(x, self.segment_model))
        self.neoChannelGroupList.doubleClicked.connect(
            lambda x: self._edit_item_annotations(x, self.channelgroup_model))
        self.neoChannelList.doubleClicked.connect(
            lambda x: self._edit_item_annotations(x, self.channel_model))
        self.neoUnitList.doubleClicked.connect(
            lambda x: self._edit_item_annotations(x, self.unit_model))

        self.neoBlockList.selectionModel().selectionChanged.connect(
            self.selected_blocks_changed)
        self.neoChannelGroupList.selectionModel().selectionChanged.connect(
            self.selected_channel_groups_changed)
        self.neoChannelList.selectionModel().selectionChanged.connect(
            self.selected_channels_changed)
        self.neoUnitList.selectionModel().selectionChanged.connect(
            self.selected_units_changed)
        self.neoSegmentList.selectionModel().selectionChanged.connect(
            self.selected_segments_changed)
    def initializePage(self):
        model = QStandardItemModel()

        # using a document model, we can obtain all the documents to list inside this view...
        all_docs = DocumentStorage.documents()
        for doc_filename in all_docs:
            # find out the last scan date, number of files, etc
            document = PersistentScanningState(doc_filename)
            logger.debug("found info: {0}".format(document.info))
            creation_date_str = str(document.info.date_created)
            last_date = str(document.info.date_last_scanned)
            num_scanned = "{0:,}".format(document.info.files_scanned)
            num_merged = "{0:,}".format(document.info.files_merged)
            is_merged = document.info.merge_complete
            if not is_merged:
                last_date_str = ""
            else:
                last_date_str = last_date

            doc = os.path.split(doc_filename)[1][:-len('.sqlite')]
            items = [
                QStandardItem(doc),
                QStandardItem(str(num_scanned)),
                QStandardItem(creation_date_str),
                QStandardItem(str(num_merged)),
                QStandardItem(last_date_str),
            ]

            items[1].setData(Qt.AlignRight, Qt.TextAlignmentRole)
            items[3].setData(Qt.AlignRight, Qt.TextAlignmentRole)

            model.invisibleRootItem().appendRow(items)

        self.ui.treeView.setModel(model)

        header = self.ui.treeView.header()

        model.setHeaderData(0, Qt.Horizontal, "Name")
        model.setHeaderData(1, Qt.Horizontal, "# First Scan")
        model.setHeaderData(2, Qt.Horizontal, "Date Created")
        model.setHeaderData(3, Qt.Horizontal, "# Second Scan")
        model.setHeaderData(4, Qt.Horizontal, "Date Scanned")

        header.setResizeMode(0, QHeaderView.ResizeToContents)
        header.setResizeMode(1, QHeaderView.ResizeToContents)
        header.setResizeMode(2, QHeaderView.ResizeToContents)
        header.setResizeMode(3, QHeaderView.ResizeToContents)
        header.setResizeMode(4, QHeaderView.ResizeToContents)

        self.ui.treeView.selectionModel().currentRowChanged.connect(
            self.__onSelectionChanged)
Beispiel #14
0
 def show_result(self, search_time):
     self.set_results_heading_text("{} Ergebnisse in {:.2f} Sekunden".format(len(self.result), search_time))
     result = self.result
     model = QStandardItemModel(self.list_results)
     for index in range(min(len(result), self.max_results)):
         node = result.get_node(index)
         context = result.get_context(index)
         item_text = [str(index + 1) + ". " + node.get_title(),
                      node.get_urls()[0],
                      "\t" + context]
         item = QStandardItem("\n".join(item_text))
         model.appendRow(item)
     self.list_results.setModel(model)
     self.list_results.show()
Beispiel #15
0
    def populateTable(self, table):
        cols = len(self.param.cols)
        rows = len(table)
        model = QStandardItemModel(rows, cols)

        # Set headers
        model.setHorizontalHeaderLabels(self.param.cols)

        # Populate table
        for i in xrange(rows):
            for j in xrange(cols):
                item = QStandardItem(table[i][j])
                model.setItem(i, j, item)
        self.tblView.setModel(model)
Beispiel #16
0
    def __init__(self, window):
        super(NameList, self).__init__('Current Plots')
        self.namelist_model = QStandardItemModel()
        self.namelist_view = QListView()
        self.namelist_view.setModel(self.namelist_model)
        self.setWidget(self.namelist_view)
        self.window = window
        self.plot_dict = {}

        self.namelist_view.doubleClicked.connect(self.activate_item)
        self.namelist_view.setContextMenuPolicy(QtConst.ActionsContextMenu)
        delete_action = QAction("Delete Selected", self.namelist_view)
        delete_action.triggered.connect(self.delete_item)
        self.namelist_view.addAction(delete_action)
    def __init__(self, xmlPath, treeControl, parent=None):
        """ Constructor """
        if xmlPath is None or not os.path.isfile(xmlPath):
            msg = "..."
            q = QMessageBox(QMessageBox.Warning, "Could not find that file",
                            msg)
            q.setStandardButtons(QMessageBox.Ok)
            i = QIcon()
            i.addPixmap(QPixmap("..."), QIcon.Normal)
            q.setWindowIcon(i)
            q.exec_()
        else:
            self.tree = treeControl
            self.model = QStandardItemModel()
            # Set up an invisible root item for the tree.
            #self.treeRoot = self.model.invisibleRootItem()
            self.treeRoot = QStandardItem("Root Item")
            self.model.appendRow(self.treeRoot)
            self.tree.setModel(self.model)
            self.tree.doubleClicked.connect(self.item_doubleClicked)
            self.tree.customContextMenuRequested.connect(self.openMenu)
            self.tree.setDragEnabled(True)

            self.xmlTreeDir = os.path.join(os.path.dirname(__file__),
                                           "Resources/XML/")
            self.xmlProjfile = xmlPath
            self.xmlProjDir = os.path.dirname(xmlPath)
            self.namespace = "{http://tempuri.org/ProjectDS.xsd}"
            self.xmlTreePath = None

            # Load the GCD Project (the raw data that will be used to populate the tree)
            # instead of ET.fromstring(xml)
            self.xmlProjectDoc = self.LoadXMLFile(self.xmlProjfile)

            if self.FindTreeParser():
                print "got ya"
                # Load the tree file (the rules we use to build the tree)

            else:
                print "This is an error"

            # Set up the first domino for the recursion
            projectName = self.xmlProjectDoc.find("Project/name")
            if projectName is not None:
                self.treeRoot.setText(projectName.text)

            self.LoadNode(None, self.xmlTemplateDoc.find("node"),
                          self.xmlProjectDoc)
            self.tree.expandToDepth(5)
Beispiel #18
0
    def get_attributes(self):
        """Place excludable attributes in model list"""
        # Model Structure used from Tutorial at
        # http://pythoncentral.io/pyside-pyqt-tutorial-qlistview-and-qstandarditemmodel/

        self.model = QStandardItemModel(self.listTblAttrib)
        self.hasGeometry = self.iface.activeLayer().hasGeometryType()
        self.provider = self.iface.activeLayer().dataProvider()
        fields = self.iface.activeLayer().pendingFields()

        for field in fields:
            item = QStandardItem(field.name())
            item.setCheckable(True)
            self.model.appendRow(item)
        self.listTblAttrib.setModel(self.model)
Beispiel #19
0
    def init_quest_list(self):

        self.bot.QuestManager.EnumActiveQuests()
        self.model = QStandardItemModel(self.quest_list)
        for quest in [
                self.bot.QuestManager.GetQuest(quest_id)
                for quest_id in self.bot.QuestManager.GetQuestIds()
        ]:
            item = QStandardItem(quest.GetTitle())
            item.setEditable(False)
            self.model.appendRow(item)
        self.quest_list.setModel(self.model)
        self.quest_list.connect(self.quest_list,
                                SIGNAL('itemActivated(QModelIndex)'),
                                self.quest_id_edit, SLOT('setText'))
Beispiel #20
0
    def __init__(self, parent=None):
        QTableView.__init__(self, parent)

        self.setEditTriggers(QAbstractItemView.DoubleClicked
                             | QAbstractItemView.SelectedClicked)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)

        self._pair_model = QStandardItemModel(1, 2, self)
        self._pair_model.dataChanged.connect(self._on_pair_data_changed)

        self.setModel(self._pair_model)
        self.horizontalHeader().setResizeMode(QHeaderView.Stretch)

        self._combo_delegate = PairComboBoxDelegate(self)
        self.setItemDelegate(self._combo_delegate)
Beispiel #21
0
    def __init__(self, engine, gui_parent, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)

        self.setWindowTitle("Enregistrement d'une formation")

        self.engine = engine
        self.dateEdit.setDate(pendulum.now('Europe/Paris'))
        self.cmr_bdd = Bdd_Cmr(self.engine)

        gen_cmr = self.cmr_bdd.recup_cmr_en_activite()

        self.remplir_tableau_cmr(next(gen_cmr))

        #        self.threadpool = QThreadPool()

        self.gui_parent = gui_parent

        ####Threads
        self.thread_finish = False
        #        self.affectation_lancement_threads()

        init_domaine = Insertion_Domaine(self.engine)
        areas = init_domaine.recuperation_domaine()
        #        print(areas)

        self.model = QStandardItemModel((len(areas) + 1), 1)  # 5 rows, 1 col

        firstItem = QStandardItem("---- Select domaine(s) ----")
        firstItem.setBackground(QBrush(QColor(200, 200, 200)))
        firstItem.setSelectable(False)
        self.model.setItem(0, 0, firstItem)

        for i, area in enumerate(areas):
            item = QStandardItem(area)
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            item.setData(Qt.Unchecked, Qt.CheckStateRole)
            self.model.setItem(i + 1, 0, item)

        self.comboBox_domaine.setModel(self.model)

        self.gui_parent.formation_a_modifier.connect(
            self.reaffectation_formation)
Beispiel #22
0
    def __init__(self, other_or_parent=None, parent=None):
        if isinstance(other_or_parent, QObject) and parent is None:
            parent, other_or_parent = other_or_parent, None
        QObject.__init__(self, parent)
        WidgetRegistry.__init__(self, other_or_parent)

        # Should  the QStandardItemModel be subclassed?
        self.__item_model = QStandardItemModel(self)

        for i, desc in enumerate(self.categories()):
            cat_item = self._cat_desc_to_std_item(desc)
            self.__item_model.insertRow(i, cat_item)

            for j, wdesc in enumerate(self.widgets(desc.name)):
                widget_item = self._widget_desc_to_std_item(wdesc, desc)
                cat_item.insertRow(j, widget_item)
Beispiel #23
0
    def __init__(self, parent=None, profile=None, social_tenure=None):
        super(STRPartyListView, self).__init__(parent)

        self._model = QStandardItemModel(self)
        self._model.setColumnCount(1)
        self.setModel(self._model)
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self._model.itemChanged.connect(self._on_item_changed)

        self._profile = profile
        if not self._profile is None:
            self._load_profile_entities()

        self._social_tenure = social_tenure
        if not self._social_tenure is None:
            self.select_parties(self._social_tenure.parties)
    def set_headers(self, qtable):
        feature_type = utils_giswater.get_item_data(
            self.dlg_lot, self.dlg_lot.cmb_visit_class, 2).lower()
        columns_name = self.controller.get_columns_list('om_visit_lot_x_' +
                                                        str(feature_type))
        columns_name.append(['validate'])
        standard_model = QStandardItemModel()
        qtable.setModel(standard_model)
        qtable.horizontalHeader().setStretchLastSection(True)

        # # Get headers
        headers = []
        for x in columns_name:
            headers.append(x[0])
        # Set headers
        standard_model.setHorizontalHeaderLabels(headers)
    def __init__(self, parent=None, selectMode=True):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        self.notifBar = NotificationBar(self.vlNotification)

        if selectMode:
            self.buttonBox.setVisible(True)
            self.manageButtonBox.setVisible(False)
            currHeight = self.size().height()
            self.resize(200, currHeight)

        else:
            self.buttonBox.setVisible(False)
            self.manageButtonBox.setVisible(True)
            self.setWindowTitle(
                QApplication.translate("TemplateDocumentSelector",
                                       "Template Manager"))

        #Configure manage buttons
        btnEdit = self.manageButtonBox.button(QDialogButtonBox.Ok)
        btnEdit.setText(
            QApplication.translate("TemplateDocumentSelector", "Edit..."))
        btnEdit.setIcon(QIcon(":/plugins/stdm/images/icons/edit.png"))

        btnDelete = self.manageButtonBox.button(QDialogButtonBox.Save)
        btnDelete.setText(
            QApplication.translate("TemplateDocumentSelector", "Delete"))
        btnDelete.setIcon(QIcon(":/plugins/stdm/images/icons/delete.png"))

        #Connect signals
        self.buttonBox.accepted.connect(self.onAccept)
        btnEdit.clicked.connect(self.onEditTemplate)
        btnDelete.clicked.connect(self.onDeleteTemplate)

        #Get saved document templates then add to the model
        templates = documentTemplates()

        self._docItemModel = QStandardItemModel(parent)
        self._docItemModel.setColumnCount(2)

        for name, path in templates.iteritems():
            docNameItem = self._createDocNameItem(name)
            filePathItem = QStandardItem(path)
            self._docItemModel.appendRow([docNameItem, filePathItem])

        self.lstDocs.setModel(self._docItemModel)
Beispiel #26
0
    def getSampleModel(spl, flags='peak', **kw):
        from gui.MetBaseGui import MSStandardItem
        if flags not in ('peak', 'cluster', 'id'):
            return
        model = QStandardItemModel()
        if flags == 'peak':
            from utils.misc import Hot
            areas = [peak.area for peak in spl.rawPeaks.ipeaks()]
            mxInt = max(areas)
            model.setHorizontalHeaderLabels(MSSample.peakModelLabel)

            for i, peak in enumerate(spl.rawPeaks.ipeaks()):
                model.setItem(i, 0, MSStandardItem(str(peak.mass())))
                model.item(i, 0).setBackground(
                    QBrush(Hot._get_color(areas[i] / mxInt, True, alpha=0.5)))

                model.setItem(i, 1, MSStandardItem(str(peak.rt)))
                model.item(i, 1).setBackground(
                    QBrush(Hot._get_color(areas[i] / mxInt, True, alpha=0.5)))

                model.setItem(i, 2, MSStandardItem(str(peak.area)))
                model.item(i, 2).setBackground(
                    QBrush(Hot._get_color(areas[i] / mxInt, True, alpha=0.5)))

                model.setItem(i, 3, MSStandardItem(str(peak.sn)))
                model.item(i, 3).setBackground(
                    QBrush(Hot._get_color(areas[i] / mxInt, True, alpha=0.5)))

                model.setItem(i, 4, MSStandardItem(str(peak.r_coef)))
                model.item(i, 4).setBackground(
                    QBrush(Hot._get_color(areas[i] / mxInt, True, alpha=0.5)))

        elif flags == 'cluster':
            model.setHorizontalHeaderLabels(MSSample.clusterModelLabel)
            for i, peak in enumerate(spl.mappedPeaks.ipeaks()):
                model.setItem(i, 0, MSStandardItem(str(peak.mass())))
                model.setItem(i, 1, MSStandardItem(str(peak.rt)))
                model.setItem(i, 2, MSStandardItem(str(peak.area)))
                info_iso = ""
                info_frag = ""
                for iso in peak.isoCluster:
                    info_iso += '%s/%s\t' % (str(iso.mass()), str(iso.rt))
                for add in peak.fragCluster:
                    info_frag += '%s/%s\t' % (str(add.mass()), str(add.rt))
                model.setItem(i, 3, MSStandardItem(info_iso))
                model.setItem(i, 4, MSStandardItem(info_frag))
        return model
    def __init__(self):
        """"""
        super(dbmanagerUI, self).__init__()
        self.setupUi(self)
        self.statusbar.showMessage("Ready")

        exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit Masar Configuration Manager.')
        exitAction.triggered.connect(QtGui.qApp.quit)

        self.groupdatabasemenubar()

        #default database source, could be 0: SQLite, 1: MongoDB, and 2: MySQL
        self.dbsource = None

        self.defaultdbinfo = self._loadmasarconfig()
        self.usedefaultdb = True

        self.comboxboxSignalMapper = QtCore.QSignalMapper(self)
        self.comboxboxSignalMapper.mapped[QtGui.QWidget].connect(
            self.comboboxSignalMapperMapped)

        self.pushbuttonSignalMapper = QtCore.QSignalMapper(self)
        self.pushbuttonSignalMapper.mapped[QtGui.QWidget].connect(
            self.pushbuttonSignalMapperMapped)

        self.showpvbuttonSignalMapper = QtCore.QSignalMapper(self)
        self.showpvbuttonSignalMapper.mapped[QtGui.QWidget].connect(
            self.showpvbuttonSignalMapperMapped)

        self.choosepvbuttonSignalMapper = QtCore.QSignalMapper(self)
        self.choosepvbuttonSignalMapper.mapped[QtGui.QWidget].connect(
            self.choosepvbuttonSignalMapperMapped)

        self.currentselectedrow4config = -1

        self.selectedsystem = "Others"

        # self.pvgrouptreeview = QTreeView()
        self.pvGroupTreeView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.pvgroupmodel = QStandardItemModel()
        # self.pvgroupmodel.setHorizontalHeaderLabels(['id', 'date', 'version', "description"])
        self.pvgroupmodel.setHorizontalHeaderLabels(["PV Groups"])
        self.pvGroupTreeView.setModel(self.pvgroupmodel)
        self.pvGroupTreeView.setUniformRowHeights(True)
        self.test_in_progress_flag = 0
Beispiel #28
0
    def populate_columns_list(self):
        """
        Populate the columns view.
        :return:
        :rtype:
        """
        options = {}
        options['type'] = 'combobox'
        delegate = GenericDelegate(
            self.separators, options, self.column_code_view)
        # Set delegate to add widget
        self.column_code_view.setItemDelegate(
            delegate
        )
        self.column_code_view.setItemDelegateForColumn(
            1, delegate
        )

        model = QStandardItemModel(2, 2)
        i = 0
        for row, col in enumerate(self._columns):

            column_item = QStandardItem(self._entity.columns[col].header())
            column_item.setCheckable(True)

            model.setItem(i, 0, column_item)

            column_item.setData(col)
            self.column_code_view.setModel(model)
            i = i + 1

        for col in self._entity.columns.values():
            if col.name == 'id':
                continue

            if col.name not in self._columns:
                # Correct row by reducing by one due to removal of id

                column_item = QStandardItem(col.header())
                column_item.setCheckable(True)

                model.setItem(i, 0, column_item)

                column_item.setData(col.name)
                self.column_code_view.setModel(model)
                i = i + 1
Beispiel #29
0
    def __init__(self):
        super(ListViewWindow, self).__init__()
        # ui_full_path = find_file_in_product('list_ui_widget.ui')
        ui_full_path = find_resource_in_pkg('list_window.ui')
        self.ui = uic.loadUi(ui_full_path, self)
        self.model = QStandardItemModel()
        self._mouse_button = None
        self.listView.setModel(self.model)

        # self.show()
        self.listView.clicked.connect(self.item_clicked)
        # self.listView.doubleClicked.connect(self.handle_right_click)
        self.minimized = True
        self.click_handler = None
        self.right_click_handler = None
        self.list_view_mouse_pressed = self.listView.mousePressEvent
        self.listView.mousePressEvent = self.mousePressEvent
Beispiel #30
0
    def fillCalculations(self):
        self.calculations = [
            'Stack optics (A,R,T)', 'Ellipsometry', 'Field intensity',
            'Layerwise optics (absorption, collection, QE)', 'Generation'
        ]

        self.calcListModel = QStandardItemModel()
        calculationsToShow = self.defaults['defaultCalculations']
        for value in self.calculations:
            item = QStandardItem(value)
            check = Qt.Checked if value in calculationsToShow else Qt.Unchecked
            item.setCheckState(check)
            item.setCheckable(True)
            #item.setEnabled(False)
            self.calcListModel.appendRow(item)

        self.calculationsListView.setModel(self.calcListModel)