From 2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 2 Jul 2011 06:40:27 +0000 Subject: TQt4 port tellico This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/barcode/barcode.cpp | 96 ++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'src/barcode/barcode.cpp') diff --git a/src/barcode/barcode.cpp b/src/barcode/barcode.cpp index 2427f4e..1c2d1f2 100644 --- a/src/barcode/barcode.cpp +++ b/src/barcode/barcode.cpp @@ -15,8 +15,8 @@ // includes code from http://v4l2spec.bytesex.org/spec/a16323.htm -#include -#include +#include +#include #include "barcode.h" #include @@ -53,13 +53,13 @@ void barcodeRecognitionThread::run() Barcode_EAN13 old; while (!stop) { - QImage img; + TQImage img; m_barcode_img_mutex.lock(); if (m_barcode_img.isNull()) img = m_barcode_v4l->grab_one2(); else { img = m_barcode_img; - m_barcode_img = QImage(); + m_barcode_img = TQImage(); } m_barcode_img_mutex.unlock(); @@ -69,7 +69,7 @@ void barcodeRecognitionThread::run() // //DEBUG if (!img.isNull()) { - QImage preview = img.scale( 320, 240, QImage::ScaleMin ); + TQImage preview = img.scale( 320, 240, TQ_ScaleMin ); emit gotImage( preview ); Barcode_EAN13 barcode = recognize( img ); if (barcode.isValid() && (old != barcode)) { @@ -94,7 +94,7 @@ void barcodeRecognitionThread::stop() } -void barcodeRecognitionThread::recognizeBarcode( QImage img ) +void barcodeRecognitionThread::recognizeBarcode( TQImage img ) { // attention! This function is called from GUI context m_barcode_img_mutex.lock(); @@ -102,7 +102,7 @@ void barcodeRecognitionThread::recognizeBarcode( QImage img ) m_barcode_img_mutex.unlock(); } -Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img ) +Barcode_EAN13 barcodeRecognitionThread::recognize( TQImage img ) { // PARAMETERS: int amount_scanlines = 30; @@ -110,7 +110,7 @@ Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img ) int h = img.height(); // the array which will contain the result: - QValueVector< QValueVector > numbers( amount_scanlines, QValueVector(13,-1) ); // no init in java source!!!!!!!!! + TQValueVector< TQValueVector > numbers( amount_scanlines, TQValueVector(13,-1) ); // no init in java source!!!!!!!!! // generate and initialize the array that will contain all detected // digits at a specific code position: @@ -170,14 +170,14 @@ Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img ) void barcodeRecognitionThread::printArray( int array[10][13][2], int level ) { for (int i = 0; i < 10; i++) { - QCString temp; + TQCString temp; temp.setNum( i ); fprintf( stderr, temp + " : " ); for (int j = 0; j < 13; j++) { if (array[i][j][level] == -1) fprintf( stderr, "x " ); else { - QCString temp; + TQCString temp; temp.setNum( array[i][j][level] ); fprintf( stderr, temp + " " ); } @@ -186,20 +186,20 @@ void barcodeRecognitionThread::printArray( int array[10][13][2], int level ) } } -barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( QImage img, int x1, int x2, int y ) +barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( TQImage img, int x1, int x2, int y ) { - QValueVector raw_path(x2-x1+1); + TQValueVector raw_path(x2-x1+1); for (int x=x1; x<=x2; x++) raw_path[x-x1] = img.pixel(x,y); // convert the given path into a string of black and white pixels: - QValueVector string = transformPathToBW( raw_path ); + TQValueVector string = transformPathToBW( raw_path ); // convert the string of black&white pixels into a list, containing // information about the black and white fields // first indes = field nr. // second index: 0 = color of the field // 1 = field length - QValueVector< QValueVector > fields = extractFieldInformation( string ); + TQValueVector< TQValueVector > fields = extractFieldInformation( string ); // try to recognize a EAN13 code: Barcode_EAN13 barcode = Decoder_EAN13::recognize( fields ); @@ -207,7 +207,7 @@ barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( QImag return barcode; } -void barcodeRecognitionThread::addNumberToPossibleNumbers( QValueVector number, int possible_numbers[10][13][2], bool correct_code ) +void barcodeRecognitionThread::addNumberToPossibleNumbers( TQValueVector number, int possible_numbers[10][13][2], bool correct_code ) { int i; bool digit_contained; @@ -278,7 +278,7 @@ void barcodeRecognitionThread::sortDigits( int possible_numbers[10][13][2] ) Barcode_EAN13 barcodeRecognitionThread::extractBarcode( int possible_numbers[10][13][2] ) { // create and initialize the temporary variables: - QValueVector temp_code(13); + TQValueVector temp_code(13); for (int i = 0; i < 13; i++) temp_code[i] = possible_numbers[0][i][0]; @@ -295,13 +295,13 @@ Barcode_EAN13 barcodeRecognitionThread::extractBarcode( int possible_numbers[10] Barcode_EAN13 barcodeRecognitionThread::detectValidBarcode ( int possible_numbers[10][13][2], int max_amount_of_considered_codes ) { // create and initialize the temporary variables: - QValueVector temp_code(13); + TQValueVector temp_code(13); for ( int i = 0; i < 13; i++ ) temp_code[i] = possible_numbers[0][i][0]; int alternative_amount = 0; - QValueVector counter( 13 ); // no init in java source!!! + TQValueVector counter( 13 ); // no init in java source!!! int counter_nr = 11; // check if there is at least one complete code present: @@ -367,12 +367,12 @@ Barcode_EAN13 barcodeRecognitionThread::detectValidBarcode ( int possible_number bool barcodeRecognitionThread::isValid( int numbers[13] ) { - QValueVector temp(13); + TQValueVector temp(13); for (int i=0; i<13; i++) temp[i] = numbers[i]; return isValid( temp ); } -bool barcodeRecognitionThread::isValid( QValueVector numbers ) +bool barcodeRecognitionThread::isValid( TQValueVector numbers ) { Q_ASSERT( numbers.count() == 13 ); // calculate the checksum of the barcode: @@ -393,17 +393,17 @@ bool barcodeRecognitionThread::isValid( QValueVector numbers ) return (numbers[12] == checksum_digit); } -QValueVector barcodeRecognitionThread::transformPathToBW( QValueVector line ) +TQValueVector barcodeRecognitionThread::transformPathToBW( TQValueVector line ) { int w = line.count(); - QValueVector bw_line(w,0); + TQValueVector bw_line(w,0); bw_line[0] = 255; // create greyscale values: - QValueVector grey_line(w,0); + TQValueVector grey_line(w,0); int average_illumination = 0; for (int x = 0; x < w; x++) { - grey_line[x] = (qRed(line.at(x)) + qGreen(line.at(x)) + qBlue(line.at(x))) / 3; + grey_line[x] = (tqRed(line.at(x)) + tqGreen(line.at(x)) + tqBlue(line.at(x))) / 3; average_illumination = average_illumination + grey_line[x]; } average_illumination = average_illumination / w; @@ -452,7 +452,7 @@ QValueVector barcodeRecognitionThread::transformPathToBW( QValueVector ret(w,0); + TQValueVector ret(w,0); for (int i=0; i barcodeRecognitionThread::transformPathToBW( QValueVector > barcodeRecognitionThread::extractFieldInformation( QValueVector string ) +TQValueVector< TQValueVector > barcodeRecognitionThread::extractFieldInformation( TQValueVector string ) { - QValueVector< QValueVector > temp_fields( string.count(), QValueVector(2,0) ); + TQValueVector< TQValueVector > temp_fields( string.count(), TQValueVector(2,0) ); if (string.count() == 0) - return QValueVector< QValueVector >(); + return TQValueVector< TQValueVector >(); int field_counter = 0; int last_value = string.at(0); @@ -513,13 +513,13 @@ Barcode_EAN13::Barcode_EAN13() } //ok -Barcode_EAN13::Barcode_EAN13( QValueVector code ) +Barcode_EAN13::Barcode_EAN13( TQValueVector code ) { setCode( code ); } //ok -void Barcode_EAN13::setCode( QValueVector code ) +void Barcode_EAN13::setCode( TQValueVector code ) { if (code.count() != 13) { m_numbers.clear(); @@ -553,18 +553,18 @@ bool Barcode_EAN13::isValid() const } //ok -QValueVector Barcode_EAN13::getNumbers() const +TQValueVector Barcode_EAN13::getNumbers() const { return m_numbers; } //ok -QString Barcode_EAN13::toString() const +TQString Barcode_EAN13::toString() const { - QString s; + TQString s; for (int i = 0; i < 13; i++) if ((m_numbers[i] >= 0) && (m_numbers[i] <= 9)) - s += QString::number(m_numbers[i]); + s += TQString::number(m_numbers[i]); else s += '?'; return s; @@ -583,17 +583,17 @@ bool Barcode_EAN13::operator!= ( const Barcode_EAN13 &code ) } //ok -Barcode_EAN13 Decoder_EAN13::recognize( QValueVector< QValueVector > fields ) +Barcode_EAN13 Decoder_EAN13::recognize( TQValueVector< TQValueVector > fields ) { // try to extract the encoded information from the field series: - QValueVector numbers = decode( fields, 0, fields.count() ); + TQValueVector numbers = decode( fields, 0, fields.count() ); Barcode_EAN13 barcode( numbers ); // return the results: return barcode; } -QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > fields, int start_i, int end_i ) +TQValueVector Decoder_EAN13::decode( TQValueVector< TQValueVector > fields, int start_i, int end_i ) { // determine the length of the path in pixels int length = 0; @@ -617,11 +617,11 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field // consistency checks: if (fields.count() <= 0) - return QValueVector(); + return TQValueVector(); if (start_i > end_i - 3) - return QValueVector(); + return TQValueVector(); if (end_i - start_i < 30) - return QValueVector(); // (just a rough value) + return TQValueVector(); // (just a rough value) // relevant indexes: int start_sentinel_i; @@ -634,7 +634,7 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field float unit_length; // results: - QValueVector numbers( 13, -1 ); // the java source does no initialization + TQValueVector numbers( 13, -1 ); // the java source does no initialization // determine the relevant positions: @@ -657,7 +657,7 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field #endif if (start_sentinel_i < 0) - return QValueVector(); + return TQValueVector(); // calculate the other positions: left_numbers_i = start_sentinel_i + 3; @@ -666,7 +666,7 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field end_sentinel_i = right_numbers_i + 6 * 4; if (end_sentinel_i + 3 > end_i) - return QValueVector(); + return TQValueVector(); // calculate the average (pixel) length of a bar that is one unit wide: // (a complete barcode consists out of 95 length units) @@ -680,10 +680,10 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field fprintf( stderr, "unit_width: %f\n", unit_length ); #endif - QValueVector< QValueVector > current_number_field( 4, QValueVector(2,0) ); + TQValueVector< TQValueVector > current_number_field( 4, TQValueVector(2,0) ); if (left_numbers_i + 1 > end_i) - return QValueVector(); + return TQValueVector(); // test the side from which we are reading the barcode: @@ -773,7 +773,7 @@ QValueVector Decoder_EAN13::decode( QValueVector< QValueVector > field return numbers; } -MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector > fields, int code_table_to_use) +MatchMakerResult Decoder_EAN13::recognizeNumber( TQValueVector< TQValueVector > fields, int code_table_to_use) { // convert the pixel lenghts of the four black&white fields into // normed values that have together a length of 70; @@ -799,7 +799,7 @@ MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector int odd_min_difference_index = 0; if ((code_table_to_use == BOTH_TABLES)||(code_table_to_use == EVEN_TABLE)) { - QValueVector even_differences(10,0); + TQValueVector even_differences(10,0); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { @@ -818,7 +818,7 @@ MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector } if ((code_table_to_use == BOTH_TABLES) || (code_table_to_use == ODD_TABLE)) { - QValueVector odd_differences(10,0); + TQValueVector odd_differences(10,0); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { -- cgit v1.2.1