Exemplo n.º 1
0
    def __fillMenu(self, menu, menuLink, store=None):
        menu.clear()
        c = struct.Folder(menuLink)
        listing = []
        for (title, link) in c.items():
            link.update()
            try:
                type = Connector().stat(link.rev()).type()
            except IOError:
                type = None

            if not type:
                continue

            if len(title) > 40:
                title = title[:40] + "..."

            listing.append(
                (title, link, Registry().conformes(type, "org.peerdrive.folder"), QtGui.QIcon(Registry().getIcon(type)))
            )

        listing = sorted(listing, cmp=Launchbox.__cmp)

        for (title, link, folder, icon) in listing:
            if folder:
                m = menu.addMenu(icon, title)
                m.aboutToShow.connect(lambda m=m, l=link: self.__fillMenu(m, l))
            else:
                a = menu.addAction(icon, title)
                a.triggered.connect(lambda x, l=link, r=menuLink: showDocument(l, referrer=r))

        menu.addSeparator()
        action = menu.addAction("Open")
        action.triggered.connect(lambda x, l=menuLink: showDocument(l))
        try:
            type = Connector().stat(menuLink.rev(), [menuLink.store()]).type()
            executables = Registry().getExecutables(type)
        except IOError:
            executables = []
        if len(executables) > 1:
            openMenu = menu.addMenu("Open with")
            for e in executables:
                action = openMenu.addAction(e)
                action.triggered.connect(lambda x, l=menuLink, e=e: showDocument(l, executable=e))
        menu.addSeparator()
        if store:
            action = menu.addAction(QtGui.QIcon("icons/unmount.png"), "Unmount")
            action.triggered.connect(lambda x, s=store: self.__unmount(s))
        action = menu.addAction("Properties")
        action.triggered.connect(lambda x, l=menuLink: showProperties(l))
Exemplo n.º 2
0
	def __fillMenu(self, menu, menuLink, store=None):
		menu.clear()
		c = struct.Folder(menuLink)
		listing = []
		for (title, link) in c.items():
			link.update()
			try:
				type = Connector().stat(link.rev()).type()
			except IOError:
				type = None

			if not type:
				continue

			if len(title) > 40:
				title = title[:40] + '...'

			listing.append((title, link, Registry().conformes(type,
				"org.peerdrive.folder"), QtGui.QIcon(Registry().getIcon(type))))

		listing = sorted(listing, cmp=Launchbox.__cmp)

		for (title, link, folder, icon) in listing:
			if folder:
				m = menu.addMenu(icon, title)
				m.aboutToShow.connect(lambda m=m, l=link: self.__fillMenu(m, l))
			else:
				a = menu.addAction(icon, title)
				a.triggered.connect(lambda x,l=link,r=menuLink: showDocument(l, referrer=r))

		menu.addSeparator()
		action = menu.addAction("Open")
		action.triggered.connect(lambda x,l=menuLink: showDocument(l))
		try:
			type = Connector().stat(menuLink.rev(), [menuLink.store()]).type()
			executables = Registry().getExecutables(type)
		except IOError:
			executables = []
		if len(executables) > 1:
			openMenu = menu.addMenu("Open with")
			for e in executables:
				action = openMenu.addAction(e)
				action.triggered.connect(lambda x,l=menuLink,e=e: showDocument(l, executable=e))
		menu.addSeparator()
		if store:
			action = menu.addAction(QtGui.QIcon("icons/unmount.png"), "Unmount")
			action.triggered.connect(lambda x,s=store: self.__unmount(s))
		action = menu.addAction("Properties")
		action.triggered.connect(lambda x,l=menuLink: showProperties(l))
Exemplo n.º 3
0
	def __showSelfProperties(self):
		if self.doc():
			link = struct.DocLink(self.store(), self.doc(), False)
		else:
			link = struct.RevLink(self.store(), self.rev())
		utils.showProperties(link)
Exemplo n.º 4
0
	def __showItemProperties(self):
		index = self.listView.selectionModel().currentIndex()
		link = self.model().getItemLink(self.modelMapIndex(index))
		if link:
			utils.showProperties(link)
Exemplo n.º 5
0
 def __showSelfProperties(self):
     if self.doc():
         link = connector.DocLink(self.store(), self.doc(), False)
     else:
         link = connector.RevLink(self.store(), self.rev())
     utils.showProperties(link)
Exemplo n.º 6
0
 def __showItemProperties(self):
     index = self.listView.selectionModel().currentIndex()
     link = self.model().getItemLink(self.modelMapIndex(index))
     if link:
         utils.showProperties(link)