コード例 #1
0
 def on_btnGetLinks_clicked(self):
     if self.tblSearchResult.rowCount()<1:
         return
     links_text = ""
     for row in range(self.tblSearchResult.rowCount()):
         if( self.tblSearchResult.item(row, 0 ).checkState() is Qt.Checked ):
             downloadlink = self.data.getDownloadLink(self.tblSearchResult.item(row, 3).text())
             '''只处理带有可用link的对象'''
             if 'link' in downloadlink:
                 links_text += (downloadlink['link']+'\n')
             #print links_text
         else:
             print 'row: %d'%row
     self.linksDialog = Links_dialog(links_text.strip())
     self.linksDialog.setWindowTitle(self.tr("Selected Download Links for copying"))
     self.linksDialog.show()
コード例 #2
0
 def on_btnAbout_clicked(self):
     self.aboutDialog = Links_dialog(self.about)
     self.aboutDialog.setWindowTitle(self.tr("About"))
     self.aboutDialog.show()
     pass
コード例 #3
0
class Settings(QDialog, Ui_PanSearcher):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None):
        super(Settings,self).__init__(parent)
        self.setupUi(self)      
        self.initData()
        self.initUi()
        
    def initUi(self):
        #QTimer.singleShot(0,self.searchWords,QtCore.SLOT(self.searchWords.setFocus()))
        #self.tblPcsSet.setRowCount(self.maxRowCount);
        pass
        
    def initData(self):
        self.data = MyDataWrapper("")
        self.linksDialog = None
        self.aboutDialog = None
        self.author = self.tr("kjpioo2006 # gmail.com")
        self.thanksto = self.tr("daimajia and meibenjin")
        self.license = self.tr("MIT license")
        self.ver = "0.1.0"
        self.about = self.tr("A baidu yun file-share download links getter. Version:{0}\n\n\tAuthor:{1}\n\tThanks to {2}\n\n\tLicense: {3}").format(self.ver, self.author, self.thanksto, self.license)
        pass

    @pyqtSlot(int)
    def on_ckbxSelectAll_stateChanged(self, stat):
        allCheckState = set([Qt.Unchecked, Qt.Checked])
        #use a workaround for "PySide.QtGui.QTableWidgetItem.setCheckState(int)" error
        checkedState = (allCheckState -(allCheckState - set([stat]))).pop()
        #print 'stat:%d'%stat
        for row in range(self.tblSearchResult.rowCount()):
            self.tblSearchResult.item(row, 0 ).setCheckState(checkedState)
        pass
    
    @pyqtSlot()
    def on_btnStartSearch_clicked(self):
        if(self.tblSearchResult.rowCount()>0):
            self.tblSearchResult.clearContents()
        
        results = test( self.lnedtKeyword.text() )
        if len(results)>0:
            self.populateUiSearchResult(results)
            
    @pyqtSlot()
    def on_btnAbout_clicked(self):
        self.aboutDialog = Links_dialog(self.about)
        self.aboutDialog.setWindowTitle(self.tr("About"))
        self.aboutDialog.show()
        pass
    
    @pyqtSlot()
    def on_btnGetLinks_clicked(self):
        if self.tblSearchResult.rowCount()<1:
            return
        links_text = ""
        for row in range(self.tblSearchResult.rowCount()):
            if( self.tblSearchResult.item(row, 0 ).checkState() is Qt.Checked ):
                downloadlink = self.data.getDownloadLink(self.tblSearchResult.item(row, 3).text())
                '''只处理带有可用link的对象'''
                if 'link' in downloadlink:
                    links_text += (downloadlink['link']+'\n')
                #print links_text
            else:
                print 'row: %d'%row
        self.linksDialog = Links_dialog(links_text.strip())
        self.linksDialog.setWindowTitle(self.tr("Selected Download Links for copying"))
        self.linksDialog.show()
    
    def populateUiSearchResult(self, results):
        self.tblSearchResult.clearContents()
        self.tblSearchResult.setRowCount(len(results))
        for row in range(len(results)):
            newItem = QTableWidgetItem()
            newItem.setCheckState(Qt.Unchecked)
            self.tblSearchResult.setItem(row, 0, newItem)
            
            newTitle = QTableWidgetItem(results[row].getTitle().split("_免费高速下载")[0])
            self.tblSearchResult.setItem(row, 1, newTitle)
            
            print QTableWidgetItem(results[row].getContent())
            filesize = results[row].getContent().split(" 分享者")[0].split(' 文件大小:')[1].strip()
            newDesc = QTableWidgetItem(filesize)
            self.tblSearchResult.setItem(row, 2, newDesc)
            
            newUrl = QTableWidgetItem(results[row].getURL())
            self.tblSearchResult.setItem(row, 3, newUrl)
        pass