Esempio n. 1
0
    def openLink(self, key, arg="", fileArg=None):
        """Use `QDesktopServices` to open an url using
        the system default applications

        Parameters:
            key: the entry key or the link (if `arg` == "link")
            arg:
                if `arg` == "file", `fileArg` must be the file name
                if `arg` == "link", `key` must be the link to be opened
                for any other values, the link will be generated using
                    the `physbiblio.view.viewWntry.getLink` method
            fileArg: the file name if `arg` == "file", or
                the argument passed to `physbiblio.view.viewWntry.getLink`
                if needed
        """
        if isinstance(key, list):
            for k in key:
                self.openLink(k, arg, fileArg)
        else:
            if arg == "file":
                url = QUrl.fromLocalFile(fileArg)
            elif arg == "link":
                url = QUrl(key)
            else:
                link = self.getLink(key, arg=arg, fileArg=fileArg)
                url = QUrl(link)
            if QDesktopServices.openUrl(url):
                pBLogger.debug(ccstr.openSuccess % (url.toString(), key))
            else:
                pBLogger.warning(ccstr.openFailed % key)
Esempio n. 2
0
 def _graph_url_changed(self, url: QtCore.QUrl):
     node_uri = url.toString()
     node_uri_stem = node_uri.split("/")[-1]
     node_index = node_uri_stem.split("node_id_")[-1]
     if node_index.isdigit():
         node_index = int(node_index)
         self._update_node_graph_view([node_index])
Esempio n. 3
0
    def testSetAttributes(self):
        #Construct QUrl by set* methods
        url = QUrl()

        url.setScheme('ftp')
        self.assertEqual(url.toString(), 'ftp:')

        url.setHost('www.google.com')
        self.assertEqual(url.toString(), 'ftp://www.google.com')

        url.setPort(8080)
        self.assertEqual(url.toString(), 'ftp://www.google.com:8080')

        url.setPath('/mail/view')
        self.assertEqual(url.toString(), 'ftp://www.google.com:8080/mail/view')

        url.setUserName('john')
        self.assertEqual(url.toString(),
                         'ftp://[email protected]:8080/mail/view')

        url.setPassword('abc123')
        self.assertEqual(url.toString(),
                         'ftp://*****:*****@www.google.com:8080/mail/view')
Esempio n. 4
0
    def testSetAttributes(self):
        #Construct QUrl by set* methods
        url = QUrl()

        url.setScheme('ftp')
        self.assertEqual(url.toString(), 'ftp:')

        url.setHost('www.google.com')
        self.assertEqual(url.toString(), 'ftp://www.google.com')

        url.setPort(8080)
        self.assertEqual(url.toString(), 'ftp://www.google.com:8080')

        url.setPath('mail/view')
        self.assertEqual(url.toString(),
                        'ftp://www.google.com:8080/mail/view')

        url.setUserName('john')
        self.assertEqual(url.toString(),
                        'ftp://[email protected]:8080/mail/view')

        url.setPassword('abc123')
        self.assertEqual(url.toString(),
                        'ftp://*****:*****@www.google.com:8080/mail/view')
Esempio n. 5
0
 def __isModelExtensionValid(self, modelPath:QUrl) -> bool:
     if modelPath.toString().toLower().endsWith('.stl') or modelPath.toString().toLower().endsWith('.obj'):
         return True
     else:
         return False
Esempio n. 6
0
 def testBasic(self):
     #Default constructor for QUrl
     url = QUrl()
     self.assertEqual(url.toString(), "")
Esempio n. 7
0
 def _url_changed(self, url: QtCore.QUrl) -> None:
     self.address_line_edit.setText(url.toString())
Esempio n. 8
0
 def testBasic(self):
     #Default constructor for QUrl
     url = QUrl()
     self.assertEqual(url.toString(), "")