Beispiel #1
0
void KSANEOCR::finishedOCRVisible( bool success )
{
   bool doSpellcheck = m_wantKSpell;

   if( m_ocrProcessDia )
   {
       m_ocrProcessDia->stopOCR();
       doSpellcheck = m_ocrProcessDia->wantSpellCheck();
   }

   if( success )
   {
       QString goof = ocrResultText();

       emit newOCRResultText(goof);

       if( m_imgCanvas )
       {
	   if( m_resultImage != 0 ) delete m_resultImage;
	   kdDebug(28000) << "Result image name: " << m_ocrResultImage << endl;
	   m_resultImage = new QImage( m_ocrResultImage, "BMP" );
	   kdDebug(28000) << "New result image has dimensions: " << m_resultImage->width() << "x" << m_resultImage->height()<< endl;
           /* The image canvas is non-zero. Set it to our image */
           m_imgCanvas->newImageHoldZoom( m_resultImage );
	   m_imgCanvas->setReadOnly(true);

           /* now handle double clicks to jump to the word */
           m_applyFilter=true;
       }

       /** now it is time to invoke the dictionary if required **/
       emit readOnlyEditor( false );

       if( doSpellcheck )
       {
           m_ocrCurrLine = 0;
           /*
            * create a new kspell object, based on the config of the base dialog
            */

           connect( new KSpell( m_parent, i18n("Kooka OCR Dictionary Check"),
                                this, SLOT( slSpellReady(KSpell*)),
                                m_ocrProcessDia->spellConfig() ),
                    SIGNAL( death()), this, SLOT(slSpellDead()));
       }

       delete m_ocrProcessDia;
       m_ocrProcessDia = 0L;

   }

   visibleOCRRunning =  false;
   cleanUpFiles();


   kdDebug(28000) << "# ocr finished #" << endl;
}
Beispiel #2
0
void OcrEngine::finishResultDocument()
{
    kDebug() << "words" << m_wordCount
             << "lines" << m_document->blockCount()
             << "chars" << m_document->characterCount();

    if (m_cursor!=NULL) delete m_cursor;

    emit readOnlyEditor(false);				// now let user edit it
}
Beispiel #3
0
QTextDocument *OcrEngine::startResultDocument()
{
    kDebug();

    m_document->setUndoRedoEnabled(false);
    m_document->clear();
    m_wordCount = 0;

    m_cursor = new QTextCursor(m_document);

    emit readOnlyEditor(true);				// read only while updating

    return (m_document);
}
Beispiel #4
0
void OcrEngine::finishedOCRVisible(bool success)
{
    if (m_ocrDialog!=NULL) m_ocrDialog->enableGUI(false);

    if (success)
    {
        emit newOCRResultText();

        if (m_imgCanvas!=NULL)
        {
            if (m_resultImage!=NULL) delete m_resultImage;

            m_resultImage = new QImage(m_ocrResultFile);
            kDebug() << "Result image" << m_ocrResultFile
                     << "size" << m_resultImage->size();

            /* The image canvas is present. Set it to our image */
            m_imgCanvas->newImage(m_resultImage, true);
            m_imgCanvas->setReadOnly(true);

            /* now handle double clicks to jump to the word */
            m_trackingActive = true;
        }

        /* now it is time to invoke the dictionary if required */
        // TODO: readOnlyEditor needed here? Also done in finishResultDocument()
        emit readOnlyEditor(false);			// user can now edit
        if (m_ocrDialog!=NULL)
        {
            emit setSpellCheckConfig(m_ocrDialog->customSpellConfigFile());

            bool doSpellcheck = m_ocrDialog->wantInteractiveSpellCheck();
            bool bgSpellcheck = m_ocrDialog->wantBackgroundSpellCheck();
            emit startSpellCheck(doSpellcheck, bgSpellcheck);
        }
    }

    if (m_ocrDialog!=NULL) m_ocrDialog->hide();		// close the dialogue

    m_ocrRunning = false;
    removeTempFiles();

    kDebug() << "OCR finished";
}