Esempio n. 1
0
		def _replaceContent(self, index):
			try:
				nodes = hou.selectedItems()
			except:
				nodes = hou.selectedNodes()
			if (len(nodes)==0):
				QMessageBox.warning(self,'cannot replace','selection is empty')
				return
			item=index.internalPointer()
			good = QMessageBox.warning(self,'sure?','confirm that you want to replace the content of selected item "%s". This operation can not be undone.'%item.name() ,QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Ok
			if(not good):return
			try:
				item.setContent(hpaste.nodesToString(nodes))
			except CollectionSyncError as e:
				QMessageBox.critical(self,'something went wrong!','Server error occured: %s'%e.message)
Esempio n. 2
0
        def _addItem(self, collection):
            #Please, dont throw from here!
            try:
                nodes = hou.selectedItems()
            except:
                nodes = hou.selectedNodes()
            if (len(nodes) == 0):
                QMessageBox.warning(self, 'not created',
                                    'selection is empty, nothing to add')
                return

            while True:
                #btn,(name,desc) = (0,('1','2'))#hou.ui.readMultiInput('enter some information about new item',('name','description'),buttons=('Ok','Cancel'))
                name, desc, public, good = QDoubleInputDialog.getDoubleTextCheckbox(
                    self, 'adding a new item to %s' % collection.name(),
                    'enter new item details', 'name', 'description', 'public',
                    '', 'a snippet', False)
                if (not good): return

                if (len(name) > 0):
                    break
                    #validity check

            try:
                #print(name)
                #print(desc)
                #print(hpaste.nodesToString(nodes))
                self.model().addItemToCollection(
                    collection,
                    name,
                    desc,
                    hpaste.nodesToString(nodes),
                    public,
                    metadata={'nettype': self.__netType})
            except CollectionSyncError as e:
                QMessageBox.critical(self, 'something went wrong!',
                                     'Server error occured: %s' % e.message)