Plugins/VcsPlugins/vcsPySvn/SvnRevisionSelectionDialog.py

Sun, 03 Nov 2013 15:58:22 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 03 Nov 2013 15:58:22 +0100
branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3057
10516539f238
parent 3037
a417a0670a36
child 3145
a9de05d4a22f
permissions
-rw-r--r--

Merge with default branch after fixed indentation issues and lates changes.

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

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

"""
Module implementing a dialog to enter the revisions for the svn diff command.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtCore import QDate, QDateTime, Qt
from PyQt4.QtGui import QDialog

from .Ui_SvnRevisionSelectionDialog import Ui_SvnRevisionSelectionDialog


class SvnRevisionSelectionDialog(QDialog, Ui_SvnRevisionSelectionDialog):
    """
    Class implementing a dialog to enter the revisions for the svn diff
    command.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent parent widget of the dialog (QWidget)
        """
        super(SvnRevisionSelectionDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.date1Edit.setDate(QDate.currentDate())
        self.date2Edit.setDate(QDate.currentDate())
        
    def __getRevision(self, no):
        """
        Private method to generate the revision.
        
        @param no revision number to generate (1 or 2)
        @return revision (integer or string)
        """
        if no == 1:
            numberButton = self.number1Button
            numberSpinBox = self.number1SpinBox
            dateButton = self.date1Button
            dateEdit = self.date1Edit
            timeEdit = self.time1Edit
            headButton = self.head1Button
            workingButton = self.working1Button
            baseButton = self.base1Button
            committedButton = self.committed1Button
            prevButton = self.prev1Button
        else:
            numberButton = self.number2Button
            numberSpinBox = self.number2SpinBox
            dateButton = self.date2Button
            dateEdit = self.date2Edit
            timeEdit = self.time2Edit
            headButton = self.head2Button
            workingButton = self.working2Button
            baseButton = self.base2Button
            committedButton = self.committed2Button
            prevButton = self.prev2Button
        
        if numberButton.isChecked():
            return numberSpinBox.value()
        elif dateButton.isChecked():
            return "{{{0}}}".format(
                QDateTime(dateEdit.date(), timeEdit.time())
                .toString(Qt.ISODate))
        elif headButton.isChecked():
            return "HEAD"
        elif workingButton.isChecked():
            return "WORKING"
        elif baseButton.isChecked():
            return "BASE"
        elif committedButton.isChecked():
            return "COMMITTED"
        elif prevButton.isChecked():
            return "PREV"
        
    def getRevisions(self):
        """
        Public method to get the revisions.
        
        @return list two integers or strings
        """
        rev1 = self.__getRevision(1)
        rev2 = self.__getRevision(2)
        
        return [rev1, rev2]

eric ide

mercurial