Example #1
2
    def view(self):
        """create view and import layers"""
        layer = QgsMapLayerRegistry.instance().mapLayer(
                self.current_layers[0] )
        uri = QgsDataSourceURI(layer.source())
        mtch = re.match(r'(.+)_([^_]+)_rev_(head|\d+)', uri.schema())
        schema = mtch.group(1)
        assert(schema)
        dlg = QDialog()
        layout = QVBoxLayout(dlg)
        button_box = QDialogButtonBox(dlg)
        button_box.setStandardButtons(
                QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        button_box.accepted.connect(dlg.accept)
        button_box.rejected.connect(dlg.reject)

        pcur = versioning_base.Db( psycopg2.connect(self.pg_conn_info()) )
        pcur.execute("SELECT rev, commit_msg, branch, date, author "
            "FROM "+schema+".revisions")
        revs = pcur.fetchall()
        pcur.close()
        tblw = QTableWidget( dlg )
        tblw.setRowCount(len(revs))
        tblw.setColumnCount(5)
        tblw.setSortingEnabled(True)
        tblw.setHorizontalHeaderLabels(['Revision', 'Commit Message',
                                      'Branch', 'Date', 'Author'])
        tblw.verticalHeader().setVisible(False)
        for i, rev in enumerate(revs):
            for j, item in enumerate(rev):
                tblw.setItem(i, j, QTableWidgetItem( str(item) ))
        layout.addWidget( tblw )
        layout.addWidget( button_box )
        dlg.resize( 600, 300 )
        if not dlg.exec_() :
            return

        rows = set()
        for i in tblw.selectedIndexes():
            rows.add(i.row())
        for row in rows:
            branch = revs[row][2]
            rev = revs[row][0]
            versioning_base.add_revision_view(uri.connectionInfo(),
                    schema, branch, rev )
            grp_name = branch+' revision '+str(rev)
            grp_idx = self.iface.legendInterface().addGroup( grp_name )
            for layer_id in reversed(self.current_layers):
                layer = QgsMapLayerRegistry.instance().mapLayer(layer_id)
                new_uri = QgsDataSourceURI(layer.source())
                new_uri.setDataSource(schema+'_'+branch+'_rev_'+str(rev),
                        new_uri.table(),
                        new_uri.geometryColumn(),
                        new_uri.sql(),
                        new_uri.keyColumn())
                display_name =  QgsMapLayerRegistry.instance().mapLayer(layer_id).name()
                src = new_uri.uri().replace('()','')
                new_layer = self.iface.addVectorLayer( src,
                        display_name, 'postgres')
                self.iface.legendInterface().moveLayer( new_layer, grp_idx)
Example #2
0
    def __init__(self, opPixelClassification, parent):
        super( QDialog, self ).__init__(parent=parent)
        self._op = opPixelClassification
        classifier_listwidget = QListWidget(parent=self)
        classifier_listwidget.setSelectionMode( QListWidget.SingleSelection )

        classifier_factories = self._get_available_classifier_factories()
        for name, classifier_factory in classifier_factories.items():
            item = QListWidgetItem( name )
            item.setData( Qt.UserRole, QVariant(classifier_factory) )
            classifier_listwidget.addItem(item)

        buttonbox = QDialogButtonBox( Qt.Horizontal, parent=self )
        buttonbox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel )
        buttonbox.accepted.connect( self.accept )
        buttonbox.rejected.connect( self.reject )
        
        layout = QVBoxLayout()
        layout.addWidget( classifier_listwidget )
        layout.addWidget( buttonbox )

        self.setLayout(layout)
        self.setWindowTitle( "Select Classifier Type" )
        
        # Save members
        self._classifier_listwidget = classifier_listwidget
Example #3
0
    def __createLayout( self, pathsToAdd ):
        " Creates the dialog layout "

        self.resize( 640, 480 )
        self.setSizeGripEnabled( True )

        vboxLayout = QVBoxLayout( self )

        # Paths to add part
        vboxLayout.addWidget( QLabel( "Paths to add (total: " +
                                              str( len( pathsToAdd ) ) + ")" ) )

        self.__pathToAddView = QTreeWidget()
        self.__configTable( self.__pathToAddView )

        self.__pathToAddHeader = QTreeWidgetItem( [ "", "Path" ] )
        self.__pathToAddView.setHeaderItem( self.__pathToAddHeader )
        self.__pathToAddView.header().setSortIndicator( PATH_COL,
                                                        Qt.AscendingOrder )
        self.__pathToAddView.itemChanged.connect( self.__onAddPathChanged )
        vboxLayout.addWidget( self.__pathToAddView )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok |
                                      QDialogButtonBox.Cancel )
        self.__OKButton = buttonBox.button( QDialogButtonBox.Ok )
        self.__OKButton.setText( "Add" )
        buttonBox.button( QDialogButtonBox.Cancel ).setDefault( True )
        buttonBox.accepted.connect( self.userAccept )
        buttonBox.rejected.connect( self.close )
        vboxLayout.addWidget( buttonBox )
        return
Example #4
0
class SimpleRichTypesDialog(QDialog):
    """Simple dialog to display and change RichTypes"""

    def __init__(self, parent=None, windowTitle='', scrolling=True, text=''):
        QDialog.__init__(self, parent)
        self.mainLayout = QVBoxLayout(self)
        self.textLabel = QLabel(self)
        self.textLabel.setText(text)
        self.mainLayout.addWidget(self.textLabel)
        if scrolling:
            self.scrollArea = QScrollArea(self)
            self.mainLayout.addWidget(self.scrollArea)
            self.richTypesWidget = RichTypesWidget(self.scrollArea)
            self.scrollArea.setWidget(self.richTypesWidget)
            self.scrollArea.setWidgetResizable(False)
        else:
            self.richTypesWidget = RichTypesWidget(self)
            self.mainLayout.addWidget(self.richTypesWidget)
        self.buttonBox =  QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.NoButton | QDialogButtonBox.Ok)
        self.mainLayout.addWidget(self.buttonBox)
        QObject.connect(self.buttonBox, SIGNAL('accepted()'), self.accept)
        QObject.connect(self.buttonBox, SIGNAL('rejected()'), self.reject)
        self.setWindowTitle(windowTitle)
        self.result = None

    def addRichTypes(self, l):
        """set the list of richtypes"""
        self.richTypesWidget.addRichTypes(l)

    def accept(self):
        """after dialog closes, RichType list is available as self.result"""
        self.result = self.richTypesWidget.applyChanges()
        QDialog.accept(self)
class GoogleFinanceUrlSetupDialog(QDialog):

    SETTING_GOOGLE_URL = 'googleUrl'
    SETTING_GOOGLE_COUNTRY = 'googleCountry'

    def __init__(self, parent):

        QDialog.__init__(self, parent)

        self.prop = MaeMoneyProperties.instance()
        self.urls = {}
        self.urls[self.prop.GOOGLE_COUNTRY_HK] = 'www.google.com.hk'
        self.urls[self.prop.GOOGLE_COUNTRY_CN] = 'www.google.com.cn'
        self.urls[self.prop.GOOGLE_COUNTRY_CAN] = 'www.google.ca'
        self.urls[self.prop.GOOGLE_COUNTRY_UK] = 'www.google.co.uk'
        self.urls[self.prop.GOOGLE_COUNTRY_US] = 'www.google.com'

        self.setupUi()

    def setupUi(self):
        self.setWindowModality(Qt.WindowModal)
        self.buttonBox = QDialogButtonBox(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)

        self.gridLayout = QGridLayout()
        self.setLayout(self.gridLayout)

        self.labelGFinanceUrl = QLabel(self.tr("Google URL"))
        self.gridLayout.addWidget(self.labelGFinanceUrl, 0, 1, 1, 1)
        self.comboBoxGFinanceUrl = QComboBox()
        for [country, url] in sorted(self.urls.iteritems()):
            self.comboBoxGFinanceUrl.addItem(country, url)

        googleCountry = self.prop.getGoogleCountry()
        index = self.comboBoxGFinanceUrl.findText(googleCountry)
        self.comboBoxGFinanceUrl.setCurrentIndex(index)
        self.gridLayout.addWidget(self.comboBoxGFinanceUrl, 0, 2, 1, 1)

        self.gridLayout.addWidget(QLabel(self.tr("Current setting")), 1, 1, 1, 1)
        self.gridLayout.addWidget(QLabel(self.prop.getGoogleCountry()),
                                  1, 2, 1, 1)

        self.setUrlButton = QPushButton(self.tr("Set URL"))
        self.gridLayout.addWidget(self.setUrlButton, 2, 1, 1, 2)

        self.loginErrorMsgLabel = QLabel("")
        self.gridLayout.addWidget(self.loginErrorMsgLabel, 3, 1, 1, 2)

        self.setWindowTitle(self.tr("Setup"))

        self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
        self.connect(self.setUrlButton, SIGNAL("clicked()"), self.setUrl)

    def setUrl(self):
        indexSelected = self.comboBoxGFinanceUrl.currentIndex()
        country = self.comboBoxGFinanceUrl.itemText(indexSelected)
        url = self.comboBoxGFinanceUrl.itemData(indexSelected).toString().toAscii()
        self.prop.setGoogleCountryUrl(country, url)
        self.accept()
Example #6
0
    def __createLayout( self ):
        """ Creates the dialog layout """

        self.resize( 450, 20 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )

        # Info label
        self.infoLabel = QLabel( self )
        verticalLayout.addWidget( self.infoLabel )

        # Progress bar
        self.progressBar = QProgressBar( self )
        self.progressBar.setValue( 0 )
        self.progressBar.setOrientation( Qt.Horizontal )
        verticalLayout.addWidget( self.progressBar )

        # Buttons
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Close )
        verticalLayout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.__onClose )
        return
Example #7
0
    def __createLayout( self ):
        """ Creates the dialog layout """

        self.resize( 450, 20 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )

        # Info label
        self.infoLabel = QLabel( self )
        self.infoLabel.setTextFormat( 1 )
        self.infoLabel.setText( "Profiling of the " + self.__scriptName + \
                                 " script is in progress...<br>" \
                                 "<b>Note:</b> cancelling will try to " \
                                 "kill the profiler session." )
        verticalLayout.addWidget( self.infoLabel )

        # Buttons
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Cancel )
        self.__cancelButton = buttonBox.button( QDialogButtonBox.Cancel )
        verticalLayout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.__onClose )
        return
Example #8
0
    def __init__(self, password, parent=None):
        super(AuthenDlg, self).__init__(parent)
        self.setWindowTitle('Authentication')
        self.password = password
        layout = QGridLayout(self)

        desc = QLabel()
        if self.password != "":#authentication is required only once Once it is correct
            desc.setText("Caution! your action will be recorded on the logbook\n \
Click OK if you want to continue, otherwise click Cancel")
        else: 
            desc.setText("Your action will be recorded on the logbook\n \
Please enter your password if you want to continue\n \
Otherwise Click Cancel \n")       
            self.passWdLineEdit = QLineEdit()
            self.passWdLineEdit.setEchoMode(QLineEdit.Password)
            vbox = QVBoxLayout()
            vbox.addWidget(self.passWdLineEdit)
            vbox.addStretch(1)    
            QObject.connect(self.passWdLineEdit, SIGNAL(_fromUtf8("textChanged(QString)")), 
                        self.getPassWd)
            layout.addWidget(self.passWdLineEdit,1,0,1,1)
        
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        QObject.connect(buttonBox, SIGNAL("rejected()"), self.reject)
        QObject.connect(buttonBox, SIGNAL("accepted()"), self.accept)
        
        layout.addWidget(desc,0,0,1,1)
        layout.addWidget(buttonBox,2,0,1,1)
        self.setLayout(layout)
Example #9
0
    def __createLayout( self ):
        " Creates the dialog layout "

        self.resize( 300, 50 )
        self.setSizeGripEnabled( True )

        # Top level layout
        layout = QVBoxLayout( self )

        gridLayout = QGridLayout()
        nameLabel = QLabel( "Name" )
        gridLayout.addWidget( nameLabel, 0, 0 )
        valueLabel = QLabel( "Value" )
        gridLayout.addWidget( valueLabel, 1, 0 )
        self.__nameEdit = QLineEdit()
        self.__nameEdit.textChanged.connect( self.__nameChanged )
        gridLayout.addWidget( self.__nameEdit, 0, 1 )
        self.__valueEdit = QLineEdit()
        self.__valueEdit.textChanged.connect( self.__valueChanged )
        gridLayout.addWidget( self.__valueEdit, 1, 1 )
        layout.addLayout( gridLayout )

        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok |
                                      QDialogButtonBox.Cancel )
        self.__OKButton = buttonBox.button( QDialogButtonBox.Ok )
        self.__OKButton.setDefault( True )
        buttonBox.accepted.connect( self.accept )
        buttonBox.rejected.connect( self.close )
        layout.addWidget( buttonBox )
        return
Example #10
0
class Login(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self)
        self.parent = parent
        self.resize(270, 160)
        self.verticalLayout = QVBoxLayout(self)
        self.label_username = QLabel(self)
        self.verticalLayout.addWidget(self.label_username)
        self.username = QLineEdit(self)
        self.verticalLayout.addWidget(self.username)
        self.label_password = QLabel(self)
        self.verticalLayout.addWidget(self.label_password)
        self.password = QLineEdit(self)
        self.password.setEchoMode(QLineEdit.Password)
        self.verticalLayout.addWidget(self.password)
        self.save_password = QCheckBox(self)
        self.verticalLayout.addWidget(self.save_password)
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(
                QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)
        self.label_username.setBuddy(self.username)
        self.label_password.setBuddy(self.password)
        self.setWindowIcon(get_icon(MAIL_IMAGE))
        self.setWindowTitle("Gmail Login")
        self.label_username.setText("Username")
        self.label_password.setText("Password")
        self.save_password.setText("Save password")
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
Example #11
0
 class Dial(QDialog):
     choices =['flat', 'hanning', 'hamming', 'bartlett', 'blackman']
     def __init__(self, parent):
         QDialog.__init__(self, parent)
         f =QFormLayout(self)
         self.a =QSpinBox(self)
         self.a.setValue(30)
         self.b = QComboBox(self)
         self.b.addItems(self.choices)
         self.c= QDialogButtonBox(self)
         self.c.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
         f.addRow("window:" ,self.a)
         f.addRow("method:", self.b)
         f.addRow("", self.c)
         self.connect(self.c, SIGNAL("accepted()"), self.sendData)
         self.connect(self.c, SIGNAL("rejected()"), self.reinitialize)
     
     def sendData(self):
         self.parent().window = self.a.value()
         self.parent().method = self.b.currentText()
         self.close()
     
     def reinitialize(self):
         self.parent().window = None
         self.parent().method = None
         self.close()
Example #12
0
    def __init__(self, interface, net=None, parent=None):
        CentralDialog.__init__(self, parent)

        self.net=net
        self.interface = interface

        self.editor = NetFrame(interface, net=net)
        #easy accessors
        self.net_label = self.editor.net_label
        self.ip_addrs = self.editor.ip_addrs
        self.net_ip = self.editor.net_ip

        button_box = QDialogButtonBox()
        button_box.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok |QDialogButtonBox.Help)
        self.ok_button = button_box.Ok
        self.connectButtons(button_box)

        #layout
        box = QVBoxLayout(self)
        box.addWidget(self.editor)
        box.addWidget(button_box)

        self.connect(self.editor, SIGNAL("change title"), self.changeTitle)
        self.editor.changeTitle()

        self.acceptableInput()
    def __init__(self, channel_names, feature_names, default_selections=None, parent=None):
        """
        Parameters
        ----------
        channel_names
            *list of str*
            The user will be shown a separate checklist of feature options for each channel.
        
        feature_names
            *list of str*
            Feature names, exactly as expected by :py:meth:`~ilastikrag.rag.Rag.compute_features()`.
            The features will be grouped by category and shown in duplicate checklist widgets for each channel.
        
        default_selections
            *dict, str: list-of-str*
            Mapping from channel_name -> feature_names, indicating which
            features should be selected by default for each channel.
        
        parent
            *QWidget*
        """
        super(FeatureSelectionDialog, self).__init__(parent)
        
        self.setWindowTitle("Select Edge Features")
        self.tree_widgets = {}

        self.checklist_widgets = OrderedDict()
        boxes_layout = QHBoxLayout()
        for channel_name in channel_names:
            default_checked = []
            if default_selections and channel_name in default_selections:
                default_checked = default_selections[channel_name]
            checklist = _make_checklist(feature_names, default_checked)
            checklist.name = channel_name
            checklist_widget = HierarchicalChecklistView( checklist, parent=self )
            self.checklist_widgets[channel_name] = checklist_widget
            boxes_layout.addWidget(checklist_widget)

        buttonbox = QDialogButtonBox( Qt.Horizontal, parent=self )
        buttonbox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel )
        buttonbox.accepted.connect( self.accept )
        buttonbox.rejected.connect( self.reject )

        widget_layout = QVBoxLayout()

        # FIXME: Would like to hold the TreeWidgets in a QScrollArea,
        #        but they don't seem to respect fixed size policies,
        #        so the scroll area never shows a scrollbar...
        #scrollarea = QScrollArea()
        #scrollarea.setLayout(boxes_layout)
        #widget_layout.addWidget(scrollarea)
        widget_layout.addLayout(boxes_layout)

        widget_layout.addWidget(buttonbox)
        self.setLayout(widget_layout)

        total_spacing = self.width() - (len(channel_names)*checklist_widget.width())
        total_width = total_spacing + len(channel_names) * ( 20 + checklist_widget.columnWidth(0) )
        self.resize(total_width, 500)
Example #14
0
class NewProjectDirDialog( QDialog, object ):
    " New project directory dialog "

    def __init__( self, parent = None ):
        QDialog.__init__( self, parent )

        self.__dirnameEdit = None
        self.__buttonBox = None
        self.__createLayout()

        self.okButton = self.__buttonBox.button( QDialogButtonBox.Ok )
        self.okButton.setEnabled( False )
        return

    def __createLayout( self ):
        " Creates the dialog layout "

        self.resize( 400, 100 )
        self.setWindowTitle( "Create subdirectory" )
        vboxlayout = QVBoxLayout( self )

        inputLabel = QLabel( self )
        inputLabel.setText( "Type new subdirectory name" )
        vboxlayout.addWidget( inputLabel )

        self.__dirnameEdit = QLineEdit( self )
        self.__dirnameEdit.setToolTip( "Subdirectory name without "
                                       "path separators" )
        self.__dirnameEdit.installEventFilter( self )
        self.__dirnameEdit.textEdited.connect( self.__onTextChanged )
        vboxlayout.addWidget( self.__dirnameEdit )

        self.__buttonBox = QDialogButtonBox( self )
        self.__buttonBox.setOrientation( Qt.Horizontal )
        self.__buttonBox.setStandardButtons( QDialogButtonBox.Cancel |
                                             QDialogButtonBox.Ok )
        vboxlayout.addWidget( self.__buttonBox )

        self.__buttonBox.accepted.connect( self.accept )
        self.__buttonBox.rejected.connect( self.reject )
        return

    def __onTextChanged( self, text ):
        " Triggered when the input text has been changed "
        self.okButton.setEnabled( text != "" )
        return

    def getDirName( self ):
        " Provides the user input "
        return self.__dirnameEdit.text()

    def eventFilter( self, obj, event ):
        " Event filter for the project name field "

        # Do not allow path separators
        if event.type() == QEvent.KeyPress:
            if event.key() == ord( os.path.sep ):
                return True
        return QObject.eventFilter( self, obj, event )
class config_window(QDialog):

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setMaximumSize(QSize(0, 0))
        self.setMinimumSize(500, 0)
        self.setWindowTitle('Minecraft Backup Manager - Configuration')

        #STANNDARD BUTTONS
        self.button_box = QDialogButtonBox(self)
        self.button_box.setStandardButtons(QDialogButtonBox.Cancel |
             QDialogButtonBox.Save)

        #input_save_folder
        self.input_save_folder = QLineEdit(self)
        self.input_save_folder.setText(load_config('save_backup_folder'))
        self.input_save_folder.setToolTip('Default folder save backup')

        #change_save_folder
        self.btn_save_folder = QPushButton('Change', self)

        #LAYOUTS
        #Save Folder Layout
        self.layout_save_folder = QHBoxLayout()
        self.layout_save_folder.addWidget(QLabel('Save folder:', self))
        self.layout_save_folder.addWidget(self.input_save_folder)
        self.layout_save_folder.addWidget(self.btn_save_folder)

        #Button Box Layout
        self.layout_button_box = QHBoxLayout()
        self.layout_button_box.setContentsMargins(0, 25, 0, 0)
        self.layout_button_box.addWidget(self.button_box)

        #Vertical Container Layout
        self.Vcontainer = QVBoxLayout(self)
        self.Vcontainer.addLayout(self.layout_save_folder)
        self.Vcontainer.addLayout(self.layout_button_box)

        #CONNECT SIGNALS
        self.connect(self.btn_save_folder, SIGNAL('clicked()'),
                     self.change_save_folder)
        self.connect(self.button_box, SIGNAL('accepted()'),
                     self.save_configurations)
        self.connect(self.button_box, SIGNAL('rejected()'), self.close)

    def change_save_folder(self):
        self.file_dialog = QFileDialog.getExistingDirectory(self,
                           'Change Default folder save backup',
                           directory=self.input_save_folder.text())

        if self.file_dialog != '':
            self.input_save_folder.setText(self.file_dialog)

    def save_configurations(self):
        self.backup_folder = str(self.input_save_folder.text().toUtf8())

        save_new_config(self.backup_folder)
        self.close()
Example #16
0
    def checkout_pg(self):
        """create postgres working copy (schema) from versioned
        database layers"""
        # for each connection, we need the list of tables
        tables_for_conninfo = []
        uri = None
        conn_info = ''
        for layer_id in self.current_layers:
            layer = QgsMapLayerRegistry.instance().mapLayer( layer_id )
            uri = QgsDataSourceURI(layer.source())
            if not conn_info:
                conn_info = uri.connectionInfo()
            else:
                assert(conn_info == uri.connectionInfo())
            table =  uri.schema()+"."+uri.table()
            tables_for_conninfo.append(table)


        dlg = QDialog()
        dlg.setWindowTitle('Enter working copy schema name')
        layout = QVBoxLayout(dlg)
        button_box = QDialogButtonBox(dlg)
        button_box.setStandardButtons(
                QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
        button_box.accepted.connect(dlg.accept)
        button_box.rejected.connect(dlg.reject)

        line_edit = QLineEdit( dlg )
        layout.addWidget( line_edit )
        layout.addWidget( button_box )
        if not dlg.exec_() :
            return
        working_copy_schema = line_edit.text()
        if not working_copy_schema:
            print "aborted"
            return

        print "checking out ", tables_for_conninfo, " from ", uri.connectionInfo()
        versioning_base.pg_checkout( self.pg_conn_info(),
                tables_for_conninfo, working_copy_schema )

        # add layers from offline version
        grp_idx = self.iface.legendInterface().addGroup( working_copy_schema )
        for layer_id in reversed(self.current_layers):
            layer = QgsMapLayerRegistry.instance().mapLayer( layer_id )
            new_uri = QgsDataSourceURI(layer.source())
            new_uri.setDataSource(working_copy_schema,
                    new_uri.table()+"_view",
                    new_uri.geometryColumn(),
                    new_uri.sql(),
                    new_uri.keyColumn())
            display_name =  QgsMapLayerRegistry.instance().mapLayer(layer_id).name()
            print "replacing ", display_name
            src = new_uri.uri().replace('()','')
            new_layer = self.iface.addVectorLayer(src, display_name, 'postgres')
            self.iface.legendInterface().moveLayer( new_layer, grp_idx)
Example #17
0
    def __createLayout( self, bpoint ):
        """ Creates the dialog layout """

        self.resize( 400, 150 )
        self.setSizeGripEnabled( True )

        # Top level layout
        layout = QVBoxLayout( self )

        gridLayout = QGridLayout()
        fileLabel = QLabel( "File name:" )
        gridLayout.addWidget( fileLabel, 0, 0 )
        fileValue = QLabel( bpoint.getAbsoluteFileName() )
        gridLayout.addWidget( fileValue, 0, 1 )
        lineLabel = QLabel( "Line:" )
        gridLayout.addWidget( lineLabel, 1, 0 )
        lineValue = QLabel( str( bpoint.getLineNumber() ) )
        gridLayout.addWidget( lineValue, 1, 1 )
        conditionLabel = QLabel( "Condition:" )
        gridLayout.addWidget( conditionLabel, 2, 0 )
        self.__conditionValue = CDMComboBox( True )
        self.__conditionValue.lineEdit().setText( bpoint.getCondition() )
        gridLayout.addWidget( self.__conditionValue, 2, 1 )
        ignoreLabel = QLabel( "Ignore count:" )
        gridLayout.addWidget( ignoreLabel, 3, 0 )
        self.__ignoreValue = QSpinBox()
        self.__ignoreValue.setMinimum( 0 )
        self.__ignoreValue.setValue( bpoint.getIgnoreCount() )
        gridLayout.addWidget( self.__ignoreValue, 3, 1 )
        layout.addLayout( gridLayout )

        # Checkboxes part
        self.__tempCheckbox = QCheckBox( "&Temporary" )
        self.__tempCheckbox.setChecked( bpoint.isTemporary() )
        layout.addWidget( self.__tempCheckbox )
        self.__enabled = QCheckBox( "&Enabled" )
        self.__enabled.setChecked( bpoint.isEnabled() )
        layout.addWidget( self.__enabled )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok |
                                      QDialogButtonBox.Cancel )
        self.__OKButton = buttonBox.button( QDialogButtonBox.Ok )
        self.__OKButton.setDefault( True )
        buttonBox.accepted.connect( self.accept )
        buttonBox.rejected.connect( self.close )
        layout.addWidget( buttonBox )

        self.__conditionValue.setFocus()
        return
Example #18
0
    def __createLayout( self, paths, ignoredPaths ):
        " Creates the dialog layout "

        self.resize( 640, 420 )
        self.setSizeGripEnabled( True )

        vboxLayout = QVBoxLayout( self )

        # Paths to commit part
        vboxLayout.addWidget( QLabel( "Paths (total: " +
                              str( len( paths ) ) + ")" ) )

        self.__pathView = QTreeWidget()
        self.__pathView.setAlternatingRowColors( True )
        self.__pathView.setRootIsDecorated( False )
        self.__pathView.setItemsExpandable( False )
        self.__pathView.setSortingEnabled( True )
        self.__pathView.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        self.__pathView.setUniformRowHeights( True )

        self.__pathHeader = QTreeWidgetItem( [ "", "Path", "Status", "Message" ] )
        self.__pathView.setHeaderItem( self.__pathHeader )
        self.__pathView.header().setSortIndicator( 1, Qt.AscendingOrder )
        vboxLayout.addWidget( self.__pathView )

        # Paths to ignore part
        vboxLayout.addWidget( QLabel( "Ignored paths (total: " +
                              str( len( ignoredPaths ) ) + ")" ) )

        self.__ignoredPathView = QTreeWidget()
        self.__ignoredPathView.setAlternatingRowColors( True )
        self.__ignoredPathView.setRootIsDecorated( False )
        self.__ignoredPathView.setItemsExpandable( False )
        self.__ignoredPathView.setSortingEnabled( True )
        self.__ignoredPathView.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        self.__ignoredPathView.setUniformRowHeights( True )

        pathToIgnoreHeader = QTreeWidgetItem( [ "Path", "Status" ] )
        self.__ignoredPathView.setHeaderItem( pathToIgnoreHeader )
        self.__ignoredPathView.header().setSortIndicator( 0, Qt.AscendingOrder )
        vboxLayout.addWidget( self.__ignoredPathView )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok )
        buttonBox.button( QDialogButtonBox.Ok ).setDefault( True )
        buttonBox.accepted.connect( self.accept )
        vboxLayout.addWidget( buttonBox )
        return
Example #19
0
class AppLocaleSetupDialog(QDialog):
    def __init__(self, parent):

        QDialog.__init__(self, parent)

        self.prop = MaeMoneyProperties.instance()
        self.locales = {}
        self.locales[self.prop.LANGUAGE_ZH_CN] = self.prop.LOCALE_ZH_CN
        self.locales[self.prop.LANGUAGE_ZH_HK] = self.prop.LOCALE_ZH_HK
        self.locales[self.prop.LANGUAGE_EN_US] = self.prop.LOCALE_EN_US

        self.setupUi()

    def setupUi(self):
        self.setWindowModality(Qt.WindowModal)
        self.buttonBox = QDialogButtonBox(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)

        self.gridLayout = QGridLayout()
        self.setLayout(self.gridLayout)

        self.labelAppLocale = QLabel(u"語言 Language")
        self.gridLayout.addWidget(self.labelAppLocale, 0, 1, 1, 1)
        self.comboBoxAppLocale = QComboBox()
        for [lang, appLocale] in sorted(self.locales.iteritems()):
            self.comboBoxAppLocale.addItem(lang, appLocale)

        language = self.prop.getAppLanguage()
        index = self.comboBoxAppLocale.findText(language)
        self.comboBoxAppLocale.setCurrentIndex(index)
        self.gridLayout.addWidget(self.comboBoxAppLocale, 0, 2, 1, 1)

        self.gridLayout.addWidget(QLabel(self.tr("Current setting")), 1, 1, 1, 1)
        self.gridLayout.addWidget(QLabel(self.prop.getAppLanguage()), 1, 2, 1, 1)

        self.setLanguageButton = QPushButton(self.tr("Set language"))
        self.gridLayout.addWidget(self.setLanguageButton, 2, 1, 1, 2)

        self.setWindowTitle(self.tr("Language setup"))

        self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
        self.connect(self.setLanguageButton, SIGNAL("clicked()"), self.setLanguage)

    def setLanguage(self):
        indexSelected = self.comboBoxAppLocale.currentIndex()
        locale = self.comboBoxAppLocale.itemData(indexSelected)
        self.prop.setAppLocale(locale)
        self.accept()
Example #20
0
    def __createLayout( self ):
        """ Creates the dialog layout """

        self.resize( 400, 100 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )

        # Check boxes
        self.includeClassesBox = QCheckBox( self )
        self.includeClassesBox.setText( "Show &classes in modules" )
        self.includeClassesBox.setChecked( self.options.includeClasses )
        self.includeClassesBox.stateChanged.connect( self.__updateOptions )
        self.includeFuncsBox = QCheckBox( self )
        self.includeFuncsBox.setText( "Show &functions in modules" )
        self.includeFuncsBox.setChecked( self.options.includeFuncs )
        self.includeFuncsBox.stateChanged.connect( self.__updateOptions )
        self.includeGlobsBox = QCheckBox( self )
        self.includeGlobsBox.setText( "Show &global variables in modules" )
        self.includeGlobsBox.setChecked( self.options.includeGlobs )
        self.includeGlobsBox.stateChanged.connect( self.__updateOptions )
        self.includeDocsBox = QCheckBox( self )
        self.includeDocsBox.setText( "Show modules &docstrings" )
        self.includeDocsBox.setChecked( self.options.includeDocs )
        self.includeDocsBox.stateChanged.connect( self.__updateOptions )
        self.includeConnTextBox = QCheckBox( self )
        self.includeConnTextBox.setText( "Show connection &labels" )
        self.includeConnTextBox.setChecked( self.options.includeConnText )
        self.includeConnTextBox.stateChanged.connect( self.__updateOptions )

        verticalLayout.addWidget( self.includeClassesBox )
        verticalLayout.addWidget( self.includeFuncsBox )
        verticalLayout.addWidget( self.includeGlobsBox )
        verticalLayout.addWidget( self.includeDocsBox )
        verticalLayout.addWidget( self.includeConnTextBox )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Cancel )
        generateButton = buttonBox.addButton( "Generate",
                                              QDialogButtonBox.ActionRole )
        generateButton.setDefault( True )
        generateButton.clicked.connect( self.accept )
        verticalLayout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.close )
        return
Example #21
0
    def __createLayout( self ):
        " Creates the dialog layout "
        self.resize( 450, 20 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )
        self.__infoLabel = QLabel( "Annotating '" + self.__path + "'..." )
        verticalLayout.addWidget( self.__infoLabel )

        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Close )
        verticalLayout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.__onClose )
        return
Example #22
0
class AboutBox(QDialog):
    def __init__(self, parent, app):
        flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint
        QDialog.__init__(self, parent, flags)
        self.app = app
        self._setupUi()
        
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
    
    def _setupUi(self):
        self.setWindowTitle(tr("About {}").format(QCoreApplication.instance().applicationName()))
        self.resize(400, 190)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        self.horizontalLayout = QHBoxLayout(self)
        self.logoLabel = QLabel(self)
        self.logoLabel.setPixmap(QPixmap(':/%s_big' % self.app.LOGO_NAME))
        self.horizontalLayout.addWidget(self.logoLabel)
        self.verticalLayout = QVBoxLayout()
        self.nameLabel = QLabel(self)
        font = QFont()
        font.setWeight(75)
        font.setBold(True)
        self.nameLabel.setFont(font)
        self.nameLabel.setText(QCoreApplication.instance().applicationName())
        self.verticalLayout.addWidget(self.nameLabel)
        self.versionLabel = QLabel(self)
        self.versionLabel.setText(tr("Version {}").format(QCoreApplication.instance().applicationVersion()))
        self.verticalLayout.addWidget(self.versionLabel)
        self.label_3 = QLabel(self)
        self.verticalLayout.addWidget(self.label_3)
        self.label_3.setText(tr("Copyright Hardcoded Software 2014"))
        self.label = QLabel(self)
        font = QFont()
        font.setWeight(75)
        font.setBold(True)
        self.label.setFont(font)
        self.verticalLayout.addWidget(self.label)
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)
        self.horizontalLayout.addLayout(self.verticalLayout)
Example #23
0
    def __createLayout( self, fileName, info ):
        """ Creates the dialog layout """

        self.resize( 600, 220 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )

        # Info label
        infoLabel = FitLabel( self )
        sizePolicy = QSizePolicy( QSizePolicy.Minimum, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(infoLabel.sizePolicy().hasHeightForWidth())
        infoLabel.setSizePolicy( sizePolicy )
        infoLabel.setText( "Lexer/parser errors for " + fileName )
        verticalLayout.addWidget( infoLabel )

        # Result window
        resultEdit = QTextEdit( self )
        resultEdit.setTabChangesFocus( False )
        resultEdit.setAcceptRichText( False )
        resultEdit.setReadOnly( True )
        resultEdit.setFontFamily( GlobalData().skin.baseMonoFontFace )
        if info is not None:
            modInfo = info
        else:
            modInfo = GlobalData().briefModinfoCache.get( fileName )
        if modInfo.isOK:
            resultEdit.setText( "No errors found" )
        else:
            resultEdit.setText( "\n".join( modInfo.lexerErrors +
                                           modInfo.errors ) )
        verticalLayout.addWidget( resultEdit )

        # Buttons
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Close )
        verticalLayout.addWidget( buttonBox )

        buttonBox.rejected.connect( self.close )
        return
Example #24
0
    def __createLayout( self ):
        " Creates the dialog layout "
        self.resize( 640, 480 )
        self.setSizeGripEnabled( True )

        vboxLayout = QVBoxLayout( self )
        hboxLayout = QHBoxLayout()
        iconLabel = QLabel()
        iconLabel.setPixmap( PixmapCache().getPixmap( "logo-48x48.png" ) )
        iconLabel.setScaledContents( False )
        hboxLayout.addWidget( iconLabel )
        versionLabel = QLabel( "<b>Codimension IDE version " +
                               str( GlobalData().version ) + "<br>"
                               "CML version " +
                               str( CMLVersion.VERSION ) +
                               "</b><p>Copyright (c) Sergey Satskiy 2010-2016</p>" )
        versionLabel.setSizePolicy( QSizePolicy.Expanding,
                                    QSizePolicy.Expanding )
        versionLabel.setFixedHeight( versionLabel.minimumSizeHint().height() )
        versionLabel.setAlignment( Qt.AlignCenter )
        hboxLayout.addWidget( versionLabel )
        vboxLayout.addLayout( hboxLayout )

        tabWidget = QTabWidget( self )
        tabWidget.setFocusPolicy( Qt.NoFocus )

        description = self.__createDescription()
        tabWidget.addTab( description, "About" )
        versioning = self.__createVersioning()
        tabWidget.addTab( versioning, "Versions and licenses" )
        authors = self.__createAuthors()
        tabWidget.addTab( authors, "Contributors" )
        vboxLayout.addWidget( tabWidget )

        # Button at the bottom
        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok )
        buttonBox.accepted.connect( self.close )
        buttonBox.rejected.connect( self.close )
        vboxLayout.addWidget( buttonBox )
        return
            def __init__(self, source_stage_index, num_stages, *args, **kwargs):
                super(LabelDistributionOptionsDlg, self).__init__(*args, **kwargs)

                from PyQt4.QtCore import Qt
                from PyQt4.QtGui import QGroupBox, QCheckBox, QRadioButton, QDialogButtonBox
            
                self.setWindowTitle("Distributing from Stage {}".format(source_stage_index+1))

                self.stage_checkboxes = []
                for stage_index in range(1, num_stages+1):
                    self.stage_checkboxes.append( QCheckBox("Stage {}".format( stage_index )) )
                
                # By default, send labels back into the current stage, at least.
                self.stage_checkboxes[source_stage_index].setChecked(True)
                
                stage_selection_layout = QVBoxLayout()
                for checkbox in self.stage_checkboxes:
                    stage_selection_layout.addWidget( checkbox )

                stage_selection_groupbox = QGroupBox("Send labels from Stage {} to:".format( source_stage_index+1 ), self)
                stage_selection_groupbox.setLayout(stage_selection_layout)
                
                self.copy_button = QRadioButton("Copy", self)
                self.partition_button = QRadioButton("Partition", self)
                self.partition_button.setChecked(True)
                distribution_mode_layout = QVBoxLayout()
                distribution_mode_layout.addWidget(self.copy_button)
                distribution_mode_layout.addWidget(self.partition_button)
                
                distribution_mode_group = QGroupBox("Distribution Mode", self)
                distribution_mode_group.setLayout(distribution_mode_layout)
                
                buttonbox = QDialogButtonBox( Qt.Horizontal, parent=self )
                buttonbox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel )
                buttonbox.accepted.connect( self.accept )
                buttonbox.rejected.connect( self.reject )
                
                dlg_layout = QVBoxLayout()
                dlg_layout.addWidget(stage_selection_groupbox)
                dlg_layout.addWidget(distribution_mode_group)
                dlg_layout.addWidget(buttonbox)
                self.setLayout(dlg_layout)
Example #26
0
 def __init__(self, datasetNames, parent):
     super(H5VolumeSelectionDlg, self).__init__(parent)                        
     label = QLabel( "Your HDF5 File contains multiple image volumes.\n"
                     "Please select the one you would like to open." )
     
     self.combo = QComboBox()
     for name in datasetNames:
         self.combo.addItem(name)
     
     buttonbox = QDialogButtonBox( Qt.Horizontal, parent=self )
     buttonbox.setStandardButtons( QDialogButtonBox.Ok | QDialogButtonBox.Cancel )
     buttonbox.accepted.connect( self.accept )
     buttonbox.rejected.connect( self.reject )
     
     layout = QVBoxLayout()
     layout.addWidget( label )
     layout.addWidget( self.combo )
     layout.addWidget( buttonbox )
     
     self.setLayout(layout)
Example #27
0
            def __init__(self):
                QtGui.QWidget.__init__(self)
                layout = QVBoxLayout(self)
                self.setWindowTitle("Preprocessing")
                self.cbox1 = QCheckBox("Normalize")
                self.cbox2 = QCheckBox("Standardize")
                self.cbox3 = QCheckBox("Remove examples containing:")

                text_area = QLineEdit(self.cbox3)
                text_area.setText("?")
                dbx = QDialogButtonBox(self)
                dbx.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
                # self.connect(dbx, SIGNAL("accepted()"), dbx, SLOT("accept()"))
                # self.connect(dbx, SIGNAL("rejected()"), dbx, SLOT("reject()"))
                layout.addWidget(self.cbox1)
                layout.addWidget(self.cbox2)
                layout.addWidget(self.cbox3)
                layout.addWidget(text_area)
                layout.addWidget(dbx, alignment=Qt.AlignCenter)
                self.setLayout(layout)
Example #28
0
    def __createLayout( self ):
        """ Creates the dialog layout """

        self.resize( 450, 150 )
        self.setSizeGripEnabled( True )

        verticalLayout = QVBoxLayout( self )

        whereGroupbox = QGroupBox( self )
        whereGroupbox.setTitle( "Garbage collector message destination" )
        sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred )
        sizePolicy.setHorizontalStretch( 0 )
        sizePolicy.setVerticalStretch( 0 )
        sizePolicy.setHeightForWidth(
                        whereGroupbox.sizePolicy().hasHeightForWidth() )
        whereGroupbox.setSizePolicy( sizePolicy )

        layoutWhere = QVBoxLayout( whereGroupbox )
        self.__silentRButton = QRadioButton( whereGroupbox )
        self.__silentRButton.setText( "Silent" )
        layoutWhere.addWidget( self.__silentRButton )
        self.__statusbarRButton = QRadioButton( whereGroupbox )
        self.__statusbarRButton.setText( "Status bar" )
        layoutWhere.addWidget( self.__statusbarRButton )
        self.__logtabRButton = QRadioButton( whereGroupbox )
        self.__logtabRButton.setText( "Log tab" )
        layoutWhere.addWidget( self.__logtabRButton )

        verticalLayout.addWidget( whereGroupbox )

        buttonBox = QDialogButtonBox( self )
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Ok |
                                      QDialogButtonBox.Cancel )
        self.__OKButton = buttonBox.button( QDialogButtonBox.Ok )
        self.__OKButton.setDefault( True )
        buttonBox.accepted.connect( self.accept )
        buttonBox.rejected.connect( self.close )
        verticalLayout.addWidget( buttonBox )
        return
Example #29
0
class ResourceChooserDialogUi(object):

    def setupUi(self, dialog, nepomukType=None, excludeList=None):
        
        self.dialog = dialog
        dialog.setObjectName("dialog")
        dialog.resize(500, 300)
        self.gridlayout = QGridLayout(dialog)
        self.gridlayout.setMargin(9)
        self.gridlayout.setSpacing(6)
        self.gridlayout.setObjectName("gridlayout")

        self.table = ResourcesByTypeTable(mainWindow=dialog.parent(), nepomukType=nepomukType, excludeList=excludeList, dialog=self)
        self.table.table.setColumnWidth(0,250)
        
        self.gridlayout.addWidget(self.table, 0, 0, 1, 1)
      
        self.buttonBox = QDialogButtonBox(dialog)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.NoButton | QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridlayout.addWidget(self.buttonBox, 1, 0, 1, 1)

        self.retranslateUi(dialog)
      
        self.table.table.activated.connect(self.activated)
        
        self.buttonBox.accepted.connect(dialog.accept)
        self.buttonBox.rejected.connect(dialog.reject)
        QMetaObject.connectSlotsByName(dialog)
        
        #dialog.setTabOrder(self.firstname, self.yearSpinBox)
        #dialog.setTabOrder(self.yearSpinBox, self.minutesSpinBox)
        
    def activated(self, index):
        if index.isValid():
            self.dialog.accept()

    def retranslateUi(self, dialog):
        dialog.setWindowTitle(i18n("Link to..."))
    def __init__(self, eventIDs, parent=None):
        super(ShowSelectRefDlg, self).__init__(parent)
        self.setWindowTitle('Select reference snapshot')
        self.eventIDs=eventIDs
        self.refSnapshot = ""
        #print(self.eventIDs)
        
        desc = QLabel()
        desc.setText("%d snapshots with IDs %s to be compared.\n\n\
Please select one as the reference snapshot\n\n"%(len(eventIDs),eventIDs))
        gBox = QGroupBox("Reference Snapshot Selection") 
        
        self.radio = [0]*len(eventIDs)
        vbox = QVBoxLayout()
        for i in range(len(eventIDs)):
            self.radio[i] = QRadioButton("Snapshot ID: %s"%eventIDs[i])   
            self.radio[i].setChecked(False)    
            vbox.addWidget(self.radio[i])
            self.radio[i].clicked.connect(self.reorderEventIDs)
        vbox.addStretch(1)
        gBox.setLayout(vbox)
        
        #okButton = QPushButton("OK")
        #cancelButton = QPushButton("Cancle")
        #okButton.clicked.connect(self.returnOrderedIDs)
        #okButton.clicked.connect(self.ignore)

        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        QObject.connect(buttonBox, SIGNAL("rejected()"), self.reject)
        QObject.connect(buttonBox, SIGNAL("accepted()"), self.accept)
        
        layout = QGridLayout(self)
        layout.addWidget(desc,0,0,1,1)
        layout.addWidget(gBox,1,0,1,1)
        #layout.addWidget(okButton,2,0,1,1)
        #layout.addWidget(cancelButton,2,1,1,1)
        layout.addWidget(buttonBox,2,0,1,1)
        self.setLayout(layout)
class DlgCrcReadWrite(QDialog):
    def __init__(self, parent, rwFlag="r"):
        QDialog.__init__(self, parent)
        self.rwFlag = rwFlag
        self.resize(100, 70)
        if self.rwFlag == "r":
            self.setWindowTitle("CRC Reader")
        else:
            self.setWindowTitle("CRC Writer")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.groupBox1 = GroupBox(self)
        self.groupBox1.Caption = ""
        verticalLayoutDlg.addWidget(self.groupBox1)

        self.pnlFile = TextBoxPanel(self.groupBox1)
        self.pnlFile.Caption = "File"
        self.pnlFile.LabelWidth = 120
        self.pnlFile.textBox.setMaximumWidth(200)
        self.pnlFile.textBox.setMinimumWidth(200)
        self.pnlFile.Button = "openData.png"
        self.groupBox1.Add = self.pnlFile

        self.pnlSuppliedCrcValue = TextBoxPanel(self.groupBox1)
        self.pnlSuppliedCrcValue.Caption = "Supplied CRC Value"
        self.pnlSuppliedCrcValue.LabelWidth = 120
        self.pnlSuppliedCrcValue.Enabled = False
        self.groupBox1.Add = self.pnlSuppliedCrcValue

        if self.rwFlag == "w":
            self.pnlSuppliedCrcValue.Visible = False

        self.pnlCalculatedCrcValue = TextBoxPanel(self.groupBox1)
        self.pnlCalculatedCrcValue.Caption = "Calculated CRC Value"
        self.pnlCalculatedCrcValue.LabelWidth = 120
        self.pnlCalculatedCrcValue.Enabled = False
        self.groupBox1.Add = self.pnlCalculatedCrcValue

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        btnQuit = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        btnQuit.setText("Quit")
        btnCancel = self.btnBoxOkCancel.button(QDialogButtonBox.Cancel)
        btnCancel.setVisible(False)

        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)

        self.connect(self.pnlFile, SIGNAL("Event_1"), self.pnlFileEvent_1)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

    def pnlFileEvent_1(self):

        inputFilePath = QFileDialog.getOpenFileName(
            self, "Open Xml File", QCoreApplication.applicationDirPath(),
            "Xml Files (*.xml)")
        if inputFilePath == "":
            return
        fileInfo = QFileInfo(inputFilePath)
        self.pnlFile.Value = fileInfo.fileName()
        contents = None
        with open(inputFilePath, 'rb', 0) as tempFile:
            contents = tempFile.read()
            tempFile.close()
        bytes = FasDataBlockFile.CRC_Calculation(contents)

        string_0 = QString(inputFilePath)

        crcFileDir = string_0.left(string_0.length() - 3) + "crc"
        fileInfo = QFileInfo(crcFileDir)
        if self.rwFlag == "r":
            if not fileInfo.exists():
                QMessageBox.warning(self, "Warning",
                                    "CRC file is not existing.")
                return
            crcFileContents = None
            with open(crcFileDir, 'rb', 0) as tempFileCrc:
                crcFileContents = tempFileCrc.read()
                tempFileCrc.close()
            if bytes != crcFileContents:
                self.pnlCalculatedCrcValue.textBox.setStyleSheet(
                    "color: rgb(255, 0, 0);")
            else:
                self.pnlCalculatedCrcValue.textBox.setStyleSheet(
                    "color: rgb(0, 0, 0);")
            self.pnlSuppliedCrcValue.Value = crcFileContents
            self.pnlCalculatedCrcValue.Value = bytes
        else:
            fileStream = open(crcFileDir, 'wb')
            fileStream.write(bytes)
            fileStream.close()
            self.pnlCalculatedCrcValue.Value = bytes

    def acceptDlg(self):

        self.accept()

    @staticmethod
    def smethod_0(parent, inputFilePath, rwFlag="r"):
        flag = False
        dlgCrcReadWrite = DlgCrcReadWrite(parent, rwFlag)

        resultDlg = dlgCrcReadWrite.exec_()
        if (resultDlg == 0):
            flag = False
        else:
            flag = True
        return flag
Example #32
0
class DlgRunway(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(290, 136)
        self.setWindowTitle("Runway Setup")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.basicFrame = Frame(self)
        verticalLayoutDlg.addWidget(self.basicFrame)

        self.groupBox = GroupBox(self.basicFrame)
        self.basicFrame.Add = self.groupBox

        self.pnlName = TextBoxPanel(self.groupBox)
        self.pnlName.Caption = "Name"
        self.pnlName.LabelWidth = 70
        self.groupBox.Add = self.pnlName

        self.pnlDesignatorFrame = Frame(self.groupBox, "HL")
        self.groupBox.Add = self.pnlDesignatorFrame

        self.pnlDesignator = TextBoxPanel(self.groupBox)
        self.pnlDesignator.Caption = "Designator"
        self.pnlDesignator.LabelWidth = 70
        self.pnlDesignator.Button = "Calculator.bmp"
        self.pnlDesignatorFrame.Add = self.pnlDesignator

        self.cmbDesignator = ComboBoxPanel(self.groupBox)
        self.cmbDesignator.Caption = ""
        self.cmbDesignator.LabelWidth = 0
        self.cmbDesignator.Items = ["", "L", "C", "R"]
        self.pnlDesignatorFrame.Add = self.cmbDesignator

        self.gbPositions = GroupBox(self.groupBox)
        self.gbPositions.Caption = "Positions"
        self.groupBox.Add = self.gbPositions

        self.pnlPosition = PositionPanel(self.gbPositions)
        # self.pnlPosition.hideframe_Altitude()
        self.pnlPosition.btnCalculater.setVisible(False)
        self.gbPositions.Add = self.pnlPosition

        self.pnlTree = Frame(self.gbPositions)
        self.gbPositions.Add = self.pnlTree

        self.trvPositions = TreeView(self.pnlTree)
        self.pnlTree.Add = self.trvPositions

        self.pnlButtons = Frame(self.pnlTree, "HL")
        self.pnlTree.Add = self.pnlButtons

        self.btnPrevious = QPushButton(self.pnlButtons)
        self.btnPrevious.setObjectName("btnPrevious")
        self.btnPrevious.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/btnImage/Prev_32x32.png"),
                       QIcon.Normal, QIcon.Off)
        self.btnPrevious.setIcon(icon)
        self.pnlButtons.Add = self.btnPrevious

        self.btnInsert = QPushButton(self.pnlButtons)
        self.btnInsert.setObjectName("btnInsert")
        self.btnInsert.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/add.png"), QIcon.Normal, QIcon.Off)
        self.btnInsert.setIcon(icon)
        self.pnlButtons.Add = self.btnInsert

        self.btnRemove = QPushButton(self.pnlButtons)
        self.btnRemove.setObjectName("btnRemove")
        self.btnRemove.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/remove.png"), QIcon.Normal, QIcon.Off)
        self.btnRemove.setIcon(icon)
        self.pnlButtons.Add = self.btnRemove

        self.btnNext = QPushButton(self.pnlButtons)
        self.btnNext.setObjectName("btnNext")
        self.btnNext.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/btnImage/Next_32x32.png"),
                       QIcon.Normal, QIcon.Off)
        self.btnNext.setIcon(icon)
        self.pnlButtons.Add = self.btnNext

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)

        self.btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)

        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.btnOK.setText("Save")
        self.connect(self.pnlDesignator, SIGNAL("Event_1"), self.method_14)

        self.connect(self.pnlPosition, SIGNAL("captureFinished"),
                     self.method_13)
        self.btnInsert.clicked.connect(self.btnInsert_Click)
        self.btnNext.clicked.connect(self.btnNext_Click)
        self.btnPrevious.clicked.connect(self.btnPrevious_Click)
        self.btnRemove.clicked.connect(self.btnRemove_Click)

        self.trvPositions.clicked.connect(self.trvPositions_clicked)

        # item = self.trvPositions.Add("Parent")
        # item.appendRow(TreeNode("Child0"))
        #
        # item00 = item0.appendRow(TreeNode("Child00"))

    def trvPositions_clicked(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        tag = selectedNode.Tag
        if (tag == None):
            return
        if not tag.IsEmpty and tag.IsValid:
            self.pnlPosition.Point3d = tag.Point3d
        else:
            self.pnlPosition.Point3d = None

    def get_Runway(self):
        return self.method_6()

    def set_Runway(self, runway):
        if (runway != None):
            self.pnlName.Value = runway.Name
            self.pnlDesignator.Value = runway.DesignatorHeading
            self.cmbDesignator.SelectedIndex = self.cmbDesignator.comboBox.findText(
                (runway.DesignatorCode))
        self.method_5(runway)

    RunwayValue = property(get_Runway, set_Runway, None, None)

    def acceptDlg(self):
        current = None
        # self.errorProvider.method_1()
        # self.pnlName.method_0()
        for current in self.trvPositions.Nodes:
            # IEnumerator enumerator = self.trvPositions.Nodes.GetEnumerator()
            # try
            # {
            #     while (true)
            #     {
            #         if (enumerator.MoveNext())
            #         {
            #     current = (TreeNode)enumerator.Current
            tag = current.Tag
            if (not tag.IsValidIncludingAltitude):
                if (tag.Type == PositionType.THR):
                    break
                if (tag.Type == PositionType.END):
                    break
                elif (not tag.IsEmpty):
                    self.trvPositions.SelectedNode = current
                    self.emit(SIGNAL("DlgRunway_accept"), self.method_6())
                    # self.pnlPosition.method_6()
                    return
            for treeNode in current.Nodes:
                # IEnumerator enumerator1 = current.Nodes.GetEnumerator()
                # try
                # {
                #     while (enumerator1.MoveNext())
                #     {
                #         TreeNode treeNode = (TreeNode)enumerator1.Current
                position = current.Tag
                if (position.IsValidIncludingAltitude or position.IsEmpty):
                    continue
                self.trvPositions.SelectedNode = treeNode
                self.pnlPosition.method_6()
                self.emit(SIGNAL("DlgRunway_accept"), self.method_6())
                return
            #     }
            # }
            # finally
            # {
            #     IDisposable disposable = enumerator1 as IDisposable
            #     if (disposable != null)
            #     {
            #         disposable.Dispose()
            #     }
            # }
            #     }
            #     else
            #     {
            #         goto Label0
            #     }
            # }
        self.trvPositions.SelectedNode = current
        # self.pnlPosition.method_6()
        self.emit(SIGNAL("DlgRunway_accept"), self.method_6())
        # }
        # finally
        # {
        #     IDisposable disposable1 = enumerator as IDisposable
        #     if (disposable1 != null)
        #     {
        #         disposable1.Dispose()
        #     }
        # }
        # return
        # Label0:
        #     if (!self.errorProvider.HasErrors)
        #     {
        #         if (self.method_6().method_7(self))
        #         {
        #             base.DialogResult = System.Windows.Forms.DialogResult.OK
        #         }
        #         return
        #     }
        #     else
        #     {
        #         return
        #     }
        self.accept()

    def btnInsert_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        tag = selectedNode.Tag
        if (tag == None):
            return
        if (tag.Type == PositionType.THR):
            selectedNode = selectedNode.Insert(
                0, PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        elif (tag.Type != PositionType.END):
            if (tag.Type != PositionType.Position):
                return
            if selectedNode.Parent == None:
                selectedNode = self.trvPositions.Insert(
                    selectedNode.Index,
                    PositionType.VariableNames[PositionType.Position - 1])
            else:
                selectedNode = selectedNode.Parent.Insert(
                    selectedNode.Index,
                    PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        else:
            selectedNode = selectedNode.PrevNode.Add(
                PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        self.trvPositions.SelectedNode = selectedNode

    def btnNext_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.NextNode == None):
                self.trvPositions.SelectedNode = selectedNode.Parent.NextNode
                return
            self.trvPositions.SelectedNode = selectedNode.NextNode
        else:
            if (len(selectedNode.Nodes) > 0):
                self.trvPositions.SelectedNode = selectedNode.Nodes[0]
                return
            if (selectedNode.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.NextNode
                return

    def btnPrevious_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.Index == 0):
                self.trvPositions.SelectedNode = selectedNode.Parent
                return
            self.trvPositions.SelectedNode = selectedNode.PrevNode
        else:
            selectedNode = selectedNode.PrevNode
            if (selectedNode != None):
                if (len(selectedNode.Nodes) <= 0):
                    self.trvPositions.SelectedNode = selectedNode
                    return
                self.trvPositions.SelectedNode = selectedNode.LastNode
                return

    def btnRemove_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.NextNode
            elif (selectedNode.Parent.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.Parent.NextNode
            else:
                self.trvPositions.SelectedNode = selectedNode.Parent
            parentNode = selectedNode.Parent
            if parentNode == None:
                self.trvPositions.Remove(selectedNode)
            else:
                parentNode.Remove(selectedNode)
        else:
            self.trvPositions.Remove(selectedNode)

    def method_5(self, runway_0):
        self.trvPositions.treeNodeList = []
        if (runway_0 != None):
            position = runway_0.method_1(PositionType.START)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = runway_0.method_1(PositionType.THR)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = runway_0.method_1(PositionType.END)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = runway_0.method_1(PositionType.SWY)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = runway_0.method_1(PositionType.CWY)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            item = self.trvPositions.Nodes[1]
            for position0 in runway_0:
                if (position0.Type != PositionType.Position):
                    continue
                item.Add(PositionType.VariableNames[position0.Type -
                                                    1]).Tag = position0
            # item.Expand()
        else:
            self.trvPositions.Add("START").Tag = Position(PositionType.START)
            self.trvPositions.Add("THR").Tag = Position(PositionType.THR)
            self.trvPositions.Add("END").Tag = Position(PositionType.END)
            self.trvPositions.Add("SWY").Tag = Position(PositionType.SWY)
            self.trvPositions.Add("CWY").Tag = Position(PositionType.CWY)
        self.trvPositions.SelectedNode = self.trvPositions.Nodes[0]
        self.method_10()

    def method_6(self):
        runway = Runway()
        runway.Name = self.pnlName.Value
        runway.DesignatorHeading = self.pnlDesignator.Value
        if (self.cmbDesignator.SelectedIndex > 0):
            runway.DesignatorCode = self.cmbDesignator.SelectedItem  #.ToString()
        for node in self.trvPositions.Nodes:
            tag = node.Tag
            runway[node.Index] = tag
            if (tag.Type != PositionType.THR):
                continue
            for treeNode in node.Nodes:
                position = treeNode.Tag
                if position == None:
                    continue
                if (not position.IsValidIncludingAltitude):
                    continue
                runway.Add(position)
        return runway

    def method_7(self):
        selectedNode = self.trvPositions.SelectedNode
        flag = False
        if (selectedNode != None):
            flag = True if (
                selectedNode.PrevNode != None) else selectedNode.Parent != None
        self.btnPrevious.setEnabled(flag)
        nextNode = False
        if (selectedNode != None):
            if (selectedNode.NextNode != None):
                nextNode = True
            elif (selectedNode.Parent != None):
                nextNode = selectedNode.Parent.NextNode != None
        self.btnNext.setEnabled(nextNode)
        flag1 = False
        if (selectedNode != None):
            tag = selectedNode.Tag
            if (tag != None):
                flag1 = True if (tag.Type == PositionType.THR
                                 or tag.Type == PositionType.Position
                                 ) else tag.Type == PositionType.END
        self.btnInsert.setEnabled(flag1)
        type = False
        if (selectedNode != None):
            position = selectedNode.Tag
            if (position != None):
                type = position.Type == PositionType.Position
        self.btnRemove.setEnabled(type)

    def method_8(self, treeNode_0, bool_0):
        if (treeNode_0 != None):
            text = treeNode_0.Text
            treeNode_0.Text = " "
            if (not bool_0):
                treeNode_0.NodeFont = QFont()
            else:
                font = QFont()
                font.setBold(True)
                treeNode_0.NodeFont = font
            treeNode_0.Text = text

    def method_9(self, treeNode_0):
        position = treeNode_0.Tag
        if not isinstance(position, Position):
            return
        num = 0
        if (not position.IsValidIncludingAltitude):
            if (position.Type != PositionType.THR):
                if (position.Type == PositionType.END):
                    num = 2
                else:
                    if (not position.IsEmpty):
                        num = 2
                        # treeNode_0.ImageIndex = num
                        # treeNode_0.SelectedImageIndex = num
                        for node in treeNode_0.Nodes:
                            self.method_9(node)
                        return
                    else:
                        # treeNode_0.ImageIndex = num
                        # treeNode_0.SelectedImageIndex = num
                        for treeNode in treeNode_0.Nodes:
                            self.method_9(treeNode)
                        return
            num = 2
        else:
            num = 1
        # treeNode_0.ImageIndex = num
        # treeNode_0.SelectedImageIndex = num
        for node1 in treeNode_0.Nodes:
            self.method_9(node1)

    def method_10(self):
        for node in self.trvPositions.Nodes:
            self.method_9(node)

    def method_11(self):
        point3d_0 = Point3D.get_Origin()
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode != None):
            selectedNode = selectedNode.PrevNode
            if (selectedNode != None):
                if (len(selectedNode.Nodes) > 0):
                    selectedNode = selectedNode.LastNode
                point3d_0 = selectedNode.Tag.Point3d
                return True, point3d_0
        return False, None

    def method_12(self):
        # Point3d point3d
        # Point3d point3d1
        # if (AcadHelper.Ready)
        # {
        #     AcadHelper.smethod_27(DrawingSpace.ModelSpace, true)
        #     Position tag = self.trvPositions.SelectedNode.Tag as Position
        #     string rUNWAYPOSITION = Captions.RUNWAY_POSITION
        #     if (tag.Type != PositionType.Position)
        #     {
        #         rUNWAYPOSITION = string.Format(Captions.RUNWAY_X_POSITION, EnumHelper.smethod_0(tag.Type))
        #     }
        #     if (self.method_11(out point3d1))
        #     {
        #         if (!AcadHelper.smethod_82(this, rUNWAYPOSITION, point3d1, out point3d))
        #         {
        #             return
        #         }
        #     }
        #     else if (!AcadHelper.smethod_80(this, rUNWAYPOSITION, out point3d))
        #     {
        #         return
        #     }
        #     self.pnlPosition.Point3d = point3d
        self.method_13()

    def method_13(self):
        if self.trvPositions.SelectedNode == None:
            return
        self.pnlPosition.posType = self.trvPositions.SelectedNode.Tag.Type
        self.trvPositions.SelectedNode.Tag = self.pnlPosition.PositionValue
        self.method_10()

    def method_14(self):
        runway = self.method_6()
        self.pnlDesignator.Value = runway.method_0()

    @staticmethod
    def smethod_0(iwin32Window_0, runway_0):
        flag = False
        dlgRunway = DlgRunway(iwin32Window_0)
        dlgRunway.RunwayValue = runway_0
        dlgRunway.show()
        # if (dlgRunway.method_2(iwin32Window_0) != System.Windows.Forms.DialogResult.OK)
        # {
        #     flag = false
        # }
        # else
        # {
        #     runway_0 = dlgRunway.Runway
        #     flag = true
        # }
        # }
        return dlgRunway
class DlgFapCalcPosition(QDialog):
    def __init__(self, parent, thrPos, rwyPos=None, track=None):
        QDialog.__init__(self, parent)
        self.baseTrack = track
        self.resize(290, 136)
        self.setWindowTitle("Calculate FAP")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.groupBox = GroupBox(self)
        verticalLayoutDlg.addWidget(self.groupBox)

        self.pnlThrPosition = PositionPanel(self.groupBox)
        self.pnlThrPosition.Point3d = thrPos
        self.groupBox.Add = self.pnlThrPosition
        self.pnlThrPosition.Visible = False

        self.pnlRwyEndPosition = PositionPanel(self.groupBox)
        self.pnlRwyEndPosition.Point3d = rwyPos
        self.groupBox.Add = self.pnlRwyEndPosition
        self.pnlRwyEndPosition.Visible = False

        self.pnlTrack = TrackRadialBoxPanel(self.groupBox)
        self.pnlTrack.Caption = "Track"
        if rwyPos == None:
            self.pnlTrack.Value = track
        else:
            self.pnlTrack.Value = MathHelper.getBearing(thrPos, rwyPos)
        self.pnlTrack.LabelWidth = 100
        self.groupBox.Add = self.pnlTrack

        self.pnlDist = DistanceBoxPanel(self.groupBox, DistanceUnits.M,
                                        DistanceUnits.NM)
        self.pnlDist.Caption = "Distance"
        self.pnlDist.Value = Distance(5, DistanceUnits.NM)
        self.pnlDist.LabelWidth = 100
        self.groupBox.Add = self.pnlDist

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

    def acceptDlg(self):
        nauticalMiles = self.pnlDist.Value.NauticalMiles
        value = Unit.ConvertDegToRad(self.pnlTrack.Value)
        num1 = math.fabs(self.baseTrack - value)
        if (num1 > 180):
            num1 = 360 - num1
        num2 = math.sin(Unit.smethod_0(num1)) * 0.7559395
        num3 = Unit.smethod_1(math.asin(num2 / nauticalMiles))
        num4 = math.cos(Unit.smethod_0(num1)) * 0.755939525
        num5 = math.cos(Unit.smethod_0(num3)) * nauticalMiles
        calcPt = RnavWaypoints.smethod_3(
            self.pos1400m, self.pnlTrack.Value,
            Distance(math.fabs(num5 - num4), DistanceUnits.NM))

        self.accept()
Example #34
0
    def __createLayout(self):
        " Creates the dialog layout "
        self.resize(640, 480)
        self.setSizeGripEnabled(True)

        layout = QVBoxLayout()

        # Plugins list
        self.__pluginsView = QTreeWidget()
        self.__pluginsView.setAlternatingRowColors(True)
        self.__pluginsView.setRootIsDecorated(False)
        self.__pluginsView.setItemsExpandable(False)
        self.__pluginsView.setSortingEnabled(True)
        self.__pluginsView.setItemDelegate(NoOutlineHeightDelegate(4))
        self.__pluginsView.setUniformRowHeights(True)

        # Alert | system/user | Enable | Name | Version
        self.__pluginsHeader = QTreeWidgetItem(
            ["", "", "", "Name", "Version", ""])
        self.__pluginsView.setHeaderItem(self.__pluginsHeader)
        self.__pluginsView.header().setSortIndicator(NAME_COL,
                                                     Qt.AscendingOrder)
        self.connect(self.__pluginsView, SIGNAL("itemSelectionChanged()"),
                     self.__pluginSelectionChanged)
        self.connect(self.__pluginsView,
                     SIGNAL("itemChanged(QTreeWidgetItem*,int)"),
                     self.__onItemChanged)

        layout.addWidget(self.__pluginsView)

        # Detailed information
        detailsLabel = QLabel("Detailed information")
        layout.addWidget(detailsLabel)
        self.__details = QTreeWidget()
        self.__details.setAlternatingRowColors(False)
        self.__details.setRootIsDecorated(False)
        self.__details.setItemsExpandable(False)
        self.__details.setSortingEnabled(False)
        self.__details.setItemDelegate(NoOutlineHeightDelegate(4))
        self.__details.setUniformRowHeights(True)

        detailsHeader = QTreeWidgetItem(["", ""])
        self.__details.setHeaderItem(detailsHeader)
        self.__details.setHeaderHidden(True)

        metrics = QFontMetrics(self.__details.font())
        rect = metrics.boundingRect("X")
        self.__details.setFixedHeight(rect.height() * 6 + 5)
        layout.addWidget(self.__details)

        # Errors/warnings
        errorsLabel = QLabel("Errors / warnings")
        layout.addWidget(errorsLabel)
        self.__errorsText = QTextEdit()
        self.__errorsText.setReadOnly(True)
        self.__errorsText.setAcceptRichText(False)
        metrics = QFontMetrics(self.__errorsText.font())
        rect = metrics.boundingRect("X")
        self.__errorsText.setFixedHeight(rect.height() * 4 + 5)
        layout.addWidget(self.__errorsText)

        # Buttons box
        buttonBox = QDialogButtonBox(self)
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        self.__OKButton = buttonBox.button(QDialogButtonBox.Ok)
        self.__OKButton.setDefault(True)
        self.connect(buttonBox, SIGNAL("accepted()"), self.close)
        self.connect(buttonBox, SIGNAL("rejected()"), self.close)
        layout.addWidget(buttonBox)

        self.setLayout(layout)
        return
Example #35
0
class DlgAixmProcLegs(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(290, 136)
        self.setWindowTitle("Procedure Legs (AIXM 4.5)")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.gbAll = GroupBox(self, "HL")
        self.gbAll.Caption = "Legs"
        verticalLayoutDlg.addWidget(self.gbAll)

        self.trvLegs = QTreeView(self.gbAll)
        self.trvLegsStdModel = StandardItemModel()
        self.trvLegs.setModel(self.trvLegsStdModel)
        self.gbAll.Add = self.trvLegs

        self.flowLayoutPanel1 = Frame(self.gbAll)
        self.gbAll.Add = self.flowLayoutPanel1

        self.btnAdd = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/add.png"), QIcon.Normal, QIcon.Off)
        self.btnAdd.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnAdd

        self.btnRemove = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/remove.png"), QIcon.Normal, QIcon.Off)
        self.btnRemove.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnRemove

        self.btnMoveUp = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/up.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveUp.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveUp

        self.btnMoveDown = QPushButton(self.flowLayoutPanel1)
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/down.png"), QIcon.Normal, QIcon.Off)
        self.btnMoveDown.setIcon(icon)
        self.flowLayoutPanel1.Add = self.btnMoveDown

        self.scrollBox = Frame(self.gbAll)
        self.gbAll.Add = self.scrollBox

        self.gbFix = GroupBox(self.scrollBox)
        self.gbFix.Caption = "Fix"
        self.scrollBox.Add = self.gbFix

        self.cmbFixPos = ComboBoxPanel(self.gbFix)
        self.cmbFixPos.Caption = "Position"
        self.cmbFixPos.Button = "coordinate_capture.png"
        self.gbFix.Add = self.cmbFixPos

        self.pnlCodeRoleFix = ComboBoxPanel(self.gbFix)
        self.pnlCodeRoleFix.Caption = "Type"
        self.gbFix.Add = self.pnlCodeRoleFix

        self.gbAttributes = GroupBox(self.scrollBox)
        self.gbAttributes.Caption = "Attributes"
        self.scrollBox.Add = self.gbAttributes

        self.cmbRecommendedEnt = ComboBoxPanel(self.gbAttributes)
        self.cmbRecommendedEnt.Caption = "Recommended Navigational Aid"
        self.gbAttributes.Add = self.cmbRecommendedEnt

        self.pnlCodePhase = ComboBoxPanel(self.gbAttributes)
        self.pnlCodePhase.Caption = "Fligh Phase"
        self.gbAttributes.Add = self.pnlCodePhase

        self.pnlCodeType = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeType.Caption = "Leg Type"
        self.gbAttributes.Add = self.pnlCodeType

        self.pnlLegVOR = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlLegVOR

        self.cmbCodeTypeCourse = ComboBoxPanel(self.pnlLegVOR)
        self.cmbCodeTypeCourse.Caption = "Course Angle (" + define._degreeStr + ")"
        self.pnlLegVOR.Add = self.cmbCodeTypeCourse

        self.txtValCourse = TrackRadialBoxPanel(self.pnlLegVOR)
        self.txtValCourse.LabelWidth = 0
        self.pnlLegVOR.Add = self.txtValCourse

        self.pnlCodeDirTurn = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeDirTurn.Caption = "Turn Direction"
        self.gbAttributes.Add = self.pnlCodeDirTurn

        self.pnlTurnValid = ComboBoxPanel(self.gbAttributes)
        self.pnlTurnValid.Caption = "Fly-By"
        self.gbAttributes.Add = self.pnlTurnValid

        self.cmbCenter = ComboBoxPanel(self.gbAttributes)
        self.cmbCenter.Caption = "Center"
        self.cmbCenter.Button = "coordinate_capture.png"
        self.gbAttributes.Add = self.cmbCenter

        self.pnlValBankAngle = NumberBoxPanel(self.gbAttributes)
        self.pnlValBankAngle.Caption = "Bank Angle (" + define._degreeStr + ")"
        self.gbAttributes.Add = self.pnlValBankAngle

        self.pnlCodeDescrDistVer = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeDescrDistVer.Caption = "Altitude Interpretation"
        self.gbAttributes.Add = self.pnlCodeDescrDistVer

        self.pnlVerDistLower = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlVerDistLower

        self.cmbDistVerLower = ComboBoxPanel(self.pnlVerDistLower)
        self.cmbDistVerLower.CaptionUnits = "ft"
        self.cmbDistVerLower.Caption = "Lower Altitude Limit"
        self.pnlVerDistLower.Add = self.cmbDistVerLower

        self.txtDistVerLower = AltitudeBoxPanel(self.pnlVerDistLower)
        self.txtDistVerLower.CaptionUnits = "ft"
        self.txtDistVerLower.LabelWidth = 0
        self.pnlVerDistLower.Add = self.txtDistVerLower

        self.pnlDistVerUpper = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.pnlDistVerUpper

        self.cmbDistVerUpper = ComboBoxPanel(self.pnlDistVerUpper)
        self.cmbDistVerUpper.CaptionUnits = "ft"
        self.cmbDistVerUpper.Caption = "Upper Altitude Limit"
        self.pnlDistVerUpper.Add = self.cmbDistVerUpper

        self.txtDistVerUpper = AltitudeBoxPanel(self.pnlDistVerUpper)
        self.txtDistVerUpper.CaptionUnits = "ft"
        self.txtDistVerUpper.LabelWidth = 0
        self.pnlDistVerUpper.Add = self.txtDistVerUpper

        self.pnlValVerAngle = NumberBoxPanel(self.gbAttributes)
        self.pnlValVerAngle.Caption = "Climb / Descent Angle [+/-] (" + define._degreeStr + ")"
        self.gbAttributes.Add = self.pnlValVerAngle

        self.tableLayoutPanel2 = Frame(self.gbAttributes, "HL")
        self.gbAttributes.Add = self.tableLayoutPanel2

        self.cmbCodeSpeedRef = ComboBoxPanel(self.tableLayoutPanel2)
        self.cmbCodeSpeedRef.CaptionUnits = "kts"
        self.cmbCodeSpeedRef.Caption = "Speed Restriction"
        self.tableLayoutPanel2.Add = self.cmbCodeSpeedRef

        self.txtValSpeed = SpeedBoxPanel(self.tableLayoutPanel2)
        self.txtValSpeed.LabelWidth = 0
        self.tableLayoutPanel2.Add = self.txtValSpeed

        self.pnlValDist = DistanceBoxPanel(self.gbAttributes, DistanceUnits.NM)
        self.pnlValDist.Caption = "Segment Length"
        self.pnlValDist.Button = None
        self.gbAttributes.Add = self.pnlValDist

        self.pnlValDur = NumberBoxPanel(self.gbAttributes)
        self.pnlValDur.CaptionUnits = "min"
        self.pnlValDur.Caption = "Duration"
        self.gbAttributes.Add = self.pnlValDur

        self.pnlCodeRepAtc = ComboBoxPanel(self.gbAttributes)
        self.pnlCodeRepAtc.Caption = "ATC Reporting"
        self.gbAttributes.Add = self.pnlCodeRepAtc

        self.pnlValTheta = TrackRadialBoxPanel(self.gbAttributes)
        self.pnlValTheta.Caption = "Magnetic Bearing / Radial from Recommended Nav. Aid"
        self.pnlValTheta.LabelWidth = 350
        self.gbAttributes.Add = self.pnlValTheta

        self.pnlValRho = DistanceBoxPanel(self.gbAttributes, DistanceUnits.NM)
        self.pnlValRho.Caption = "Distance from Recommended Nav. Aid"
        self.pnlValRho.LabelWidth = 350
        self.gbAttributes.Add = self.pnlValRho

        self.txtRemarks = TextBoxPanel(self.gbAttributes, True)
        self.txtRemarks.Caption = "Remarks"
        self.gbAttributes.Add = self.txtRemarks

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.trvLegs.pressed.connect(self.trvLegs_pressed)

        self.data = None
        self.legs = None
        self.aerodrome = None
        self.magnVar = 0.0

        for value in CodeIapFixAixm.Items:
            self.pnlCodeRoleFix.Add(value)
        for codeTypeProcPathAixm in CodeTypeProcPathAixm.Items:
            self.pnlCodeType.Add(codeTypeProcPathAixm)
        for codePhaseProcAixm in CodePhaseProcAixm.Items:
            self.pnlCodePhase.Add(codePhaseProcAixm)
        for codeTypeCourseAixm in CodeTypeCourseAixm.Items:
            self.cmbCodeTypeCourse.Add(codeTypeCourseAixm)
        for codeDirTurnAixm in CodeDirTurnAixm.Items:
            self.pnlCodeDirTurn.Add(codeDirTurnAixm)
        for codeDescrDistVerAixm in CodeDescrDistVerAixm.Items:
            self.pnlCodeDescrDistVer.Add(codeDescrDistVerAixm)
        for codeDistVerAixm in CodeDistVerAixm.Items:
            self.cmbDistVerLower.Add(codeDistVerAixm)
        for value1 in CodeDistVerAixm.Items:
            self.cmbDistVerUpper.Add(value1)
        for codeSpeedRefAixm in CodeSpeedRefAixm.Items:
            self.cmbCodeSpeedRef.Add(codeSpeedRefAixm)
        for codeTypeFlyByAixm in CodeTypeFlyByAixm.Items:
            self.pnlTurnValid.Add(codeTypeFlyByAixm)
        for codeRepAtcAixm in CodeRepAtcAixm.Items:
            self.pnlCodeRepAtc.Add(codeRepAtcAixm)
        self.method_6()

        self.connect(self.pnlValRho, SIGNAL("Event_0"), self.pnlValRho_Event_0)
        self.connect(self.pnlValTheta, SIGNAL("Event_0"),
                     self.pnlValTheta_Event_0)
        self.connect(self.pnlCodeRepAtc, SIGNAL("Event_0"),
                     self.pnlCodeRepAtc_Event_0)
        self.connect(self.pnlValDur, SIGNAL("Event_0"), self.pnlValDur_Event_0)
        self.connect(self.pnlValDist, SIGNAL("Event_0"),
                     self.pnlValDist_Event_0)
        self.connect(self.cmbCodeSpeedRef, SIGNAL("Event_0"),
                     self.cmbCodeSpeedRef_Event_0)
        self.connect(self.txtValSpeed, SIGNAL("Event_0"),
                     self.txtValSpeed_Event_0)
        self.connect(self.txtDistVerUpper, SIGNAL("Event_0"),
                     self.txtDistVerUpper_Event_0)
        self.connect(self.cmbDistVerUpper, SIGNAL("Event_0"),
                     self.cmbDistVerUpper_Event_0)
        self.connect(self.txtDistVerLower, SIGNAL("Event_0"),
                     self.txtDistVerLower_Event_0)

        self.connect(self.cmbDistVerLower, SIGNAL("Event_0"),
                     self.cmbDistVerLower_Event_0)
        self.connect(self.pnlValBankAngle, SIGNAL("Event_0"),
                     self.pnlValBankAngle_Event_0)
        self.connect(self.cmbCenter, SIGNAL("Event_0"), self.cmbCenter_Event_0)
        self.connect(self.pnlTurnValid, SIGNAL("Event_0"),
                     self.pnlTurnValid_Event_0)
        self.connect(self.pnlCodeDirTurn, SIGNAL("Event_0"),
                     self.pnlCodeDirTurn_Event_0)
        self.connect(self.cmbCodeTypeCourse, SIGNAL("Event_0"),
                     self.cmbCodeTypeCourse_Event_0)
        self.connect(self.txtValCourse, SIGNAL("Event_0"),
                     self.txtValCourse_Event_0)
        self.connect(self.pnlCodeType, SIGNAL("Event_0"),
                     self.pnlCodeType_Event_0)
        self.connect(self.pnlCodePhase, SIGNAL("Event_0"),
                     self.pnlCodePhase_Event_0)
        self.connect(self.pnlCodeRoleFix, SIGNAL("Event_0"),
                     self.pnlCodeRoleFix_Event_0)
        self.connect(self.txtRemarks, SIGNAL("Event_0"),
                     self.txtRemarks_Event_0)
        self.connect(self.cmbRecommendedEnt, SIGNAL("Event_0"),
                     self.cmbRecommendedEnt_Event_0)

        self.connect(self.cmbFixPos, SIGNAL("Event_0"), self.cmbFixPos_Event_0)
        self.connect(self.cmbCenter, SIGNAL("Event_3"), self.method_14)
        self.connect(self.cmbFixPos, SIGNAL("Event_3"), self.method_13)

        self.btnAdd.clicked.connect(self.btnAdd_Click)
        self.btnMoveDown.clicked.connect(self.btnMoveDown_Click)
        self.btnMoveUp.clicked.connect(self.btnMoveUp_Click)
        self.btnRemove.clicked.connect(self.btnRemove_Click)

        self.trvLegs.setHeaderHidden(True)

        if self.trvLegsStdModel.rowCount() > 0:
            self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(0, 0))
            self.method_8()
        # rootModelIndex = self.trvLegs.rootIndex()
        # rootItem = self.trvLegsStdModel.itemFromIndex(rootModelIndex)
        # rootItem.setText("Legs")
    def btnAdd_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0 and not self.method_5()):
            return
        listInsertPosition = ListInsertPosition.Append
        resultDlg, listInsertPosition = DlgAixmInsertLeg.smethod_0(
            listInsertPosition)
        if (self.trvLegsStdModel.rowCount() > 0 and not resultDlg):
            return
        count = self.trvLegsStdModel.rowCount()
        if (listInsertPosition == ListInsertPosition.Before):
            count = self.trvLegs.selectedIndexes()[0].row()
        elif (listInsertPosition == ListInsertPosition.After):
            count = self.trvLegs.selectedIndexes()[0].row() + 1
        self.trvLegsStdModel.setItem(
            self.trvLegsStdModel.rowCount(),
            QStandardItem(str(self.trvLegsStdModel.rowCount() + 1)))
        self.legs.insert(count, DataBaseProcedureLeg())
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(count, 0))
        self.trvLegs_pressed()

    def btnMoveDown_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        index = self.trvLegs.selectedIndexes()[0].row()
        item = self.legs[index]
        self.legs.pop(index)
        self.legs.insert(index + 1, item)
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index + 1, 0))
        self.trvLegs_pressed()

    def btnMoveUp_Click(self):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        index = self.trvLegs.selectedIndexes()[0].row()
        item = self.legs[index]
        self.legs.pop(index)
        self.legs.insert(index - 1, item)
        self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index - 1, 0))
        self.trvLegs_pressed()

    def btnRemove_Click(self):
        item = None
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        if (QMessageBox.question(
                self, "Question",
                "Are you sure you want to delete the selected procedure leg?",
                QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes):
            index = self.trvLegs.selectedIndexes()[0].row()
            self.legs.pop(index)
            self.trvLegsStdModel.takeRow(self.trvLegsStdModel.rowCount() - 1)
            if (index >= self.trvLegsStdModel.rowCount() - 1):
                index -= 1
            # treeView = self.trvLegs;
            # if (index >= 0):
            if self.trvLegsStdModel.rowCount() > 0 and index < 0:
                index = 0
            self.trvLegs.setCurrentIndex(self.trvLegsStdModel.index(index, 0))

            self.trvLegs_pressed()

    def cmbRecommendedEnt_Event_0(self):
        self.method_10(self.cmbRecommendedEnt)

    def txtRemarks_Event_0(self):
        self.method_10(self.txtRemarks)

    def cmbFixPos_Event_0(self):
        self.method_10(self.cmbFixPos)

    def cmbDistVerLower_Event_0(self):
        self.method_10(self.cmbDistVerLower)

    def pnlValBankAngle_Event_0(self):
        self.method_10(self.pnlValBankAngle)

    def cmbCenter_Event_0(self):
        self.method_10(self.cmbCenter)

    def pnlTurnValid_Event_0(self):
        self.method_10(self.pnlTurnValid)

    def pnlCodeDirTurn_Event_0(self):
        self.method_10(self.pnlCodeDirTurn)

    def cmbCodeTypeCourse_Event_0(self):
        self.method_10(self.cmbCodeTypeCourse)

    def txtValCourse_Event_0(self):
        self.method_10(self.txtValCourse)

    def pnlCodeType_Event_0(self):
        self.method_10(self.pnlCodeType)

    def pnlCodePhase_Event_0(self):
        self.method_10(self.pnlCodePhase)

    def pnlCodeRoleFix_Event_0(self):
        self.method_10(self.pnlCodeRoleFix)

    def txtDistVerLower_Event_0(self):
        self.method_10(self.txtDistVerLower)

    def cmbDistVerUpper_Event_0(self):
        self.method_10(self.cmbDistVerUpper)

    def txtDistVerUpper_Event_0(self):
        self.method_10(self.txtDistVerUpper)

    def txtValSpeed_Event_0(self):
        self.method_10(self.txtValSpeed)

    def cmbCodeSpeedRef_Event_0(self):
        self.method_10(self.cmbCodeSpeedRef)

    def pnlValDist_Event_0(self):
        self.method_10(self.pnlValDist)

    def pnlValDur_Event_0(self):
        self.method_10(self.pnlValDur)

    def pnlCodeRepAtc_Event_0(self):
        self.method_10(self.pnlCodeRepAtc)

    def pnlValTheta_Event_0(self):
        self.method_10(self.pnlValTheta)

    def pnlValRho_Event_0(self):
        self.method_10(self.pnlValRho)

    def trvLegs_pressed(self):
        self.method_6()
        self.method_8()

    def acceptDlg(self):
        self.legs.refresh()
        QObject.emit(self, SIGNAL("DlgAixmProcLegs_Smethod_0_Event"),
                     self.legs, self.data)
        self.accept()

    def method_5(self):
        pass

    def method_6(self):
        self.btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        self.btnOK.setEnabled(len(self.trvLegs.selectedIndexes()) > 0)
        self.btnRemove.setEnabled(len(self.trvLegs.selectedIndexes()) > 0)
        self.btnMoveUp.setEnabled(
            (len(self.trvLegs.selectedIndexes()) > 0
             and self.trvLegs.selectedIndexes()[0].row() != 0) and True
            or False)
        self.btnMoveDown.setEnabled(
            (len(self.trvLegs.selectedIndexes()) <= 0
             or self.trvLegsStdModel.rowCount() <= 0) and False
            or ((len(self.trvLegs.selectedIndexes()) > 0)
                and self.trvLegs.selectedIndexes()[0].row() <
                self.trvLegsStdModel.rowCount() - 1))

    def method_7(self):
        for i in range(self.legs.Count):
            num = i + 1
            self.trvLegsStdModel.setItem(i, QStandardItem(str(num)))
        self.method_6()
        # if (self.trvLegsStdModel.rowCount() > 0):
        #     self.trvLegs.setCurrentIndex() = self.trvLegs.Nodes[0];
    def method_8(self):
        if (len(self.trvLegs.selectedIndexes()) <= 0):
            self.scrollBox.Enabled = False
            self.cmbFixPos.SelectedIndex = -1
            self.pnlCodeRoleFix.SelectedIndex = -1
            self.cmbRecommendedEnt.SelectedIndex = -1
            self.pnlCodePhase.SelectedIndex = -1
            self.pnlCodeType.SelectedIndex = -1
            self.cmbCodeTypeCourse.SelectedIndex = -1
            self.txtValCourse.Value = 0
            self.pnlCodeDirTurn.SelectedIndex = -1
            self.cmbCenter.SelectedIndex = -1
            self.pnlTurnValid.SelectedIndex = -1
            self.pnlValBankAngle.Value = 0
            self.pnlCodeDescrDistVer.SelectedIndex = -1
            self.cmbDistVerLower.SelectedIndex = -1
            self.txtDistVerLower.Value = None
            self.cmbDistVerUpper.SelectedIndex = -1
            self.txtDistVerUpper.Value = None
            self.pnlValVerAngle.Value = None
            self.cmbCodeSpeedRef.SelectedIndex = -1
            self.txtValSpeed.Value = None
            self.pnlValDist.Value = None
            self.pnlValDur.Value = 0
            self.pnlCodeRepAtc.SelectedIndex = -1
            self.pnlValTheta.Value = 0
            self.pnlValRho.Value = None
            self.txtRemarks.Value = ""
            return
        self.scrollBox.Enabled = True
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()]
        if (item.PointEnt == None):
            self.cmbFixPos.SelectedIndex = -1
        else:
            self.cmbFixPos.SelectedIndex = self.cmbFixPos.IndexOf(
                item.PointEnt)
        self.pnlCodeRoleFix.SelectedIndex = self.method_9(
            self.pnlCodeRoleFix.Items, item.CodeRoleFix)
        if (item.RecommendedEnt == None):
            self.cmbRecommendedEnt.SelectedIndex = -1
        else:
            self.cmbRecommendedEnt.SelectedIndex = self.cmbRecommendedEnt.IndexOf(
                item.RecommendedEnt)
        self.pnlCodePhase.SelectedIndex = self.method_9(
            self.pnlCodePhase.Items, item.CodePhase)
        self.pnlCodeType.SelectedIndex = self.method_9(self.pnlCodeType.Items,
                                                       item.CodeType)
        self.cmbCodeTypeCourse.SelectedIndex = self.method_9(
            self.cmbCodeTypeCourse.Items, item.CodeTypeCourse)
        self.txtValCourse.Value = item.ValCourse
        self.pnlCodeDirTurn.SelectedIndex = self.method_9(
            self.pnlCodeDirTurn.Items, item.CodeDirTurn)
        if (item.CenterEnt == None):
            self.cmbCenter.SelectedIndex = -1
        else:
            self.cmbCenter.SelectedIndex = self.cmbCenter.IndexOf(
                item.CenterEnt)
        self.pnlTurnValid.SelectedIndex = self.method_9(
            self.pnlTurnValid.Items, item.CodeTurnValid)
        self.pnlValBankAngle.Value = item.ValBankAngle
        self.pnlCodeDescrDistVer.SelectedIndex = self.method_9(
            self.pnlCodeDescrDistVer.Items, item.CodeDescrDistVer)
        self.cmbDistVerLower.SelectedIndex = self.method_9(
            self.cmbDistVerLower.Items, item.CodeDistVerLower)
        self.txtDistVerLower.Value = item.ValDistVerLower
        self.cmbDistVerUpper.SelectedIndex = self.method_9(
            self.cmbDistVerUpper.Items, item.CodeDistVerUpper)
        self.txtDistVerUpper.Value = item.ValDistVerUpper
        self.pnlValVerAngle.Value = item.ValVerAngle
        self.cmbCodeSpeedRef.SelectedIndex = self.method_9(
            self.cmbCodeSpeedRef.Items, item.CodeSpeedRef)
        self.txtValSpeed.Value = item.ValSpeedLimit
        self.pnlValDist.Value = item.ValDist
        self.pnlValDur.Value = item.ValDur
        self.pnlCodeRepAtc.SelectedIndex = self.method_9(
            self.pnlCodeRepAtc.Items, item.CodeRepAtc)
        self.pnlValTheta.Value = item.ValTheta
        self.pnlValRho.Value = item.ValRho
        self.txtRemarks.Value = item.TxtRmk
        self.method_6()

    def method_9(self, ilist_0, string_0):
        for i in range(len(ilist_0)):
            if (ilist_0[i] == string_0):
                return i
        return -1

    def method_10(self, sender):
        if (len(self.trvLegs.selectedIndexes()) == 0):
            return
        item = self.legs[self.trvLegs.selectedIndexes()[0].row()]
        if (sender == self.cmbFixPos):
            item.PointEnt = self.cmbFixPos.SelectedItem
        if (sender == self.pnlCodeRoleFix):
            item.CodeRoleFix = self.pnlCodeRoleFix.SelectedItem
        if (sender == self.cmbRecommendedEnt):
            item.RecommendedEnt = self.cmbRecommendedEnt.SelectedItem
        if (sender == self.pnlCodePhase):
            item.CodePhase = self.pnlCodePhase.SelectedItem
        if (sender == self.pnlCodeType):
            item.CodeType = self.pnlCodeType.SelectedItem
        if (sender == self.cmbCodeTypeCourse):
            item.CodeTypeCourse = self.cmbCodeTypeCourse.SelectedItem
        if (sender == self.txtValCourse):
            item.ValCourse = self.txtValCourse.Value
        if (sender == self.pnlCodeDirTurn):
            item.CodeDirTurn = self.pnlCodeDirTurn.SelectedItem
        if (sender == self.cmbCenter):
            item.CenterEnt = self.cmbCenter.SelectedItem
            return
        if (sender == self.pnlTurnValid):
            item.CodeTurnValid = self.pnlTurnValid.SelectedItem
            return
        if (sender == self.pnlValBankAngle):
            item.ValBankAngle = self.pnlValBankAngle.Value
            return
        if (sender == self.pnlCodeDescrDistVer):
            item.CodeDescrDistVer = self.pnlTurnValid.SelectedItem
            return
        if (sender == self.cmbDistVerLower):
            item.CodeDistVerLower = self.cmbDistVerLower.SelectedItem
            return
        if (sender == self.txtDistVerLower):
            item.ValDistVerLower = self.txtDistVerLower.Value
            return
        if (sender == self.cmbDistVerUpper):
            item.CodeDistVerUpper = self.cmbDistVerUpper.SelectedItem
            return
        if (sender == self.txtDistVerUpper):
            item.ValDistVerUpper = self.txtDistVerUpper.Value
            return
        if (sender == self.pnlValVerAngle):
            item.ValVerAngle = self.pnlValVerAngle.Value
            return
        if (sender == self.cmbCodeSpeedRef):
            item.CodeSpeedRef = self.cmbCodeSpeedRef.SelectedItem
            return
        if (sender == self.txtValSpeed):
            item.ValSpeedLimit = self.txtValSpeed.Value
            return
        if (sender == self.pnlValDist):
            item.ValDist = self.pnlValDist.Value
            return
        if (sender == self.pnlValDur):
            item.ValDur = self.pnlValDur.Value
            return
        if (sender == self.pnlCodeRepAtc):
            item.CodeRepAtc = self.pnlCodeRepAtc.SelectedItem
            return
        if (sender == self.pnlValTheta):
            item.ValTheta = self.pnlValTheta.Value
            return
        if (sender == self.pnlValRho):
            item.ValRho = self.pnlValRho.Value
            return
        if (sender == self.txtRemarks):
            item.TxtRmk = self.txtRemarks.Value

    def method_13(self):
        point3d = None
        procEntityBase = None
        selectTool = DlgAixmSelectPosition.smethod_0(self.data, point3d,
                                                     ProcEntityListType.Fixes)
        QObject.connect(selectTool,
                        SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"),
                        self.method_13_Event)

    def method_13_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Fixes)
        if (flag and procEntityBase != None):
            if (not self.cmbFixPos.Contains(procEntityBase)):
                self.cmbFixPos.Add(procEntityBase)
            self.cmbFixPos.SelectedIndex = self.cmbFixPos.IndexOf(
                procEntityBase)
            self.method_10(self.cmbFixPos)

    def method_14(self):
        point3d = None
        procEntityBase = None
        selectTool = DlgAixmSelectPosition.smethod_0(
            self.data, point3d, ProcEntityListType.Centers)
        QObject.connect(selectTool,
                        SIGNAL("DlgAixmSelectPosition_Smethod_0_Event"),
                        self.method_14_Event)

    def method_14_Event(self, flag, procEntityBase):
        # flag, procEntityBase = DlgAixmSelectPosition.smethod_0(self.data, point3d, ProcEntityListType.Centers)
        if (flag and procEntityBase != None):
            if (not self.cmbCenter.Contains(procEntityBase)):
                self.cmbCenter.Add(procEntityBase)
            self.cmbCenter.SelectedIndex = self.cmbCenter.IndexOf(
                procEntityBase)
            self.method_10(self.cmbCenter)

    @staticmethod
    def smethod_0(parent, dataBaseProcedureLegs_0, dataBaseProcedureData_0,
                  procEntityAHP_0):
        flag = False
        dlgAixmProcLeg = DlgAixmProcLegs(parent)
        dlgAixmProcLeg.legs = dataBaseProcedureLegs_0
        dlgAixmProcLeg.data = dataBaseProcedureData_0
        if (procEntityAHP_0 != None):
            dlgAixmProcLeg.aerodrome = procEntityAHP_0
            dlgAixmProcLeg.magnVar = procEntityAHP_0.ValMagVar
        dataBaseProcedureData_0.method_59(dlgAixmProcLeg.cmbFixPos,
                                          ProcEntityListType.Fixes)
        dataBaseProcedureData_0.method_59(dlgAixmProcLeg.cmbCenter,
                                          ProcEntityListType.Centers)
        dataBaseProcedureData_0.method_59(
            dlgAixmProcLeg.cmbRecommendedEnt,
            ProcEntityListType.RecommendedNavAids)
        if (dlgAixmProcLeg.legs.Count == 0):
            dlgAixmProcLeg.legs.Add(DataBaseProcedureLeg())

        dlgAixmProcLeg.method_7()
        if dlgAixmProcLeg.trvLegsStdModel.rowCount() > 0:
            dlgAixmProcLeg.trvLegs.setCurrentIndex(
                dlgAixmProcLeg.trvLegsStdModel.index(0, 0))
            dlgAixmProcLeg.method_6()

        dlgAixmProcLeg.method_8()
        dlgAixmProcLeg.show()
        return dlgAixmProcLeg
Example #36
0
class DlgCrcCheck(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(100, 70)
        self.setWindowTitle("CRC Check")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.groupBox1 = GroupBox(self)
        self.groupBox1.Caption = ""
        verticalLayoutDlg.addWidget(self.groupBox1)

        self.pnlSuppliedCrcValue = TextBoxPanel(self.groupBox1)
        self.pnlSuppliedCrcValue.Caption = "Supplied CRC Value"
        self.pnlSuppliedCrcValue.LabelWidth = 120
        self.pnlSuppliedCrcValue.Enabled = False
        self.groupBox1.Add = self.pnlSuppliedCrcValue

        self.pnlCalculatedCrcValue = TextBoxPanel(self.groupBox1)
        self.pnlCalculatedCrcValue.Caption = "Calculated CRC Value"
        self.pnlCalculatedCrcValue.LabelWidth = 120
        self.pnlCalculatedCrcValue.Enabled = False
        self.groupBox1.Add = self.pnlCalculatedCrcValue

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        # btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        # btnOK.setText("Create")
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.crcCalcMethodStr = None

        # self.pnlCodeType.Items = CodeTypeDesigPtAixm.Items

    def acceptDlg(self):

        self.accept()

    @staticmethod
    def smethod_0(parent, inputFilePath, crcCalcMethodStr=None):
        flag = False
        dlgCrcCheck = DlgCrcCheck(parent)
        dlgCrcCheck.crcCalcMethodStr = crcCalcMethodStr

        contents = None
        try:
            with open(inputFilePath, 'rb', 0) as tempFile:
                contents = tempFile.read()
                tempFile.close()
        except:
            return False
        bytes = FasDataBlockFile.CRC_Calculation(contents)

        string_0 = QString(inputFilePath)

        crcFileDir = string_0.left(string_0.length() - 3) + "crc"
        fileInfo = QFileInfo(crcFileDir)
        if not fileInfo.exists():
            if QMessageBox.warning(
                    dlgCrcCheck, "Warning",
                    "CRC file is not existing.\nDo you want to create the CRC file for this file?",
                    QMessageBox.Yes | QMessageBox.No) == QMessageBox.No:
                return False
            contents = None
            # with open(inputFilePath, 'rb', 0) as tempFile:
            #     contents = tempFile.read()
            #     tempFile.flush()
            #     tempFile.close()
            # bytes = FasDataBlockFile.CRC_Calculation(contents)
            # string_0 = QString(inputFilePath)
            # path = string_0.left(string_0.length() - 3) + "crc"
            fileStream = open(crcFileDir, 'wb')
            fileStream.write(bytes)
            fileStream.close()

        crcFileContents = None
        with open(crcFileDir, 'rb', 0) as tempFileCrc:
            crcFileContents = tempFileCrc.read()
            tempFileCrc.close()
        if bytes != crcFileContents:
            dlgCrcCheck.pnlCalculatedCrcValue.textBox.setStyleSheet(
                "color: rgb(255, 0, 0);")
        else:
            dlgCrcCheck.pnlCalculatedCrcValue.textBox.setStyleSheet(
                "color: rgb(0, 0, 0);")
        dlgCrcCheck.pnlSuppliedCrcValue.Value = crcFileContents
        dlgCrcCheck.pnlCalculatedCrcValue.Value = bytes

        resultDlg = dlgCrcCheck.exec_()
        if (resultDlg == 0):
            flag = False
        else:
            flag = True
        return flag
Example #37
0
    def __init__(self, widget, name, text=""):
        super(Edit, self).__init__(widget)

        self._name = name

        layout = QVBoxLayout()
        self.setLayout(layout)

        self.topLabel = QLabel()
        self.text = QTextEdit(cursorWidth=2, acceptRichText=False)
        self.titleLabel = QLabel()
        self.titleEntry = QLineEdit()
        self.shortcutLabel = QLabel()
        self.shortcutButton = ShortcutButton(clicked=self.editShortcuts)

        layout.addWidget(self.topLabel)
        layout.addWidget(self.text)

        grid = QGridLayout()
        layout.addLayout(grid)

        grid.addWidget(self.titleLabel, 0, 0)
        grid.addWidget(self.titleEntry, 0, 1)
        grid.addWidget(self.shortcutLabel, 1, 0)
        grid.addWidget(self.shortcutButton, 1, 1)

        layout.addWidget(widgets.Separator())

        b = QDialogButtonBox(accepted=self.accept, rejected=self.reject)
        layout.addWidget(b)

        buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
        if name and name in builtin.builtin_snippets:
            b.setStandardButtons(buttons | QDialogButtonBox.RestoreDefaults)
            b.button(QDialogButtonBox.RestoreDefaults).clicked.connect(
                self.slotDefaults)
        else:
            b.setStandardButtons(buttons)
        userguide.addButton(b, "snippet_editor")

        # PyQt4.10 en sip4.14.5 delete the Highlighter, even though it is
        # constructed with a parent, that's why we save it in an unused attribute.
        self._highlighter = highlight.Highlighter(self.text.document())
        Matcher(self.text)
        widgets.indenter.Indenter(self.text)
        self.text.installEventFilter(homekey.handler)
        wordboundary.handler.install_textedit(self.text)
        completer.Completer(self.text)

        if name:
            self.titleEntry.setText(snippets.title(name, False) or '')
            self.text.setPlainText(snippets.text(name))
            ac = self.parent().parent().snippetActions
            self.setShortcuts(ac.shortcuts(name))
        else:
            self.text.setPlainText(text)
            self.setShortcuts(None)

        app.translateUI(self)

        self.readSettings()
        app.settingsChanged.connect(self.readSettings)
        qutil.saveDialogSize(self, "snippettool/editor/size", QSize(400, 300))
        self.show()
class CalculatorModelerParametersDialog(ModelerParametersDialog):

    def setupUi(self):
        self.valueItems = {}
        self.dependentItems = {}
        self.resize(650, 450)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        self.infoText = QTextEdit()
        numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber)
        text = self.tr('You can refer to model values in your formula, using '
                       'single-letter variables, as follows:\n', 'CalculatorModelerParametersDialog')
        ichar = 97
        if numbers:
            for number in numbers:
                text += chr(ichar) + '->' + self.resolveValueDescription(number) + '\n'
                ichar += 1
        else:
            text += self.tr('\n - No numerical variables are available.', 'CalculatorModelerParametersDialog')
        self.infoText.setText(text)
        self.infoText.setEnabled(False)
        self.formulaText = QLineEdit()
        if hasattr(self.formulaText, 'setPlaceholderText'):
            self.formulaText.setPlaceholderText(self.tr('[Enter your formula here]', 'CalculatorModelerParametersDialog'))
        alg = self.model.algs[self._algName]
        self.formulaText.setText(alg.params[FORMULA])
        self.setWindowTitle(self.tr('Calculator', 'CalculatorModelerParametersDialog'))
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(2)
        self.verticalLayout.setMargin(0)
        self.verticalLayout.addWidget(self.infoText)
        self.verticalLayout.addWidget(self.formulaText)
        self.verticalLayout.addWidget(self.buttonBox)
        self.setLayout(self.verticalLayout)
        QObject.connect(self.buttonBox, SIGNAL('accepted()'), self.okPressed)
        QObject.connect(self.buttonBox, SIGNAL('rejected()'), self.cancelPressed)
        QMetaObject.connectSlotsByName(self)

    def createAlgorithm(self):
        alg = Algorithm('modelertools:calculator')
        alg.setName(self.model)
        alg.description = self.tr('Calculator', 'CalculatorModelerParametersDialog')

        formula = self.formulaText.text()
        alg.params[FORMULA] = formula

        for i in xrange(AVAILABLE_VARIABLES):
            paramname = NUMBER + unicode(i)
            alg.params[paramname] = None

        numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber)
        used = []
        for i in range(len(numbers)):
            if unicode(chr(i + 97)) in formula:
                used.append(numbers[i])

        for i, variable in enumerate(used):
            paramname = NUMBER + unicode(i)
            alg.params[paramname] = variable

        # TODO check formula is correct
        return alg
Example #39
0
class DlgFato(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(290, 136)
        self.setWindowTitle("Runway Setup")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.basicFrame = Frame(self)
        verticalLayoutDlg.addWidget(self.basicFrame)

        self.groupBox = GroupBox(self.basicFrame)
        self.basicFrame.Add = self.groupBox

        self.pnlName = TextBoxPanel(self.groupBox)
        self.pnlName.Caption = "Name"
        self.pnlName.LabelWidth = 70
        self.groupBox.Add = self.pnlName

        self.pnlDesignatorFrame = Frame(self.groupBox, "HL")
        self.groupBox.Add = self.pnlDesignatorFrame

        self.pnlDesignator = TextBoxPanel(self.groupBox)
        self.pnlDesignator.Caption = "Designator"
        self.pnlDesignator.LabelWidth = 70
        self.pnlDesignator.Button = "Calculator.bmp"
        self.pnlDesignatorFrame.Add = self.pnlDesignator

        self.cmbDesignator = ComboBoxPanel(self.groupBox)
        self.cmbDesignator.Caption = ""
        self.cmbDesignator.LabelWidth = 0
        self.cmbDesignator.Items = ["", "L", "C", "R"]
        self.pnlDesignatorFrame.Add = self.cmbDesignator

        self.gbPositions = GroupBox(self.groupBox)
        self.gbPositions.Caption = "Positions"
        self.groupBox.Add = self.gbPositions

        self.pnlPosition = PositionPanel(self.gbPositions)
        # self.pnlPosition.hideframe_Altitude()
        self.pnlPosition.btnCalculater.setVisible(False)
        self.gbPositions.Add = self.pnlPosition

        self.pnlTree = Frame(self.gbPositions)
        self.gbPositions.Add = self.pnlTree

        self.trvPositions = TreeView(self.pnlTree)
        self.pnlTree.Add = self.trvPositions

        self.pnlButtons = Frame(self.pnlTree, "HL")
        self.pnlTree.Add = self.pnlButtons

        self.btnPrevious = QPushButton(self.pnlButtons)
        self.btnPrevious.setObjectName("btnPrevious")
        self.btnPrevious.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/btnImage/Prev_32x32.png"),
                       QIcon.Normal, QIcon.Off)
        self.btnPrevious.setIcon(icon)
        self.pnlButtons.Add = self.btnPrevious

        self.btnInsert = QPushButton(self.pnlButtons)
        self.btnInsert.setObjectName("btnInsert")
        self.btnInsert.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/add.png"), QIcon.Normal, QIcon.Off)
        self.btnInsert.setIcon(icon)
        self.pnlButtons.Add = self.btnInsert

        self.btnRemove = QPushButton(self.pnlButtons)
        self.btnRemove.setObjectName("btnRemove")
        self.btnRemove.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/remove.png"), QIcon.Normal, QIcon.Off)
        self.btnRemove.setIcon(icon)
        self.pnlButtons.Add = self.btnRemove

        self.btnNext = QPushButton(self.pnlButtons)
        self.btnNext.setObjectName("btnNext")
        self.btnNext.setText("")
        icon = QIcon()
        icon.addPixmap(QPixmap("Resource/btnImage/Next_32x32.png"),
                       QIcon.Normal, QIcon.Off)
        self.btnNext.setIcon(icon)
        self.pnlButtons.Add = self.btnNext

        self.pnlSafetyAreaWidth = DistanceBoxPanel(self.groupBox,
                                                   DistanceUnits.M)
        self.pnlSafetyAreaWidth.Caption = "Safety Area Width"
        self.pnlSafetyAreaWidth.LabelWidth = 250
        self.groupBox.Add = self.pnlSafetyAreaWidth

        self.pnlSafetyAreaStart = DistanceBoxPanel(self.groupBox,
                                                   DistanceUnits.M)
        self.pnlSafetyAreaStart.Caption = "Safety Area Length [START -> boundary]"
        self.pnlSafetyAreaStart.LabelWidth = 250
        self.groupBox.Add = self.pnlSafetyAreaStart

        self.pnlSafetyAreaEnd = DistanceBoxPanel(self.groupBox,
                                                 DistanceUnits.M)
        self.pnlSafetyAreaEnd.Caption = "Safety Area Length [END -> boundary]"
        self.pnlSafetyAreaEnd.LabelWidth = 250
        self.groupBox.Add = self.pnlSafetyAreaEnd

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)

        self.btnOK = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)

        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.btnOK.setText("Save")
        self.connect(self.pnlDesignator, SIGNAL("Event_1"), self.method_15)

        self.connect(self.pnlPosition, SIGNAL("captureFinished"),
                     self.method_14)
        self.btnInsert.clicked.connect(self.btnInsert_Click)
        self.btnNext.clicked.connect(self.btnNext_Click)
        self.btnPrevious.clicked.connect(self.btnPrevious_Click)
        self.btnRemove.clicked.connect(self.btnRemove_Click)

        self.trvPositions.clicked.connect(self.trvPositions_clicked)

    def trvPositions_clicked(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        tag = selectedNode.Tag
        if (tag == None):
            return
        self.pnlPosition.posType = tag.Type
        if not tag.IsEmpty and tag.IsValid:
            self.pnlPosition.Point3d = tag.Point3d
        else:
            self.pnlPosition.Point3d = None

    def get_Fato(self):
        return self.method_6()

    def set_Fato(self, fato):
        if (fato != None):
            self.pnlName.Value = fato.Name
            self.pnlDesignator.Value = fato.DesignatorHeading
            self.cmbDesignator.SelectedIndex = self.cmbDesignator.FindString(
                fato.DesignatorCode)
            self.pnlSafetyAreaWidth.Value = Distance(fato.SafetyAreaWidth)
            self.pnlSafetyAreaStart.Value = Distance(fato.SafetyAreaStart)
            self.pnlSafetyAreaEnd.Value = Distance(fato.SafetyAreaEnd)
        self.method_5(fato)

    Fato = property(get_Fato, set_Fato, None, None)

    def acceptDlg(self):
        current = None
        # self.errorProvider.method_1()
        # self.pnlName.method_0()
        for current in self.trvPositions.Nodes:
            # IEnumerator enumerator = self.trvPositions.Nodes.GetEnumerator()
            # try
            # {
            #     while (true)
            #     {
            #         if (enumerator.MoveNext())
            #         {
            #     current = (TreeNode)enumerator.Current
            tag = current.Tag
            if (not tag.IsValidIncludingAltitude):
                if (tag.Type == PositionType.START):
                    break
                if (tag.Type == PositionType.END):
                    break
                elif (not tag.IsEmpty):
                    self.trvPositions.SelectedNode = current
                    fato = self.method_6()
                    self.emit(SIGNAL("DlgFato_accept"), fato)
                    # self.pnlPosition.method_6()
                    return
            for treeNode in current.Nodes:
                # IEnumerator enumerator1 = current.Nodes.GetEnumerator()
                # try
                # {
                #     while (enumerator1.MoveNext())
                #     {
                #         TreeNode treeNode = (TreeNode)enumerator1.Current
                position = current.Tag
                if (position.IsValidIncludingAltitude or position.IsEmpty):
                    continue
                self.trvPositions.SelectedNode = treeNode
                self.pnlPosition.method_6()
                fato = self.method_6()
                self.emit(SIGNAL("DlgFato_accept"), fato)
                return
            #     }
            # }
            # finally
            # {
            #     IDisposable disposable = enumerator1 as IDisposable
            #     if (disposable != null)
            #     {
            #         disposable.Dispose()
            #     }
            # }
            #     }
            #     else
            #     {
            #         goto Label0
            #     }
            # }
        self.trvPositions.SelectedNode = current
        # self.pnlPosition.method_6()
        fato = self.method_6()
        self.emit(SIGNAL("DlgFato_accept"), fato)
        # }
        # finally
        # {
        #     IDisposable disposable1 = enumerator as IDisposable
        #     if (disposable1 != null)
        #     {
        #         disposable1.Dispose()
        #     }
        # }
        # return
        # Label0:
        #     if (!self.errorProvider.HasErrors)
        #     {
        #         if (self.method_6().method_7(self))
        #         {
        #             base.DialogResult = System.Windows.Forms.DialogResult.OK
        #         }
        #         return
        #     }
        #     else
        #     {
        #         return
        #     }
        self.accept()

    def btnInsert_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        tag = selectedNode.Tag
        if (tag == None):
            return
        if (tag.Type == PositionType.START):
            selectedNode = selectedNode.Insert(
                0, PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        elif (tag.Type != PositionType.END):
            if (tag.Type != PositionType.Position):
                return
            if selectedNode.Parent == None:
                selectedNode = self.trvPositions.Insert(
                    selectedNode.Index,
                    PositionType.VariableNames[PositionType.Position - 1])
            else:
                selectedNode = selectedNode.Parent.Insert(
                    selectedNode.Index,
                    PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        else:
            selectedNode = selectedNode.PrevNode.Add(
                PositionType.VariableNames[PositionType.Position - 1])
            selectedNode.Tag = Position(PositionType.Position)
        self.trvPositions.SelectedNode = selectedNode

    def btnNext_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.NextNode == None):
                self.trvPositions.SelectedNode = selectedNode.Parent.NextNode
                return
            self.trvPositions.SelectedNode = selectedNode.NextNode
        else:
            if (len(selectedNode.Nodes) > 0):
                self.trvPositions.SelectedNode = selectedNode.Nodes[0]
                return
            if (selectedNode.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.NextNode
                return

    def btnPrevious_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.Index == 0):
                self.trvPositions.SelectedNode = selectedNode.Parent
                return
            self.trvPositions.SelectedNode = selectedNode.PrevNode
        else:
            selectedNode = selectedNode.PrevNode
            if (selectedNode != None):
                if (len(selectedNode.Nodes) <= 0):
                    self.trvPositions.SelectedNode = selectedNode
                    return
                self.trvPositions.SelectedNode = selectedNode.LastNode
                return

    def btnRemove_Click(self):
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode == None):
            return
        if (selectedNode.Parent != None):
            if (selectedNode.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.NextNode
            elif (selectedNode.Parent.NextNode != None):
                self.trvPositions.SelectedNode = selectedNode.Parent.NextNode
            else:
                self.trvPositions.SelectedNode = selectedNode.Parent
            parentNode = selectedNode.Parent
            if parentNode == None:
                self.trvPositions.Remove(selectedNode)
            else:
                parentNode.Remove(selectedNode)
        else:
            self.trvPositions.Remove(selectedNode)

    def method_5(self, fato_0):
        self.trvPositions.Clear()
        if (fato_0 != None):
            position = fato_0.method_1(PositionType.START)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = fato_0.method_1(PositionType.END)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            position = fato_0.method_1(PositionType.CWY)
            self.trvPositions.Add(PositionType.VariableNames[position.Type -
                                                             1]).Tag = position
            item = self.trvPositions.Nodes[0]
            for fato0 in fato_0:
                if (fato0.Type != PositionType.Position):
                    continue
                item.Add(PositionType.VariableNames[fato0.Type -
                                                    1]).Tag = fato0
        else:
            self.trvPositions.Nodes.Add("START").Tag = Position(
                PositionType.START)
            self.trvPositions.Nodes.Add("END").Tag = Position(PositionType.END)
            self.trvPositions.Nodes.Add("CWY").Tag = Position(PositionType.CWY)
        self.trvPositions.SelectedNode = self.trvPositions.Nodes[0]
        self.pnlPosition.posType = PositionType.START
        self.method_10()

    def method_6(self):
        fato = Fato()
        fato.Name = self.pnlName.Value
        fato.DesignatorHeading = self.pnlDesignator.Value
        if (self.cmbDesignator.SelectedIndex > 0):
            fato.DesignatorCode = self.cmbDesignator.SelectedItem
        fato.SafetyAreaWidth = self.pnlSafetyAreaWidth.Value.Metres
        fato.SafetyAreaStart = self.pnlSafetyAreaStart.Value.Metres
        fato.SafetyAreaEnd = self.pnlSafetyAreaEnd.Value.Metres
        for node in self.trvPositions.Nodes:
            tag = node.Tag  # as Position
            fato[node.Index] = tag
            if (tag.Type != PositionType.START):
                continue
            for treeNode in node.Nodes:
                position = treeNode.Tag  # as Position
                if (not position.IsValidIncludingAltitude):
                    continue
                fato.Add(position)
        return fato

    def method_7(self):
        selectedNode = self.trvPositions.SelectedNode
        flag = False
        if (selectedNode != None):
            flag = True if (
                selectedNode.PrevNode != None) else selectedNode.Parent != None
        self.btnPrevious.setEnabled(flag)
        nextNode = False
        if (selectedNode != None):
            if (selectedNode.NextNode != None):
                nextNode = True
            elif (selectedNode.Parent != None):
                nextNode = selectedNode.Parent.NextNode != None
        self.btnNext.setEnabled(nextNode)
        flag1 = False
        if (selectedNode != None):
            tag = selectedNode.Tag
            if (tag != None):
                flag1 = True if (tag.Type == PositionType.START
                                 or tag.Type == PositionType.Position
                                 ) else tag.Type == PositionType.END
        self.btnInsert.setEnabled(flag1)
        type = False
        if (selectedNode != None):
            position = selectedNode.Tag
            if (position != None):
                type = position.Type == PositionType.Position
        self.btnRemove.setEnabled(type)

    def method_8(self, treeNode_0, bool_0):
        if (treeNode_0 != None):
            text = treeNode_0.Text
            treeNode_0.Text = " "
            if (not bool_0):
                treeNode_0.NodeFont = QFont()
            else:
                font = QFont()
                font.setBold(True)
                treeNode_0.NodeFont = font
            treeNode_0.Text = text

    def method_9(self, treeNode_0):
        position = treeNode_0.Tag
        if not isinstance(position, Position):
            return
        num = 0
        if (not position.IsValidIncludingAltitude):
            if (position.Type != PositionType.START):
                if (position.Type == PositionType.END):
                    num = 2
                else:
                    if (not position.IsEmpty):
                        num = 2
                        # treeNode_0.ImageIndex = num
                        # treeNode_0.SelectedImageIndex = num
                        for node in treeNode_0.Nodes:
                            self.method_9(node)
                        return
                    else:
                        # treeNode_0.ImageIndex = num
                        # treeNode_0.SelectedImageIndex = num
                        for treeNode in treeNode_0.Nodes:
                            self.method_9(treeNode)
                        return
            num = 2
        else:
            num = 1
        # treeNode_0.ImageIndex = num
        # treeNode_0.SelectedImageIndex = num
        for node1 in treeNode_0.Nodes:
            self.method_9(node1)

    def method_10(self):
        for node in self.trvPositions.Nodes:
            self.method_9(node)

    def method_11(self):
        point3d_0 = Point3D.get_Origin()
        selectedNode = self.trvPositions.SelectedNode
        if (selectedNode != None):
            selectedNode = selectedNode.PrevNode
            if (selectedNode != None):
                if (len(selectedNode.Nodes) > 0):
                    selectedNode = selectedNode.LastNode
                point3d_0 = selectedNode.Tag.Point3d
                return True, point3d_0
        return False, None

    def method_12(self, positionType_0):
        point3d_0 = Point3D.get_Origin()
        try:
            item = None
            if (positionType_0 == PositionType.START):
                item = self.trvPositions.Nodes[0]
            elif (positionType_0 == PositionType.END):
                item = self.trvPositions.Nodes[1]
            if (positionType_0 == PositionType.SWY):
                item = self.trvPositions.Nodes[2]
            if (item != None and item.Tag != None):
                point3d_0 = item.Tag.Point3d
                return True, point3d_0
        except:
            pass
        return False, point3d_0

    def method_14(self):
        self.trvPositions.SelectedNode.Tag = self.pnlPosition.PositionValue
        self.method_10()

    def method_15(self):
        fato = self.method_6()
        self.pnlDesignator.Value = fato.method_0()

    @staticmethod
    def smethod_0(iwin32Window_0, fato):
        flag = False
        dlgFato = DlgFato(iwin32Window_0)
        dlgFato.Fato = fato
        dlgFato.show()
        # if (dlgRunway.method_2(iwin32Window_0) != System.Windows.Forms.DialogResult.OK)
        # {
        #     flag = false
        # }
        # else
        # {
        #     runway_0 = dlgRunway.Runway
        #     flag = true
        # }
        # }
        return dlgFato
Example #40
0
    def registerEvent(self):
        selection = self.ui.modulesList.selectedItems()
        if not selection:
            return

        try:
            module = self.weboob.modules_loader.get_or_load_module(unicode(selection[0].text()).lower())
        except ModuleLoadError:
            module = None

        if not module:
            return

        dialog = QDialog(self)
        vbox = QVBoxLayout(dialog)
        if module.website:
            website = 'on the website <b>%s</b>' % module.website
        else:
            website = 'with the module <b>%s</b>' % module.name
        vbox.addWidget(QLabel('To create an account %s, please provide this information:' % website))
        formlayout = QFormLayout()
        props_widgets = OrderedDict()
        for key, prop in module.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems():
            widget = QtValue(prop)
            formlayout.addRow(QLabel(u'%s:' % prop.label), widget)
            props_widgets[prop.id] = widget

        vbox.addLayout(formlayout)
        buttonBox = QDialogButtonBox(dialog)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
        buttonBox.accepted.connect(dialog.accept)
        buttonBox.rejected.connect(dialog.reject)
        vbox.addWidget(buttonBox)

        end = False
        while not end:
            end = True
            if dialog.exec_():
                account = Account()
                account.properties = {}
                for key, widget in props_widgets.iteritems():
                    try:
                        v = widget.get_value()
                    except ValueError as e:
                        QMessageBox.critical(self, self.tr('Invalid value'),
                            unicode(self.tr('Invalid value for field "%s":<br /><br />%s')) % (key, e))
                        end = False
                        break
                    else:
                        account.properties[key] = v
                if end:
                    try:
                        module.klass.register_account(account)
                    except AccountRegisterError as e:
                        QMessageBox.critical(self, self.tr('Error during register'),
                            unicode(self.tr('Unable to register account %s:<br /><br />%s')) % (website, e))
                        end = False
                    else:
                        for key, value in account.properties.iteritems():
                            if key in self.config_widgets:
                                self.config_widgets[key][1].set_value(value)
Example #41
0
class DlgAerodromeSurfacesCriteria(QDialog):
    def __init__(self, parent = None):
        QDialog.__init__(self, parent)

        self.resize(400, 500)
        self.setWindowTitle("Aerodrome Surfaces Criteria")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        scrollArea = QScrollArea(self);
        scrollArea.setObjectName("scrollArea")
        scrollArea.setWidgetResizable(True)
        scrollAreaWidgetContents = QWidget(scrollArea)
        scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
        # scrollAreaWidgetContents.setGeometry(QRect(0, 0, 380, 280))
        vLayoutScrollArea = QVBoxLayout(scrollAreaWidgetContents)
        vLayoutScrollArea.setObjectName("vLayoutScrollArea")
        scrollArea.setWidget(scrollAreaWidgetContents)
        verticalLayoutDlg.addWidget(scrollArea)

        self.groupBox = GroupBox(self)
        self.groupBox.Caption = ""
        vLayoutScrollArea.addWidget(self.groupBox)

        self.panel = Frame(self.groupBox)
        self.groupBox.Add = self.panel

        self.pnlName = TextBoxPanel(self.panel)
        self.pnlName.LabelWidth = 0
        self.panel.Add = self.pnlName

        self.gbApproach = GroupBox(self.panel)
        self.gbApproach.Caption = "Approach"
        self.panel.Add = self.gbApproach

        self.pnlAPP_InnerEdge = DistanceBoxPanel(self.gbApproach, DistanceUnits.M)
        self.pnlAPP_InnerEdge.Caption = "Inner Edge"
        self.pnlAPP_InnerEdge.Button = None
        self.gbApproach.Add = self.pnlAPP_InnerEdge

        self.pnlAPP_DistFromTHR = DistanceBoxPanel(self.gbApproach, DistanceUnits.M)
        self.pnlAPP_DistFromTHR.Caption = "Distance From Threshold"
        self.pnlAPP_DistFromTHR.Button = None
        self.gbApproach.Add = self.pnlAPP_DistFromTHR

        self.pnlAPP_Divergence = AngleGradientBoxPanel(self.gbApproach)
        self.pnlAPP_Divergence.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlAPP_Divergence.Caption = "Divergence (each side)"
        self.gbApproach.Add = self.pnlAPP_Divergence

        self.gbApproach1 = GroupBox(self.gbApproach)
        self.gbApproach1.Caption = "First Section"
        self.gbApproach.Add = self.gbApproach1

        self.pnlAPP_Length1 = DistanceBoxPanel(self.gbApproach1, DistanceUnits.M)
        self.pnlAPP_Length1.Caption = "Length"
        self.pnlAPP_Length1.Button = None
        self.gbApproach1.Add = self.pnlAPP_Length1

        self.pnlAPP_Slope1 = AngleGradientBoxPanel(self.gbApproach1)
        self.pnlAPP_Slope1.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlAPP_Slope1.Caption = "Slope"
        self.gbApproach1.Add = self.pnlAPP_Slope1

        self.gbApproach2 = GroupBox(self.gbApproach)
        self.gbApproach2.Caption = "Second Section"
        self.gbApproach.Add = self.gbApproach2

        self.pnlAPP_Length2 = DistanceBoxPanel(self.gbApproach2, DistanceUnits.M)
        self.pnlAPP_Length2.Caption = "Length"
        self.pnlAPP_Length2.Button = None
        self.gbApproach2.Add = self.pnlAPP_Length2

        self.pnlAPP_Slope2 = AngleGradientBoxPanel(self.gbApproach2)
        self.pnlAPP_Slope2.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlAPP_Slope2.Caption = "Slope"
        self.gbApproach2.Add = self.pnlAPP_Slope2

        self.gbApproach3 = GroupBox(self.gbApproach)
        self.gbApproach3.Caption = "Horizontal Section"
        self.gbApproach.Add = self.gbApproach3

        self.pnlAPP_Length3 = DistanceBoxPanel(self.gbApproach3, DistanceUnits.M)
        self.pnlAPP_Length3.Caption = "Length"
        self.pnlAPP_Length3.Button = None
        self.gbApproach3.Add = self.pnlAPP_Length3

        self.pnlAPP_TotalLength = DistanceBoxPanel(self.gbApproach3, DistanceUnits.M)
        self.pnlAPP_TotalLength.Caption = "Total Length"
        self.pnlAPP_TotalLength.Button = None
        self.gbApproach3.Add = self.pnlAPP_TotalLength

        self.gbBalkedLanding = GroupBox(self.panel)
        self.gbBalkedLanding.Caption = "Balked Landing"
        self.panel.Add = self.gbBalkedLanding

        self.pnlBL_InnerEdge = DistanceBoxPanel(self.gbBalkedLanding, DistanceUnits.M)
        self.pnlBL_InnerEdge.Caption = "Length of Inner Edge"
        self.pnlBL_InnerEdge.Button = None
        self.gbBalkedLanding.Add = self.pnlBL_InnerEdge

        self.pnlBL_DistFromTHR = Frame(self.gbBalkedLanding, "HL")
        self.gbBalkedLanding.Add = self.pnlBL_DistFromTHR

        self.cmbBL_DistFromTHR = ComboBoxPanel(self.pnlBL_DistFromTHR)
        self.cmbBL_DistFromTHR.CaptionUnits = "m"
        self.cmbBL_DistFromTHR.Caption = "Distance From Threshold"
        self.pnlBL_DistFromTHR.Add = self.cmbBL_DistFromTHR

        self.txtBL_DistFromTHR = DistanceBoxPanel(self.pnlBL_DistFromTHR, DistanceUnits.M)
        self.txtBL_DistFromTHR.LabelWidth = 0
        self.txtBL_DistFromTHR.Button = None
        self.pnlBL_DistFromTHR.Add = self.txtBL_DistFromTHR

        self.pnlBL_Divergence = AngleGradientBoxPanel(self.gbBalkedLanding)
        self.pnlBL_Divergence.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlBL_Divergence.Caption = "Divergence (each side)"
        self.gbBalkedLanding.Add = self.pnlBL_Divergence

        self.pnlBL_Slope = AngleGradientBoxPanel(self.gbBalkedLanding)
        self.pnlBL_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlBL_Slope.Caption = "Slope"
        self.gbBalkedLanding.Add = self.pnlBL_Slope

        self.gbConical = GroupBox(self.panel)
        self.gbConical.Caption = "Conical"
        self.panel.Add = self.gbConical

        self.pnlCON_Slope = AngleGradientBoxPanel(self.gbConical)
        self.pnlCON_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlCON_Slope.Caption = "Slope"
        self.gbConical.Add = self.pnlCON_Slope

        self.pnlCON_Height = AltitudeBoxPanel(self.gbConical)
        self.pnlCON_Height.CaptionUnits = "m"
        self.pnlCON_Height.Caption = "Height"
        self.gbConical.Add = self.pnlCON_Height

        self.gbInnerApproach = GroupBox(self.panel)
        self.gbInnerApproach.Caption = "Inner Approach"
        self.panel.Add = self.gbInnerApproach

        self.pnlIA_Width = DistanceBoxPanel(self.gbInnerApproach, DistanceUnits.M)
        self.pnlIA_Width.Caption = "Width"
        self.pnlIA_Width.Button = None
        self.gbInnerApproach.Add = self.pnlIA_Width

        self.pnlIA_DistFromTHR = DistanceBoxPanel(self.gbInnerApproach, DistanceUnits.M)
        self.pnlIA_DistFromTHR.Caption = "Distance From Threshold"
        self.pnlIA_DistFromTHR.Button = None
        self.gbInnerApproach.Add = self.pnlIA_DistFromTHR

        self.pnlIA_Length = DistanceBoxPanel(self.gbInnerApproach, DistanceUnits.M)
        self.pnlIA_Length.Caption = "Length"
        self.pnlIA_Length.Button = None
        self.gbInnerApproach.Add = self.pnlIA_Length

        self.pnlIA_Slope = AngleGradientBoxPanel(self.gbInnerApproach)
        self.pnlIA_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlIA_Slope.Caption = "Slope"
        self.gbInnerApproach.Add = self.pnlIA_Slope

        self.gbInnerHorizontal = GroupBox(self.panel)
        self.gbInnerHorizontal.Caption = "Inner Horizontal"
        self.panel.Add = self.gbInnerHorizontal

        self.pnlIH_Location = ComboBoxPanel(self.gbInnerHorizontal)
        self.pnlIH_Location.Caption = "Location"
        self.gbInnerHorizontal.Add = self.pnlIH_Location

        self.pnlIH_Height = AltitudeBoxPanel(self.gbInnerHorizontal)
        self.pnlIH_Height.CaptionUnits = "m"
        self.pnlIH_Height.Caption = "Height"
        self.gbInnerHorizontal.Add = self.pnlIH_Height

        self.pnlIH_Radius = DistanceBoxPanel(self.gbInnerHorizontal, DistanceUnits.M)
        self.pnlIH_Radius.Caption = "Radius"
        self.pnlIH_Radius.Button = None
        self.gbInnerHorizontal.Add = self.pnlIH_Radius

        self.gbInnerTransitional = GroupBox(self.panel)
        self.gbInnerTransitional.Caption = "Inner Transitional"
        self.panel.Add = self.gbInnerTransitional

        self.pnlIT_Slope = AngleGradientBoxPanel(self.gbInnerTransitional)
        self.pnlIT_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlIT_Slope.Caption = "Slope"
        self.gbInnerTransitional.Add = self.pnlIT_Slope

        self.gbNavAid = GroupBox(self.panel)
        self.gbNavAid.Caption = "1:10 Navigational Aid"
        self.panel.Add = self.gbNavAid

        self.pnlNA_Slope = AngleGradientBoxPanel(self.gbNavAid)
        self.pnlNA_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlNA_Slope.Caption = "Slope"
        self.gbNavAid.Add = self.pnlNA_Slope

        self.gbOuterHorizontal = GroupBox(self.panel)
        self.gbOuterHorizontal.Caption = "Outer Horizontal"
        self.panel.Add = self.gbOuterHorizontal

        self.pnlOH_Height = AltitudeBoxPanel(self.gbOuterHorizontal)
        self.pnlOH_Height.CaptionUnits = "m"
        self.pnlOH_Height.Caption = "Height"
        self.gbOuterHorizontal.Add = self.pnlOH_Height

        self.pnlOH_Radius = DistanceBoxPanel(self.gbOuterHorizontal, DistanceUnits.M)
        self.pnlOH_Radius.Caption = "Radius"
        self.pnlOH_Radius.Button = None
        self.gbOuterHorizontal.Add = self.pnlOH_Radius

        self.gbStrip = GroupBox(self.panel)
        self.gbStrip.Caption = "Strip"
        self.panel.Add = self.gbStrip

        self.pnlS_Width = DistanceBoxPanel(self.gbStrip, DistanceUnits.M)
        self.pnlS_Width.Caption = "Width"
        self.pnlS_Width.Button = None
        self.gbStrip.Add = self.pnlS_Width

        self.pnlS_Length = DistanceBoxPanel(self.gbStrip, DistanceUnits.M)
        self.pnlS_Length.Caption = "Length"
        self.pnlS_Length.Button = None
        self.gbStrip.Add = self.pnlS_Length

        self.gbTakeOff = GroupBox(self.panel)
        self.gbTakeOff.Caption = "Take-off "
        self.panel.Add = self.gbTakeOff

        self.pnlTO_InnerEdge = DistanceBoxPanel(self.gbTakeOff, DistanceUnits.M)
        self.pnlTO_InnerEdge.Caption = "Length of Inner Edge"
        self.pnlTO_InnerEdge.Button = None
        self.gbTakeOff.Add = self.pnlTO_InnerEdge

        self.pnlTO_DistFromEND = Frame(self.gbTakeOff, "HL")
        self.gbTakeOff.Add = self.pnlTO_DistFromEND

        self.cmbTO_DistFromEND = ComboBoxPanel(self.pnlTO_DistFromEND)
        self.cmbTO_DistFromEND.CaptionUnits = "m"
        self.cmbTO_DistFromEND.Caption = "Distance From Runway End"
        self.pnlTO_DistFromEND.Add = self.cmbTO_DistFromEND

        self.txtTO_DistFromEND = DistanceBoxPanel(self.pnlTO_DistFromEND, DistanceUnits.M)
        self.txtTO_DistFromEND.LabelWidth = 0
        self.txtTO_DistFromEND.Button = None
        self.pnlTO_DistFromEND.Add = self.txtTO_DistFromEND

        self.pnlTO_Divergence = AngleGradientBoxPanel(self.gbTakeOff)
        self.pnlTO_Divergence.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlTO_Divergence.Caption = "Divergence (each side)"
        self.gbTakeOff.Add = self.pnlTO_Divergence

        self.pnlTO_FinalWidth = DistanceBoxPanel(self.gbTakeOff, DistanceUnits.M)
        self.pnlTO_FinalWidth.Caption = "Final Width"
        self.pnlTO_FinalWidth.Button = None
        self.gbTakeOff.Add = self.pnlTO_FinalWidth

        self.pnlTO_Length = DistanceBoxPanel(self.gbTakeOff, DistanceUnits.M)
        self.pnlTO_Length.Caption = "Length"
        self.pnlTO_Length.Button = None
        self.gbTakeOff.Add = self.pnlTO_Length

        self.pnlTO_Slope = AngleGradientBoxPanel(self.gbTakeOff)
        self.pnlTO_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlTO_Slope.Caption = "Slope"
        self.gbTakeOff.Add = self.pnlTO_Slope

        self.gbTransitional = GroupBox(self.panel)
        self.gbTransitional.Caption = "Transitional"
        self.panel.Add = self.gbTransitional

        self.pnlT_Slope = AngleGradientBoxPanel(self.gbTransitional)
        self.pnlT_Slope.CaptionUnits = AngleGradientSlopeUnits.Percent
        self.pnlT_Slope.Caption = "Slope"
        self.gbTransitional.Add = self.pnlT_Slope

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)

        self.btnSave = self.btnBoxOkCancel.button(QDialogButtonBox.Ok)
        self.btnSave.setText("Save")

        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        vLayoutScrollArea.addWidget(self.btnBoxOkCancel)

        self.cmbBL_DistFromTHR.Items = AerodromeSurfacesBalkedLandingFrom.Items
        self.pnlIH_Location.Items = AerodromeSurfacesInnerHorizontalLocation.Items
        self.cmbTO_DistFromEND.Items = AerodromeSurfacesTakeOffFrom.Items


        self.connect(self.pnlT_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlTO_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlTO_Length, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlTO_FinalWidth, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlTO_Divergence, SIGNAL("Event_0"), self.method_6)
        self.connect(self.txtTO_DistFromEND, SIGNAL("Event_0"), self.method_6)
        self.connect(self.cmbTO_DistFromEND, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlTO_InnerEdge, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlS_Length, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlS_Width, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlOH_Radius, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlOH_Height, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlNA_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIT_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIH_Radius, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIH_Height, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIH_Location, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIA_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIA_Length, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIA_DistFromTHR, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlIA_Width, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlCON_Height, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlCON_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlBL_Slope, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlBL_Divergence, SIGNAL("Event_0"), self.method_6)

        self.connect(self.txtBL_DistFromTHR, SIGNAL("Event_0"), self.method_6)
        self.connect(self.cmbBL_DistFromTHR, SIGNAL("Event_0"), self.cmbBL_DistFromTHR_currentIndexChanged)
        self.connect(self.pnlBL_InnerEdge, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_TotalLength, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Length3, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Slope2, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Length2, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Slope1, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Length1, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_Divergence, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_DistFromTHR, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlAPP_InnerEdge, SIGNAL("Event_0"), self.method_6)
        self.connect(self.pnlName, SIGNAL("Event_0"), self.method_6)

        self.modified = False
        self.criteria = None

    def acceptDlg(self):
        self.accept()

    def method_5(self):
        self.txtBL_DistFromTHR.Enabled = self.cmbBL_DistFromTHR.SelectedIndex > 0
    def method_6(self):
        if (not self.modified):
            self.setWindowTitle(Captions.CRITERIA_MODIFIED)
            self.btnSave.setEnabled(True)
            self.modified = True

    def cmbBL_DistFromTHR_currentIndexChanged(self):
        self.method_5()
        if (not self.modified):
            self.setWindowTitle(Captions.CRITERIA_MODIFIED)
            self.btnSave.setEnabled(True)
            self.modified = True

    @staticmethod
    def smethod_0(parent, aerodromeSurfacesCriteria_0):
        flag = False
        dlgAerodromeSurfacesCriterium = DlgAerodromeSurfacesCriteria()
        dlgAerodromeSurfacesCriterium.Criteria = aerodromeSurfacesCriteria_0
        resultDlg = dlgAerodromeSurfacesCriterium.exec_()
        if (not resultDlg == 1):
            flag = False
        else:
            aerodromeSurfacesCriteria_0 = dlgAerodromeSurfacesCriterium.Criteria
            flag = True
        return flag, aerodromeSurfacesCriteria_0

    def get_Criteria(self):
        num = None
        self.criteria.Criteria = AerodromeSurfacesCriteriaType.Custom
        self.criteria.Name = self.pnlName.Value
        approachSurfaceCriterium = self.criteria
        metres = self.pnlAPP_InnerEdge.Value.Metres
        metres1 = self.pnlAPP_DistFromTHR.Value.Metres
        percent = self.pnlAPP_Divergence.Value.Percent
        num1 = self.pnlAPP_Length1.Value.Metres
        percent1 = self.pnlAPP_Slope1.Value.Percent
        metres2 = self.pnlAPP_Length2.Value.Metres
        percent2 = self.pnlAPP_Slope2.Value.Percent
        num2 = self.pnlAPP_Length3.Value.Metres
        value = self.pnlAPP_TotalLength.Value
        approachSurfaceCriterium.Approach = ApproachSurfaceCriteria(metres, metres1, percent, num1, percent1, metres2, percent2, num2, value.Metres)
        balkedLandingSurfaceCriterium = self.criteria
        metres3 = self.pnlBL_InnerEdge.Value.Metres
        num = (self.cmbBL_DistFromTHR.SelectedIndex > 0) and self.txtBL_DistFromTHR.Value.Metres or None
        percent3 = self.pnlBL_Divergence.Value.Percent
        angleGradientSlope = self.pnlBL_Slope.Value
        balkedLandingSurfaceCriterium.BalkedLanding = BalkedLandingSurfaceCriteria(metres3, num, self.cmbBL_DistFromTHR.SelectedIndex == 2, percent3, angleGradientSlope.Percent)
        conicalSurfaceCriterium = self.criteria
        num3 = self.pnlCON_Slope.Value.Percent
        altitude = self.pnlCON_Height.Value
        conicalSurfaceCriterium.Conical = ConicalSurfaceCriteria(num3, altitude.Metres)
        innerApproachSurfaceCriterium = self.criteria
        metres4 = self.pnlIA_Width.Value.Metres
        num4 = self.pnlIA_DistFromTHR.Value.Metres
        metres5 = self.pnlIA_Length.Value.Metres
        value1 = self.pnlIA_Slope.Value
        innerApproachSurfaceCriterium.InnerApproach = InnerApproachSurfaceCriteria(metres4, num4, metres5, value1.Percent)
        innerHorizontalSurfaceCriterium = self.criteria
        selectedItem = self.pnlIH_Location.SelectedItem
        num5 = self.pnlIH_Height.Value.Metres
        distance = self.pnlIH_Radius.Value
        innerHorizontalSurfaceCriterium.InnerHorizontal = InnerHorizontalSurfaceCriteria(selectedItem, num5, distance.Metres)
        self.criteria.InnerTransitional =  InnerTransitionalSurfaceCriteria(self.pnlIT_Slope.Value.Percent)
        self.criteria.NavigationalAid = NavigationalAidSurfaceCriteria(self.pnlNA_Slope.Value.Percent)
        outerHorizontalSurfaceCriterium = self.criteria
        metres6 = self.pnlOH_Height.Value.Metres
        distance1 = self.pnlOH_Radius.Value
        outerHorizontalSurfaceCriterium.OuterHorizontal = OuterHorizontalSurfaceCriteria(metres6, distance1.Metres)
        stripSurfaceCriterium = self.criteria
        num6 = self.pnlS_Length.Value.Metres
        value2 = self.pnlS_Width.Value
        stripSurfaceCriterium.Strip = StripSurfaceCriteria(num6, value2.Metres)
        takeOffSurfaceCriterium = self.criteria
        metres7 = self.pnlTO_InnerEdge.Value.Metres
        num7 = self.txtTO_DistFromEND.Value.Metres
        percent4 = self.pnlTO_Divergence.Value.Percent
        metres8 = self.pnlTO_FinalWidth.Value.Metres
        num8 = self.pnlTO_Length.Value.Metres
        angleGradientSlope1 = self.pnlTO_Slope.Value
        takeOffSurfaceCriterium.TakeOff = TakeOffSurfaceCriteria(metres7, num7, self.cmbTO_DistFromEND.SelectedIndex == 1, percent4, metres8, num8, angleGradientSlope1.Percent)
        self.criteria.Transitional = TransitionalSurfaceCriteria(self.pnlT_Slope.Value.Percent)
        return self.criteria
    def set_Criteria(self, value):
        if value == None:
            return
        self.criteria = value
        self.pnlName.Value = self.criteria.Name
        if (self.criteria.Approach.Enabled):
            self.pnlAPP_InnerEdge.Value = Distance(self.criteria.Approach.InnerEdge)
            self.pnlAPP_DistFromTHR.Value = Distance(self.criteria.Approach.DistFromTHR)
            self.pnlAPP_Divergence.Value = AngleGradientSlope(self.criteria.Approach.Divergence, AngleGradientSlopeUnits.Percent)
            self.pnlAPP_Length1.Value = Distance(self.criteria.Approach.Length1)
            self.pnlAPP_Slope1.Value = AngleGradientSlope(self.criteria.Approach.Slope1, AngleGradientSlopeUnits.Percent)
            if (self.criteria.Approach.HasSection2):
                self.pnlAPP_Length2.Value = Distance(self.criteria.Approach.Length2)
                self.pnlAPP_Slope2.Value = AngleGradientSlope(self.criteria.Approach.Slope2, AngleGradientSlopeUnits.Percent)
                self.pnlAPP_Length3.Value = Distance(self.criteria.Approach.Length3)
                self.pnlAPP_TotalLength.Value = Distance(self.criteria.Approach.TotalLength)
        self.cmbBL_DistFromTHR.SelectedIndex = 0
        if (self.criteria.BalkedLanding.Enabled):
            self.pnlBL_InnerEdge.Value = Distance(self.criteria.BalkedLanding.InnerEdge)
            if (not MathHelper.smethod_97(self.criteria.BalkedLanding.DistFromTHR, 0)):
                self.txtBL_DistFromTHR.Value = Distance(self.criteria.BalkedLanding.DistFromTHR)
                if (not self.criteria.BalkedLanding.DistFromTHRFixed):
                    self.cmbBL_DistFromTHR.SelectedIndex = 1
                else:
                    self.cmbBL_DistFromTHR.SelectedIndex = 2
            else:
                self.cmbBL_DistFromTHR.SelectedIndex = 0
            self.pnlBL_Divergence.Value = AngleGradientSlope(self.criteria.BalkedLanding.Divergence, AngleGradientSlopeUnits.Percent)
            self.pnlBL_Slope.Value = AngleGradientSlope(self.criteria.BalkedLanding.Slope, AngleGradientSlopeUnits.Percent)
        if (self.criteria.Conical.Enabled):
            self.pnlCON_Slope.Value = AngleGradientSlope(self.criteria.Conical.Slope, AngleGradientSlopeUnits.Percent)
            self.pnlCON_Height.Value = Altitude(self.criteria.Conical.Height)
        if (self.criteria.InnerApproach.Enabled):
            self.pnlIA_Width.Value = Distance(self.criteria.InnerApproach.Width)
            self.pnlIA_DistFromTHR.Value = Distance(self.criteria.InnerApproach.DistFromTHR)
            self.pnlIA_Length.Value = Distance(self.criteria.InnerApproach.Length)
            self.pnlIA_Slope.Value = AngleGradientSlope(self.criteria.InnerApproach.Slope, AngleGradientSlopeUnits.Percent)
        self.pnlIH_Location.SelectedItem = self.criteria.InnerHorizontal.Location
        self.pnlIH_Height.Value = Altitude(self.criteria.InnerHorizontal.Height)
        self.pnlIH_Radius.Value = Distance(self.criteria.InnerHorizontal.Radius)
        if (self.criteria.InnerTransitional.Enabled):
            self.pnlIT_Slope.Value = AngleGradientSlope(self.criteria.InnerTransitional.Slope, AngleGradientSlopeUnits.Percent)
        if (self.criteria.NavigationalAid.Enabled):
            self.pnlNA_Slope.Value = AngleGradientSlope(self.criteria.NavigationalAid.Slope, AngleGradientSlopeUnits.Percent)
        if (self.criteria.OuterHorizontal.Enabled):
            self.pnlOH_Height.Value = Altitude(self.criteria.OuterHorizontal.Height)
            self.pnlOH_Radius.Value = Distance(self.criteria.OuterHorizontal.Radius)
        self.pnlS_Width.Value = Distance(self.criteria.Strip.Width)
        self.pnlS_Length.Value = Distance(self.criteria.Strip.Length)
        if (not self.criteria.TakeOff.DistFromENDFixed):
            self.cmbTO_DistFromEND.SelectedIndex = 0
        else:
            self.cmbTO_DistFromEND.SelectedIndex = 1
        if (self.criteria.TakeOff.Enabled):
            self.pnlTO_InnerEdge.Value = Distance(self.criteria.TakeOff.InnerEdge)
            self.txtTO_DistFromEND.Value = Distance(self.criteria.TakeOff.DistFromEND)
            self.pnlTO_Divergence.Value = AngleGradientSlope(self.criteria.TakeOff.Divergence, AngleGradientSlopeUnits.Percent)
            self.pnlTO_FinalWidth.Value = Distance(self.criteria.TakeOff.FinalWidth)
            self.pnlTO_Length.Value = Distance(self.criteria.TakeOff.Length)
            self.pnlTO_Slope.Value = AngleGradientSlope(self.criteria.TakeOff.Slope, AngleGradientSlopeUnits.Percent)
        if (self.criteria.Transitional.Enabled):
            self.pnlT_Slope.Value = AngleGradientSlope(self.criteria.Transitional.Slope, AngleGradientSlopeUnits.Percent)
    Criteria = property(get_Criteria, set_Criteria)
Example #42
0
class ColumnsDialog(QDialog):
    """"""

    #----------------------------------------------------------------------
    def __init__(self,
                 full_column_name_list,
                 init_selected_colum_name_list,
                 permanently_selected_column_name_list,
                 parentWindow=None):
        """Constructor"""

        QDialog.__init__(self, parent=parentWindow)

        self.setWindowFlags(
            QtCore.Qt.Window)  # To add Maximize & Minimize buttons

        self.setWindowTitle('Column Visibility/Order')

        self.verticalLayout = QVBoxLayout(self)

        widget = QWidget(self)
        self.visible_column_order_selector = OrderSelector(
            parentWidget=widget,
            full_string_list=full_column_name_list,
            init_selected_string_list=init_selected_colum_name_list,
            permanently_selected_string_list=
            permanently_selected_column_name_list,
            label_text_NotSelected='NOT Visible Column Names:',
            label_text_Selected='Visible Column Names:')
        self.verticalLayout.addWidget(widget)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        self.verticalLayout.addWidget(self.buttonBox)

        self.output = None

        self.connect(self.buttonBox, SIGNAL('accepted()'), self.accept)
        self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject)

    #----------------------------------------------------------------------
    def closeEvent(self, event):
        """"""

        self.output = None

        event.accept()

    #----------------------------------------------------------------------
    def accept(self):
        """"""

        selected_listView = self.visible_column_order_selector.view.listView_Selected
        SMod = selected_listView.model()
        self.output = [
            SMod.item(row_ind, 0).text() for row_ind in range(SMod.rowCount())
        ]

        super(ColumnsDialog, self).accept()

    #----------------------------------------------------------------------
    def reject(self):
        """"""

        self.output = None

        super(ColumnsDialog, self).reject()
class DlgFasDataBlockImport(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.resize(290, 136)
        self.setWindowTitle("Reference Positions")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"))

        self.groupBox = GroupBox(self)
        self.groupBox.Caption = "Output Data"
        verticalLayoutDlg.addWidget(self.groupBox)

        self.txtDataBlock = TextBoxPanel(self.groupBox, True)
        self.txtDataBlock.Caption = "Data Block"
        self.txtDataBlock.Value = "10 20 10 07 05 8C 20 02 01 36 30 05 54 9D AA 18 7C E8 D5 FC 72 16 A0 F5 00 94 96 02 2C 81 2C 01 64 01 C8 FA 6A E4 AF 51"
        self.groupBox.Add = self.txtDataBlock

        self.pnlSuppliedCRC = TextBoxPanel(self.groupBox)
        self.pnlSuppliedCRC.Caption = "Supplied CRC Value"
        self.pnlSuppliedCRC.ReadOnly = True
        self.groupBox.Add = self.pnlSuppliedCRC

        self.pnlCalculatedCRC = TextBoxPanel(self.groupBox)
        self.pnlCalculatedCRC.Caption = "Calculated CRC Value"
        self.pnlCalculatedCRC.ReadOnly = True
        self.groupBox.Add = self.pnlCalculatedCRC

        self.frameBtn = Frame(self, "HL")
        verticalLayoutDlg.addWidget(self.frameBtn)

        self.btnFile = QPushButton(self.frameBtn)
        self.btnFile.setObjectName(("btnFile"))
        self.btnFile.setText("File...")
        self.frameBtn.Add = self.btnFile

        self.btnBoxOkCancel = QDialogButtonBox(self.frameBtn)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"))
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel
                                               | QDialogButtonBox.Ok)
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        self.btnFile.clicked.connect(self.btnFile_clicked)

        self.frameBtn.Add = self.btnBoxOkCancel

        self.txtDataBlock.textBox.textChanged.connect(
            self.txtDataBlock_TextChanged)

    def acceptDlg(self):
        if self.txtDataBlock.Value == "":
            self.reject()
            return
        self.accept()

    # def reject(self):
    #     self.reject()
    def btnFile_clicked(self):
        filePathDir = QFileDialog.getOpenFileName(
            self, "Open Fas Data", QCoreApplication.applicationDirPath(),
            "FAS Data Block Binary Files (*.bin)")
        if filePathDir == "":
            return
        fasDataBlockFile = FasDataBlockFile()
        fasDataBlockFile.method_1(filePathDir)
        self.txtDataBlock.Value = fasDataBlockFile.HexString

    def method_5(self):
        flag = False
        # self.errorProvider.method_1();
        fasDataBlockFile = FasDataBlockFile()
        fasDataBlockFile.set_HexString(self.txtDataBlock.Value)
        if self.txtDataBlock.Value == "":
            self.pnlCalculatedCRC.set_Value("")
        else:
            self.pnlCalculatedCRC.set_Value(fasDataBlockFile.CRC)
        if self.txtDataBlock.Value == "":
            self.pnlSuppliedCRC.set_Value("")
        else:
            value = fasDataBlockFile.HexString.split(' ')
            str0 = ""
            for i in range(36, 40):
                str0 += value[i]
            self.pnlSuppliedCRC.set_Value(str0)
        flag = True
        # except:
        #     # self.errorProvider.method_0(self.txtDataBlock, exception.Message);
        #     self.pnlCalculatedCRC.Value = "";
        #     self.pnlSuppliedCRC.Value = "";
        #     return False;
        return flag

    @staticmethod
    def smethod_0(parent):
        fasDataBlockFile = None
        dlgFasDataBlockImport = DlgFasDataBlockImport()
        dlgFasDataBlockImport.txtDataBlock.set_Value("")
        dlgFasDataBlockImport.pnlCalculatedCRC.set_Value("")
        dlgResult = dlgFasDataBlockImport.exec_()
        if dlgResult != 1:
            fasDataBlockFile = None
        else:
            fasDataBlockFile = FasDataBlockFile()
            fasDataBlockFile.set_HexString(
                dlgFasDataBlockImport.txtDataBlock.get_Value())
        return fasDataBlockFile

    def txtDataBlock_TextChanged(self):
        self.method_5()
class DlgAixmStar(QDialog):
    def __init__(self, parent = None):
        QDialog.__init__(self, parent)
        
        self.resize(290, 136);
        self.setWindowTitle("Standard Terminal Arrival Route (STAR)")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth());
        self.setSizePolicy(sizePolicy);
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"));

        self.groupBox = GroupBox(self)
        verticalLayoutDlg.addWidget(self.groupBox)

        self.pnlAerodrome = ComboBoxPanel(self.groupBox)
        self.pnlAerodrome.Caption = "Aerodrome"
        self.groupBox.Add = self.pnlAerodrome

        self.pnlDesignator = TextBoxPanel(self.groupBox)
        self.pnlDesignator.Caption = "Designator"
        self.groupBox.Add = self.pnlDesignator

        self.pnlAcCategory = ComboBoxPanel(self.groupBox)
        self.pnlAcCategory.Caption = "Ac. Category"
        self.groupBox.Add = self.pnlAcCategory

        self.pnlTransID = TextBoxPanel(self.groupBox)
        self.pnlTransID.Caption = "ransitional Identifier"
        self.groupBox.Add = self.pnlTransID

        self.pnlType = ComboBoxPanel(self.groupBox)
        self.pnlType.Caption = "Type"
        self.groupBox.Add = self.pnlType

        self.pnlMSA = ComboBoxPanel(self.groupBox)
        self.pnlMSA.Caption = "MSA Group"
        self.groupBox.Add = self.pnlMSA

        self.pnlRNP = NumberBoxPanel(self.groupBox)
        self.pnlRNP.Caption = "RNP"
        self.groupBox.Add = self.pnlRNP

        self.tableLayoutPanel = Frame(self.groupBox)
        self.groupBox.Add = self.tableLayoutPanel

        self.txtDescription = TextBoxPanel(self.tableLayoutPanel, True)
        self.txtDescription.Caption = "Description"
        self.tableLayoutPanel.Add = self.txtDescription

        self.txtDescrComFail = TextBoxPanel(self.tableLayoutPanel, True)
        self.txtDescrComFail.Caption = "Communication Failure"
        self.tableLayoutPanel.Add = self.txtDescrComFail

        self.txtRemarks = TextBoxPanel(self.tableLayoutPanel, True)
        self.txtRemarks.Caption = "Remarks"
        self.tableLayoutPanel.Add = self.txtRemarks

        self.btnBoxOkCancel = QDialogButtonBox(self)
        self.btnBoxOkCancel.setObjectName(("btnBoxOkCancel"));
        self.btnBoxOkCancel.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok);
        self.connect(self.btnBoxOkCancel, SIGNAL("accepted()"), self.acceptDlg)
        self.connect(self.btnBoxOkCancel, SIGNAL("rejected()"), self.reject)

        verticalLayoutDlg.addWidget(self.btnBoxOkCancel)

        self.data = None
        self.table = None
        self.selected = None;
    def acceptDlg(self):
        strS = None;
        # self.errorProvider.method_1();
        # self.pnlAerodrome.method_0();
        # self.pnlDesignator.method_0();
        # self.pnlType.method_0();
        # self.pnlRNP.method_1(new Validator(ValidationFlags.AllowEmpty | ValidationFlags.Positive));
        # if (self.errorProvider.HasErrors)
        # {
        #     return;
        # }
        selectedItem = self.pnlAerodrome.SelectedItem;
        num = (self.pnlAcCategory.SelectedIndex >= 0) and self.pnlAcCategory.SelectedIndex or -1;
        for row in self.table:
            flag = True;
            if (self.selected != None and row == self.selected):
                flag = False;
            if (row["ahpEnt"] != selectedItem):
                flag = False;
            if (not self.pnlDesignator.Value == row["txtDesig"]):
                flag = False;
            if (num != (row["codeCatAcft"] == None) and -1 or int(row["codeCatAcft"])):
                flag = False;
            strS = (row["codeTransId"] == None) and "" or row["codeTransId"];
            if (not self.pnlTransID.Value == strS):
                flag = False;

            if (not flag):
                continue;
            str1 = "Cannot create a duplicate procedure entry.\n\nAerodrome = {0}\nDesignator = {1}".format(self.pnlAerodrome.SelectedItem, self.pnlDesignator.Value);
            if (self.pnlAcCategory.SelectedIndex >= 0):
                str1 = String.Concat([str1, "\nAc. Category = {0}".format(self.pnlAcCategory.SelectedItem)]);
            if (not String.IsNullOrEmpty(self.pnlTransID.Value)):
                str1 = String.Concat([str1, "\nTransition Identifier = {0}".format(self.pnlTransID.Value)]);
            QMessageBox.warning(self, "Error", str1);
            return;
        self.accept()
    
    def method_5(self):
        self.data.method_35(self.pnlRunway.Items, self.pnlAerodrome.SelectedItem);
        # self.pnlRunway.comboBox.insertItem(0, "");
    
    @staticmethod
    def smethod_0(dataBaseSTARs_0, dataBaseProcedureData_0, dataRow_0):
        flag = False;
        dlgAixmStar = DlgAixmStar()
        dlgAixmStar.data = dataBaseProcedureData_0;
        dlgAixmStar.table = dataBaseSTARs_0;
        dlgAixmStar.selected = dataRow_0;
        dataBaseProcedureData_0.method_51(dlgAixmStar.pnlAerodrome);
        dataBaseProcedureData_0.method_47(dlgAixmStar.pnlMSA);
        dlgAixmStar.pnlAcCategory.Items = CodeCatAcftAixm.Items;
        dlgAixmStar.pnlType.Items = CodeTypeStarAixm.Items;
        # dlgAixmStar.pnlAcCategory.comboBox.insertItem(0, "");
        # dlgAixmStar.pnlMSA.comboBox.insertItem(0, "");
        if (dataRow_0 != None and len(dataRow_0) != 0):
            dlgAixmStar.pnlAerodrome.SelectedIndex = dlgAixmStar.pnlAerodrome.IndexOf(dataRow_0["ahpEnt"]);
            dlgAixmStar.pnlDesignator.Value = dataRow_0["txtDesig"];
            if (dataRow_0["codeCatAcft"] != None):
                dlgAixmStar.pnlAcCategory.SelectedIndex = dlgAixmStar.pnlAcCategory.method_3(dataRow_0["codeCatAcft"]);
            if (dataRow_0["codeTransId"] != None):
                dlgAixmStar.pnlTransID.Value = dataRow_0["codeTransId"];
            if (dataRow_0["mgpEnt"] != None):
                dlgAixmStar.pnlMSA.SelectedIndex = dlgAixmStar.pnlMSA.IndexOf(dataRow_0["mgpEnt"]);
            if (dataRow_0["codeRnp"] != None):
                dlgAixmStar.pnlRNP.Value = dataRow_0["codeRnp"]
            if (dataRow_0["txtDescrComFail"] != None):
                dlgAixmStar.txtDescrComFail.Value = dataRow_0["txtDescrComFail"];
            dlgAixmStar.pnlType.SelectedIndex = dlgAixmStar.pnlType.method_3(dataRow_0["codeTypeRte"]);
            if (dataRow_0["txtDescr"] != None):
                dlgAixmStar.txtDescription.Value = dataRow_0["txtDescr"];
            if (dataRow_0["txtRmk"] != None):
                dlgAixmStar.txtRemarks.Value = dataRow_0["txtRmk"];
        resultDlg = dlgAixmStar.exec_()
        if (resultDlg == 1):
            dataRow0 = dataRow_0 == None or len(dataRow_0) == 0;
            strS = [];
            if (not dataRow0):
                for i in range(dataBaseSTARs_0.ColumnsCount()):
                    strS.append(None)
                # strS = new string[dataBaseSTARs_0.ColumnsCount];
                i = 0
                for name in dataBaseSTARs_0.nameList:
                    strS[i] = dataRow_0[name];
                    i += 1
            else:
                dataRow_0 = dataBaseSTARs_0.NewRow();
            dataRow_0["ahpEnt"] = dlgAixmStar.pnlAerodrome.SelectedItem;
            if (dataRow0):
                dataRow_0["oldAhpEnt"] = dataRow_0["ahpEnt"];
            dataRow_0["txtDesig"] = dlgAixmStar.pnlDesignator.Value;
            if (dataRow0):
                dataRow_0["oldTxtDesig"] = dataRow_0["txtDesig"];
            if (dlgAixmStar.pnlAcCategory.SelectedIndex >= 0):
                dataRow_0["codeCatAcft"] = dlgAixmStar.pnlAcCategory.SelectedItem;
            else:
                dataRow_0["codeCatAcft"] = None;
            if (dataRow0):
                dataRow_0["oldCodeCatAcft"] = dataRow_0["codeCatAcft"];
            if (not String.IsNullOrEmpty(dlgAixmStar.pnlTransID.Value)):
                dataRow_0["codeTransId"] = dlgAixmStar.pnlTransID.Value;
            else:
                dataRow_0["codeTransId"] = None;
            if (dataRow0):
                dataRow_0["oldCodeTransId"] = dataRow_0["codeTransId"];
            if (dlgAixmStar.pnlMSA.SelectedIndex >= 0):
                dataRow_0["mgpEnt"] = dlgAixmStar.pnlMSA.SelectedItem;
            else:
                dataRow_0["mgpEnt"] = None;
            if (not math.isnan(dlgAixmStar.pnlRNP.Value) and not math.isinf(dlgAixmStar.pnlRNP.Value)):
                dataRow_0["codeRnp"] = dlgAixmStar.pnlRNP.Value;
            else:
                dataRow_0["codeRnp"] = None;
            dataRow_0["codeTypeRte"] = dlgAixmStar.pnlType.SelectedItem;
            if (not String.IsNullOrEmpty(dlgAixmStar.txtDescrComFail.Value)):
                dataRow_0["txtDescrComFail"] = dlgAixmStar.txtDescrComFail.Value;
            else:
                dataRow_0["txtDescrComFail"] = None;
            if (not String.IsNullOrEmpty(dlgAixmStar.txtDescription.Value)):
                dataRow_0["txtDescr"] = dlgAixmStar.txtDescription.Value;
            else:
                dataRow_0["txtDescr"] = None;
            if (not String.IsNullOrEmpty(dlgAixmStar.txtRemarks.Value)):
                dataRow_0["txtRmk"] = dlgAixmStar.txtRemarks.Value;
            else:
                dataRow_0["txtRmk"] = None;
            if (dataRow0):
                dataRow_0["procLegs"] = DataBaseProcedureLegs();
                dataRow_0["procLegsEx"] = DataBaseProcedureLegsEx();
            if (not dataRow0):
                num = 1;
                while (num < len(strS)):
                    if (not strS[num] == dataRow_0[dataRow_0.nameList[num]]):
                        dataRow_0["changed"] = "True";
                        if (dataRow0):
                            dataBaseSTARs_0.RowsAdd(dataRow_0);
                        flag = True;
                        return flag;
                    else:
                        num += 1;
            else:
                dataRow_0["new"] = "True";
            if (dataRow0):
                dataBaseSTARs_0.RowsAdd(dataRow_0);
            flag = True;
            return flag;
Example #45
0
class PreferencesDialogBase(QDialog):
    def __init__(self, parent, app):
        flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
        QDialog.__init__(self, parent, flags)
        self.app = app
        self._setupUi()

        self.connect(self.filterHardnessSlider, SIGNAL("valueChanged(int)"),
                     self.filterHardnessLabel.setNum)
        self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'),
                     self.buttonClicked)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

    def _setupScanTypeBox(self, labels):
        self.scanTypeHLayout = QHBoxLayout()
        self.scanTypeLabel = QLabel(self)
        self.scanTypeLabel.setText(tr("Scan Type:"))
        self.scanTypeLabel.setMinimumSize(QSize(100, 0))
        self.scanTypeLabel.setMaximumSize(QSize(100, 16777215))
        self.scanTypeHLayout.addWidget(self.scanTypeLabel)
        self.scanTypeComboBox = QComboBox(self)
        for label in labels:
            self.scanTypeComboBox.addItem(label)
        self.scanTypeHLayout.addWidget(self.scanTypeComboBox)
        self.widgetsVLayout.addLayout(self.scanTypeHLayout)

    def _setupFilterHardnessBox(self):
        self.filterHardnessHLayout = QHBoxLayout()
        self.filterHardnessLabel = QLabel(self)
        self.filterHardnessLabel.setText(tr("Filter Hardness:"))
        self.filterHardnessLabel.setMinimumSize(QSize(0, 0))
        self.filterHardnessHLayout.addWidget(self.filterHardnessLabel)
        self.filterHardnessVLayout = QVBoxLayout()
        self.filterHardnessVLayout.setSpacing(0)
        self.filterHardnessHLayoutSub1 = QHBoxLayout()
        self.filterHardnessHLayoutSub1.setSpacing(12)
        self.filterHardnessSlider = QSlider(self)
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.filterHardnessSlider.sizePolicy().hasHeightForWidth())
        self.filterHardnessSlider.setSizePolicy(sizePolicy)
        self.filterHardnessSlider.setMinimum(1)
        self.filterHardnessSlider.setMaximum(100)
        self.filterHardnessSlider.setTracking(True)
        self.filterHardnessSlider.setOrientation(Qt.Horizontal)
        self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessSlider)
        self.filterHardnessLabel = QLabel(self)
        self.filterHardnessLabel.setText("100")
        self.filterHardnessLabel.setMinimumSize(QSize(21, 0))
        self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessLabel)
        self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub1)
        self.filterHardnessHLayoutSub2 = QHBoxLayout()
        self.filterHardnessHLayoutSub2.setContentsMargins(-1, 0, -1, -1)
        self.moreResultsLabel = QLabel(self)
        self.moreResultsLabel.setText(tr("More Results"))
        self.filterHardnessHLayoutSub2.addWidget(self.moreResultsLabel)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.filterHardnessHLayoutSub2.addItem(spacerItem)
        self.fewerResultsLabel = QLabel(self)
        self.fewerResultsLabel.setText(tr("Fewer Results"))
        self.filterHardnessHLayoutSub2.addWidget(self.fewerResultsLabel)
        self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub2)
        self.filterHardnessHLayout.addLayout(self.filterHardnessVLayout)

    def _setupBottomPart(self):
        # The bottom part of the pref panel is always the same in all editions.
        self.fontSizeLabel = QLabel(tr("Font size:"))
        self.fontSizeSpinBox = QSpinBox()
        self.fontSizeSpinBox.setMinimum(5)
        self.widgetsVLayout.addLayout(
            horizontalWrap([self.fontSizeLabel, self.fontSizeSpinBox, None]))
        self.languageLabel = QLabel(tr("Language:"), self)
        self.languageComboBox = QComboBox(self)
        for lang in SUPPORTED_LANGUAGES:
            self.languageComboBox.addItem(LANGNAMES[lang])
        self.widgetsVLayout.addLayout(
            horizontalWrap([self.languageLabel, self.languageComboBox, None]))
        self.copyMoveLabel = QLabel(self)
        self.copyMoveLabel.setText(tr("Copy and Move:"))
        self.widgetsVLayout.addWidget(self.copyMoveLabel)
        self.copyMoveDestinationComboBox = QComboBox(self)
        self.copyMoveDestinationComboBox.addItem(tr("Right in destination"))
        self.copyMoveDestinationComboBox.addItem(tr("Recreate relative path"))
        self.copyMoveDestinationComboBox.addItem(tr("Recreate absolute path"))
        self.widgetsVLayout.addWidget(self.copyMoveDestinationComboBox)
        self.customCommandLabel = QLabel(self)
        self.customCommandLabel.setText(
            tr("Custom Command (arguments: %d for dupe, %r for ref):"))
        self.widgetsVLayout.addWidget(self.customCommandLabel)
        self.customCommandEdit = QLineEdit(self)
        self.widgetsVLayout.addWidget(self.customCommandEdit)

    def _setupAddCheckbox(self, name, label, parent=None):
        if parent is None:
            parent = self
        cb = QCheckBox(parent)
        cb.setText(label)
        setattr(self, name, cb)

    def _setupPreferenceWidgets(self):
        # Edition-specific
        pass

    def _setupUi(self):
        self.setWindowTitle(tr("Preferences"))
        self.resize(304, 263)
        self.setSizeGripEnabled(False)
        self.setModal(True)
        self.mainVLayout = QVBoxLayout(self)
        self.widgetsVLayout = QVBoxLayout()
        self._setupPreferenceWidgets()
        self.mainVLayout.addLayout(self.widgetsVLayout)
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok
                                          | QDialogButtonBox.RestoreDefaults)
        self.mainVLayout.addWidget(self.buttonBox)
        if (not ISOSX) and (not ISLINUX):
            self.mainVLayout.removeWidget(self.ignoreHardlinkMatches)
            self.ignoreHardlinkMatches.setHidden(True)

    def _load(self, prefs, setchecked):
        # Edition-specific
        pass

    def _save(self, prefs, ischecked):
        # Edition-specific
        pass

    def load(self, prefs=None):
        if prefs is None:
            prefs = self.app.prefs
        self.filterHardnessSlider.setValue(prefs.filter_hardness)
        self.filterHardnessLabel.setNum(prefs.filter_hardness)
        setchecked = lambda cb, b: cb.setCheckState(Qt.Checked
                                                    if b else Qt.Unchecked)
        setchecked(self.mixFileKindBox, prefs.mix_file_kind)
        setchecked(self.useRegexpBox, prefs.use_regexp)
        setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders)
        setchecked(self.ignoreHardlinkMatches, prefs.ignore_hardlink_matches)
        setchecked(self.debugModeBox, prefs.debug_mode)
        self.copyMoveDestinationComboBox.setCurrentIndex(
            prefs.destination_type)
        self.customCommandEdit.setText(prefs.custom_command)
        self.fontSizeSpinBox.setValue(prefs.tableFontSize)
        try:
            langindex = SUPPORTED_LANGUAGES.index(self.app.prefs.language)
        except ValueError:
            langindex = 0
        self.languageComboBox.setCurrentIndex(langindex)
        self._load(prefs, setchecked)

    def save(self):
        prefs = self.app.prefs
        prefs.filter_hardness = self.filterHardnessSlider.value()
        ischecked = lambda cb: cb.checkState() == Qt.Checked
        prefs.mix_file_kind = ischecked(self.mixFileKindBox)
        prefs.use_regexp = ischecked(self.useRegexpBox)
        prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox)
        prefs.ignore_hardlink_matches = ischecked(self.ignoreHardlinkMatches)
        prefs.debug_mode = ischecked(self.debugModeBox)
        prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex(
        )
        prefs.custom_command = str(self.customCommandEdit.text())
        prefs.tableFontSize = self.fontSizeSpinBox.value()
        lang = SUPPORTED_LANGUAGES[self.languageComboBox.currentIndex()]
        oldlang = self.app.prefs.language
        if oldlang not in SUPPORTED_LANGUAGES:
            oldlang = 'en'
        if lang != oldlang:
            QMessageBox.information(
                self, "",
                tr("dupeGuru has to restart for language changes to take effect."
                   ))
        self.app.prefs.language = lang
        self._save(prefs, ischecked)

    #--- Events
    def buttonClicked(self, button):
        role = self.buttonBox.buttonRole(button)
        if role == QDialogButtonBox.ResetRole:
            self.resetToDefaults()
Example #46
0
    def __createLayout(self, action, title, files):
        """ Creates the dialog layout """

        self.resize(400, 300)
        self.setSizeGripEnabled(True)

        # Top level layout
        layout = QVBoxLayout(self)

        # Pixmap and the message
        topLayout = QHBoxLayout()
        pixmap = QLabel()
        pixmap.setPixmap(PixmapCache().getPixmap('warning.png'))
        topLayout.addWidget(pixmap)
        hSpacer = QWidget()
        hSpacer.setFixedSize(15, 15)
        topLayout.addWidget(hSpacer)
        message = QLabel( "All the project files must be " \
                          "saved before start debugging" )
        message.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        message.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        message.setWordWrap(True)
        topLayout.addWidget(message)
        layout.addLayout(topLayout)

        vSpacer = QWidget()
        vSpacer.setFixedSize(15, 15)
        layout.addWidget(vSpacer)

        layout.addWidget(QLabel(title + ":"))
        filesList = QTreeWidget()
        filesList.setRootIsDecorated(False)
        filesList.setAlternatingRowColors(True)
        filesList.setUniformRowHeights(True)
        filesList.setItemsExpandable(False)
        filesList.setItemDelegate(NoOutlineHeightDelegate(4))
        filesList.setSelectionMode(QAbstractItemView.NoSelection)
        filesList.setHeaderHidden(True)
        for item in files:
            fileName = item[0]
            fileItem = QTreeWidgetItem([fileName])
            fileType = detectFileType(fileName)
            fileItem.setIcon(0, getFileIcon(fileType))
            if fileType in [PythonFileType, Python3FileType]:
                infoSrc = GlobalData().briefModinfoCache
                info = infoSrc.get(fileName)
                if info.docstring is not None:
                    fileItem.setToolTip(0, info.docstring.text)
                else:
                    fileItem.setToolTip(0, "")
            filesList.addTopLevelItem(fileItem)
        layout.addWidget(filesList)

        # Buttons at the bottom
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
        continueButton = buttonBox.addButton(action,
                                             QDialogButtonBox.ActionRole)
        continueButton.setDefault(True)
        layout.addWidget(buttonBox)

        continueButton.clicked.connect(self.accept)
        buttonBox.rejected.connect(self.close)
        continueButton.setFocus()
        return
Example #47
0
    def __createLayout(self, varName, varType, varValue, isGlobal):
        """ Creates the dialog layout """

        varTypeParts = varType.split()
        if varTypeParts[0].lower() in ["string", "unicode", "qstring"]:
            length = str(len(varValue))
            lines = str(len(varValue.splitlines()))
            varType = varType.split( "(" )[ 0 ].strip() + \
                      " (lines: " + lines + ", characters: " + length + ")"

        self.resize(600, 250)
        self.setSizeGripEnabled(True)

        # Top level layout
        layout = QVBoxLayout(self)

        gridLayout = QGridLayout()
        gridLayout.setSpacing(2)
        varScopeLabel = QLabel("Scope:")
        gridLayout.addWidget(varScopeLabel, 0, 0, Qt.AlignTop)
        if isGlobal:
            varScopeValue = FramedLabelWithDoubleClick("Global")
        else:
            varScopeValue = FramedLabelWithDoubleClick("Local")
        varScopeValue.setToolTip("Double click to copy")
        font = varScopeValue.font()
        font.setFamily(GlobalData().skin.baseMonoFontFace)
        varScopeValue.setFont(font)
        gridLayout.addWidget(varScopeValue, 0, 1)

        varNameLabel = QLabel("Name:")
        gridLayout.addWidget(varNameLabel, 1, 0, Qt.AlignTop)
        varNameValue = FramedLabelWithDoubleClick(varName)
        varNameValue.setToolTip("Double click to copy")
        varNameValue.setFont(font)
        gridLayout.addWidget(varNameValue, 1, 1)
        varTypeLabel = QLabel("Type:")
        gridLayout.addWidget(varTypeLabel, 2, 0, Qt.AlignTop)
        varTypeValue = FramedLabelWithDoubleClick(varType)
        varTypeValue.setToolTip("Double click to copy")
        varTypeValue.setFont(font)
        gridLayout.addWidget(varTypeValue, 2, 1)
        varValueLabel = QLabel("Value:")
        gridLayout.addWidget(varValueLabel, 3, 0, Qt.AlignTop)
        varValueValue = QTextEdit()
        varValueValue.setReadOnly(True)
        varValueValue.setFontFamily(GlobalData().skin.baseMonoFontFace)
        # varValueValue.setLineWrapMode( QTextEdit.NoWrap )
        varValueValue.setAcceptRichText(False)
        varValueValue.setPlainText(varValue)
        gridLayout.addWidget(varValueValue, 3, 1)
        layout.addLayout(gridLayout)

        # Buttons at the bottom
        buttonBox = QDialogButtonBox(self)
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        self.__OKButton = buttonBox.button(QDialogButtonBox.Ok)
        self.__OKButton.setDefault(True)
        buttonBox.accepted.connect(self.close)
        buttonBox.rejected.connect(self.close)
        layout.addWidget(buttonBox)

        varValueValue.setFocus()
        return
class DlgMagneticVariationParameters(QDialog):
    def __init__(self, parent = None):
        QDialog.__init__(self, parent)
        
        self.resize(290, 136);
        self.setWindowTitle("Reference Positions")
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth());
        self.setSizePolicy(sizePolicy);
        verticalLayoutDlg = QVBoxLayout(self)
        verticalLayoutDlg.setObjectName(("verticalLayoutDlg"));
        frameDate = QFrame(self);
        frameDate.setObjectName(("frameDate"));
        frameDate.setFrameShape(QFrame.StyledPanel);
        frameDate.setFrameShadow(QFrame.Raised);
        horizontalLayoutDate = QHBoxLayout(frameDate);
        horizontalLayoutDate.setObjectName(("horizontalLayoutDate"));
        labelDate = QLabel(frameDate);
        labelDate.setObjectName(("labelDate"));
        labelDate.setMinimumSize(QSize(70, 0));
        labelDate.setMaximumSize(QSize(70, 16777215));
        labelDate.setText("Date:")

        horizontalLayoutDate.addWidget(labelDate);

        self.dtpDate = QDateEdit(frameDate);
        self.dtpDate.setObjectName(("dtpDate"));

        horizontalLayoutDate.addWidget(self.dtpDate);

        self.btnDtpDate =  QToolButton(frameDate);
        self.btnDtpDate.setObjectName(("btnDtpDate"));
        sizePolicy.setHeightForWidth(self.btnDtpDate.sizePolicy().hasHeightForWidth());
        self.btnDtpDate.setSizePolicy(sizePolicy);
        self.btnDtpDate.setMinimumSize(QSize(25, 0));
        self.btnDtpDate.setMaximumSize(QSize(25, 16777215));
        icon = QIcon()
        icon.addPixmap(QPixmap(("Resource/calender.png")), QIcon.Normal, QIcon.Off)
        self.btnDtpDate.setIcon(icon)

        horizontalLayoutDate.addWidget(self.btnDtpDate);


        verticalLayoutDlg.addWidget(frameDate);

        frameModel = QFrame(self);
        frameModel.setObjectName(("frameModel"));
        frameModel.setFrameShape(QFrame.StyledPanel);
        frameModel.setFrameShadow(QFrame.Raised);
        horizontalLayoutModel = QHBoxLayout(frameModel);
        horizontalLayoutModel.setObjectName(("horizontalLayoutModel"));
        labelModel = QLabel(frameModel);
        labelModel.setObjectName(("labelModel"));
        labelModel.setMinimumSize(QSize(70, 0));
        labelModel.setMaximumSize(QSize(70, 16777215));
        labelModel.setText("Model:")

        horizontalLayoutModel.addWidget(labelModel);

        self.cmbModel = QComboBox(frameModel);
        self.cmbModel.setObjectName(("cmbModel"));

        horizontalLayoutModel.addWidget(self.cmbModel);


        verticalLayoutDlg.addWidget(frameModel);

        self.buttonBox = QDialogButtonBox(self);
        self.buttonBox.setObjectName(("buttonBox"));
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok);
        self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)


        verticalLayoutDlg.addWidget(self.buttonBox);

        self.calendar = QCalendarWidget()
        self.calendar.clicked.connect(self.calendar_clicked)
        self.menu = QMenu()
        layout = QVBoxLayout(self.menu)
        layout.addWidget(self.calendar)

        self.btnDtpDate.clicked.connect(self.btnDtpDate_clicked)
        self.cmbModel.addItems(["WMM2015", "WMM2010" , "WMM2005", "WMM2000", "WMM95", "WMM90", "WMM85", "IGRF2000", "IGRF95", "IGRF90"])

    def btnDtpDate_clicked(self):
        rcRect = self.btnDtpDate.geometry()
        ptPoint = rcRect.bottomLeft()

        self.menu.exec_( self.mapToGlobal(ptPoint) )

    def calendar_clicked(self, date):
        self.dtpDate.setDate(date)

    def get_Date(self):
        return self.dtpDate.date()
    def setDate(self, date):
        if date != None:
            self.dtpDate.setDate(date)
    Date = property(get_Date, setDate, None, None)

    def get_Model(self):
        return self.cmbModel.currentIndex()
    def set_Model(self, index):
        if index == None:
            self.cmbModel.setCurrentIndex(1)
            return
        self.cmbModel.setCurrentIndex(index)
    Model = property(get_Model, set_Model, None, None)

    @staticmethod
    def smethod_0(date_0, magneticModelIndex_0):

        dlgMagneticVariationParameters = DlgMagneticVariationParameters()
        dlgMagneticVariationParameters.Date = date_0
        dlgMagneticVariationParameters.Model = magneticModelIndex_0
        dialogResult = dlgMagneticVariationParameters.exec_()
        if dialogResult != QDialog.Accepted:
            return (False, None, None)
        else:
            date  = dlgMagneticVariationParameters.Date;
            magneticIndex = dlgMagneticVariationParameters.Model;
            return (True, date, magneticIndex)
Example #49
0
class SVNPluginConfigDialog(QDialog):
    " SVN Plugin config dialog "

    def __init__(self, ideWideSettings, projectSettings, parent=None):
        QDialog.__init__(self, parent)
        self.__createLayout()
        self.setWindowTitle("SVN plugin configuration")

        self.ideWideSettings = copy.deepcopy(ideWideSettings)
        if projectSettings is None:
            self.projectSettings = None
        else:
            self.projectSettings = copy.deepcopy(projectSettings)

        # Set the values
        self.__setIDEWideValues()
        if projectSettings is None:
            self.__tabWidget.setTabEnabled(1, False)
        else:
            self.__setProjectValues()
            self.__tabWidget.setCurrentIndex(1)
        self.__updateOKStatus()

        self.__idewideUser.textChanged.connect(self.__updateOKStatus)
        self.__projectUser.textChanged.connect(self.__updateOKStatus)
        return

    def __setIDEWideValues(self):
        " Sets the values in the IDE wide tab "
        if self.ideWideSettings.authKind == AUTH_EXTERNAL:
            self.__idewideAuthExtRButton.setChecked(True)
            self.__idewideUser.setEnabled(False)
            self.__idewidePasswd.setEnabled(False)
        else:
            self.__idewideAuthPasswdRButton.setChecked(True)
            if self.ideWideSettings.userName:
                self.__idewideUser.setText(self.ideWideSettings.userName)
            if self.ideWideSettings.password:
                self.__idewidePasswd.setText(self.ideWideSettings.password)

        if self.ideWideSettings.statusKind == STATUS_REPOSITORY:
            self.__idewideReposRButton.setChecked(True)
        else:
            self.__idewideLocalRButton.setChecked(True)
        return

    def __setProjectValues(self):
        " Sets the values in the project tab "
        if self.projectSettings.authKind == AUTH_EXTERNAL:
            self.__projectAuthExtRButton.setChecked(True)
            self.__projectUser.setEnabled(False)
            self.__projectPasswd.setEnabled(False)
        else:
            self.__projectAuthPasswdRButton.setChecked(True)
            if self.projectSettings.userName:
                self.__projectUser.setText(self.projectSettings.userName)
            if self.projectSettings.password:
                self.__projectPasswd.setText(self.projectSettings.password)

        if self.projectSettings.statusKind == STATUS_REPOSITORY:
            self.__projectReposRButton.setChecked(True)
        else:
            self.__projectLocalRButton.setChecked(True)
        return

    def __createLayout(self):
        " Creates the dialog layout "

        self.resize(640, 420)
        self.setSizeGripEnabled(True)

        vboxLayout = QVBoxLayout(self)
        hboxLayout = QHBoxLayout()
        iconLabel = QLabel()
        logoPath = os.path.dirname( os.path.abspath( __file__ ) ) + \
                   os.path.sep + "svn-logo.png"
        iconLabel.setPixmap(QPixmap(logoPath))
        iconLabel.setScaledContents(True)
        iconLabel.setFixedSize(48, 48)
        hboxLayout.addWidget(iconLabel)
        titleLabel = QLabel("Codimension SVN plugin settings")
        titleLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        titleLabel.setFixedHeight(48)
        titleLabel.setAlignment(Qt.AlignCenter)
        hboxLayout.addWidget(titleLabel)
        vboxLayout.addLayout(hboxLayout)

        self.__tabWidget = QTabWidget(self)
        self.__tabWidget.setFocusPolicy(Qt.NoFocus)

        ideWide = self.__createIDEWide()
        self.__tabWidget.addTab(ideWide, "IDE Wide")
        projectSpecific = self.__createProjectSpecific()
        self.__tabWidget.addTab(projectSpecific, "Project Specific")
        version = self.__createVersionWidget()
        self.__tabWidget.addTab(version, "Versions")
        vboxLayout.addWidget(self.__tabWidget)

        # Buttons at the bottom
        self.__buttonBox = QDialogButtonBox(self)
        self.__buttonBox.setOrientation(Qt.Horizontal)
        self.__buttonBox.setStandardButtons(QDialogButtonBox.Ok
                                            | QDialogButtonBox.Cancel)
        self.__buttonBox.accepted.connect(self.userAccept)
        self.__buttonBox.rejected.connect(self.close)
        vboxLayout.addWidget(self.__buttonBox)
        return

    def __createIDEWide(self):
        " Creates the IDE wide part "
        widget = QWidget()

        verticalLayout = QVBoxLayout(widget)
        infoLabel = QLabel("Note: the settings below are used "
                           "when there is no project loaded.")
        verticalLayout.addWidget(infoLabel)

        # Authorization group box
        authGroupbox = QGroupBox(self)
        authGroupbox.setTitle("Authorization")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            authGroupbox.sizePolicy().hasHeightForWidth())
        authGroupbox.setSizePolicy(sizePolicy)

        layoutAuth = QVBoxLayout(authGroupbox)
        self.__idewideAuthExtRButton = QRadioButton("External", authGroupbox)
        self.__idewideAuthExtRButton.clicked.connect(self.__idewideAuthChanged)
        layoutAuth.addWidget(self.__idewideAuthExtRButton)
        self.__idewideAuthPasswdRButton = QRadioButton(
            "Use user name / password", authGroupbox)
        self.__idewideAuthPasswdRButton.clicked.connect(
            self.__idewideAuthChanged)
        layoutAuth.addWidget(self.__idewideAuthPasswdRButton)

        upLayout = QGridLayout()
        self.__idewideUser = QLineEdit()
        self.__idewideUser.setToolTip("Attention: user name is "
                                      "saved unencrypted")
        self.__idewidePasswd = QLineEdit()
        self.__idewidePasswd.setToolTip("Attention: password is "
                                        "saved unencrypted")
        spacer = QWidget()
        spacer.setFixedWidth(16)
        upLayout.addWidget(spacer, 0, 0)
        upLayout.addWidget(QLabel("User name"), 0, 1)
        upLayout.addWidget(self.__idewideUser, 0, 2)
        upLayout.addWidget(QLabel("Password"), 1, 1)
        upLayout.addWidget(self.__idewidePasswd, 1, 2)
        layoutAuth.addLayout(upLayout)

        # Update status group box
        updateGroupbox = QGroupBox(self)
        updateGroupbox.setTitle("Update status policy")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            updateGroupbox.sizePolicy().hasHeightForWidth())
        updateGroupbox.setSizePolicy(sizePolicy)

        layoutUpdate = QVBoxLayout(updateGroupbox)
        self.__idewideReposRButton = QRadioButton("Check repository",
                                                  updateGroupbox)
        layoutUpdate.addWidget(self.__idewideReposRButton)
        self.__idewideLocalRButton = QRadioButton("Local only", updateGroupbox)
        layoutUpdate.addWidget(self.__idewideLocalRButton)

        verticalLayout.addWidget(authGroupbox)
        verticalLayout.addWidget(updateGroupbox)

        return widget

    def __idewideAuthChanged(self):
        " Triggered when authorization has been changed "
        if self.__idewideAuthExtRButton.isChecked():
            self.__idewideUser.setEnabled(False)
            self.__idewidePasswd.setEnabled(False)
        else:
            self.__idewideUser.setEnabled(True)
            self.__idewidePasswd.setEnabled(True)
            self.__idewideUser.setFocus()
        self.__updateOKStatus()
        return

    def __createProjectSpecific(self):
        " Creates the project specific part "
        widget = QWidget()

        verticalLayout = QVBoxLayout(widget)
        infoLabel = QLabel("Note: the settings below are used "
                           "only for the specific project.")
        verticalLayout.addWidget(infoLabel)

        # Authorization group box
        authGroupbox = QGroupBox(self)
        authGroupbox.setTitle("Authorization")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            authGroupbox.sizePolicy().hasHeightForWidth())
        authGroupbox.setSizePolicy(sizePolicy)

        layoutAuth = QVBoxLayout(authGroupbox)
        self.__projectAuthExtRButton = QRadioButton("External", authGroupbox)
        self.__projectAuthExtRButton.clicked.connect(self.__projectAuthChanged)
        layoutAuth.addWidget(self.__projectAuthExtRButton)
        self.__projectAuthPasswdRButton = QRadioButton(
            "Use user name / password", authGroupbox)
        self.__projectAuthPasswdRButton.clicked.connect(
            self.__projectAuthChanged)
        layoutAuth.addWidget(self.__projectAuthPasswdRButton)

        upLayout = QGridLayout()
        self.__projectUser = QLineEdit()
        self.__projectUser.setToolTip("Attention: user name is "
                                      "saved unencrypted")
        self.__projectPasswd = QLineEdit()
        self.__projectPasswd.setToolTip("Attention: password is "
                                        "saved unencrypted")
        spacer = QWidget()
        spacer.setFixedWidth(16)
        upLayout.addWidget(spacer, 0, 0)
        upLayout.addWidget(QLabel("User name"), 0, 1)
        upLayout.addWidget(self.__projectUser, 0, 2)
        upLayout.addWidget(QLabel("Password"), 1, 1)
        upLayout.addWidget(self.__projectPasswd, 1, 2)
        layoutAuth.addLayout(upLayout)

        # Update status group box
        updateGroupbox = QGroupBox(self)
        updateGroupbox.setTitle("Update status policy")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            updateGroupbox.sizePolicy().hasHeightForWidth())
        updateGroupbox.setSizePolicy(sizePolicy)

        layoutUpdate = QVBoxLayout(updateGroupbox)
        self.__projectReposRButton = QRadioButton("Check repository",
                                                  updateGroupbox)
        layoutUpdate.addWidget(self.__projectReposRButton)
        self.__projectLocalRButton = QRadioButton("Local only", updateGroupbox)
        layoutUpdate.addWidget(self.__projectLocalRButton)

        verticalLayout.addWidget(authGroupbox)
        verticalLayout.addWidget(updateGroupbox)

        return widget

    def __projectAuthChanged(self):
        " Triggered when authorization has been changed "
        if self.__projectAuthExtRButton.isChecked():
            self.__projectUser.setEnabled(False)
            self.__projectPasswd.setEnabled(False)
        else:
            self.__projectUser.setEnabled(True)
            self.__projectPasswd.setEnabled(True)
            self.__projectUser.setFocus()
        self.__updateOKStatus()
        return

    def __createVersionWidget(self):
        " Creates the version tab content "
        ver = pysvn.svn_version
        svnVersion = ".".join([str(ver[0]), str(ver[1]), str(ver[2])])
        ver = pysvn.version
        pysvnVersion = ".".join([str(ver[0]), str(ver[1]), str(ver[2])])

        text = "<p>The major Codimension SVN plugin components are listed below:</p>" \
               "<ul>" \
               "<li><a href='http://subversion.apache.org/'>Subversion</a><br>" \
               "Version: " + svnVersion + "<br></li>" \
               "<li><a href='http://pysvn.tigris.org/docs/pysvn.html'>PySvn</a><br>" \
               "Version: " + pysvnVersion + "<br>" \
               "License: <a href='http://www.apache.org/licenses/LICENSE-1.1'>Apache License 1.1</a>" \
               "<br></li>" \
               "</ul>"

        browser = QTextBrowser()
        browser.setHtml(text)
        browser.setOpenExternalLinks(True)
        return browser

    def userAccept(self):
        " Triggered when the user clicks OK "
        # Collect IDE-wide values
        if self.__idewideAuthExtRButton.isChecked():
            self.ideWideSettings.authKind = AUTH_EXTERNAL
            self.ideWideSettings.userName = None
            self.ideWideSettings.password = None
        else:
            self.ideWideSettings.authKind = AUTH_PASSWD
            self.ideWideSettings.userName = self.__idewideUser.text().strip()
            self.ideWideSettings.password = self.__idewidePasswd.text().strip()

        if self.__idewideReposRButton.isChecked():
            self.ideWideSettings.statusKind = STATUS_REPOSITORY
        else:
            self.ideWideSettings.statusKind = STATUS_LOCAL_ONLY

        if self.projectSettings is not None:
            if self.__projectAuthExtRButton.isChecked():
                self.projectSettings.authKind = AUTH_EXTERNAL
                self.projectSettings.userName = None
                self.projectSettings.password = None
            else:
                self.projectSettings.authKind = AUTH_PASSWD
                self.projectSettings.userName = self.__projectUser.text(
                ).strip()
                self.projectSettings.password = self.__projectPasswd.text(
                ).strip()

            if self.__projectReposRButton.isChecked():
                self.projectSettings.statusKind = STATUS_REPOSITORY
            else:
                self.projectSettings.statusKind = STATUS_LOCAL_ONLY

        self.accept()
        return

    def __updateOKStatus(self):
        " Updates the OK button status "
        okButton = self.__buttonBox.button(QDialogButtonBox.Ok)
        if self.__idewideAuthPasswdRButton.isChecked():
            userName = self.__idewideUser.text().strip()
            if not userName:
                okButton.setEnabled(False)
                okButton.setToolTip("IDE wide SVN user name cannot be empty")
                return
        if self.projectSettings is not None:
            if self.__projectAuthPasswdRButton.isChecked():
                userName = self.__projectUser.text().strip()
                if not userName:
                    okButton.setEnabled(False)
                    okButton.setToolTip("Project specific SVN "
                                        "user name cannot be empty")
                    return

        okButton.setEnabled(True)
        okButton.setToolTip("")
        return
class WExportDesign(QtHelper.EnhancedQDialog, Logger.ClassLogger):
    """
    Export design widget
    """
    def __init__(self, parent, data, dataXml): 
        """
        Constructs export design dialog

        @param parent: 
        @type parent:
        """     
        super(WExportDesign, self).__init__(parent)

        self.__data = data
        self.__dataXml = dataXml

        self.createWidgets()
        self.createConnections()

    def pluginDataAccessor(self):
        """
        Return data to plugins
        """
        return {
                    'design-html': self.rawWidget.cacheHtml,
                    'design-xml': self.xmlWidget.txtEdit.text()
                }
        
    def addPlugin(self, pluginAct):
        """
        Register plugins in widgets
        """
        self.rawWidget.registerPlugin(pluginAct)
        self.xmlWidget.registerPlugin(pluginAct)
  
    def createWidgets(self):
        """
        QtWidgets creation
        """
        self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setStyleSheet( """QDialogButtonBox { 
            dialogbuttonbox-buttons-have-icons: 1;
            dialog-ok-icon: url(:/ok.png);
            dialog-cancel-icon: url(:/ko.png);
        }""")
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)


        layout = QVBoxLayout()
        self.mainTab = QTabWidget()
        
        self.rawWidget = RawView(self, self.__data, toCsv=True, toHtml=True, toXml=False, 
                                    toPrinter=True, toTxt=True, toPdf=True)
        self.xmlWidget = RawView(self, self.__dataXml, toCsv=False, toHtml=False, toXml=True, 
                                    toPrinter=True, toTxt=False, toPdf=True)
        self.mainTab.addTab( self.rawWidget , 'Raw')
        self.mainTab.addTab( self.xmlWidget , 'Xml')

        layout.addWidget(self.mainTab)
        layout.addWidget(self.buttonBox)
        
        self.setWindowTitle("Export Test Design")
        self.setLayout(layout)

    def createConnections (self):
        """
        Qt connections
        """
        self.buttonBox.accepted.connect(self.accept)
Example #51
0
class ModelerParametersDialog(QDialog):

    ENTER_NAME = '[Enter name if this is a final result]'
    NOT_SELECTED = '[Not selected]'
    USE_MIN_COVERING_EXTENT = '[Use min covering extent]'

    def __init__(self, alg, model, algName=None):
        QDialog.__init__(self)
        self.setModal(True)
        #The algorithm to define in this dialog. It is an instance of GeoAlgorithm
        self._alg = alg
        #The resulting algorithm after the user clicks on OK. it is an instance of the container Algorithm class
        self.alg = None
        #The model this algorithm is going to be added to
        self.model = model
        #The name of the algorithm in the model, in case we are editing it and not defining it for the first time
        self._algName = algName
        self.setupUi()
        self.params = None

    def setupUi(self):
        self.labels = {}
        self.widgets = {}
        self.checkBoxes = {}
        self.showAdvanced = False
        self.valueItems = {}
        self.dependentItems = {}
        self.resize(650, 450)
        self.buttonBox = QDialogButtonBox()
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                          | QDialogButtonBox.Ok)
        tooltips = self._alg.getParameterDescriptions()
        self.setSizePolicy(QSizePolicy.Expanding,
                           QSizePolicy.Expanding)
        self.verticalLayout = QVBoxLayout()
        self.verticalLayout.setSpacing(5)
        self.verticalLayout.setMargin(20)

        hLayout = QHBoxLayout()
        hLayout.setSpacing(5)
        hLayout.setMargin(0)
        descriptionLabel = QLabel(self.tr("Description"))
        self.descriptionBox = QLineEdit()
        self.descriptionBox.setText(self._alg.name)
        hLayout.addWidget(descriptionLabel)
        hLayout.addWidget(self.descriptionBox)
        self.verticalLayout.addLayout(hLayout)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.verticalLayout.addWidget(line)

        for param in self._alg.parameters:
            if param.isAdvanced:
                self.advancedButton = QPushButton()
                self.advancedButton.setText(self.tr('Show advanced parameters'))
                self.advancedButton.setMaximumWidth(150)
                self.advancedButton.clicked.connect(
                    self.showAdvancedParametersClicked)
                self.verticalLayout.addWidget(self.advancedButton)
                break
        for param in self._alg.parameters:
            if param.hidden:
                continue
            desc = param.description
            if isinstance(param, ParameterExtent):
                desc += '(xmin, xmax, ymin, ymax)'
            label = QLabel(desc)
            self.labels[param.name] = label
            widget = self.getWidgetFromParameter(param)
            self.valueItems[param.name] = widget
            if param.name in tooltips.keys():
                tooltip = tooltips[param.name]
            else:
                tooltip = param.description
            label.setToolTip(tooltip)
            widget.setToolTip(tooltip)
            if param.isAdvanced:
                label.setVisible(self.showAdvanced)
                widget.setVisible(self.showAdvanced)
                self.widgets[param.name] = widget
            self.verticalLayout.addWidget(label)
            self.verticalLayout.addWidget(widget)

        for output in self._alg.outputs:
            if output.hidden:
                continue
            if isinstance(output, (OutputRaster, OutputVector, OutputTable,
                          OutputHTML, OutputFile, OutputDirectory)):
                label = QLabel(output.description + '<'
                               + output.__class__.__name__ + '>')
                item = QLineEdit()
                if hasattr(item, 'setPlaceholderText'):
                    item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
                self.verticalLayout.addWidget(label)
                self.verticalLayout.addWidget(item)
                self.valueItems[output.name] = item

        label = QLabel(' ')
        self.verticalLayout.addWidget(label)
        label = QLabel(self.tr('Parent algorithms'))
        self.dependenciesPanel = self.getDependenciesPanel()
        self.verticalLayout.addWidget(label)
        self.verticalLayout.addWidget(self.dependenciesPanel)

        self.verticalLayout.addStretch(1000)
        self.setLayout(self.verticalLayout)

        self.setPreviousValues()
        self.setWindowTitle(self._alg.name)
        self.verticalLayout2 = QVBoxLayout()
        self.verticalLayout2.setSpacing(2)
        self.verticalLayout2.setMargin(0)
        self.tabWidget = QTabWidget()
        self.tabWidget.setMinimumWidth(300)
        self.paramPanel = QWidget()
        self.paramPanel.setLayout(self.verticalLayout)
        self.scrollArea = QScrollArea()
        self.scrollArea.setWidget(self.paramPanel)
        self.scrollArea.setWidgetResizable(True)
        self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
        self.webView = QWebView()

        html = None
        url = None
        isText, help = self._alg.help()
        if help is not None:
            if isText:
                html = help
            else:
                url = QUrl(help)
        else:
            html = self.tr('<h2>Sorry, no help is available for this '
                           'algorithm.</h2>')
        try:
            if html:
                self.webView.setHtml(html)
            elif url:
                self.webView.load(url)
        except:
            self.webView.setHtml(self.tr('<h2>Could not open help file :-( </h2>'))
        self.tabWidget.addTab(self.webView, 'Help')
        self.verticalLayout2.addWidget(self.tabWidget)
        self.verticalLayout2.addWidget(self.buttonBox)
        self.setLayout(self.verticalLayout2)
        self.buttonBox.accepted.connect(self.okPressed)
        self.buttonBox.rejected.connect(self.cancelPressed)
        QMetaObject.connectSlotsByName(self)

    def getAvailableDependencies(self):
        if self._algName is None:
            dependent = []
        else:
            dependent = self.model.getDependentAlgorithms(self._algName)
        opts = []
        for alg in self.model.algs.values():
            if alg.name not in dependent:
                opts.append(alg)
        return opts

    def getDependenciesPanel(self):
        return MultipleInputPanel([alg.algorithm.name for alg in self.getAvailableDependencies()])

    def showAdvancedParametersClicked(self):
        self.showAdvanced = not self.showAdvanced
        if self.showAdvanced:
            self.advancedButton.setText(self.tr('Hide advanced parameters'))
        else:
            self.advancedButton.setText(self.tr('Show advanced parameters'))
        for param in self._alg.parameters:
            if param.isAdvanced:
                self.labels[param.name].setVisible(self.showAdvanced)
                self.widgets[param.name].setVisible(self.showAdvanced)

    def getAvailableValuesOfType(self, paramType, outType=None):
        values = []
        inputs = self.model.inputs
        for i in inputs.values():
            param = i.param
            if isinstance(param, paramType):
                values.append(ValueFromInput(param.name))
        if outType is None:
            return values
        if self._algName is None:
            dependent = []
        else:
            dependent = self.model.getDependentAlgorithms(self._algName)
        for alg in self.model.algs.values():
            if alg.name not in dependent:
                for out in alg.algorithm.outputs:
                    if isinstance(out, outType):
                        values.append(ValueFromOutput(alg.name, out.name))

        return values

    def resolveValueDescription(self, value):
        if isinstance(value, ValueFromInput):
            return self.model.inputs[value.name].param.description
        else:
            alg = self.model.algs[value.alg]
            return self.tr("'%s' from algorithm '%s'") % (alg.algorithm.getOutputFromName(value.output).description, alg.description)

    def getWidgetFromParameter(self, param):
        if isinstance(param, ParameterRaster):
            item = QComboBox()
            layers = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
            if param.optional:
                item.addItem(self.NOT_SELECTED, None)
            for layer in layers:
                item.addItem(self.resolveValueDescription(layer), layer)
        elif isinstance(param, ParameterVector):
            item = QComboBox()
            layers = self.getAvailableValuesOfType(ParameterVector, OutputVector)
            if param.optional:
                item.addItem(self.NOT_SELECTED, None)
            for layer in layers:
                item.addItem(self.resolveValueDescription(layer), layer)
        elif isinstance(param, ParameterTable):
            item = QComboBox()
            tables = self.getAvailableValuesOfType(ParameterTable, OutputTable)
            layers = self.getAvailableValuesOfType(ParameterVector, OutputVector)
            if param.optional:
                item.addItem(self.NOT_SELECTED, None)
            for table in tables:
                item.addItem(self.resolveValueDescription(table), table)
            for layer in layers:
                item.addItem(self.resolveValueDescription(layer), layer)
        elif isinstance(param, ParameterBoolean):
            item = QComboBox()
            item.addItem('Yes')
            item.addItem('No')
            bools = self.getAvailableValuesOfType(ParameterBoolean, None)
            for b in bools:
                item.addItem(self.resolveValueDescription(b), b)
        elif isinstance(param, ParameterSelection):
            item = QComboBox()
            item.addItems(param.options)
            item.setCurrentIndex(param.default)
        elif isinstance(param, ParameterFixedTable):
            item = FixedTablePanel(param)
        elif isinstance(param, ParameterRange):
            item = RangePanel(param)
        elif isinstance(param, ParameterMultipleInput):
            if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
            else:
                options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
            opts = []
            for opt in options:
                opts.append(self.resolveValueDescription(opt))
            item = MultipleInputPanel(opts)
        elif isinstance(param, ParameterString):
            strings = self.getAvailableValuesOfType(ParameterString, OutputString)
            options = [(self.resolveValueDescription(s), s) for s in strings]
            if param.multiline:
                item = MultilineTextPanel(options)
                item.setText(unicode(param.default))
            else:
                item = QComboBox()
                item.setEditable(True)
                for desc, val in options:
                    item.addItem(desc, val)
                item.setEditText(unicode(param.default))
        elif isinstance(param, ParameterTableField):
            item = QComboBox()
            item.setEditable(True)
            fields = self.getAvailableValuesOfType(ParameterTableField, None)
            for f in fields:
                item.addItem(self.resolveValueDescription(f), f)
        elif isinstance(param, ParameterNumber):
            item = QComboBox()
            item.setEditable(True)
            numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber)
            for n in numbers:
                item.addItem(self.resolveValueDescription(n), n)
            item.setEditText(unicode(param.default))
        elif isinstance(param, ParameterCrs):
            item = CrsSelectionPanel(param.default)
        elif isinstance(param, ParameterExtent):
            item = QComboBox()
            item.setEditable(True)
            extents = self.getAvailableValuesOfType(ParameterExtent, OutputExtent)
            if self.canUseAutoExtent():
                item.addItem(self.USE_MIN_COVERING_EXTENT, None)
            for ex in extents:
                item.addItem(self.resolveValueDescription(ex), ex)
            if not self.canUseAutoExtent():
                item.setEditText(unicode(param.default))
        elif isinstance(param, ParameterFile):
            item = QComboBox()
            item.setEditable(True)
            files = self.getAvailableValuesOfType(ParameterFile, OutputFile)
            for f in files:
                item.addItem(self.resolveValueDescription(f), f)
        elif isinstance(param, ParameterGeometryPredicate):
            item = GeometryPredicateSelectionPanel(param.enabledPredicates)
        else:
            item = QLineEdit()
            try:
                item.setText(unicode(param.default))
            except:
                pass
        return item

    def canUseAutoExtent(self):
        for param in self._alg.parameters:
            if isinstance(param, (ParameterRaster, ParameterVector, ParameterMultipleInput)):
                return True
        return False

    def setTableContent(self):
        params = self._alg.parameters
        outputs = self._alg.outputs
        visibleParams = [p for p in params if not p.hidden]
        visibleOutputs = [p for o in outputs if not o.hidden]
        self.tableWidget.setRowCount(len(visibleParams) + len(visibleOutputs))

        for i, param in visibleParams:
            item = QTableWidgetItem(param.description)
            item.setFlags(Qt.ItemIsEnabled)
            self.tableWidget.setItem(i, 0, item)
            item = self.getWidgetFromParameter(param)
            self.valueItems[param.name] = item
            self.tableWidget.setCellWidget(i, 1, item)
            self.tableWidget.setRowHeight(i, 22)

        for i, output in visibleOutputs:
            item = QTableWidgetItem(output.description + '<'
                                    + output.__module__.split('.')[-1] + '>')
            item.setFlags(Qt.ItemIsEnabled)
            self.tableWidget.setItem(i, 0, item)
            item = QLineEdit()
            if hasattr(item, 'setPlaceholderText'):
                item.setPlaceholderText(ModelerParametersDialog.ENTER_NAME)
            self.valueItems[output.name] = item
            self.tableWidget.setCellWidget(i, 1, item)
            self.tableWidget.setRowHeight(i, 22)

    def setComboBoxValue(self, combo, value, param):
        if isinstance(value, list):
            value = value[0]
        items = [combo.itemData(i) for i in range(combo.count())]
        try:
            idx = items.index(value)
            combo.setCurrentIndex(idx)
            return
        except ValueError:
            pass
        if combo.isEditable():
            if value is not None:
                combo.setEditText(unicode(value))
        elif isinstance(param, ParameterSelection):
            combo.setCurrentIndex(int(value))
        elif isinstance(param, ParameterBoolean):
            if value:
                combo.setCurrentIndex(0)
            else:
                combo.setCurrentIndex(1)

    def setPreviousValues(self):
        if self._algName is not None:
            alg = self.model.algs[self._algName]
            self.descriptionBox.setText(alg.description)
            for param in alg.algorithm.parameters:
                if param.hidden:
                    continue
                widget = self.valueItems[param.name]
                if param.name in alg.params:
                    value = alg.params[param.name]
                else:
                    value = None
                if isinstance(param, (
                        ParameterRaster,
                        ParameterVector,
                        ParameterTable,
                        ParameterTableField,
                        ParameterSelection,
                        ParameterNumber,
                        ParameterBoolean,
                        ParameterExtent,
                        ParameterFile
                )):
                    self.setComboBoxValue(widget, value, param)
                elif isinstance(param, ParameterString):
                    if param.multiline:
                        widget.setValue(value)
                    else:
                        self.setComboBoxValue(widget, value, param)
                elif isinstance(param, ParameterCrs):
                    widget.setAuthId(value)
                elif isinstance(param, ParameterFixedTable):
                    pass  # TODO!
                elif isinstance(param, ParameterMultipleInput):
                    if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                        options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
                    else:
                        options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
                    selected = []
                    for i, opt in enumerate(options):
                        if opt in value:
                            selected.append(i)
                    widget.setSelectedItems(selected)
                elif isinstance(param, ParameterGeometryPredicate):
                    widget.setValue(value)

            for name, out in alg.outputs.iteritems():
                widget = self.valueItems[name].setText(out.description)

            selected = []
            dependencies = self.getAvailableDependencies()
            for idx, dependency in enumerate(dependencies):
                if dependency.name in alg.dependencies:
                    selected.append(idx)

            self.dependenciesPanel.setSelectedItems(selected)

    def createAlgorithm(self):
        alg = Algorithm(self._alg.commandLineName())
        alg.setName(self.model)
        alg.description = self.descriptionBox.text()
        params = self._alg.parameters
        outputs = self._alg.outputs
        for param in params:
            if param.hidden:
                continue
            if not self.setParamValue(alg, param, self.valueItems[param.name]):
                return None
        for output in outputs:
            if not output.hidden:
                name = unicode(self.valueItems[output.name].text())
                if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
                    alg.outputs[output.name] = ModelerOutput(name)

        selectedOptions = self.dependenciesPanel.selectedoptions
        availableDependencies = self.getAvailableDependencies()
        for selected in selectedOptions:
            alg.dependencies.append(availableDependencies[selected].name)

        return alg

    def setParamValueLayerOrTable(self, alg, param, widget):
        idx = widget.currentIndex()
        if idx < 0:
            return False
        else:
            value = widget.itemData(widget.currentIndex())
            alg.params[param.name] = value
            return True

    def setParamTableFieldValue(self, alg, param, widget):
        idx = widget.findText(widget.currentText())
        if idx < 0:
            s = unicode(widget.currentText()).strip()
            if s == '':
                if param.optional:
                    alg.params[param.name] = None
                    return True
                else:
                    return False
            else:
                alg.params[param.name] = s
                return True
        else:
            alg.params[param.name] = widget.itemData(widget.currentIndex())
        return True

    def setParamStringValue(self, alg, param, widget):
        if param.multiline:
            value = widget.getValue()
            option = widget.getOption()
            if option == MultilineTextPanel.USE_TEXT:
                if value == '':
                    if param.optional:
                        alg.params[param.name] = None
                        return True
                    else:
                        return False
                else:
                    alg.params[param.name] = value
            else:
                alg.params[param.name] = value
        else:
            idx = widget.findText(widget.currentText())
            if idx < 0:
                value = widget.currentText().strip()
                if value == '':
                    if param.optional:
                        alg.params[param.name] = None
                        return True
                    else:
                        return False
                else:
                    alg.params[param.name] = value
            else:
                alg.params[param.name] = widget.itemData(widget.currentIndex())
        return True

    def setParamFileValue(self, alg, param, widget):
        idx = widget.findText(widget.currentText())
        if idx < 0:
            value = widget.currentText()
        else:
            value = widget.itemData(widget.currentIndex())
        alg.params[param.name] = value
        return True

    def setParamNumberValue(self, alg, param, widget):
        idx = widget.findText(widget.currentText())
        if idx < 0:
            s = widget.currentText()
            try:
                value = float(s)
            except:
                return False
        else:
            value = widget.itemData(widget.currentIndex())
        alg.params[param.name] = value
        return True

    def setParamExtentValue(self, alg, param, widget):
        idx = widget.findText(widget.currentText())
        if idx < 0:
            s = unicode(widget.currentText())
            try:
                tokens = s.split(',')
                if len(tokens) != 4:
                    return False
                for token in tokens:
                    float(token)
            except:
                return False
            alg.params[param.name] = [s]
        else:
            value = widget.itemData(widget.currentIndex())
            alg.params[param.name] = value
        return True

    def setParamValue(self, alg, param, widget):
        if isinstance(param, (ParameterRaster, ParameterVector,
                      ParameterTable)):
            return self.setParamValueLayerOrTable(alg, param, widget)
        elif isinstance(param, ParameterBoolean):
            if widget.currentIndex() < 2:
                value = widget.currentIndex() == 0
            else:
                value = widget.itemData(widget.currentIndex())
            alg.params[param.name] = value
            return True
        elif isinstance(param, ParameterString):
            return self.setParamStringValue(alg, param, widget)
        elif isinstance(param, ParameterNumber):
            return self.setParamNumberValue(alg, param, widget)
        elif isinstance(param, ParameterExtent):
            return self.setParamExtentValue(alg, param, widget)
        elif isinstance(param, ParameterFile):
            return self.setParamFileValue(alg, param, widget)
        elif isinstance(param, ParameterSelection):
            alg.params[param.name] = widget.currentIndex()
            return True
        elif isinstance(param, ParameterRange):
            alg.params[param.name] = widget.getValue()
            return True
        elif isinstance(param, ParameterCrs):
            authid = widget.getValue()
            if authid is None:
                alg.params[param.name] = None
            else:
                alg.params[param.name] = authid
            return True
        elif isinstance(param, ParameterFixedTable):
            alg.params[param.name] = ParameterFixedTable.tableToString(widget.table)
            return True
        elif isinstance(param, ParameterTableField):
            return self.setParamTableFieldValue(alg, param, widget)
        elif isinstance(param, ParameterMultipleInput):
            if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
                options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
            else:
                options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
            values = [options[i] for i in widget.selectedoptions]
            if len(values) == 0 and not param.optional:
                return False
            alg.params[param.name] = values
            return True
        elif isinstance(param, ParameterGeometryPredicate):
            alg.params[param.name] = widget.value()
            return True
        else:
            alg.params[param.name] = unicode(widget.text())
            return True

    def okPressed(self):
        self.alg = self.createAlgorithm()
        if self.alg is not None:
            self.close()
        else:
            QMessageBox.warning(self, self.tr('Unable to add algorithm'),
                                self.tr('Wrong or missing parameter values'))

    def cancelPressed(self):
        self.alg = None
        self.close()