Project/UserPropertiesDialog.py

Mon, 25 Mar 2013 03:11:06 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 25 Mar 2013 03:11:06 +0100
branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
permissions
-rw-r--r--

Script changes: Future import added, super calls modified and unicode behavior for str.

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

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

"""
Module implementing the user specific project properties dialog.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtGui import QDialog

from E5Gui.E5Application import e5App

import Preferences

from .Ui_UserPropertiesDialog import Ui_UserPropertiesDialog


class UserPropertiesDialog(QDialog, Ui_UserPropertiesDialog):
    """
    Class implementing the user specific project properties dialog.
    """
    def __init__(self, project, parent=None, name=None):
        """
        Constructor
        
        @param project reference to the project object
        @param parent parent widget of this dialog (QWidget)
        @param name name of this dialog (string)
        """
        super(UserPropertiesDialog, self).__init__(parent)
        if name:
            self.setObjectName(name)
        self.setupUi(self)
        
        self.project = project
        
        if self.project.pudata["VCSSTATUSMONITORINTERVAL"]:
            self.vcsStatusMonitorIntervalSpinBox.setValue(
                self.project.pudata["VCSSTATUSMONITORINTERVAL"][0])
        else:
            self.vcsStatusMonitorIntervalSpinBox.setValue(
                Preferences.getVCS("StatusMonitorInterval"))
        
        enableVcsGroup = False
        if self.project.pdata["VCS"]:
            found = False
            for indicator, vcsData in list(e5App().getObject("PluginManager")\
                                             .getVcsSystemIndicators().items()):
                for vcsSystem, vcsSystemDisplay in vcsData:
                    if vcsSystem == self.project.pdata["VCS"][0]:
                        found = True
                        break
                
                if found:
                    for vcsSystem, vcsSystemDisplay in vcsData:
                        self.vcsInterfaceCombo.addItem(vcsSystemDisplay, vcsSystem)
                    enableVcsGroup = len(vcsData) > 1
                    break
        self.vcsGroup.setEnabled(enableVcsGroup)
        
        if self.vcsGroup.isEnabled():
            if self.project.pudata["VCSOVERRIDE"]:
                vcsSystem = self.project.pudata["VCSOVERRIDE"][0]
            else:
                vcsSystem = self.project.pdata["VCS"][0]
            index = self.vcsInterfaceCombo.findData(vcsSystem)
            if index == -1:
                index = 0
            self.vcsInterfaceCombo.setCurrentIndex(index)

    def storeData(self):
        """
        Public method to store the entered/modified data.
        """
        vcsStatusMonitorInterval = self.vcsStatusMonitorIntervalSpinBox.value()
        if vcsStatusMonitorInterval != Preferences.getVCS("StatusMonitorInterval"):
            self.project.pudata["VCSSTATUSMONITORINTERVAL"] = [vcsStatusMonitorInterval]
        else:
            self.project.pudata["VCSSTATUSMONITORINTERVAL"] = []
        
        if self.vcsGroup.isEnabled():
            vcsSystem = self.vcsInterfaceCombo\
                .itemData(self.vcsInterfaceCombo.currentIndex())
            if self.vcsInterfaceDefaultCheckBox.isChecked():
                if vcsSystem != self.project.pdata["VCS"][0]:
                    self.project.pdata["VCS"] = [vcsSystem]
                    self.project.pudata["VCSOVERRIDE"] = []
                    self.project.setDirty(True)
            else:
                if vcsSystem != self.project.pdata["VCS"][0]:
                    self.project.pudata["VCSOVERRIDE"] = [vcsSystem]
                else:
                    self.project.pudata["VCSOVERRIDE"] = []

eric ide

mercurial