本文整理汇总了Python中PyQt4.QtGui.QListView.mapToGlobal方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.mapToGlobal方法的具体用法?Python QListView.mapToGlobal怎么用?Python QListView.mapToGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.mapToGlobal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DirectoryWidget
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import mapToGlobal [as 别名]
#.........这里部分代码省略.........
self.listView.setRootIndex(self.proxyModel.mapFromSource(self.model.index(text, 0)))
def rootChanged(self):
index1 = self.listView.rootIndex()
index2 = self.proxyModel.mapToSource(index1)
self.lineEdit.setText(self.model.filePath(index2))
self.listView.setCurrentIndex(index1)
def customContext(self, pos):
index = self.listView.indexAt(pos)
index = self.proxyModel.mapToSource(index)
if not index.isValid():
self.rmAction.setEnabled(False)
self.openAction.setEnabled(False)
self.loadAction.setEnabled(False)
elif not self.model.isDir(index):
info = self.model.fileInfo(index)
suffix = info.suffix()
if suffix in ("Rd","Rdata","RData"):
self.loadAction.setEnabled(True)
self.openAction.setEnabled(False)
self.loadExternal.setEnabled(False)
elif suffix in ("txt","csv","R","r"):
self.openAction.setEnabled(True)
self.loadAction.setEnabled(False)
self.loadExternal.setEnabled(True)
else:
self.loadAction.setEnabled(False)
self.openAction.setEnabled(False)
self.loadExternal.setEnabled(True)
menu = QMenu(self)
for action in self.actions:
menu.addAction(action)
menu.exec_(self.listView.mapToGlobal(pos))
def openItem(self):
index = self.listView.currentIndex()
index = self.proxyModel.mapToSource(index)
self.emit(SIGNAL("openFileRequest(QString)"),
self.model.filePath(index))
def loadItem(self):
index = self.listView.currentIndex()
index = self.proxyModel.mapToSource(index)
self.emit(SIGNAL("loadFileRequest(QString)"),
self.model.filePath(index))
def externalItem(self):
index = self.listView.currentIndex()
index = self.proxyModel.mapToSource(index)
QDesktopServices.openUrl(QUrl(self.model.filePath(index)))
def newFolder(self):
text, ok = QInputDialog.getText(self,
"New Folder", "Folder name:", QLineEdit.Normal,
"new_folder")
if ok:
index = self.listView.rootIndex()
index = self.proxyModel.mapToSource(index)
self.model.mkdir(index, text)
def setFolder(self):
index = self.listView.currentIndex()
index = self.proxyModel.mapToSource(index)
commands = "setwd('%s')" % self.model.filePath(index)
self.emitCommands(commands)