ProjectDjango/DjangoDiffsettingsDataDialog.py

Sat, 24 Mar 2018 19:11:39 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 24 Mar 2018 19:11:39 +0100
changeset 125
d280acf98fb5
child 142
ecadd7fd0963
permissions
-rw-r--r--

- additions for Django > 1.9.0
- updated API files for Django 1.8 up to 2.0

# -*- coding: utf-8 -*-

# Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to enter the data for the 'diffsettings' command.
"""

from __future__ import unicode_literals

from PyQt5.QtWidgets import QDialog

from .Ui_DjangoDiffsettingsDataDialog import Ui_DjangoDiffsettingsDataDialog


class DjangoDiffsettingsDataDialog(QDialog, Ui_DjangoDiffsettingsDataDialog):
    """
    Class implementing a dialog to enter the data for the 'diffsettings'
    command.
    """
    def __init__(self, django, parent=None):
        """
        Constructor
        
        @param django reference to the Django project object
        @type Project
        @param parent reference to the parent widget
        @type QWidget
        """
        super(DjangoDiffsettingsDataDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.__version = django.getDjangoVersion()
        if self.__version < (1, 11, 0):
            self.defaultEdit.setEnabled(False)
        if self.__version < (2, 0, 0):
            self.formatComboBox.setEnabled(False)
        else:
            self.formatComboBox.addItem(self.tr("Hash Format"), "hash")
            self.formatComboBox.addItem(self.tr("Unified Diff"), "unified")
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    def getData(self):
        """
        Public method to get the dialog data.
        
        @return tuple containing a flag indicating to show all settings,
            the name of a module containing the default settings and the
            output format (Django 2.0.0+)
        @rtype tuple of (bool, str, str)
        """
        if self.__version < (2, 0, 0):
            outputFormat = ""
        else:
            outputFormat = self.formatComboBox.itemData(
                self.formatComboBox.currentIndex())
        
        return (self.allCheckBox.isChecked(), self.defaultEdit.text(),
                outputFormat)

eric ide

mercurial