Example #1
0
    def fillSourceList(self):
        """ Change dialog controls when an other calculation type selected.
        """
        # get the selected stations
        stn1 = self.ui.Station1Combo.itemData(self.ui.Station1Combo.currentIndex())
        stn2 = self.ui.Station2Combo.itemData(self.ui.Station2Combo.currentIndex())
        # clear source and target list
        self.ui.SourceList.clear()
        self.ui.TargetList.clear()
        # get target points according to the stations
        targets = []
        if stn1 is not None and (self.ui.OrientRadio.isChecked() or
                                 self.ui.ResectionRadio.isChecked() or self.ui.FreeRadio.isChecked()):
            targets = get_targets(stn1[0], stn1[1], stn1[2], True)
        elif stn1 is not None and self.ui.RadialRadio.isChecked():
            targets = get_targets(stn1[0], stn1[1], stn1[2], False, True)
        elif stn1 is not None and stn2 is not None and \
                self.ui.IntersectRadio.isChecked():
            # fill source list for intersection (common points)
            targets_stn1 = get_targets(stn1[0], stn1[1], stn1[2], False)
            targets_stn2 = get_targets(stn2[0], stn2[1], stn2[2], False)
            for t1 in targets_stn1:
                for t2 in targets_stn2:
                    if t1[0] == t2[0]:
                        if not t1[0] in targets:
                            targets.append([t1, t2])
                        break

        # fill source list widget
        known_list = get_known()
        if targets is not None:
            for target in targets:
                if self.ui.IntersectRadio.isChecked():
                    item = QListWidgetItem(target[0][0])
                    item.setData(Qt.UserRole, target)
                    if known_list is not None and target[0][0] in known_list:
                        itemfont = item.font()
                        itemfont.setWeight(QFont.Bold)
                        item.setFont(itemfont)
                else:
                    item = QListWidgetItem(u"%s (id:%s)" % (target[0], target[2]))
                    item.setData(Qt.UserRole, target)
                    if known_list is not None and target[0] in known_list:
                        itemfont = item.font()
                        itemfont.setWeight(QFont.Bold)
                        item.setFont(itemfont)
                self.ui.SourceList.addItem(item)
 def refresh_available(self):
     '''
     Method for refreshing dialog list widget with available GooGIS layers
     '''
     self.myDrive.configure_service()
     self.available_sheets = self.myDrive.list_files(
         orderBy=self.dlg.orderByCombo.itemData(
             self.dlg.orderByCombo.currentIndex()))
     logger("refreshing panel")
     try:
         self.dlg.listWidget.currentItemChanged.disconnect(
             self.viewMetadata)
     except:
         pass
     self.dlg.listWidget.clear()
     self.dlg.writeListTextBox.clear()
     self.dlg.readListTextBox.clear()
     sharedIconOwner = QIcon(os.path.join(self.plugin_dir, 'shared.png'))
     anyoneIconOwner = QIcon(os.path.join(self.plugin_dir, 'globe.png'))
     sharedIcon = QIcon(os.path.join(self.plugin_dir, 'shared_gray.png'))
     anyoneIcon = QIcon(os.path.join(self.plugin_dir, 'globe_gray.png'))
     nullIcon = QIcon(os.path.join(self.plugin_dir, 'null.png'))
     for sheet_name, sheet_metadata in self.available_sheets.items():
         if sheet_metadata["id"] != self.myDrive.credentials.pubDbId:
             newItem = QListWidgetItem(QIcon(), sheet_name,
                                       self.dlg.listWidget,
                                       QListWidgetItem.UserType)
             if not sheet_metadata["capabilities"]["canEdit"]:
                 font = newItem.font()
                 font.setItalic(True)
                 newItem.setFont(font)
             #if sheet in shared_sheets.keys():
             permissions = self.get_permissions(sheet_metadata)
             owners_list = [
                 owner["emailAddress"] for owner in sheet_metadata['owners']
             ]
             if 'anyone' in permissions:
                 if self.client_id in owners_list:
                     newItem.setIcon(anyoneIconOwner)
                 else:
                     newItem.setIcon(anyoneIcon)
             elif permissions != {}:
                 if self.client_id in owners_list:
                     newItem.setIcon(sharedIconOwner)
                 else:
                     newItem.setIcon(sharedIcon)
             else:
                 newItem.setIcon(nullIcon)
             #newItem.setIcon(QIcon(os.path.join(self.plugin_dir,'shared.png')))
             #newItem.setText(sheet)
             self.dlg.listWidget.addItem(newItem)
     self.dlg.listWidget.currentItemChanged.connect(self.viewMetadata)
Example #3
0
 def fillTargetList(self):
     """ Change Target List when an other calculation type selected.
     """
     self.ui.TargetList.clear()
     self.ui.OrderList.clear()
     # get target points
     targets = get_stations(False, False)
     # fill target list widget
     known_list = get_known()
     if targets is not None:
         for target in targets:
             item = QListWidgetItem(u"%s (%s:%s)" %
                                    (target[0], target[1], target[2]))
             item.setData(Qt.UserRole, target)
             if known_list is not None and target[0] in known_list:
                 itemfont = item.font()
                 itemfont.setWeight(QFont.Bold)
                 item.setFont(itemfont)
             self.ui.TargetList.addItem(item)