예제 #1
0
파일: Gui.py 프로젝트: bossbux/alfanous
    def search_all( self, page = 1 ):
        """
        The main search function
        """
        # add to undo stack
        if self.o_query.currentText() in self.undo_stack:
            self.undo_stack.remove( self.o_query.currentText() )
        self.undo_stack.insert( 0, self.o_query.currentText() )
        self.o_query.clear()
        self.o_query.addItems( self.undo_stack )
        self.o_query.setCurrentIndex( 0 )

        limit = int( self.limit_group.checkedAction().text() )

        suggest_flags = {
                "action":"suggest",
                "query": self.o_query.currentText()
                }
        suggestion_output = RAWoutput.do( suggest_flags )

        #search
        results, terms = None, []
        search_flags = {"action":"search",
                 "query": unicode( self.o_query.currentText() ),
                 "sortedby":"score" if self.actionRelevance.isChecked() \
                        else "mushaf" if self.actionPosition_in_Mus_haf.isChecked() \
                        else "tanzil" if self.actionRevelation.isChecked() \
                        else "subject" if self.actionSubject.isChecked() \
                        else unicode( self.sorted_by_group.checkedAction().text() ), # ara2eng_names[self.sorted_by_group.checkedAction().text()] for Arabic,
                 "page": self.o_page.value(),
                 "reverse_order": self.actionInverse.isChecked(),
                 "word_info":self.actionWord_Info.isChecked(),
                 "highlight": "html" if self.actionHighlight_Keywords.isChecked() else None,
                 "script": "uthmani" if self.actionUthmani.isChecked()
                            else "standard",
                 "prev_aya":self.actionPrevios_aya.isChecked(),
                 "next_aya": self.actionNext_aya.isChecked(),
                 "sura_info": self.actionSura_info.isChecked(),
                 "aya_position_info":  self.actionAya_Info.isChecked(),
                 "aya_theme_info":  self.actionAya_Info.isChecked(),
                 "aya_stat_info":  self.actionAya_Info.isChecked(),
                 "aya_sajda_info":  self.actionAya_Info.isChecked(),
                 "translation":self.translation_group.checkedAction().text(),
                 "word_info": self.actionWord_Info.isChecked(),
                 }
        self.Queries.insert( 0, search_flags )
        results = RAWoutput.do( search_flags )

        #if self.o_filter.isChecked() and self.last_results:
        #    results = QFilter( self.last_results, results )
        self.last_results = results
        ayas = results["search"]["ayas"]
        #outputs
        self.o_time.display( results["search"]["runtime"] )
        self.o_resnum.display( results["search"]["interval"]["total"] )

        # get page
        numpagereal = ( results["search"]["interval"]["total"] - 1 ) / PERPAGE + 1
        numpagelimit = ( limit - 1 ) / PERPAGE + 1
        numpage = numpagelimit if numpagelimit < numpagereal else numpagereal
        self.o_numpage.display( numpage )
        self.o_page.setMinimum( 1 if numpage else 0 )
        self.o_page.setMaximum( numpage )
        #self.o_page.setValue(  )

        template_vars = {
						   "results": results, 
						   "suggestions":suggestion_output ,
						   "_": lambda x:x 
						}

        self.o_results.setHtml( AYA_RESULTS_TEMPLATE.render(template_vars) )
예제 #2
0
파일: Gui.py 프로젝트: AhmedSalem/alfanous
    def search_all( self, page = 1 ):
        """
        The main search function
        """
        # add to history
        if self.o_query.currentText() in self.history:
            self.history.remove( self.o_query.currentText() )
        self.history.insert( 0, self.o_query.currentText() )
        self.o_query.clear()
        self.o_query.addItems( self.history )
        self.o_query.setCurrentIndex( 0 )

        limit = self.o_limit.value()


        suggest_flags = {
                "action":"suggest",
                "query": self.o_query.currentText()
                }
        suggestion_output = RAWoutput.do( suggest_flags )

        #search
        results, terms = None, []
        search_flags = {"action":"search",
                 "query": unicode( self.o_query.currentText() ),
                 "sortedby":"score" if self.o_sortedbyscore.isChecked() \
                        else "mushaf" if self.o_sortedbymushaf.isChecked() \
                        else "tanzil" if self.o_sortedbytanzil.isChecked() \
                        else "subject" if self.o_sortedbysubject.isChecked() \
                        else unicode( self.o_field.currentText() ), # ara2eng_names[self.o_field.currentText()] for Arabic,
                 "page": self.o_page.value(),
                 "reverse_order": self.o_reverse.isChecked(),
                 "word_info":self.o_word_stat.isChecked(),
                 "highlight": "html" if self.o_highlight.isChecked() else None,
                 "script": "uthmani" if self.o_script_uthmani.isChecked()
                            else "standard",
                 "prev_aya":self.o_prev.isChecked(),
                 "next_aya": self.o_suiv.isChecked(),
                 "sura_info": self.o_sura_info.isChecked(),
                 "aya_position_info":  self.o_aya_info.isChecked(),
                 "aya_theme_info":  self.o_aya_info.isChecked(),
                 "aya_stat_info":  self.o_aya_info.isChecked(),
                 "aya_sajda_info":  self.o_aya_info.isChecked(),
                 "translation":self.o_traduction.currentText(),
                 "word_info": self.o_word_stat.isChecked(),
                 }
        self.Queries.insert( 0, search_flags )
        results = RAWoutput.do( search_flags )

        #if self.o_filter.isChecked() and self.last_results:
        #    results = QFilter( self.last_results, results )
        self.last_results = results
        ayas = results["search"]["ayas"]
        #outputs
        self.o_time.display( results["search"]["runtime"] )
        self.o_resnum.display( results["search"]["interval"]["total"] )

        # get page
        numpagereal = ( results["search"]["interval"]["total"] - 1 ) / PERPAGE + 1
        numpagelimit = ( limit - 1 ) / PERPAGE + 1
        numpage = numpagelimit if numpagelimit < numpagereal else numpagereal
        self.o_numpage.display( numpage )
        self.o_page.setMinimum( 1 if numpage else 0 )
        self.o_page.setMaximum( numpage )
        #self.o_page.setValue(  )

        template_vars = {
						   "results": results, 
						   "suggestions":suggestion_output ,
						   "_": lambda x:x 
						}

        self.o_results.setText( AYA_RESULTS_TEMPLATE.render(template_vars) )
예제 #3
0
파일: Gui.py 프로젝트: telojagung/alfanous
    def search_all(self, page=1):
        """
        The main search function
        """
        # add to history
        if self.o_query.currentText() in self.history:
            self.history.remove(self.o_query.currentText())
        self.history.insert(0, self.o_query.currentText())
        self.o_query.clear()
        self.o_query.addItems(self.history)
        self.o_query.setCurrentIndex(0)

        limit = self.o_limit.value()

        suggest_flags = {
            "action": "suggest",
            "query": self.o_query.currentText()
        }
        suggestion_output = RAWoutput.do(suggest_flags)

        #search
        results, terms = None, []
        search_flags = {"action":"search",
                 "query": unicode( self.o_query.currentText() ),
                 "sortedby":"score" if self.o_sortedbyscore.isChecked() \
                        else "mushaf" if self.o_sortedbymushaf.isChecked() \
                        else "tanzil" if self.o_sortedbytanzil.isChecked() \
                        else "subject" if self.o_sortedbysubject.isChecked() \
                        else unicode( self.o_field.currentText() ), # ara2eng_names[self.o_field.currentText()] for Arabic,
                 "page": self.o_page.value(),
                 "reverse_order": self.o_reverse.isChecked(),
                 "word_info":self.o_word_stat.isChecked(),
                 "highlight": "html" if self.o_highlight.isChecked() else None,
                 "script": "uthmani" if self.o_script_uthmani.isChecked()
                            else "standard",
                 "prev_aya":self.o_prev.isChecked(),
                 "next_aya": self.o_suiv.isChecked(),
                 "sura_info": self.o_sura_info.isChecked(),
                 "aya_position_info":  self.o_aya_info.isChecked(),
                 "aya_theme_info":  self.o_aya_info.isChecked(),
                 "aya_stat_info":  self.o_aya_info.isChecked(),
                 "aya_sajda_info":  self.o_aya_info.isChecked(),
                 "translation":self.o_traduction.currentText(),
                 "word_info": self.o_word_stat.isChecked(),
                 }
        self.Queries.insert(0, search_flags)
        results = RAWoutput.do(search_flags)

        #if self.o_filter.isChecked() and self.last_results:
        #    results = QFilter( self.last_results, results )
        self.last_results = results
        ayas = results["search"]["ayas"]
        #outputs
        self.o_time.display(results["search"]["runtime"])
        self.o_resnum.display(results["search"]["interval"]["total"])

        # get page
        numpagereal = (results["search"]["interval"]["total"] -
                       1) / PERPAGE + 1
        numpagelimit = (limit - 1) / PERPAGE + 1
        numpage = numpagelimit if numpagelimit < numpagereal else numpagereal
        self.o_numpage.display(numpage)
        self.o_page.setMinimum(1 if numpage else 0)
        self.o_page.setMaximum(numpage)
        #self.o_page.setValue(  )

        template_vars = {
            "results": results,
            "suggestions": suggestion_output,
            "_": lambda x: x
        }

        self.o_results.setText(AYA_RESULTS_TEMPLATE.render(template_vars))