'Customize the dialog based on the remote action'

def __init__(self, model, action, title, parent=None, icon=None):

    standard.Dialog.__init__(self, parent=parent)
    self.model = model
    self.action = action
    self.filtered_remote_branches = []
    self.selected_remotes = []
    self.setWindowTitle(title)
    if (parent is not None):
        self.setWindowModality(Qt.WindowModal)
    self.runtask = qtutils.RunTask(parent=self)
    self.progress = ProgressDialog(title, N_(u'Updating'), self)
    self.local_label = QtWidgets.QLabel()
    self.local_label.setText(N_(u'Local    Branch'))
    self.local_branch = QtWidgets.QLineEdit()
    qtutils.add_completer(self.local_branch, self.model.local_branches)
    self.local_branches = QtWidgets.QListWidget()
    self.local_branches.addItems(self.model.local_branches)
    self.remote_label = QtWidgets.QLabel()
    self.remote_label.setText(N_(u'Remote'))
    self.remote_name = QtWidgets.QLineEdit()
    qtutils.add_completer(self.remote_name, self.model.remotes)
    self.remote_name.editingFinished.connect(self.remote_name_edited)
    self.remote_name.textEdited.connect((lambda x: self.remote_name_edited()))
    self.remotes = QtWidgets.QListWidget()
    if (action == PUSH):
        mode = QtWidgets.QAbstractItemView.ExtendedSelection
        self.remotes.setSelectionMode(mode)
    self.remotes.addItems(self.model.remotes)
    self.remote_branch_label = QtWidgets.QLabel()
    self.remote_branch_label.setText(N_(u'Remote    Branch'))
    self.remote_branch = QtWidgets.QLineEdit()
    remote_branches = strip_remotes(self.model.remote_branches)
    qtutils.add_completer(self.remote_branch, remote_branches)
    self.remote_branches = QtWidgets.QListWidget()
    self.remote_branches.addItems(self.model.remote_branches)
    text = N_(u'Prompt    on    creation')
    tooltip = N_(u'Prompt    when    pushing    creates    new    remote    branches')
    self.prompt_checkbox = qtutils.checkbox(checked=True, text=text, tooltip=tooltip)
    text = N_(u'Fast-forward    only')
    tooltip = N_(u'Refuse    to    merge    unless    the    current    HEAD    is    already    up-to-date    or    the    merge    can    be    resolved    as    a    fast-forward')
    self.ff_only_checkbox = qtutils.checkbox(checked=True, text=text, tooltip=tooltip)
    text = N_(u'No    fast-forward')
    tooltip = N_(u'Create    a    merge    commit    even    when    the    merge    resolves    as    a    fast-forward')
    self.no_ff_checkbox = qtutils.checkbox(checked=False, text=text, tooltip=tooltip)
    text = N_(u'Force')
    tooltip = N_(u'Allow    non-fast-forward    updates.        Using    "force"    can    cause    the    remote    repository    to    lose    commits;    use    it    with    care')
    self.force_checkbox = qtutils.checkbox(checked=False, text=text, tooltip=tooltip)
    self.tags_checkbox = qtutils.checkbox(text=N_(u'Include    tags    '))
    self.prune_checkbox = qtutils.checkbox(text=N_(u'Prune    '))
    tooltip = N_(u'Rebase    the    current    branch    instead    of    merging')
    self.rebase_checkbox = qtutils.checkbox(text=N_(u'Rebase'), tooltip=tooltip)
    text = N_(u'Set    upstream')
    tooltip = N_(u'Configure    the    remote    branch    as    the    the    new    upstream')
    self.upstream_checkbox = qtutils.checkbox(text=text, tooltip=tooltip)
    self.action_button = qtutils.ok_button(title, icon=icon)
    self.close_button = qtutils.close_button()
    self.buttons = utils.Group(self.action_button, self.close_button)
    self.local_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.local_label, self.local_branch)
    self.remote_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_label, self.remote_name)
    self.remote_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_branch_label, self.remote_branch)
    self.options_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.close_button, qtutils.STRETCH, self.force_checkbox, self.ff_only_checkbox, self.no_ff_checkbox, self.tags_checkbox, self.prune_checkbox, self.rebase_checkbox, self.upstream_checkbox, self.prompt_checkbox, self.action_button)
    self.remote_input_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.remote_layout, self.remotes)
    self.local_branch_input_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.local_branch_layout, self.local_branches)
    self.remote_branch_input_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.remote_branch_layout, self.remote_branches)
    if (action == PUSH):
        widgets = (self.remote_input_layout, self.local_branch_input_layout, self.remote_branch_input_layout)
    else:
        widgets = (self.remote_input_layout, self.remote_branch_input_layout, self.local_branch_input_layout)
    self.top_layout = qtutils.hbox(defs.no_margin, defs.spacing, *widgets)
    self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.top_layout, self.options_layout)
    self.setLayout(self.main_layout)
    default_remote = (gitcmds.default_remote() or u'origin')
    remotes = self.model.remotes
    if (default_remote in remotes):
        idx = remotes.index(default_remote)
        if self.select_remote(idx):
            self.set_remote_name(default_remote)
    elif self.select_first_remote():
        self.set_remote_name(remotes[0])
    self.update_remotes()
    self.set_field_defaults()
    self.remotes.itemSelectionChanged.connect(self.update_remotes)
    local = self.local_branches
    local.itemSelectionChanged.connect(self.update_local_branches)
    remote = self.remote_branches
    remote.itemSelectionChanged.connect(self.update_remote_branches)
    self.no_ff_checkbox.toggled.connect((lambda x: uncheck(x, self.ff_only_checkbox, self.rebase_checkbox)))
    self.ff_only_checkbox.toggled.connect((lambda x: uncheck(x, self.no_ff_checkbox, self.rebase_checkbox)))
    self.rebase_checkbox.toggled.connect((lambda x: uncheck(x, self.no_ff_checkbox, self.ff_only_checkbox)))
    connect_button(self.action_button, self.action_callback)
    connect_button(self.close_button, self.close)
    qtutils.add_action(self, N_(u'Close'), self.close, QtGui.QKeySequence.Close, u'Esc')
    if (action != FETCH):
        self.prune_checkbox.hide()
    if (action != PUSH):
        self.upstream_checkbox.hide()
        self.prompt_checkbox.hide()
    if (action == PULL):
        self.force_checkbox.hide()
        self.tags_checkbox.hide()
        self.local_label.hide()
        self.local_branch.hide()
        self.local_branches.hide()
    else:
        self.rebase_checkbox.hide()
        self.no_ff_checkbox.hide()
        self.ff_only_checkbox.hide()
    self.init_size(parent=parent)
