示例#1
0
class SyncWidget(QtGui.QFrame):
	def __init__(self, tag, info, parent=None):
		super(SyncWidget, self).__init__(parent)
		self.tag = tag
		fromUuid = info[0:16]
		toUuid = info[16:32]

		self.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken)

		self.fromBtn = DocButton(fromUuid, True)
		self.toBtn = DocButton(toUuid, True)
		self.progressBar = QtGui.QProgressBar()
		self.progressBar.setMaximum(255)

		layout = QtGui.QHBoxLayout()
		layout.setMargin(0)
		layout.addWidget(self.fromBtn)
		layout.addWidget(self.progressBar)
		layout.addWidget(self.toBtn)
		self.setLayout(layout)

		Connector().regProgressHandler(progress=self.progress)

	def remove(self):
		Connector().unregProgressHandler(progress=self.progress)
		self.fromBtn.cleanup()
		self.toBtn.cleanup()
		self.deleteLater()

	def progress(self, tag, value):
		if self.tag == tag:
			self.progressBar.setValue(value)
示例#2
0
class StoreWidget(QtGui.QWidget):
	class StoreWatch(Watch):
		def __init__(self, doc, callback):
			self.__callback = callback
			super(StoreWidget.StoreWatch, self).__init__(Watch.TYPE_DOC, doc)

		def triggered(self, cause):
			if cause == Watch.EVENT_DISAPPEARED:
				self.__callback()

	def __init__(self, mountId, parent=None):
		super(StoreWidget, self).__init__(parent)
		self.mountId = mountId
		self.watch = None

		self.mountBtn = QtGui.QPushButton("")
		self.storeBtn = DocButton(None, True)
		self.mountBtn.clicked.connect(self.mountUnmount)

		layout = QtGui.QHBoxLayout()
		layout.setMargin(0)
		layout.addWidget(self.storeBtn)
		layout.addStretch()
		layout.addWidget(self.mountBtn)
		self.setLayout(layout)

		self.update()

	def update(self):
		if self.watch:
			Connector().unwatch(self.watch)
			self.watch = None

		enum = Connector().enum()
		self.mountBtn.setEnabled(enum.isRemovable(self.mountId))
		if enum.isMounted(self.mountId):
			doc = enum.doc(self.mountId)
			self.mountBtn.setText("Unmount")
			self.storeBtn.setDocument(doc)
			self.watch = StoreWidget.StoreWatch(doc, self.update)
			Connector().watch(self.watch)
			self.mounted = True
		else:
			self.mountBtn.setText("Mount")
			self.storeBtn.setText(enum.name(self.mountId))
			self.mounted = False

	def mountUnmount(self):
		if self.mounted:
			Connector().unmount(self.mountId)
		else:
			Connector().mount(self.mountId)
			self.update()
示例#3
0
    def __init__(self, stores, descr, parent=None):
        super(DocumentTab, self).__init__(parent)

        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(
            QtGui.QLabel("The " + descr + " exists on the following stores:"))
        subLayout = QtGui.QHBoxLayout()
        for store in stores:
            subLayout.addWidget(DocButton(store, True))
        subLayout.addStretch()
        mainLayout.addLayout(subLayout)
        self.setLayout(mainLayout)
示例#4
0
	def __init__(self, tag, info, parent=None):
		super(SyncWidget, self).__init__(parent)
		self.tag = tag
		fromUuid = info[0:16]
		toUuid = info[16:32]

		self.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken)

		self.fromBtn = DocButton(fromUuid, True)
		self.toBtn = DocButton(toUuid, True)
		self.progressBar = QtGui.QProgressBar()
		self.progressBar.setMaximum(255)

		layout = QtGui.QHBoxLayout()
		layout.setMargin(0)
		layout.addWidget(self.fromBtn)
		layout.addWidget(self.progressBar)
		layout.addWidget(self.toBtn)
		self.setLayout(layout)

		Connector().regProgressHandler(progress=self.progress)
示例#5
0
	def __init__(self, mountId, parent=None):
		super(StoreWidget, self).__init__(parent)
		self.mountId = mountId
		self.watch = None

		self.mountBtn = QtGui.QPushButton("")
		self.storeBtn = DocButton(None, True)
		self.mountBtn.clicked.connect(self.mountUnmount)

		layout = QtGui.QHBoxLayout()
		layout.setMargin(0)
		layout.addWidget(self.storeBtn)
		layout.addStretch()
		layout.addWidget(self.mountBtn)
		self.setLayout(layout)

		self.update()
示例#6
0
    def __init__(self, revs, parent=None):
        super(RevisionTab, self).__init__(parent)

        layout = QtGui.QGridLayout()
        layout.addWidget(QtGui.QLabel("Type:"), 1, 0)
        layout.addWidget(QtGui.QLabel("Modification time:"), 2, 0)
        layout.addWidget(QtGui.QLabel("Size:"), 3, 0)
        layout.addWidget(QtGui.QLabel("Stores:"), 4, 0)

        col = 1
        for rev in revs:
            stat = Connector().stat(rev)

            layout.addWidget(RevButton(rev, True), 0, col)
            layout.addWidget(
                QtGui.QLabel(Registry().getDisplayString(stat.type())), 1, col)
            layout.addWidget(QtGui.QLabel(str(stat.mtime())), 2, col)
            size = 0
            for part in stat.parts():
                size += stat.size(part)
            for unit in ['Bytes', 'KiB', 'MiB', 'GiB']:
                if size < (1 << 10):
                    break
                else:
                    size = size >> 10
            sizeText = "%d %s (%d parts)" % (size, unit, len(stat.parts()))
            layout.addWidget(QtGui.QLabel(sizeText), 3, col)

            storeLayout = QtGui.QVBoxLayout()
            for store in Connector().lookup_rev(rev):
                storeLayout.addWidget(DocButton(store, True))
            layout.addLayout(storeLayout, 4, col)

            col += 1

        self.setLayout(layout)