示例#1
0
 def liste_guncelle(self,paketler):
     for paket in paketler:
         lm = QListWidgetItem()
         lm.setText(paket[:-1])
         lm.setFlags(lm.flags() | Qt.ItemIsUserCheckable)
         lm.setCheckState(Qt.Checked)
         self.liste.addItem(lm)
示例#2
0
    def init_list_widget_updates_arch(self):
        ftp = FTPClient(address=parameters.get('Global', 'ftp_host'),
                        login=parameters.get('Global', 'ftp_user'),
                        password=parameters.get('Global', 'ftp_pass'))
        if not os.path.exists(local_path_updates):
            os.mkdir(local_path_updates)
            logger.warning(f'Craete directory {local_path_updates}')
        with ftp as get_ftp_upd_names:
            get_ftp_upd_names.change_directory(
                parameters.get('Global', 'ftp_path_upd'))
            logger.info(
                f'Change FTP directory {parameters.get("Global", "ftp_path_upd")}'
            )
            get_ftp_upd_names.download_file(
                local_path_updates, parameters.get('Global', 'upd_comments'))
            upd_names = get_ftp_upd_names.get_file_names()

        ups_comments = read_ini(
            './{}/{}'.format(local_path_updates,
                             parameters.get('Global', 'upd_comments')),
            'utf-8')
        self.list_widget_names_updates.clear()
        for upd_name in upd_names:
            if upd_name.endswith('zip') and ups_comments.has_option(
                    'Global', upd_name):
                comment = ups_comments.get('Global', upd_name)
                item = QListWidgetItem(f"{upd_name} = {comment}")
                item.setCheckState(Qt.Checked)
                item.setCheckState(0)
                self.list_widget_names_updates.addItem(item)
    def addEntry(self, short, filename, url, documentationDir, locales):
        """
        Public method to add an entry to the list.
        
        @param short data for the description field
        @type str
        @param filename data for the filename field
        @type str
        @param url download URL for the dictionary entry
        @type str
        @param documentationDir name of the directory containing the
            dictionary documentation
        @type str
        @param locales list of locales
        @type list of str
        """
        itm = QListWidgetItem(
            self.tr("{0} ({1})").format(short, " ".join(locales)),
            self.dictionariesList)
        itm.setCheckState(Qt.Unchecked)

        itm.setData(ManageDictionariesDialog.FilenameRole, filename)
        itm.setData(ManageDictionariesDialog.UrlRole, url)
        itm.setData(ManageDictionariesDialog.DocumentationDirRole,
                    documentationDir)
        itm.setData(ManageDictionariesDialog.LocalesRole, locales)
示例#4
0
 def _setSearch(self, ip_addr):
     """ Load the daemon to the search area - inner function """
     _item = QListWidgetItem()
     _item.setText(ip_addr)
     _item.setFlags(_item.flags() | Qt.ItemIsUserCheckable)
     _item.setCheckState(Qt.Checked)
     self.search.addItem(_item)
示例#5
0
    def update_ui(self):
        self.propensities.clear()
        self.features.clear()
        self.ui.feature_list.blockSignals(True)
        self.ui.propensity_list.blockSignals(True)
        self.ui.feature_list.clear()
        self.ui.propensity_list.clear()

        # Feature list
        for feature in self.game_data["feature_list"]:
            item = QListWidgetItem(feature["name"])
            item.setWhatsThis(f"features.{feature['name']}")
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            item.setCheckState(Qt.Unchecked)
            item.setData(Qt.UserRole, feature["id"])

            self.features[feature["id"]] = item
            self.ui.feature_list.addItem(item)

        # Propensity list

        for propensity in self.game_data["propensity_list"]:
            item = QListWidgetItem(propensity["name"])
            item.setWhatsThis(f"propensities.{propensity['name']}")
            item.setData(Qt.UserRole, propensity["id"])
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            item.setCheckState(Qt.Unchecked)
            item.setData(Qt.UserRole, propensity["id"])

            self.propensities[propensity["id"]] = item
            self.ui.propensity_list.addItem(item)

        self.ui.feature_list.blockSignals(False)
        self.ui.propensity_list.blockSignals(False)
示例#6
0
 def fill(self, items, get_name: Callable, get_color: Callable = None):
     self._ui.clear()
     self._items.clear()
     for item in items:
         name = get_name(item)
         q_item = QListWidgetItem(name)
         if get_color:
             size = 13
             image = np.full(shape=(size, size, 3),
                             fill_value=get_color(item),
                             dtype=np.uint8)
             image = QImage(image.data, image.shape[1], image.shape[0],
                            image.strides[0], QImage.Format_RGB888)
             pixmap = QPixmap(image)
             q_item.setIcon(QIcon(pixmap))
         q_item.setData(Qt.UserRole, item)
         if self._checkable:
             q_item.setCheckState(Qt.Unchecked)
         # From 'default item flags' remove flag allowing user to directly change item's checkbox status.
         # The status is exclusively controlled by _on_item_clicked callback,
         #   so if user clicks within list item boundaries (not only checkbox), the status will be changed.
         q_item.setFlags(q_item.flags() & ~Qt.ItemIsUserCheckable)
         # Leaving ItemIsUserCheckable flag enabled, causes problems when user clicks on checkbox
         #   - two callbacks are launched:
         #     - first - controlled by the flag - checks/unchecks checkbox directly,
         #     - second - defined by us (_on_item_clicked) also checks/unchecks checkbox.
         #   In that case user DOES NOT see the change of checkbox status, because
         #       checkbox is checked by first callback and unchecked by second one (or the other way around)
         #       and list of checked items effectively stays unchanged,
         #       while causing side effects (eg. invocation of on_list_item_clicked_callback).
         self._items.append(q_item)
         self._ui.addItem(q_item)
示例#7
0
 def makeList(self, datelist):
     for dt in datelist:
         item = QListWidgetItem()
         item.setText(dt)
         item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
         item.setCheckState(Qt.Unchecked)
         self.listwdg.addItem(item)
 def __init__(self, parent=None):
     QDialog.__init__(self)
     self.setupUi(self)
     for it in G.categoryList:
         item = QListWidgetItem(it, self.listWidgetCategories)
         if it in G.categorySet:
             item.setCheckState(2)
         else:
             item.setCheckState(0)
     catLen = len(G.categoryList)
     sg = self.geometry()
     pg = parent.geometry()
     self.lt = pg.left() + 900
     self.tp = pg.top() + 100
     self.w = sg.width()
     self.h = catLen*35
     bOfst = (catLen *-25) +410
     self.listWidgetCategories.setGeometry(10, 10, 216, catLen * 25)
     self.pushButtonSelectAll.setGeometry(15, 445 - bOfst, 61, 23)
     self.pushButtonClearAll.setGeometry(155, 445 - bOfst, 61, 23)
     self.pushButtonOK.setGeometry(35, 495 - bOfst, 61, 23)
     self.pushButtonCancel.setGeometry(125, 495 - bOfst, 61, 23)
     # print(lt, tp, w, h)
     self.setGeometry(self.lt, self.tp, self.w, self.h)
     self.listWidgetCategories.setCurrentRow(1)
     self.pushButtonOK.clicked.connect(self.accept)
     self.pushButtonCancel.clicked.connect(self.reject)
     self.pushButtonSelectAll.clicked.connect(self.selectAll)
     self.pushButtonClearAll.clicked.connect(self.clearAll)
示例#9
0
    def on_actList_Ini_triggered(self):
        '''
		初始化,为控件内添加若干QListWidgetItem类型的对象
		:return:
		'''
        icon = QIcon(":/icons/images/724.bmp")
        editable = self.ui.chkBoxList_Editable.isChecked(
        )  #拿到可编辑的复选框的状态,通过该状态初始化列表
        if editable == True:
            Flag = self.__FlagEditable  #按照init内的设置可以修改名称
        else:
            Flag = self.__FlagNotEditable  #不可以设置名称
        self.ui.listWidget.clear()  #清除listWidget内的列表框
        for i in range(10):
            itemStr = 'Item %d' % i
            aItem = QListWidgetItem()  #添加的项每一个都是QListWidgetItem类型的对象
            aItem.setText(itemStr)  #设置名称
            aItem.setIcon(icon)  #添加图标
            '''
			setCheckState:共三种状态
			1.Unchecked 			0 	未选中
			2.PartiallyChecked 		1	部分选中,当数据分层次是,下层数据有部分选中,部分未选中,则为该状态
			3.Checked				2	选中
			'''
            aItem.setCheckState(Qt.Checked)  #设置为选中状态
            aItem.setFlags(Flag)  #按照Flag状态设置项(aItem)
            self.ui.listWidget.addItem(aItem)  #将项放入ListWidget中
示例#10
0
    def layerWasAdded(self,layers):
        if self.settingsWidget.checkBoxPolygon.isChecked():
            poly_checked = False
        else:
            poly_checked = True

        if self.settingsWidget.checkBoxLine.isChecked():
            line_checked = False
        else:
            line_checked = True

        for l in layers:
            if  l.type() == 0:
                if l.geometryType() == 1 or l.geometryType() == 2:
                    self.layers.append([l,l.id(),l.geometryType()])

                    item = QListWidgetItem(l.name())
                    item.setCheckState(Qt.Unchecked)
                    self.settingsWidget.listWidget.addItem(item)

                    if l.geometryType() == 1:
                        item.setHidden (line_checked)
                    elif l.geometryType() == 2:
                        item.setHidden (poly_checked)    
                        self.settingsWidget.comboBox_targetLayer.addItem(l.name())                  
    def load_mods(self, mods=[]):
        """
        Load mods into the list
        :param mods: 
        :return: 
        """
        self.listOfMods.clear()
        for m in self.get_available_mods():
            item = QListWidgetItem()
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            # set used mods as active
            if m['path'] in mods:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)

            item.setText(m['name'])
            item.setData(Qt.UserRole, m['path'])
            # set background for the outdated mods
            if not m['version'].startswith(self.app.game_version['release']):
                item.setText('{} *OUTDATED*'.format(item.text()))
                item.setBackground(QColor('red'))

            self.listOfMods.addItem(item)

        self.listOfMods.sortItems(Qt.AscendingOrder)
示例#12
0
 def selected_indicator(self):
     """ 选择指标准备绘图 """
     current_indicator = self.indicator_list.currentItem()
     sender_button = self.sender()
     if not current_indicator:
         return
     indicator_column = current_indicator.data(Qt.UserRole)
     indicator_text = current_indicator.text()
     axis_index = getattr(sender_button, "axis_index")
     chart_type = getattr(sender_button, "chart")
     button_text = sender_button.text()
     indicator_params = {
         "column_index": indicator_column,
         "axis_index": axis_index,
         "chart_type": chart_type,
         "chart_name": indicator_text,
         "contain_zero": 1
     }
     # 重复指标和类型不再添加了
     for item_at in range(self.current_indicator_list.count()):
         item = self.current_indicator_list.item(item_at)
         exist_list = item.data(Qt.UserRole)
         if exist_list == indicator_params:
             return
     # 已选指标内添加指标
     selected_indicator_item = QListWidgetItem("(数据含0) " + indicator_text + " = " + button_text)
     selected_indicator_item.setCheckState(Qt.Unchecked)
     selected_indicator_item.setData(Qt.UserRole, indicator_params)
     self.current_indicator_list.addItem(selected_indicator_item)
示例#13
0
 def reload_crops(self, cmd_box=None):
     """Reloads all crops comboBoxes in the GeoDataFarm widget
     Parameters
     ----------
     cmd_box: QtComboBox, optional
         a comboBox to fill with the crop names (used in text_data_handler)"""
     if cmd_box is None:
         cmd_box = [
             self.dw.CBPCrop, self.dw.CBFCrop, self.dw.CBSpCrop,
             self.dw.CBOCrop, self.dw.CBHvCrop
         ]
         crops = self.db.get_distinct('crops', 'crop_name', 'public')
         lw = self.dw.LWCrops
         lw.clear()
         for crop_name in crops:
             _nam = QApplication.translate("qadashboard", crop_name[0],
                                           None)
             item = QListWidgetItem(_nam, self.dw.LWCrops)
             item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
             item.setCheckState(QtCore.Qt.Unchecked)
     else:
         cmd_box = [cmd_box]
     crops_ = self.db.execute_and_return(
         "select crop_name from crops order by crop_name")
     crops = []
     for crop in crops_:
         crops.append(crop[0])
     for i, lw in enumerate(cmd_box):
         if len(self.crops) > 1:
             lw.clear()
         lw.addItem(self.tr('--- Select crop ---'))
         for name in crops:
             lw.addItem(str(name))
     self.crops = [self.tr('--- Select crop ---')]
     self.crops.extend(crops)
示例#14
0
    def add_oar_with_name(self, voi, voi_name):
        oar_item = QListWidgetItem()
        oar_item.setText(voi_name)
        oar_item.setData(Qt.UserRole, voi)
        oar_item.setCheckState(Qt.Unchecked)

        self.ui.OAR_listWidget.addItem(oar_item)
示例#15
0
 def populateAssociatedTaxa(self, checkall=False):
     """ populates the items in the associatedLists """
     self.associatedList.clear()
     # determine what is currently selected
     selType, siteNum, specimenNum = self.parent.getTreeSelectionType()
     existingAssociatedTaxa = self.parent.w.lineEdit_associatedTaxa.text(
     ).split(', ')
     if selType == 'specimen':  # see what is already there
         selType = 'site'  # be sure we always gather atleast site-wide taxa
     rowsToConsider = self.parent.m.getRowsToKeep(selType, siteNum, None)
     # generate a  list of all taxa from the selections
     taxaList = []
     for row in rowsToConsider:
         rowData = self.parent.m.retrieveRowData(row)
         associatedNames = rowData['associatedTaxa'].split(',')
         associatedNames.append(rowData['scientificName'])
         associatedNames = [x.strip() for x in associatedNames if x != '']
         taxaList.extend(associatedNames)
     taxaList = list(set(taxaList))
     QItems = []
     for taxon in taxaList:
         item = QListWidgetItem(taxon, self.associatedList)
         item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
         if checkall:
             item.setCheckState(Qt.Checked)
         else:
             item.setCheckState(Qt.Unchecked)
         self.associatedList.addItem(item)
     self.associatedList.sortItems(Qt.AscendingOrder)
     if None not in existingAssociatedTaxa:
         self.checkItems(existingAssociatedTaxa)
示例#16
0
 def _onLanguagesReceived(self, languages):
     loc = QLocale.system()
     sysLang = QLocale.languageToString(loc.language())
     preferredLanguages = self._getPreferredLanguages()
     self._langList.clear()
     firstCheckedItem = None
     for lang in sorted(languages, key=lambda x: x['name']):
         langName = lang['name']
         langCode = lang['code']
         nativeLang = self._getNativeLanguageName(langName)
         text = langName
         isSystemLang = langName == sysLang
         if nativeLang and not isSystemLang:
             text += " (" + nativeLang + ")"
         item = QListWidgetItem(text)
         item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
         item.setData(Qt.UserRole, langCode)
         if (preferredLanguages and langCode in preferredLanguages) \
                 or isSystemLang:
             item.setCheckState(Qt.Checked)
             firstCheckedItem = item
         else:
             item.setCheckState(Qt.Unchecked)
         self._langList.addItem(item)
     self._langList.setMinimumWidth(self._langList.sizeHintForColumn(0))
     if firstCheckedItem:
         self._langList.scrollToItem(firstCheckedItem)
示例#17
0
    def __init__(
        self,
        title: str,
        available_formats: Iterable[str],
        active_formats: Iterable[str],
        *args,
        **kwargs,
    ):
        super().__init__(title, *args, **kwargs)

        self.outputformats_list = QListWidget(self)

        for format_name in available_formats:
            item = QListWidgetItem(format_name, self.outputformats_list)
            item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
            if format_name in active_formats:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)
            self.outputformats_list.addItem(item)

        layout = QVBoxLayout()
        layout.addWidget(self.outputformats_list)

        self.setLayout(layout)
示例#18
0
 def _update_items_list(self):
     self.ui.itemsList.clear()
     for item in items_list:
         itm = QListWidgetItem(str(item))
         itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
         itm.setCheckState(Qt.Checked if item.is_checked else Qt.Unchecked)
         self.ui.itemsList.addItem(itm)
示例#19
0
文件: ClearLWT.py 项目: awwolf/tdm
    def __init__(self, env, *args, **kwargs):
        super(ClearLWTDialog, self).__init__(*args, **kwargs)
        self.setWindowTitle("Clear obsolete retained LWTs")
        self.setMinimumSize(QSize(320, 480))

        self.env = env

        vl = VLayout()

        sel_btns = QDialogButtonBox()
        sel_btns.setCenterButtons(True)
        btnSelAll = sel_btns.addButton("Select all",
                                       QDialogButtonBox.ActionRole)
        btnSelNone = sel_btns.addButton("Select none",
                                        QDialogButtonBox.ActionRole)

        self.lw = QListWidget()

        for lwt in self.env.lwts:
            itm = QListWidgetItem(lwt)
            itm.setCheckState(Qt.Unchecked)
            self.lw.addItem(itm)

        btnSelAll.clicked.connect(lambda: self.select(Qt.Checked))
        btnSelNone.clicked.connect(lambda: self.select(Qt.Unchecked))

        btns = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
        btns.accepted.connect(self.accept)
        btns.rejected.connect(self.reject)

        vl.addWidgets([sel_btns, self.lw, btns])
        self.setLayout(vl)
示例#20
0
文件: workspace.py 项目: freason/enki
    def __init__(self, workspace, documents):
        super(_UISaveFiles, self).__init__(workspace)
        self.cancelled = False
        uic.loadUi(os.path.join(DATA_FILES_PATH, 'ui/SaveFiles.ui'), self)
        self.buttonBox.clicked.connect(self._onButtonClicked)

        self._documents = documents

        for index, document in enumerate(documents):
            name = document.fileName()
            if name is None:
                name = 'untitled'
            item = QListWidgetItem(name, self.listWidget)
            if document.filePath() is not None:
                item.setToolTip(document.filePath())
            item.setCheckState(Qt.Checked)

        # Retitle buttons, add first letter shortcuts for them.
        bb = self.buttonBox
        self._shortcut = (
            self._firstLetterShortcut(bb.Discard, 'close &Without saving'),
            self._firstLetterShortcut(bb.Cancel, '&Cancel close'),
            self._firstLetterShortcut(bb.Save, '&Save checked'))

        self.buttonBox.button(QDialogButtonBox.Cancel).setFocus()
示例#21
0
 def copy_to_common_tags(self, index: QModelIndex) -> None:
     if not self.tagList.findItems(
             index.data(), Qt.MatchFixedString | Qt.MatchCaseSensitive):
         item = QListWidgetItem(self.tagList)
         item.setText(index.data())
         item.setCheckState(Qt.Unchecked)
         item.setFlags(item.flags() | Qt.ItemIsEditable)
示例#22
0
 def check_item(self, item: QListWidgetItem):
     if not item.text():
         return  # FIXME: make textless items uncheckable
     if item.checkState() == Qt.Checked:
         item.setCheckState(Qt.Unchecked)
     else:
         item.setCheckState(Qt.Checked)
示例#23
0
    def list_jobs(self):
        self.lwJobs.clear()
        self.jobs = handler.list_jobs()

        if self.jobs is None:
            self.lwJobs.addItem(f'Nothing running for {USERNAME} now')
            return

        # Group jobs by their name.
        # This step is required as jobs belonging together are not necessarily
        # allocated together: it might be that a job launches a related job
        # at a later point.
        groups: Dict[str, List[Tuple[int, Dict[str, str]]]] = defaultdict(list)
        for job_id, properties in self.jobs.items():
            groups[properties['JobName']].append((job_id, properties))

        for group in groups.values():
            for job_id, properties in group:
                line = job_id + '    '
                line += properties['JobState'].ljust(12)
                line += properties['StartTime'].ljust(22)
                line += properties['RunTime'].ljust(12)
                line += properties['NodeList'].ljust(14)
                line += properties['JobName']

                item = QListWidgetItem()
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(Qt.Unchecked)
                item.setText(line)

                self.lwJobs.addItem(item)
            self.lwJobs.addItem('')  # Add a blank line between groups
示例#24
0
def add_item(obj,
             icon: str = "",
             text: str = "",
             tooltip: str = "",
             selectable: bool = False,
             select: bool = False,
             checkable: bool = False,
             check: bool = False,
             hide: bool = False,
             font_size: int = 12,
             icon_size=(25, 25)):

    font = QFont()
    font.setPointSize(font_size)

    att = QListWidgetItem()
    att.setText(text)
    att.setHidden(hide)
    att.setFont(font)

    if icon:
        att.setIcon(icon)
    if tooltip:
        att.setToolTip(tooltip)
    if checkable:
        att.setCheckState(check)
    if selectable:
        att.setSelected(select)

    obj.setIconSize(QSize(icon_size[0], icon_size[1]))

    return att
示例#25
0
def buttonLoad_clicked():
    """"opens dialog for folder selection, """
    micrographs, _ = QFileDialog.getOpenFileNames(
        parent=None,
        caption=u"Open files",
        filter=u"All files(*. *.mrc *.tiff *.tif *.hdf *.png)"
    )  # name may be cofusing
    global itemName  # maybe problematic?
    itemName = []
    for filePath in micrographs:
        """lists all selected micrographs (or other data)
        some changes may be good (either work work with filename or filePath??) (use consisting 
        variable names with capital letters for each word)"""
        # item = QListWidgetItem(filePath)
        # item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        # url = QUrl.fromLocalFile(filePath)
        print "Path", filePath
        filename = QFileInfo(filePath).fileName()
        item = QListWidgetItem(filename)
        item.setCheckState(Qt.Checked)
        GUI.fileList.addItem(item)

        filePath = str(filePath)
        itemName.append(filePath)
    if len(micrographs) > 0:
        GUI.fileList.setCurrentRow(0)
        thread.start_new_thread(preload_images, (
            micrographs,
            img_buffer,
        ))
        GUI.loadPowerSpectrumFromItemList(0)
        GUI.loadMicrographsFromItemList(0)
        last_loaded_image = 0
示例#26
0
    def __init__(self, parent=None, name=None, modal=False):
        """
        Constructor
        
        @param parent parent widget of this dialog (QWidget)
        @param name name of this dialog (string)
        @param modal flag to indicate a modal dialog (boolean)
        """
        super(VariablesFilterDialog, self).__init__(parent)
        if name:
            self.setObjectName(name)
        self.setModal(modal)
        self.setupUi(self)

        self.defaultButton = self.buttonBox.addButton(
            self.tr("Save Default"), QDialogButtonBox.ActionRole)
        
        #populate the list widgets and set the default selection
        for widget in self.localsList, self.globalsList:
            for varType, varTypeStr in ConfigVarTypeDispStrings.items():
                itm = QListWidgetItem(self.tr(varTypeStr), widget)
                itm.setData(Qt.UserRole, ConfigVarTypeFilters[varType])
                itm.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
                itm.setCheckState(Qt.Unchecked)
                widget.addItem(itm)
        
        lDefaultFilter, gDefaultFilter = Preferences.getVarFilters()
        self.setSelection(lDefaultFilter, gDefaultFilter)
示例#27
0
    def on_product_changed(self, index: int):
        if index == -1:
            return

        self.tree.clear()
        product_name = self.cbox_product.currentData()
        current_avail_vars = self.products[product_name]
        dates = []
        for name in current_avail_vars.keys():
            item = QListWidgetItem(current_avail_vars[name]['label'])
            item.setData(Qt.UserRole, name)
            item.setCheckState(Qt.Checked)
            self.tree.addItem(item)
            dates.append(current_avail_vars[name]['start_date'])
            dates.append(current_avail_vars[name]['end_date'])
        date_min = min(dates)
        date_max = max(dates)

        for dt_input in [self.dedit_start_date, self.dedit_end_date]:
            dt_input.setDateTimeRange(
                QDateTime(QDate(date_min.year, date_min.month, date_min.day),
                          QTime(date_min.hour, date_min.minute)),
                QDateTime(QDate(date_max.year, date_max.month, date_max.day),
                          QTime(date_max.hour, date_max.minute)))

        min_dt = self.dedit_start_date.minimumDateTime()
        max_dt = self.dedit_start_date.maximumDateTime()
        self.dedit_start_date.setDateTime(min_dt)
        self.dedit_end_date.setDateTime(max_dt)
示例#28
0
 def update_table_list(self):
     """Update the list of tables in the docket widget"""
     lw_list = self.parent.populate.get_lw_list()
     if self.tables_in_db != 0:
         model = self.TMD.SATables.model()
         for item in self.items_in_table:
             qIndex = self.TMD.SATables.indexFromItem(item)
             model.removeRow(qIndex.row())
     self.tables_in_db = 0
     for lw, schema in lw_list:
         table_names = self.db.get_tables_in_db(schema)
         for name in table_names:
             if str(name) in [
                     'harrowing_manual', 'plowing_manual', 'manual'
             ]:
                 continue
             item_name = schema + '.' + str(name)
             testcase_name = QtCore.QCoreApplication.translate(
                 "qadashboard", item_name, None)
             item = QListWidgetItem(testcase_name, self.TMD.SATables)
             item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
             item.setCheckState(QtCore.Qt.Unchecked)
             self.tables_in_db += 1
     self.items_in_table = self.TMD.SATables.findItems(
         '', QtCore.Qt.MatchContains)
示例#29
0
    def __init__(self, workspace, documents):
        super(_UISaveFiles, self).__init__(workspace)
        self.cancelled = False
        uic.loadUi(os.path.join(DATA_FILES_PATH, 'ui/SaveFiles.ui'), self)
        self.buttonBox.clicked.connect(self._onButtonClicked)

        self._documents = documents

        for index, document in enumerate(documents):
            name = document.fileName()
            if name is None:
                name = 'untitled'
            item = QListWidgetItem(name, self.listWidget)
            if document.filePath() is not None:
                item.setToolTip(document.filePath())
            item.setCheckState(Qt.Checked)

        # Retitle buttons, add first letter shortcuts for them.
        bb = self.buttonBox
        self._shortcut = (self._firstLetterShortcut(bb.Discard,
                                                    'close &Without saving'),
                          self._firstLetterShortcut(bb.Cancel,
                                                    '&Cancel close'),
                          self._firstLetterShortcut(bb.Save, '&Save checked'))

        self.buttonBox.button(QDialogButtonBox.Cancel).setFocus()
示例#30
0
        def target_list_changed_callback(
                item: QtWidgets.QListWidgetItem) -> None:

            # check for current point
            if self.current_point not in self.settings.keys():
                if item.checkState():
                    item.setCheckState(False)
                return

            if item.checkState():
                # prevent channel plot select double population
                if self.channelPlotSelect.findText(
                        item.text(), QtCore.Qt.MatchExactly) >= 0:
                    return

                # populate channel plot select dropdown w/ sort
                all_items_sorted = sorted([
                    self.channelPlotSelect.itemText(i)
                    for i in range(self.channelPlotSelect.count())
                ] + [item.text()])
                self.channelPlotSelect.insertItem(
                    all_items_sorted.index(item.text()), item.text())

                # init settings and refocus plot
                self.settings[self.current_point][
                    item.text()] = self.get_params()
            else:
                # remove channel from dropdown
                item_index = self.channelPlotSelect.findText(
                    item.text(), QtCore.Qt.MatchExactly)
                self.channelPlotSelect.removeItem(item_index)

                # clean up removal settings
                for point in self.settings.keys():
                    self.settings[point].pop(item.text())
示例#31
0
    def onLogSuccess(self, cookie):
        self.cookieLineEdit.setText(cookie)
        self.selectedDict.getGroups()

        container = QDialog(self)
        group = wordGroup.Ui_Dialog()
        group.setupUi(container)

        for groupName in [
                str(group_name) for group_name, _ in self.selectedDict.groups
        ]:
            item = QListWidgetItem()
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
                          | Qt.ItemIsEnabled)
            item.setText(groupName)
            item.setCheckState(Qt.Unchecked)
            group.wordGroupListWidget.addItem(item)

        # 恢复上次选择的单词本分组
        if self.selectedGroups:
            for groupName in self.selectedGroups[
                    self.currentConfig['selectedDict']]:
                items = group.wordGroupListWidget.findItems(
                    groupName, Qt.MatchExactly)
                for item in items:
                    item.setCheckState(Qt.Checked)
        else:
            self.selectedGroups = [list()] * len(dictionaries)

        def onAccepted():
            """选择单词本弹窗确定事件"""
            # 清空 listWidget
            self.newWordListWidget.clear()
            self.needDeleteWordListWidget.clear()
            self.mainTab.setEnabled(False)

            selectedGroups = [
                group.wordGroupListWidget.item(index).text()
                for index in range(group.wordGroupListWidget.count())
                if group.wordGroupListWidget.item(index).checkState() ==
                Qt.Checked
            ]
            # 保存分组记录
            self.selectedGroups[
                self.currentConfig['selectedDict']] = selectedGroups
            self.progressBar.setValue(0)
            self.progressBar.setMaximum(1)
            logger.info(f'选中单词本{selectedGroups}')
            self.getRemoteWordList(selectedGroups)

        def onRejected():
            """选择单词本弹窗取消事件"""
            self.progressBar.setValue(0)
            self.progressBar.setMaximum(1)
            self.mainTab.setEnabled(True)

        group.buttonBox.accepted.connect(onAccepted)
        group.buttonBox.rejected.connect(onRejected)
        container.exec()
示例#32
0
 def display_connection_list(self):
     self.lstConns.clear()
     for cfg in self.connections_current:
         item = QListWidgetItem(cfg.get_description())
         item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
         item.setCheckState(Qt.Checked if cfg.enabled else Qt.Unchecked)
         item.checkState()
         self.lstConns.addItem(item)
 def keyPressEvent(self, e):
     if e.key() == Qt.Key_Return and self.lineEditCategory.hasFocus():
         if self.radioButtonNew.isChecked():
             t = self.lineEditCategory.text()
             if t > '' and not self.listWidgetCategories.findItems(t, Qt.MatchExactly):
                 item = QListWidgetItem(t, self.listWidgetCategories)
                 item.setCheckState(0)
                 self.lineEditCategory.setText('')
         else:
             it = self.listWidgetCategories.currentItem()
             it.setText(self.lineEditCategory.text())
     QLineEdit.keyPressEvent(self.lineEditCategory, e)
示例#34
0
 def update_connections(self, connections):
     """
     Clears the connection list and adds an entry for each item in connetions
     :param connections: the new connections
     :type connections: dict
     """
     self.ui.connectionList.clear()
     for c in connections.keys():
         item = QListWidgetItem("%s (%s)" % (c[0], c[1]))
         enabled = connections[c]["enabled"]
         client = connections[c]["address"]
         item.setCheckState(Qt.Checked if enabled else Qt.Unchecked)
         color = self.connectionColors[0 if client is None else 1]
         item.setBackground(QBrush(color, Qt.SolidPattern))
         self.ui.connectionList.addItem(item)
 def __init__(self, parent=None):
     QDialog.__init__(self)
     self.setupUi(self)
     for it in G.categoryList:
         item = QListWidgetItem(it, self.listWidgetCategories)
         item.setCheckState(0)
     self.listWidgetCategories.setCurrentRow(1)
     self.lineEditCategory.setText(self.listWidgetCategories.item(1).text())
     self.pushButtonOK.clicked.connect(self.accept)
     self.pushButtonCancel.clicked.connect(self.reject)
     self.listWidgetCategories.itemDoubleClicked.connect(self.editItem)
     self.radioButtonEdit.toggled.connect(self.editToggle)
     self.pushButtonDelete.clicked.connect(self.deleteCategories)
     self.pushButtonSelectAll.clicked.connect(self.selectAll)
     self.pushButtonClearAll.clicked.connect(self.clearAll)
     self.lineEditCategory.setFocus()
 def __loadScripts(self):
     """
     Private method to load all the available scripts.
     """
     for script in self.__manager.allScripts():
         itm = QListWidgetItem(
             UI.PixmapCache.getIcon("greaseMonkeyScript.png"),
             script.name(), self.scriptsList)
         itm.setData(
             GreaseMonkeyConfigurationDialog.ScriptVersionRole,
             script.version())
         itm.setData(
             GreaseMonkeyConfigurationDialog.ScriptDescriptionRole,
             script.description())
         itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
         if script.isEnabled():
             itm.setCheckState(Qt.Checked)
         else:
             itm.setCheckState(Qt.Unchecked)
         itm.setData(GreaseMonkeyConfigurationDialog.ScriptRole, script)
         self.scriptsList.addItem(itm)
     
     self.scriptsList.sortItems()
     
     itemMoved = True
     while itemMoved:
         itemMoved = False
         for row in range(self.scriptsList.count()):
             topItem = self.scriptsList.item(row)
             bottomItem = self.scriptsList.item(row + 1)
             if topItem is None or bottomItem is None:
                 continue
             
             if topItem.checkState() == Qt.Unchecked and \
                bottomItem.checkState == Qt.Checked:
                 itm = self.scriptsList.takeItem(row + 1)
                 self.scriptsList.insertItem(row, itm)
                 itemMoved = True
 def addCheckableItem(self, item, listView, state=False):
     newItem = QListWidgetItem(item, listView)
     newItem.setCheckState(state)
     newItem.setFlags(newItem.flags() | QtCore.Qt.ItemIsUserCheckable)
示例#38
0
    def __init__(self, _format, parent=None):
        QWidget.__init__(self, parent)
        self.setupUi(self)
        self.toolBox.setStyleSheet(S.toolBoxSS())

        self.mw = mainWindow()
        self._format = _format
        self.settings = {}

        #################################################################
        # Content

        self.grpContentFilters.button.setChecked(False)

        h = self.tblContent.horizontalHeader()
        h.setSectionResizeMode(h.ResizeToContents)
        h.setSectionResizeMode(0, h.Stretch)

        self.contentUpdateTable()
        self.chkContentMore.toggled.connect(self.contentTableToggle)
        self.contentTableToggle(False)

        # Labels
        self.lstContentLabels.clear()
        h = QFontMetrics(self.font()).height()
        for i in range(0, self.mw.mdlLabels.rowCount()):
            item = self.mw.mdlLabels.item(i, 0)
            if item:
                item = QListWidgetItem(item.icon(), item.text())
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(Qt.Checked)
                item.setSizeHint(QSize(100, h))
                self.lstContentLabels.addItem(item)

        self.chkContentLabels.toggled.connect(self.lstContentLabels.setVisible)
        self.chkContentLabels.toggled.connect(lambda: self.listWidgetAdjustToContent(self.lstContentLabels))
        self.lstContentLabels.setVisible(False)

        # Status
        self.lstContentStatus.clear()
        h = QFontMetrics(self.font()).height()
        for i in range(0, self.mw.mdlStatus.rowCount()):
            item = self.mw.mdlStatus.item(i, 0)
            if item:
                item = QListWidgetItem(item.icon(), item.text())
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(Qt.Checked)
                item.setSizeHint(QSize(100, h))
                self.lstContentStatus.addItem(item)

        self.chkContentStatus.toggled.connect(self.lstContentStatus.setVisible)
        self.chkContentStatus.toggled.connect(lambda: self.listWidgetAdjustToContent(self.lstContentStatus))
        self.lstContentStatus.setVisible(False)

        # Root item
        self.cmbContentParent.setModel(self.mw.mdlOutline)
        v = QTreeView()
        self.cmbContentParent.setView(v)
        v.setHeaderHidden(True)
        for i in range(1, self.mw.mdlOutline.columnCount()):
            v.hideColumn(i)
        self.chkContentParent.toggled.connect(self.cmbContentParent.setVisible)
        self.cmbContentParent.hide()

        #################################################################
        # Separations

        for cmb in [self.cmbSepFF, self.cmbSepTT, self.cmbSepFT, self.cmbSepTF]:
            cmb.clear()

            cmb.addItem(self.tr("Empty line"), "empty")
            cmb.addItem(self.tr("Custom"), "custom")
            cmb.currentIndexChanged.connect(self.sepCmbChanged)

        #################################################################
        # Transformations

        h = self.tblReplacements.horizontalHeader()
        h.setSectionResizeMode(h.ResizeToContents)
        h.setSectionResizeMode(1, h.Stretch)
        h.setSectionResizeMode(2, h.Stretch)

        # Cf. https://en.wikipedia.org/wiki/Quotation_mark
        self.cmbTransDoubleQuotes.clear()
        self.cmbTransDoubleQuotes.addItems(["”___“", "“___”", "«___»"])
        self.cmbTransSingleQuote.clear()
        self.cmbTransSingleQuote.addItems(["‘___’", "‹___›"])

        for cmb in [self.cmbTransDoubleQuotes, self.cmbTransSingleQuote]:
            cmb.addItem(self.tr("Custom"), "custom")
            cmb.currentIndexChanged.connect(self.transCmbChanged)
            cmb.currentIndexChanged.emit(0)

        self.btnTransAdd.clicked.connect(lambda: self.transAddTableRow(checked=True))
        self.btnTransRemove.clicked.connect(self.transRemoveTableRow)
        self.tableWidgetAdjustToContent(self.tblReplacements)

        #################################################################
        # Preview

        self.cmbPreviewFont.setCurrentFont(self.font())
        self.spnPreviewSize.setValue(self.font().pointSize())

        #################################################################
        # Final stuff

        self.toolBox.setCurrentIndex(0)