예제 #1
0
class Option(QWidget):
   
    def __init__(self):
        QWidget.__init__(self)
        self.resize(168, 86)
        self.name = "Progress"
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setMargin(0)
        self.label_2 = QLabel(self)
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.spinBox = QSpinBox(self)
        self.spinBox.setMinimum(60)
        self.spinBox.setMaximum(600)
        self.gridLayout.addWidget(self.spinBox, 0, 2, 1, 1)
        self.spinBox_2 = QSpinBox(self)
        self.spinBox_2.setMinimum(120)
        self.spinBox_2.setMaximum(600)
        self.spinBox_2.setProperty("value", 600)
        self.gridLayout.addWidget(self.spinBox_2, 1, 2, 1, 1)
        self.label = QLabel(self)

        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)

        self.label_2.setText(u"Max Süre(dk):")
        self.label.setText(u"Min. Süre(dk):")
예제 #2
0
 def addSpinBox(self, name):
     sb = QSpinBox(self)
     sb.setEnabled(True)
     sb.setMinimumSize(QSize(60, 20))
     sb.setMaximumSize(QSize(60, 20))
     sb.setWrapping(False)
     sb.setFrame(True)
     sb.setButtonSymbols(QSpinBox.NoButtons)
     sb.setAccelerated(True)
     sb.setCorrectionMode(QSpinBox.CorrectToPreviousValue)
     sb.setKeyboardTracking(True)
     sb.setMinimum(0)
     sb.setMaximum(99999999)
     sb.setSingleStep(1000)
     sb.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
     sb.setProperty("value", 0)
     sb.setObjectName(name)
     return sb
예제 #3
0
 def addSpinBox(self, name):
     sb = QSpinBox(self)
     sb.setEnabled(True)
     sb.setMinimumSize(QSize(60, 20))
     sb.setMaximumSize(QSize(60, 20))
     sb.setWrapping(False)
     sb.setFrame(True)
     sb.setButtonSymbols(QSpinBox.NoButtons)
     sb.setAccelerated(True)
     sb.setCorrectionMode(QSpinBox.CorrectToPreviousValue)
     sb.setKeyboardTracking(True)
     sb.setMinimum(0)
     sb.setMaximum(99999999)
     sb.setSingleStep(1000)
     sb.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
     sb.setProperty("value", 0)
     sb.setObjectName(name)
     return sb
예제 #4
0
class XSchemeConfigWidget(XConfigWidget):
    def __init__( self, parent, uifile = '' ):
        uifile = ''
        
        super(XSchemeConfigWidget, self).__init__(parent, uifile)
        
        # define the font widgets
        self._applicationFont     = QFontComboBox(self)
        self._applicationFont.setProperty('dataName', wrapVariant('font'))
        self._applicationFont.setSizePolicy( QSizePolicy.Expanding,
                                             QSizePolicy.Preferred )
                                           
        self._applicationFontSize = QSpinBox(self)
        self._applicationFontSize.setProperty('dataName', wrapVariant('fontSize'))
        
        self._colorButton = XColorButton(self)
        
        hbox = QHBoxLayout()
        hbox.addWidget(QLabel('Font:', self))
        hbox.addWidget(self._applicationFont)
        hbox.addWidget(QLabel('Size:', self))
        hbox.addWidget(self._applicationFontSize)
        hbox.addWidget(QLabel('Quick Color:', self))
        hbox.addWidget(self._colorButton)
        
        # define the color tree
        self._colorTree = XColorTreeWidget(self)
        self._colorTree.setProperty('dataName', wrapVariant('colorSet'))
        
        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(self._colorTree)
        
        self.setLayout(vbox)
        
        # create connections
        self._colorButton.colorChanged.connect( self._colorTree.setQuickColor )
예제 #5
0
class Option(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.resize(168, 86)
        self.name = "Progress"
        self.gridLayout = QGridLayout(self)
        self.gridLayout.setMargin(0)
        self.label_2 = QLabel(self)
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.spinBox = QSpinBox(self)
        self.spinBox.setMinimum(60)
        self.spinBox.setMaximum(600)
        self.gridLayout.addWidget(self.spinBox, 0, 2, 1, 1)
        self.spinBox_2 = QSpinBox(self)
        self.spinBox_2.setMinimum(120)
        self.spinBox_2.setMaximum(600)
        self.spinBox_2.setProperty("value", 600)
        self.gridLayout.addWidget(self.spinBox_2, 1, 2, 1, 1)
        self.label = QLabel(self)

        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)

        self.label_2.setText(u"Max Süre(dk):")
        self.label.setText(u"Min. Süre(dk):")
예제 #6
0
class ConfigWidget(DefaultConfigWidget):

    def __init__(self, plugin):
        DefaultConfigWidget.__init__(self, plugin)
        c = plugin_prefs[STORE_NAME]
        all_tags = get_current_db().all_tags()

        other_group_box = QGroupBox('Other options', self)
        self.l.addWidget(other_group_box, self.l.rowCount(), 0, 1, 2)
        other_group_box_layout = QVBoxLayout()
        other_group_box.setLayout(other_group_box_layout)

        max_label = QLabel('Maximum title/author search matches to evaluate (1 = fastest):', self)
        max_label.setToolTip('Kyobobook do not always have links to large covers for every ISBN\n'
                             'of the same book. Increasing this value will take effect when doing\n'
                             'title/author searches to consider more ISBN editions.\n\n'
                             'This will increase the potential likelihood of getting a larger cover\n'
                             'though does not guarantee it.')
        other_group_box_layout.addWidget(max_label) #, 0, 0, 1, 1)
        self.max_downloads_spin = QSpinBox(self)
        self.max_downloads_spin.setMinimum(1)
        self.max_downloads_spin.setMaximum(20)
        self.max_downloads_spin.setProperty('value', c.get(KEY_MAX_DOWNLOADS, DEFAULT_STORE_VALUES[KEY_MAX_DOWNLOADS]))
        other_group_box_layout.addWidget(self.max_downloads_spin)#, 0, 1, 1, 1)
        #other_group_box_layout.setColumnStretch(2, 1)


        # by sseeookk, category 20140315
        self.get_category_checkbox = QCheckBox('Add Kyobobook Categories to Calibre tags', self)
        self.get_category_checkbox.setToolTip('Add Kyobobook Categories to Calibre tags(ex, [Domestic Books > History > Korea Culture / History Journey]).')
        self.get_category_checkbox.setChecked(c[KEY_GET_CATEGORY])
        other_group_box_layout.addWidget(self.get_category_checkbox)
        
        
        self.all_authors_checkbox = QCheckBox('Get all contributing authors (e.g. illustrators, series editors etc)', self)
        self.all_authors_checkbox.setToolTip('Kyobobook for some books will list all of the contributing authors and\n'
                                              'the type of contribution like (Editor), (Illustrator) etc.\n\n'
                                              'When this option is checked, all contributing authors are retrieved.\n\n'
                                              'When unchecked (default) only the primary author(s) are returned which\n'
                                              'are those that either have no contribution type specified, or have the\n'
                                              'value of (Kyobobook Author).\n\n'
                                              'If there is no primary author then only those with the same contribution\n'
                                              'type as the first author are returned.\n'
                                              'e.g. "A, B (Illustrator)" will return author A\n'
                                              'e.g. "A (Kyobobook Author)" will return author A\n'
                                              'e.g. "A (Editor), B (Editor), C (Illustrator)" will return authors A & B\n'
                                              'e.g. "A (Editor), B (Series Editor)" will return author A\n')
        self.all_authors_checkbox.setChecked(c[KEY_GET_ALL_AUTHORS])
        other_group_box_layout.addWidget(self.all_authors_checkbox)
        
        # Add by sseeookk, 20140315
        self.toc_checkbox = QCheckBox('Append TOC from Features tab if available to comments', self)
        self.toc_checkbox.setToolTip('Kyobobook for textbooks on their website have a Features tab which\n'
                                      'contains a table of contents for the book. Checking this option will\n'
                                      'append the TOC to the bottom of the Synopsis in the comments field')
        self.toc_checkbox.setChecked(c.get(KEY_APPEND_TOC, DEFAULT_STORE_VALUES[KEY_APPEND_TOC]))
        # other_group_box_layout.addWidget(self.toc_checkbox, 2, 0, 1, 3)
        other_group_box_layout.addWidget(self.toc_checkbox)


    def commit(self):
        DefaultConfigWidget.commit(self)
        new_prefs = {}
        new_prefs[KEY_MAX_DOWNLOADS] = int(unicode(self.max_downloads_spin.value()))
        new_prefs[KEY_GET_CATEGORY] = self.get_category_checkbox.checkState() == Qt.Checked
        new_prefs[KEY_GET_ALL_AUTHORS] = self.all_authors_checkbox.checkState() == Qt.Checked
        new_prefs[KEY_APPEND_TOC] = self.toc_checkbox.checkState() == Qt.Checked
        plugin_prefs[STORE_NAME] = new_prefs
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        
        self._create_components()
        self._place_components()
        self._create_controller()
        
        self.setWindowTitle("Job Crawler")
    
    def _create_components(self):
        self.site_gb = QGroupBox(u"Choix des sites")
        self.param_gb = QGroupBox(u"Autres Paramètres")
        self.search_gb = QGroupBox(u"Mots-clé")
        self.log_gb = QGroupBox(u"Logs")

        self.apec_cb = QCheckBox(u"APEC")
        self.apec_cb.setDisabled(True)
        self.caoe_cb = QCheckBox(u"CAO Emploi")
        self.caoe_cb.setDisabled(True)
        self.inde_cb = QCheckBox(u"Indeed")
        self.mons_cb = QCheckBox(u"Monster Job")
        self.mons_cb.setDisabled(True)
        self.pole_cb = QCheckBox(u"Pole Enmploi")
        self.pole_cb.setDisabled(True)
        self.regi_cb = QCheckBox(u"Région Job")
        self.regi_cb.setDisabled(True)
        
        self.search_label = QLabel(u"Mots-clé de recherche")
        self.filter_label = QLabel(u"Critère de filtrage")
        self.region_label = QLabel(u"Région")
        self.daterange_label = QLabel(u"Plage de recherche")
        
        self.search_qle = QLineEdit()
        self.filter_qle = QLineEdit()
        
        self.start_button = QPushButton(u"Rechercher")
        self.stop_button = QPushButton(u"Stopper")
        self.stop_button.setDisabled(True)
        
        self.daterange_sb = QSpinBox()
        self.daterange_sb.setMaximum(40)
        self.daterange_sb.setProperty("value", 3)
        self.daterange_sb.setSuffix(u" Jours")
        
        self.region_cb = QComboBox()
        region_list = toolbox.getconfigvalue("STATIC", "regions").split(',')
        self.region_cb.addItems(region_list)
        
        self.log_te = QTextEdit()
        self.log_te.setReadOnly(True)
        self.log_te.setLineWrapMode(QTextEdit.NoWrap)
        
        self.file_menu = QMenu(u"Fichier")
        self.help_menu = QMenu(u"Aide")
        
    
    def _place_components(self):
        site_layout = QHBoxLayout()
        temp = QVBoxLayout()
        temp.addWidget(self.apec_cb)
        temp.addWidget(self.caoe_cb)
        temp.addWidget(self.inde_cb)
        site_layout.addLayout(temp)
        temp = QVBoxLayout()
        temp.addWidget(self.mons_cb)
        temp.addWidget(self.pole_cb)
        temp.addWidget(self.regi_cb)
        site_layout.addLayout(temp)
        self.site_gb.setLayout(site_layout)
        
        search_layout = QVBoxLayout()
        search_layout.addWidget(self.search_label)
        search_layout.addWidget(self.search_qle)
        search_layout.addWidget(self.filter_label)
        search_layout.addWidget(self.filter_qle)
        self.search_gb.setLayout(search_layout)
        
        param_layout = QVBoxLayout()
        param_layout.addWidget(self.daterange_label)
        param_layout.addWidget(self.daterange_sb)
        param_layout.addWidget(self.region_label)
        param_layout.addWidget(self.region_cb)
        self.param_gb.setLayout(param_layout)
        
        log_layout = QVBoxLayout()
        log_layout.addWidget(self.log_te)
        self.log_gb.setLayout(log_layout)
        
        command_layout = QHBoxLayout()
        command_layout.addWidget(self.start_button)
        command_layout.addWidget(self.stop_button)
        
        main_layout = QVBoxLayout()
        main_layout.addWidget(self.site_gb)
        main_layout.addWidget(self.search_gb)
        main_layout.addWidget(self.param_gb)
        main_layout.addWidget(self.log_gb)
        main_layout.addLayout(command_layout)
        
        centralwidget = QWidget(self)
        centralwidget.setLayout(main_layout)
        self.setCentralWidget(centralwidget)
        
        menubar = self.menuBar()
        menubar.addMenu(self.file_menu)
        menubar.addMenu(self.help_menu)
    
    def _create_controller(self):
        adminAction = QAction(u'Administration', self)        
        adminAction.setStatusTip(u'Régler les paramètres de l\'application')
        adminAction.triggered.connect(self.admin)
        
        exitAction = QAction(u'Quitter', self)        
        exitAction.setStatusTip(u'Quitter Job Crawler')
        exitAction.triggered.connect(qApp.quit)
        
        aboutAction = QAction(u'A propos', self)
        aboutAction.setStatusTip(u'Afficher la fenêtre à propos')
        aboutAction.triggered.connect(self.about)
        
        self.file_menu.addAction(adminAction)
        self.file_menu.addSeparator()
        self.file_menu.addAction(exitAction)
        
        self.help_menu.addAction(aboutAction)
        
        self.start_button.clicked.connect(self.start)
        self.stop_button.clicked.connect(self.stop)
        
        # Controller for logging
        XStream.stdout().messageWritten.connect( self.log_te.insertPlainText )
        XStream.stderr().messageWritten.connect( self.log_te.insertPlainText )
    
    def validate_fields(self):
        error = False
        error_list = u""
        
        inde = self.inde_cb.isChecked()
        apec = self.apec_cb.isChecked()
        caoe = self.caoe_cb.isChecked()
        mons = self.mons_cb.isChecked()
        pole = self.pole_cb.isChecked()
        regi = self.regi_cb.isChecked()
        
        if  not (inde or apec or caoe or mons or pole or regi):
            error = True
            error_list += u"<li>Site à requêter</li>"
            
        searchkeyword = unidecode(unicode(self.search_qle.text()))
        
        if searchkeyword == u"":
            error = True
            error_list += u"<li>Mots clé de recherche</li>"
        
        filterkeyword = unidecode(unicode(self.filter_qle.text()))
        
        if filterkeyword == u"":
            error = True
            error_list += u"<li>Critère de filtrage</li>"
        
        if error:
            message = u"Veuillez renseigner le(s) champ(s) suivant(s) :<ul>" + error_list + u"</ul>"
            QMessageBox.warning(self, u"Erreur", message)
        
        return not error
    
    def validate_admin(self):
        dbpath = toolbox.getconfigvalue("GENERAL", "dbfile")
        
        if not (dbpath != "" and os.access(os.path.dirname(dbpath), os.W_OK)):
            message = u"<p>Veuiller renseigner l'emplacement de la base de données dans l'administration (Fichier > Administration).</p>"\
                      u"<p>Si cela a déjà été fait, ce message signifie que vous n'avez pas les droits d'écriture dans ce répertoire. Veuillez déplacer la base de données et reconfigurer l'emplacement dans l'administration.</p>"
            QMessageBox.warning(self, u"Erreur", message)
            return False
        
        return True
        
    @pyqtSlot()
    def start(self):
        def run():
            self.start_button.setDisabled(True)
#             self.stop_button.setEnabled(True)
            
            logger.info(u"Début")
            
            inde = self.inde_cb.isChecked()
            apec = self.apec_cb.isChecked()
            caoe = self.caoe_cb.isChecked()
            mons = self.mons_cb.isChecked()
            pole = self.pole_cb.isChecked()
            regi = self.regi_cb.isChecked()
            
            searchkeyword = unidecode(unicode(self.search_qle.text())).split(",")
            filterkeyword = unidecode(unicode(self.filter_qle.text())).split(",")
            
            daterange = self.daterange_sb.value()
            region = str(self.region_cb.currentText())
            
            dbpath = toolbox.getconfigvalue("GENERAL", "dbfile")
            excludelist = unidecode(toolbox.getconfigvalue("GENERAL", "excludes")).split(",")
            
            c = core.core(dbpath)
            logger.info(u"Recherche d'annonces")
            c.found_annonce(searchkeyword, daterange, region, None, apec, caoe, inde, mons, pole, regi)
            logger.info(u"Tri des annonces par rapport aux mots-clé d'exclusion")
            c.exclude_annouces(excludelist)
            logger.info(u"Tri des annonces par rapport aux critères de filtrage")
            c.filter_announces(filterkeyword)
            
            logger.info(u"Fin")
            
#             self.stop_button.setDisabled(True)
            self.start_button.setEnabled(True)
        
        if self.validate_fields() and self.validate_admin():
            self.thread = threading.Thread(target=run)
            self.thread.start()
    
    @pyqtSlot()
    def stop(self):
        self.thread._Thread__stop()
        self.stop_button.setDisabled(True)
        self.start_button.setEnabled(True)
        
    @pyqtSlot()
    def about(self):
        self.aboutwindow = aboutdialog.AboutDialog(self).exec_()
    
    @pyqtSlot()
    def admin(self):
        admindialog.AdminDialog(self).exec_()