def __init__(self, parent, default=None):
super(PathItem, self).__init__(parent)
self.on_remove = lambda _: None
self.on_path_changed = lambda *_: None
self._remove_button = make_icon_button('remove', 'Remove this path', self,
on_clicked=lambda: self.on_remove(self))
completer = QCompleter(self)
completer.setModel(QDirModel(completer))
self._path_bar = CommitableComboBoxWithHistory(self)
if default:
self._path_bar.setCurrentText(default)
self._path_bar.setCompleter(completer)
self._path_bar.setAcceptDrops(True)
self._path_bar.setToolTip('Lookup path for file services; should point either to a file or to a directory')
self._path_bar.currentTextChanged.connect(self._on_path_changed)
self._select_file_button = make_icon_button('file-o', 'Specify file path', self,
on_clicked=self._on_select_path_file)
self._select_dir_button = make_icon_button('folder-open-o', 'Specify directory path', self,
on_clicked=self._on_select_path_directory)
self._hit_count_label = LabelWithIcon(get_icon('upload'), '0', self)
self._hit_count_label.setToolTip('Hit count')
layout = QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self._remove_button)
layout.addWidget(self._path_bar, 1)
layout.addWidget(self._select_file_button)
layout.addWidget(self._select_dir_button)
layout.addWidget(self._hit_count_label)
self.setLayout(layout)
评论列表
文章目录