def __init__(self, model, view): QObserver.__init__(self, model, view) self.add_observables('left_combo', 'right_combo', 'left_list', 'right_list', 'diff_files') # wire the compare button to the double-click action and # the combo boxes to the "update list of changed files" action self.add_callbacks(button_compare = self.diff_files_doubleclick, left_combo = lambda x: self.update_combo_boxes(left=True), right_combo = lambda x: self.update_combo_boxes(left=False), left_list = self.update_diff_files, right_list = self.update_diff_files) # aka notify observers self.refresh_view() # Pre-select the 0th elements self.view.right_combo.setCurrentIndex(1) item = self.view.left_list.item(0) self.view.left_list.setCurrentItem(item) self.view.left_list.setItemSelected(item, True) item = self.view.right_list.item(0) self.view.right_list.setCurrentItem(item) self.view.right_list.setItemSelected(item, True)
def __init__(self, model, view): QObserver.__init__(self, model, view) self.add_observables('query', 'max_results', 'start_date', 'end_date') self.add_actions(max_results = self.search_callback, start_date = self.search_callback, end_date = self.search_callback) self.add_callbacks( # Standard buttons button_search = self.search_callback, button_browse = self.browse_callback, commit_list = self.display_callback, button_export = self.export_patch, button_cherrypick = self.cherry_pick, # Radio buttons trigger a search radio_revision = self.search_callback, radio_range = self.search_callback, radio_message = self.search_callback, radio_path = self.search_callback, radio_diff = self.search_callback, radio_author = self.search_callback, radio_committer = self.search_callback, radio_daterange = self.search_callback, ) self.update_fonts()
def refresh_view(self): """Apply the configured font and update widgets.""" # The fixed-width console font qtutils.set_diff_font(self.view.global_cola_fontdiff) # Label the group box around the local repository self.view.local_groupbox.setTitle(unicode(self.tr('%s Repository')) % self.model.project) QObserver.refresh_view(self)
def __init__(self, model, view): """Sets up notifications and callbacks""" QObserver.__init__(self, model, view) self.add_observables('bookmarks') self.add_callbacks(button_open = self.open, button_delete = self.delete, button_save = self.save) self.refresh_view()
def __init__(self, model, view): QObserver.__init__(self, model, view) self.add_observables('stash_list', 'keep_index') self.add_callbacks(button_stash_show = self.stash_show, button_stash_apply = self.stash_apply, button_stash_drop = self.stash_drop, button_stash_clear = self.stash_clear, button_stash_save = self.stash_save) self.update_model()
def __init__(self, model, view): QObserver.__init__(self, model, view) self._remoteclicked = False self.add_observables('revision', 'local_branch') self.add_callbacks(branch_list = self.branch_item_changed, create_button = self.create_branch, local_radio = self.display_model, remote_radio = self.display_model, tag_radio = self.display_model) self.display_model()
def __init__(self, model, view): QObserver.__init__(self, model, view) self.add_callbacks(button_apply = self.stash_apply, button_remove = self.stash_remove, button_save = self.stash_save, button_close = self.close) self.connect(self.view.stash_list, SIGNAL('itemSelectionChanged()'), self.item_selected) self.update_model() self.update_actions()
def __init__(self, model, view, revs, summaries): QObserver.__init__(self, model, view) self.model.set_revisions(revs) self.model.set_summaries(summaries) self.connect(view.commit_list, SIGNAL('itemSelectionChanged()'), self.commit_sha1_selected) view.commit_list.contextMenuEvent = self.context_menu_event self.view.commit_text.setFont(diff_font())
def __init__(self, model, view): QObserver.__init__(self, model, view) # Set the current branch label self.view.set_branch(self.model.currentbranch) self.add_observables('revision', 'revisions') self.add_callbacks(radio_local = self.radio_callback, radio_remote = self.radio_callback, radio_tag = self.radio_callback, revisions = self.revision_selected, button_viz = self.viz_revision, button_merge = self.merge_revision) self.model.set_revisions(self.model.local_branches)
def __init__(self, model, view, revs, summaries): self.orig_model = model QObserver.__init__(self, model.clone(), view) self.model.set_revisions(revs) self.model.set_summaries(summaries) self.connect(view.commit_list, 'itemSelectionChanged()', self.commit_sha1_selected) view.commit_list.contextMenuEvent = self.context_menu_event self.set_diff_font()
def __init__(self, model, view): """Initializes the MainController's internal data.""" QObserver.__init__(self, model, view) # Binds model params to their equivalent view widget self.add_observables('commitmsg') # When a model attribute changes, this runs a specific action self.add_actions(global_cola_fontdiff = self.update_diff_font) self.add_actions(global_cola_tabwidth = self.update_tab_width) # Route events here self._init_log_window() self.refresh_view('global_cola_fontdiff') # Update the diff font
def __init__(self, model, view, action): QObserver.__init__(self, model, view) self.add_observables('remotename', 'remotes', 'local_branch', 'local_branches', 'remote_branch', 'remote_branches', 'tags_checkbox', 'rebase_checkbox', 'ffwd_only_checkbox') self.action = action """The current mode; one of fetch/push/pull""" self.action_method = { 'fetch': self.gen_remote_callback(self.model.fetch_helper), 'push': self.gen_remote_callback(self.model.push_helper), 'pull': self.gen_remote_callback(self.model.pull_helper), } [action] """Callbacks corresponding to the 3 (fetch/push/pull) modes""" self.add_actions(remotes = self.display_remotes) self.add_callbacks(action_button = self.action_method, remotes = self.update_remotes, local_branches = self.update_local_branches, remote_branches = self.update_remote_branches) self.refresh_view() remotes = self.model.remotes if 'origin' in remotes: idx = remotes.index('origin') if self.view.select_remote(idx): self.model.set_remotename('origin') else: if self.view.select_first_remote(): self.model.set_remotename(remotes[0]) # Select the current branch by default for push if action != 'push': return branches = self.model.local_branches branch = self.model.currentbranch if branch not in branches: return idx = branches.index(branch) if self.view.select_local_branch(idx): self.model.set_local_branch(branch)
def __init__(self, model, view, title='File Browser', get_file=False): QObserver.__init__(self, model, view) self.get_file = get_file """Whether we should returns a selected file""" self.filename = None """The last selected filename""" view.setWindowTitle(title) self.add_signals('itemSelectionChanged()', view.commit_list,) self.add_actions(directory = self.action_directory_changed) self.add_callbacks(commit_list = self.item_changed) view.commit_list.contextMenuEvent = self.context_menu_event # Start at the root of the tree model.set_directory('') self.refresh_view()
def __init__(self, model, view, filename=None): QObserver.__init__(self, model, view) self.filename = filename if self.filename: # If we've specified a filename up front then there's # no need to show the list of "changed files" since # we're only interested in the specified file. self.view.compare_files.hide() self.add_observables('descriptions_start', 'descriptions_end', 'revision_start', 'revision_end', 'compare_files', 'num_results', 'show_versions') # The spinbox and checkbox should both call the generic update method self.add_actions(num_results = self.update_results) self.add_actions(show_versions = self.update_results) # Clicking on a listwidget item should update the list of # "changed files". Clicking on the "Compare" button should # initiate a difftool session. self.add_callbacks(descriptions_start = lambda *x: self.update_widgets(left=True), descriptions_end = lambda *x: self.update_widgets(left=False), button_compare = self.compare_selected_file) self.refresh_view() # if we can, preselect the latest commit revisions = self.update_results() last = len(revisions) if (last > 1 and self.view.descriptions_start.topLevelItemCount() > last-1 and self.view.descriptions_end .topLevelItemCount() > last-1): # select the 2nd item on the left treewidget startitem = self.view.descriptions_start.topLevelItem(last-2) self.view.descriptions_start.setCurrentItem(startitem) self.view.descriptions_start.setItemSelected(startitem, True) # select the 1st item on the right treewidget enditem = self.view.descriptions_end.topLevelItem(last-1) self.view.descriptions_end.setCurrentItem(enditem) self.view.descriptions_end.setItemSelected(enditem, True)
def __init__(self, view): ## operate on a clone of the original model QObserver.__init__(self, cola.model().clone(), view) ## used to restore original values when cancelling self._backup_model = cola.model().clone() ## config params modified by the gui self.add_observables('local_user_email', 'local_user_name', 'local_merge_summary', 'local_merge_diffstat', 'local_merge_verbosity', 'local_gui_diffcontext', 'global_user_email', 'global_user_name', 'global_merge_keepbackup', 'global_merge_summary', 'global_merge_diffstat', 'global_merge_verbosity', 'global_gui_editor', 'global_merge_tool', 'global_diff_tool', 'global_gui_diffcontext', 'global_gui_historybrowser', 'global_cola_fontdiff_size', 'global_cola_fontdiff', 'global_cola_savewindowsettings', 'global_cola_tabwidth') # Refresh before registering callbacks to avoid extra notifications self.refresh_view() # Register actions self.add_actions(global_cola_fontdiff = self.tell_parent_model) self.add_callbacks(global_cola_fontdiff_size = self.update_size) self.add_actions(global_cola_tabwidth = self.tell_parent_model) self.add_callbacks(save_button = self.save_settings) self.connect(self.view, 'rejected()', self.restore_settings)
def __init__(self, model, view, action): QObserver.__init__(self, model, view) self.add_observables('remotename', 'remotes', 'local_branch', 'local_branches', 'remote_branch', 'remote_branches', 'tags_checkbox', 'rebase_checkbox', 'ffwd_only_checkbox') self.action = action """The current mode; one of fetch/push/pull""" self.action_method = { 'fetch': self.gen_remote_callback(self.model.fetch_helper), 'push': self.gen_remote_callback(self.model.push_helper), 'pull': self.gen_remote_callback(self.model.pull_helper), } [action] self._tasks = [] self.progress = QtGui.QProgressDialog(self.view) self.progress.setRange(0, 0) self.progress.setCancelButton(None) self.progress.setWindowTitle('git ' + action) self.progress.setWindowModality(Qt.WindowModal) """Callbacks corresponding to the 3 (fetch/push/pull) modes""" self.add_actions(remotes = self.display_remotes) self.add_callbacks(action_button = self.action_method, remotes = self.update_remotes, local_branches = self.update_local_branches, remote_branches = self.update_remote_branches) self.view.connect(self.view, SIGNAL('action_completed'), self._action_completed) self.refresh_view() remotes = self.model.remotes if 'origin' in remotes: idx = remotes.index('origin') if self.view.select_remote(idx): self.model.set_remotename('origin') else: if self.view.select_first_remote(): self.model.set_remotename(remotes[0]) # Trim the remote list to just the default remote self.update_remotes() # Default to "git fetch origin master" if action == 'fetch' or action == 'pull': self.model.set_local_branch('') self.model.set_remote_branch('') return # Select the current branch by default for push if action == 'push': branch = self.model.currentbranch try: idx = self.model.local_branches.index(branch) except ValueError: return if self.view.select_local_branch(idx): self.model.set_local_branch(branch) self.model.set_remote_branch('')