Ejemplo n.º 1
0
    def updateList(self, visualizations):
        self.ui.tablesList.clear()
        for visualization in visualizations:
            item = QListWidgetItem(self.ui.tablesList)

            owner = None
            owner = visualization['permission']['owner']['username']

            widget = CartoDBDatasetsListItem(
                visualization['name'],
                owner,
                visualization['table']['size'],
                visualization['table']['row_count'],
                shared=(owner != self.currentUser),
                multiuser=self.currentMultiuser)
            # item.setText(visualization['name'])
            readonly = False
            # qDebug('Vis:' + json.dumps(visualization, sort_keys=True, indent=2, separators=(',', ': ')))
            if visualization['permission'] is not None and owner != self.currentUser and \
               visualization['permission']['acl'] is not None:
                for acl in visualization['permission']['acl']:
                    if acl['type'] == 'user' and 'username' in acl['entity'] and acl['entity']['username'] == self.currentUser and \
                       acl['access'] == 'r':
                        readonly = True
                        break

            widget.readonly = readonly
            if readonly:
                widget.setTextColor('#999999')

            item.setSizeHint(widget.sizeHint())
            # item.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/layers.png"))
            self.ui.tablesList.setItemWidget(item, widget)
Ejemplo n.º 2
0
    def __init__(self):
        super(MainQMainWindow, self).__init__()
        # Create QListWidget
        self.setFixedSize(800, 500)
        self.myQListWidget = QListWidget(self)
        self.alerts = []
        # [Alert(AlertInfo('2018-01-12 00:00:01', '1', '1'), 'alert'),
        #  Alert(AlertInfo('2018-01-12 00:01:01', '2', '2'), 'ignored'),
        #  Alert(AlertInfo('2018-01-12 00:02:01', '3', '3'), 'resolved')
        #  ]
        # self.myQListWidget.setStyleSheet("QListWidget::item { border: 0px solid red }")
        for alert in self.alerts[::-1]:
            # Create QCustomQWidget
            myQCustomQWidget = QCustomQWidget()
            myQCustomQWidget.setItemFromAlert(alert)
            # Create QListWidgetItem
            myQListWidgetItem = QListWidgetItem(self.myQListWidget)
            # Set size hint
            myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint())
            # Add QListWidgetItem into QListWidget
            self.myQListWidget.addItem(myQListWidgetItem)
            self.myQListWidget.setItemWidget(myQListWidgetItem,
                                             myQCustomQWidget)

        self.myQListWidget.itemDoubleClicked.connect(self._handleDoubleClick)
        self.setCentralWidget(self.myQListWidget)
Ejemplo n.º 3
0
 def writeModeData(self,data):
     item = QListWidgetItem()
     item.setText(data)
     item.setSizeHint(QSize(27,27))
     item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable)
     self.insertItem(self.count()+1,item)
     self.scrollToBottom()
Ejemplo n.º 4
0
    def updateList(self, visualizations):
        self.ui.tablesList.clear()
        for visualization in visualizations:
            item = QListWidgetItem(self.ui.tablesList)

            owner = None
            owner = visualization['permission']['owner']['username']

            widget = CartoDBDatasetsListItem(
                visualization['name'], owner, visualization['table']['size'], visualization['table']['row_count'],
                shared=(owner != self.currentUser), multiuser=self.currentMultiuser)
            # item.setText(visualization['name'])
            readonly = False
            # qDebug('Vis:' + json.dumps(visualization, sort_keys=True, indent=2, separators=(',', ': ')))
            if visualization['permission'] is not None and owner != self.currentUser and \
               visualization['permission']['acl'] is not None:
                for acl in visualization['permission']['acl']:
                    if acl['type'] == 'user' and 'username' in acl['entity'] and acl['entity']['username'] == self.currentUser and \
                       acl['access'] == 'r':
                        readonly = True
                        break

            widget.readonly = readonly
            if readonly:
                widget.setTextColor('#999999')

            item.setSizeHint(widget.sizeHint())
            # item.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/layers.png"))
            self.ui.tablesList.setItemWidget(item, widget)
Ejemplo n.º 5
0
    def __init__(self, toolbar, parent=None):
        QDialog.__init__(self, parent)
        self.toolbar = toolbar
        self.settings = QSettings()

        self.ui = Ui_Upload()
        self.ui.setupUi(self)

        self.ui.uploadBT.clicked.connect(self.upload)
        self.ui.cancelBT.clicked.connect(self.reject)

        self.currentUser = self.toolbar.currentUser
        self.currentApiKey = self.toolbar.currentApiKey
        self.currentMultiuser = self.toolbar.currentMultiuser

        layers = QgsMapLayerRegistry.instance().mapLayers()

        self.ui.layersList.clear()
        self.ui.uploadBar.setValue(0)
        self.ui.uploadBar.hide()
        self.ui.uploadingLB.hide()
        for id, ly in layers.iteritems():
            if ly.type() == QgsMapLayer.VectorLayer and not isinstance(ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.layersList)
                widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly), ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.layersList.setItemWidget(item, widget)

        worker = CartoDBPluginWorker(self, 'connectUser')
        worker.start()
Ejemplo n.º 6
0
 def writeModeData(self,data):
     item = QListWidgetItem()
     item.setText(data)
     item.setSizeHint(QSize(27,27))
     item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable)
     self.insertItem(self.count()+1,item)
     self.scrollToBottom()
Ejemplo n.º 7
0
 def addHeading(self, heading):
     item = QListWidgetItem(heading)
     item.setSizeHint(QSize(10, 25))
     fnt = item.font()
     fnt.setBold(True)
     item.setFont(fnt)
     self.hostList.addItem(item)
Ejemplo n.º 8
0
    def __init__(self, iface, toolbar, parent=None):
        CartoDBPluginUserDialog.__init__(self, toolbar, parent)

        self.iface = iface

        self.ui = Ui_Upload()
        self.ui.setupUi(self)

        self.ui.bar = QgsMessageBar()
        self.ui.bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.ui.verticalLayout.insertWidget(0, self.ui.bar)

        self.ui.uploadBT.clicked.connect(self.upload)
        self.ui.cancelBT.clicked.connect(self.reject)
        self.ui.layersList.itemSelectionChanged.connect(self.validateButtons)

        layers = QgsMapLayerRegistry.instance().mapLayers()

        # TODO Implement add to project
        # self.ui.convertCH.hide()
        self.ui.overideCH.hide()

        self.ui.layersList.clear()
        self.ui.uploadBar.setValue(0)
        self.ui.uploadBar.hide()
        self.ui.uploadingLB.hide()
        for id_ly, ly in layers.iteritems():
            qDebug('Layer id {}'.format(stripAccents(id_ly)))
            if ly.type() == QgsMapLayer.VectorLayer and not isinstance(ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.layersList)
                widget = CartoDBLayerListItem(ly.name(), ly, getSize(ly), ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.layersList.setItemWidget(item, widget)
Ejemplo n.º 9
0
 def _create_help_item(self, image, text):
     Item = QListWidgetItem(QIcon(image), text)
     font = Item.font()
     font.setBold(True)
     Item.setSizeHint(QSize(20, 30))
     Item.setBackground(QBrush(Qt.lightGray))
     Item.setForeground(QBrush(Qt.black))
     Item.setFont(font)
     return Item
Ejemplo n.º 10
0
 def _create_help_item(self, image, text):
     Item = QListWidgetItem(QIcon(image), text)
     font = Item.font()
     font.setBold(True)
     Item.setSizeHint(QSize(20, 30))
     Item.setBackground(QBrush(Qt.lightGray))
     Item.setForeground(QBrush(Qt.black))
     Item.setFont(font)
     return Item
Ejemplo n.º 11
0
    def __init__(self, toolbar, parent=None):
        CartoDBPluginUserDialog.__init__(self, toolbar, parent)
        self.toolbar = toolbar

        self.ui = Ui_CreateViz()
        self.ui.setupUi(self)

        self.ui.bar = QgsMessageBar()
        self.ui.bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.ui.verticalLayout.insertWidget(0, self.ui.bar)

        self.ui.availableList = CartoDBLayersListWidget(self, 'availableList')
        self.ui.availableList.setAcceptDrops(True)
        self.ui.availableList.viewport().setAcceptDrops(True)
        self.ui.availableList.setDragEnabled(True)
        self.ui.availableList.setDropIndicatorShown(True)
        self.ui.availableList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.availableList.setDefaultDropAction(Qt.MoveAction)
        self.ui.availableList.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        self.ui.availableLayout.addWidget(self.ui.availableList)

        self.ui.mapList = CartoDBLayersListWidget(self, 'mapList')
        self.ui.mapList.setAcceptDrops(True)
        self.ui.mapList.viewport().setAcceptDrops(True)
        self.ui.mapList.setDragEnabled(True)
        self.ui.mapList.setDropIndicatorShown(True)
        self.ui.mapList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.mapList.setDefaultDropAction(Qt.MoveAction)
        self.ui.mapList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.ui.mapLayout.addWidget(self.ui.mapList)

        self.ui.mapNameTX.textChanged.connect(self.validateButtons)
        self.ui.mapList.itemSelectionChanged.connect(self.validateButtons)
        self.ui.cancelBT.clicked.connect(self.reject)
        self.ui.saveBT.clicked.connect(self.createViz)
        self.ui.cartoCssBT.clicked.connect(self.createCartoCss)

        # TODO Implement functionality
        self.ui.sqlBT.hide()
        self.ui.cartoCssBT.hide()

        self.withWarnings = False

        layers = QgsMapLayerRegistry.instance().mapLayers()

        self.ui.availableList.clear()
        for id, ly in layers.iteritems():
            if ly.type() == QgsMapLayer.VectorLayer and isinstance(
                    ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.availableList)
                widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly),
                                              ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.availableList.setItemWidget(item, widget)
Ejemplo n.º 12
0
 def __init__(self, parent=None):
     super(MenuPannel, self).__init__(parent)
     item_widget = QListWidgetItem()
     item_widget.setSizeHint(QSize(60, 60))
     self.setStyleSheet("border:0px;background-color:#27282b;")
     self.setMaximumWidth(60)
     self.setMinimumWidth(60)
     self.addItem(item_widget)
     self.self_head_image = QLabel()
     self.self_head_image.setStyleSheet("padding:10px;")
     self.setItemWidget(item_widget, self.self_head_image)
Ejemplo n.º 13
0
 def add_items(self):
     characters = self.client.results
     for character in characters:
         item = QListWidgetItem(self.get_name(character["name"]))
         item.setData(Qt.UserRole, character)
         item.setSizeHint(QSize(48, 48))
         icon = self.get_icon(character)
         if icon is not None:
             item.setIcon(icon)
         self.listWidget.addItem(item)
     self.listWidget.setCurrentRow(0)
Ejemplo n.º 14
0
 def add_items(self):
     characters = self.client.results
     for character in characters:
         item = QListWidgetItem(self.get_name(character["name"]))
         item.setData(Qt.UserRole, character)
         item.setSizeHint(QSize(48, 48))
         icon = self.get_icon(character)
         if icon is not None:
             item.setIcon(icon)
         self.listWidget.addItem(item)
     self.listWidget.setCurrentRow(0)
Ejemplo n.º 15
0
 def add_no_found(self):
     #Load no results found message
     noFoundItem = QListWidgetItem(
         QIcon(resources.IMAGES['delete']),
             'No results were found!')
     font = noFoundItem.font()
     font.setBold(True)
     noFoundItem.setSizeHint(QSize(20, 30))
     noFoundItem.setBackground(QBrush(Qt.lightGray))
     noFoundItem.setForeground(QBrush(Qt.black))
     noFoundItem.setFont(font)
     self.listWidget.addItem(noFoundItem)
Ejemplo n.º 16
0
    def __init__(self, toolbar, parent=None):
        CartoDBPluginUserDialog.__init__(self, toolbar, parent)
        self.toolbar = toolbar

        self.ui = Ui_CreateViz()
        self.ui.setupUi(self)

        self.ui.bar = QgsMessageBar()
        self.ui.bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.ui.verticalLayout.insertWidget(0, self.ui.bar)

        self.ui.availableList = CartoDBLayersListWidget(self, 'availableList')
        self.ui.availableList.setAcceptDrops(True)
        self.ui.availableList.viewport().setAcceptDrops(True)
        self.ui.availableList.setDragEnabled(True)
        self.ui.availableList.setDropIndicatorShown(True)
        self.ui.availableList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.availableList.setDefaultDropAction(Qt.MoveAction)
        self.ui.availableList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.ui.availableLayout.addWidget(self.ui.availableList)

        self.ui.mapList = CartoDBLayersListWidget(self, 'mapList')
        self.ui.mapList.setAcceptDrops(True)
        self.ui.mapList.viewport().setAcceptDrops(True)
        self.ui.mapList.setDragEnabled(True)
        self.ui.mapList.setDropIndicatorShown(True)
        self.ui.mapList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.mapList.setDefaultDropAction(Qt.MoveAction)
        self.ui.mapList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.ui.mapLayout.addWidget(self.ui.mapList)

        self.ui.mapNameTX.textChanged.connect(self.validateButtons)
        self.ui.mapList.itemSelectionChanged.connect(self.validateButtons)
        self.ui.cancelBT.clicked.connect(self.reject)
        self.ui.saveBT.clicked.connect(self.createViz)
        self.ui.cartoCssBT.clicked.connect(self.createCartoCss)

        # TODO Implement functionality
        self.ui.sqlBT.hide()
        self.ui.cartoCssBT.hide()

        self.withWarnings = False

        layers = QgsMapLayerRegistry.instance().mapLayers()

        self.ui.availableList.clear()
        for id, ly in layers.iteritems():
            if ly.type() == QgsMapLayer.VectorLayer and isinstance(ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.availableList)
                widget = CartoDBLayerListItem(ly.name(), ly, self.getSize(ly), ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.availableList.setItemWidget(item, widget)
Ejemplo n.º 17
0
 def setSchematicFilterSet(self, filterSet):
     self.removeSchematicFilters()
     for clause in filterSet.clauses():
         self.widget.schematicClauseList.setHidden(False)
         clauseWidget = self._createFilterClauseWidget()
         clauseWidget.setClause(clause)
         clauseWidget.setFilterAction(FilterWidgetAction.LockFilter)
         self._schematicClauses.append(clauseWidget)
         newItem = QListWidgetItem()
         newItem.setSizeHint(clauseWidget.minimumSizeHint())
         self.widget.schematicClauseList.addItem(newItem)
         self.widget.schematicClauseList.setItemWidget(newItem, clauseWidget)
         self._schematicItems.append(newItem)
Ejemplo n.º 18
0
    def add_new_item(self, name, project, is_new=False):
        item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
        item.setData(QListWidgetItem.UserType, project)
        item.setSizeHint(QSize(150, 150))

        projectwidget = ProjectWidget(self.moduleList, project, is_new=is_new)
        projectwidget.install_project.connect(self.projectInstall.emit)
        projectwidget.update_project.connect(self.projectUpdate.emit)

        self.moduleList.addItem(item)
        self.moduleList.setItemWidget(item, projectwidget)

        self.projectitems[name] = item
Ejemplo n.º 19
0
 def populate(self, plugin_infos):
     app = get_app()
     for ptype, pname, ppath, pinfo in plugin_infos:
         widget = app.load_ui("", "pluginDialogItem.ui")
         widget.title.setText(tr(pname, pinfo['Title']))
         widget.author.setText(tr(pname, pinfo['Author']))
         widget.description.setText(tr(pname, pinfo['Description']))
         widget.version.setText(pinfo['Version'])
         widget.setObjectName(pname)
         widget.adjustSize()
         item = QListWidgetItem('', self)
         item.setSizeHint(widget.sizeHint())
         self.setItemWidget(item, widget)
Ejemplo n.º 20
0
	def add_images_to_list (self):
		"""To add a widget to the listview you must add a QListWidgetItem
		and replace with your widget"""

		for image in library:
			item = QListWidgetItem ()
			pixmap = QPixmap.fromImage (QImage (library[image]))
			label = QLabel ()
			label.setPixmap (pixmap.scaled (600, 400))
			item.setSizeHint (label.sizeHint ())
			item.setData (0, library[image])
			self.list_view.addItem (item)
			self.list_view.setItemWidget (item, label)
Ejemplo n.º 21
0
    def add_images_to_list(self):
        """To add a widget to the listview you must add a QListWidgetItem
		and replace with your widget"""

        for image in library:
            item = QListWidgetItem()
            pixmap = QPixmap.fromImage(QImage(library[image]))
            label = QLabel()
            label.setPixmap(pixmap.scaled(600, 400))
            item.setSizeHint(label.sizeHint())
            item.setData(0, library[image])
            self.list_view.addItem(item)
            self.list_view.setItemWidget(item, label)
Ejemplo n.º 22
0
 def add_page(self, widget):
     self.connect(self, SIGNAL('check_settings()'), widget.check_settings)
     self.connect(widget, SIGNAL('show_this_page()'),
                  lambda row=self.contents_widget.count():
                  self.contents_widget.setCurrentRow(row))
     self.connect(widget, SIGNAL("apply_button_enabled(bool)"),
                  self.apply_btn.setEnabled)
     self.pages_widget.addWidget(widget)
     item = QListWidgetItem(self.contents_widget)
     item.setIcon(widget.get_icon())
     item.setText(widget.get_name())
     item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
     item.setSizeHint(QSize(0, 25))
Ejemplo n.º 23
0
 def add_page(self, widget):
     self.connect(self, SIGNAL('check_settings()'), widget.check_settings)
     self.connect(widget,
                  SIGNAL('show_this_page()'),
                  lambda row=self.contents_widget.count(): self.
                  contents_widget.setCurrentRow(row))
     self.connect(widget, SIGNAL("apply_button_enabled(bool)"),
                  self.apply_btn.setEnabled)
     self.pages_widget.addWidget(widget)
     item = QListWidgetItem(self.contents_widget)
     item.setIcon(widget.get_icon())
     item.setText(widget.get_name())
     item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
     item.setSizeHint(QSize(0, 25))
Ejemplo n.º 24
0
 def _addFilterClause(self, filterClauseWidget):
     idx = self._filterIndex
     filterClauseWidget.setIndex(idx)
     self._filterClauses[idx] = filterClauseWidget
     filterClauseWidget.clauseRemoved.connect(self._filterClauseRemoved)
     filterClauseWidget.clauseChanged.connect(self.filterChanged)
     newItem = QListWidgetItem()
     newItem.setData(Qt.UserRole, idx)
     newItem.setSizeHint(filterClauseWidget.minimumSizeHint())
     self.widget.filterClauseList.addItem(newItem)
     self.widget.filterClauseList.setItemWidget(newItem, filterClauseWidget)
     self._items[idx] = newItem
     self._filterIndex += 1
     return idx
Ejemplo n.º 25
0
 def setSchematicFilterSet(self, filterSet):
     self.removeSchematicFilters()
     for clause in filterSet.clauses():
         self.widget.schematicClauseList.setHidden(False)
         clauseWidget = self._createFilterClauseWidget()
         clauseWidget.setClause(clause)
         clauseWidget.setFilterAction(FilterWidgetAction.LockFilter)
         self._schematicClauses.append(clauseWidget)
         newItem = QListWidgetItem()
         newItem.setSizeHint(clauseWidget.minimumSizeHint())
         self.widget.schematicClauseList.addItem(newItem)
         self.widget.schematicClauseList.setItemWidget(
             newItem, clauseWidget)
         self._schematicItems.append(newItem)
Ejemplo n.º 26
0
 def _addFilterClause(self, filterClauseWidget):
     idx = self._filterIndex
     filterClauseWidget.setIndex(idx)
     self._filterClauses[idx] = filterClauseWidget
     filterClauseWidget.clauseRemoved.connect(self._filterClauseRemoved)
     filterClauseWidget.clauseChanged.connect(self.filterChanged)
     newItem = QListWidgetItem()
     newItem.setData(Qt.UserRole, idx)
     newItem.setSizeHint(filterClauseWidget.minimumSizeHint())
     self.widget.filterClauseList.addItem(newItem)
     self.widget.filterClauseList.setItemWidget(newItem, filterClauseWidget)
     self._items[idx] = newItem
     self._filterIndex += 1
     return idx
Ejemplo n.º 27
0
 def open_dir(self):
     print(self.working_dir)
     for file_type in ('cho', 'crd'):
         for file_name in glob.iglob('{}/*.{}'.format(self.working_dir, file_type)):
             item = QListWidgetItem(os.path.basename(file_name))
             item.setData(Qt.UserRole, file_name)
             item.setSizeHint(QSize(0, 30))
             self.ui.fileWidget.addItem(item)
             with codecs.open(file_name, 'r', "ISO-8859-1") as f:
                 artist = None
                 for line in f:
                     artist = re.search(r'\{st:(.*)\}', line)
                     if artist:
                         break
                 print(artist.group(1).strip())
Ejemplo n.º 28
0
    def updateValues(self, alerts):
        self.myQListWidget.clear()
        for alert in alerts[::-1]:
            print(alert.state)
            myQCustomQWidget = QCustomQWidget()
            myQCustomQWidget.setItemFromAlert(alert)
            # Create QListWidgetItem
            myQListWidgetItem = QListWidgetItem(self.myQListWidget)
            # Set size hint
            myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint())
            # Add QListWidgetItem into QListWidget
            self.myQListWidget.addItem(myQListWidgetItem)
            self.myQListWidget.setItemWidget(myQListWidgetItem,
                                             myQCustomQWidget)

        self.alerts = alerts
Ejemplo n.º 29
0
    def add_new_item(self, name, project, is_new=False, is_valid=True):
        item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
        item.setData(QListWidgetItem.UserType, project)
        item.setSizeHint(QSize(150, 150))
        if not is_valid:
            item.setFlags(item.flags() & ~Qt.ItemIsEnabled)

        projectwidget = ProjectWidget(self.moduleList, project, is_new=is_new)
        projectwidget.install_project.connect(self.projectInstall.emit)
        projectwidget.update_project.connect(self.projectUpdate.emit)
        projectwidget.setEnabled(is_valid)

        self.moduleList.addItem(item)
        self.moduleList.setItemWidget(item, projectwidget)

        self.projectitems[name] = item
Ejemplo n.º 30
0
    def add_new_item(self, name, project, is_new=False, is_valid=True):
        item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
        item.setData(QListWidgetItem.UserType, project)
        item.setSizeHint(QSize(150, 150))
        if not is_valid:
            item.setFlags(item.flags() & ~Qt.ItemIsEnabled)

        projectwidget = ProjectWidget(self.moduleList, project, is_new=is_new)
        projectwidget.install_project.connect(self.projectInstall.emit)
        projectwidget.update_project.connect(self.projectUpdate.emit)
        projectwidget.setEnabled(is_valid)

        self.moduleList.addItem(item)
        self.moduleList.setItemWidget(item, projectwidget)

        self.projectitems[name] = item
Ejemplo n.º 31
0
 def add_help(self):
     #Load help
     fileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-file']),
             '@\t(Filter only by Files)')
     font = fileItem.font()
     font.setBold(True)
     fileItem.setSizeHint(QSize(20, 30))
     fileItem.setBackground(QBrush(Qt.lightGray))
     fileItem.setForeground(QBrush(Qt.black))
     fileItem.setFont(font)
     self.listWidget.addItem(fileItem)
     classItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-class']),
             '<\t(Filter only by Classes)')
     self.listWidget.addItem(classItem)
     classItem.setSizeHint(QSize(20, 30))
     classItem.setBackground(QBrush(Qt.lightGray))
     classItem.setForeground(QBrush(Qt.black))
     classItem.setFont(font)
     methodItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-function']),
             '>\t(Filter only by Methods)')
     self.listWidget.addItem(methodItem)
     methodItem.setSizeHint(QSize(20, 30))
     methodItem.setBackground(QBrush(Qt.lightGray))
     methodItem.setForeground(QBrush(Qt.black))
     methodItem.setFont(font)
     thisFileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-on-this-file']),
             '.\t(Filter only by Classes and Methods in this File)')
     font = thisFileItem.font()
     font.setBold(True)
     thisFileItem.setSizeHint(QSize(20, 30))
     thisFileItem.setBackground(QBrush(Qt.lightGray))
     thisFileItem.setForeground(QBrush(Qt.black))
     thisFileItem.setFont(font)
     self.listWidget.addItem(thisFileItem)
     nonPythonItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-nonpython']),
             '!\t(Filter only by Non Python Files)')
     self.listWidget.addItem(nonPythonItem)
     nonPythonItem.setSizeHint(QSize(20, 30))
     nonPythonItem.setBackground(QBrush(Qt.lightGray))
     nonPythonItem.setForeground(QBrush(Qt.black))
     nonPythonItem.setFont(font)
Ejemplo n.º 32
0
    def createGroupItem(self, name, content = None):
        if not content:
            group = self.iface.getGroup(name)
            localName, icon_path = unicode(group.localName), group.icon
            package_count = len(self.state.groupPackages(name))
            if package_count == 0:
                return
        else:
            localName, icon_path = content[0], content[1]
            package_count = content[2]

        icon = KIcon(icon_path, KIconLoader.SizeSmallMedium)
        if icon.isNull():
            icon = self.defaultIcon
        item = QListWidgetItem(icon, "%s (%d)" % (localName, package_count), self)
        item.setData(Qt.UserRole, QVariant(unicode(name)))
        item.setSizeHint(QSize(0, KIconLoader.SizeMedium))
    def add_last_used_services(self):
        services = CachedServices().get_cached_services()
        if len(services) == 0:
            return

        self.lstSearchResult.insertItem(0, self.tr("Last used:"))
        # l = QLabel(self.tr("Last used:"))
        # l.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        # self.lSearchResult.addWidget(l)

        for attributes, image_qByteArray in services:
            custom_widget = QmsSearchResultItemWidget(attributes,
                                                      image_qByteArray)
            new_item = QListWidgetItem(self.lstSearchResult)
            new_item.setSizeHint(custom_widget.sizeHint())
            self.lstSearchResult.addItem(new_item)
            self.lstSearchResult.setItemWidget(new_item, custom_widget)
    def show_result(self, geoservice, image_ba):
        if geoservice:
            custom_widget = QmsSearchResultItemWidget(geoservice, image_ba)
            new_item = QListWidgetItem(self.lstSearchResult)
            new_item.setSizeHint(custom_widget.sizeHint())
            self.lstSearchResult.addItem(new_item)
            self.lstSearchResult.setItemWidget(new_item, custom_widget)
            # self.lSearchResult.addWidget(custom_widget)

        else:
            new_item = QListWidgetItem()
            new_item.setText(self.tr('No results!'))
            new_item.setData(Qt.UserRole, None)
            self.lstSearchResult.addItem(new_item)
            # l = QLabel(self.tr("No results!"))
            # l.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
            # self.lSearchResult.addWidget(l)
        self.lstSearchResult.update()
Ejemplo n.º 35
0
 def loadProjectList(self, projects):
     self.moduleList.clear()
     for project in projects:
         if not project.valid:
             continue
         
         item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
         item.setData(QListWidgetItem.UserType, project)
         item.setSizeHint(QSize(150, 150))
         
         projectwidget = ProjectWidget(self.moduleList)
         projectwidget.image = QPixmap(project.splash)
         projectwidget.name = project.name
         projectwidget.description = project.description
         projectwidget.version = project.version
         
         self.moduleList.addItem(item)
         self.moduleList.setItemWidget(item, projectwidget)
Ejemplo n.º 36
0
    def loadProjectList(self, projects):
        self.moduleList.clear()
        for project in projects:
            if not project.valid:
                roam.utils.warning("Project {} is invalid because {}".format(project.name, project.error))
                continue

            item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
            item.setData(QListWidgetItem.UserType, project)
            item.setSizeHint(QSize(150, 150))

            projectwidget = ProjectWidget(self.moduleList)
            projectwidget.image = QPixmap(project.splash)
            projectwidget.name = project.name
            projectwidget.description = project.description
            projectwidget.version = project.version

            self.moduleList.addItem(item)
            self.moduleList.setItemWidget(item, projectwidget)
Ejemplo n.º 37
0
    def loadProjectList(self, projects):
        self.moduleList.clear()
        for project in projects:
            if not project.valid:
                roam.utils.warning("Project {} is invalid because {}".format(project.name, project.error))
                continue

            item = QListWidgetItem(self.moduleList, QListWidgetItem.UserType)
            item.setData(QListWidgetItem.UserType, project)
            item.setSizeHint(QSize(150, 150))
            
            projectwidget = ProjectWidget(self.moduleList)
            projectwidget.image = QPixmap(project.splash)
            projectwidget.name = project.name
            projectwidget.description = project.description
            projectwidget.version = project.version

            self.moduleList.addItem(item)
            self.moduleList.setItemWidget(item, projectwidget)
Ejemplo n.º 38
0
    def createGroupItem(self, name, content = None):
        if not content:
            group = self.iface.getGroup(name)
            localName, icon_path = unicode(group.localName), group.icon
            package_count = len(self.state.groupPackages(name))
            if package_count <= 0:
                return
        else:
            localName, icon_path = content[0], content[1]
            package_count = content[2]

        icon = QIcon(KIconLoader().loadIcon(icon_path, KIconLoader.NoGroup, 22))
        if icon.isNull():
            icon = self.defaultIcon
        text = "%s (%d)" % (localName, package_count)
        item = QListWidgetItem(icon, text, self)
        item.setToolTip(localName)
        item.setData(Qt.UserRole, QVariant(unicode(name)))
        item.setSizeHint(QSize(0, KIconLoader.SizeMedium))
        self._list[name] = item
 def search_finished_progress(self):
     self.lstSearchResult.takeItem(0)
     # self.lSearchResult.itemAt(0).widget().setParent(None)
     if self.lstSearchResult.count() == 0:
         # if self.lSearchResult.count() == 0:
         new_widget = QLabel()
         new_widget.setTextFormat(Qt.RichText)
         new_widget.setOpenExternalLinks(True)
         new_widget.setWordWrap(True)
         new_widget.setText(
             u"<div align='center'> <strong>{}</strong> </div><div align='center' style='margin-top: 3px'> {} </div>"
             .format(
                 self.tr(u"No results."),
                 self.
                 tr(u"You can add a service to become searchable. Start <a href='{}'>here</a>."
                    ).format(u"https://qms.nextgis.com/create"),
             ))
         new_item = QListWidgetItem(self.lstSearchResult)
         new_item.setSizeHint(new_widget.sizeHint())
         self.lstSearchResult.addItem(new_item)
         self.lstSearchResult.setItemWidget(new_item, new_widget)
Ejemplo n.º 40
0
    def loadProjectList(self, projects):
        self.ui.moduleList.clear()
        for project in projects:
            if not project.vaild:
                continue
            
            item = QListWidgetItem(self.ui.moduleList, QListWidgetItem.UserType)
            item.setData(QListWidgetItem.UserType, project)
            item.setSizeHint(QSize(200, 200))
            
            projectwidget = ProjectWidget(self.ui.moduleList)
            projectwidget.image = QPixmap(project.splash)
            projectwidget.name = project.name
            projectwidget.description = project.description
            projectwidget.version = project.version
            
#             pix = QPixmap(project.splash)
#             icon = QIcon(pix.scaled(200,200))
#             item.setIcon(icon)
            self.ui.moduleList.addItem(item)
            self.ui.moduleList.setItemWidget(item, projectwidget)
Ejemplo n.º 41
0
    def updateList(self, visualizations):
        self.ui.tablesList.clear()
        for visualization in visualizations:
            item = QListWidgetItem(self.ui.tablesList)

            owner = None
            owner = visualization["permission"]["owner"]["username"]

            widget = CartoDBDatasetsListItem(
                visualization["name"],
                owner,
                visualization["table"]["size"],
                visualization["table"]["row_count"],
                shared=(owner != self.currentUser),
            )
            # item.setText(visualization['name'])
            readonly = False
            # qDebug('Vis:' + json.dumps(visualization, sort_keys=True, indent=2, separators=(',', ': ')))
            if (
                visualization["permission"] is not None
                and owner != self.currentUser
                and visualization["permission"]["acl"] is not None
            ):
                for acl in visualization["permission"]["acl"]:
                    if (
                        acl["type"] == "user"
                        and "username" in acl["entity"]
                        and acl["entity"]["username"] == self.currentUser
                        and acl["access"] == "r"
                    ):
                        readonly = True
                        break

            widget.readonly = readonly
            if readonly:
                widget.setTextColor("#999999")

            item.setSizeHint(widget.sizeHint())
            # item.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/layers.png"))
            self.ui.tablesList.setItemWidget(item, widget)
Ejemplo n.º 42
0
    def __init__(self, toolbar, iface, parent=None):
        CartoDBPluginUserDialog.__init__(self, toolbar, parent)

        self.currentViz = None
        self.iface = iface

        self.ui = Ui_CreateViz()
        self.ui.setupUi(self)

        self.ui.bar = QgsMessageBar()
        self.ui.bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.ui.verticalLayout.insertWidget(0, self.ui.bar)

        '''
        self.ui.availableList = CartoDBLayersListWidget(self, 'availableList')
        self.ui.availableList.setAcceptDrops(True)
        self.ui.availableList.viewport().setAcceptDrops(True)
        self.ui.availableList.setDragEnabled(True)
        self.ui.availableList.setDropIndicatorShown(True)
        self.ui.availableList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.availableList.setDefaultDropAction(Qt.MoveAction)
        self.ui.availableList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.ui.availableLayout.addWidget(self.ui.availableList)

        self.ui.mapList = CartoDBLayersListWidget(self, 'mapList')
        self.ui.mapList.setAcceptDrops(True)
        self.ui.mapList.viewport().setAcceptDrops(True)
        self.ui.mapList.setDragEnabled(True)
        self.ui.mapList.setDropIndicatorShown(True)
        self.ui.mapList.setDragDropMode(QAbstractItemView.DragDrop)
        self.ui.mapList.setDefaultDropAction(Qt.MoveAction)
        self.ui.mapList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.ui.mapLayout.addWidget(self.ui.mapList)
        '''

        self.ui.mapNameTX.textChanged.connect(self.validateButtons)
        # self.ui.mapList.itemSelectionChanged.connect(self.validateButtons)
        # pylint: disable-msg=E1101
        self.ui.cancelBT.clicked.connect(self.reject)
        self.ui.saveBT.clicked.connect(self.createViz)
        self.ui.cartoCssBT.clicked.connect(self.createCartoCss)
        '''
        self.ui.addAllBT.clicked.connect(self.addAllItems)
        self.ui.addBT.clicked.connect(self.addItems)
        self.ui.removeAllBT.clicked.connect(self.removeAllItems)
        self.ui.removeBT.clicked.connect(self.removeItems)
        '''

        # TODO Implement functionality
        self.ui.sqlBT.hide()
        self.ui.cartoCssBT.hide()

        self.withWarnings = False

        layers = self.iface.legendInterface().layers()

        self.ui.availableList.clear()
        self.cartoDBLayers = []
        cartodb_layers_count = 0
        for ly in layers:
            if ly.type() == QgsMapLayer.VectorLayer and isinstance(ly, CartoDBLayer):
                cartodb_layers_count = cartodb_layers_count + 1
                # pylint: disable-msg=E1101
                if ly.user == self.currentUser:
                    self.cartoDBLayers.append(ly)
                    item = QListWidgetItem(self.ui.availableList)
                    widget = CartoDBLayerListItem(ly.name(), ly, getSize(ly), ly.dataProvider().featureCount())
                    item.setSizeHint(widget.sizeHint())
                    self.ui.availableList.setItemWidget(item, widget)

        if cartodb_layers_count > 0 and len(self.cartoDBLayers) == 0:
            self.ui.bar.clearWidgets()
            # pylint: disable-msg=E1101
            self.ui.bar.pushMessage(QApplication.translate('CartoDBPlugin', 'Warning') + '!!',
                                    QApplication.translate('CartoDBPlugin',
                                                           'At least one CartoDB layer should belong or be visible to {}').format(self.currentUser),
                                    level=QgsMessageBar.WARNING)
            self.ui.mapNameTX.setEnabled(False)
            self.ui.descriptionTX.setEnabled(False)
            self.ui.publicCH.setEnabled(False)
        elif cartodb_layers_count == 0:
            self.ui.bar.clearWidgets()
            self.ui.bar.pushMessage(QApplication.translate('CartoDBPlugin', 'Warning') + '!!',
                                    QApplication.translate('CartoDBPlugin',
                                                           'At least there should be a CartoDB layer in the project.'),
                                    level=QgsMessageBar.WARNING)
            self.ui.mapNameTX.setEnabled(False)
            self.ui.descriptionTX.setEnabled(False)
            self.ui.publicCH.setEnabled(False)
        else:
            self.cartoDBLayers.reverse()
Ejemplo n.º 43
0
 def add_help(self):
     #Load help
     fileItem = QListWidgetItem(QIcon(resources.IMAGES['locate-file']),
                                '@\t(Filter only by Files)')
     font = fileItem.font()
     font.setBold(True)
     fileItem.setSizeHint(QSize(20, 30))
     fileItem.setBackground(QBrush(Qt.lightGray))
     fileItem.setForeground(QBrush(Qt.black))
     fileItem.setFont(font)
     self.listWidget.addItem(fileItem)
     classItem = QListWidgetItem(QIcon(resources.IMAGES['locate-class']),
                                 '<\t(Filter only by Classes)')
     self.listWidget.addItem(classItem)
     classItem.setSizeHint(QSize(20, 30))
     classItem.setBackground(QBrush(Qt.lightGray))
     classItem.setForeground(QBrush(Qt.black))
     classItem.setFont(font)
     methodItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-function']),
         '>\t(Filter only by Methods)')
     self.listWidget.addItem(methodItem)
     methodItem.setSizeHint(QSize(20, 30))
     methodItem.setBackground(QBrush(Qt.lightGray))
     methodItem.setForeground(QBrush(Qt.black))
     methodItem.setFont(font)
     attributeItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-attributes']),
         '-\t(Filter only by Attributes)')
     self.listWidget.addItem(attributeItem)
     attributeItem.setSizeHint(QSize(20, 30))
     attributeItem.setBackground(QBrush(Qt.lightGray))
     attributeItem.setForeground(QBrush(Qt.black))
     attributeItem.setFont(font)
     thisFileItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-on-this-file']),
         '.\t(Filter only by Classes and Methods in this File)')
     font = thisFileItem.font()
     font.setBold(True)
     thisFileItem.setSizeHint(QSize(20, 30))
     thisFileItem.setBackground(QBrush(Qt.lightGray))
     thisFileItem.setForeground(QBrush(Qt.black))
     thisFileItem.setFont(font)
     self.listWidget.addItem(thisFileItem)
     nonPythonItem = QListWidgetItem(
         QIcon(resources.IMAGES['locate-nonpython']),
         '!\t(Filter only by Non Python Files)')
     self.listWidget.addItem(nonPythonItem)
     nonPythonItem.setSizeHint(QSize(20, 30))
     nonPythonItem.setBackground(QBrush(Qt.lightGray))
     nonPythonItem.setForeground(QBrush(Qt.black))
     nonPythonItem.setFont(font)
Ejemplo n.º 44
0
 def addItem(label, icon_pixmap, width, height):
     item = QListWidgetItem(list_option)
     item.setText(label)
     item.setTextAlignment(Qt.AlignHCenter)
     item.setIcon(QIcon(icon_pixmap))
     item.setSizeHint(QSize(width, height))