diff options
Diffstat (limited to 'krecipes/src/dialogs/similarcategoriesdialog.cpp')
-rw-r--r-- | krecipes/src/dialogs/similarcategoriesdialog.cpp | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/krecipes/src/dialogs/similarcategoriesdialog.cpp b/krecipes/src/dialogs/similarcategoriesdialog.cpp index 3d37113..944dec0 100644 --- a/krecipes/src/dialogs/similarcategoriesdialog.cpp +++ b/krecipes/src/dialogs/similarcategoriesdialog.cpp @@ -9,15 +9,15 @@ #include "similarcategoriesdialog.h" -#include <qvariant.h> -#include <qpushbutton.h> -#include <qcombobox.h> -#include <qslider.h> -#include <qlabel.h> -#include <qheader.h> -#include <qlayout.h> -#include <qtooltip.h> -#include <qwhatsthis.h> +#include <ntqvariant.h> +#include <ntqpushbutton.h> +#include <ntqcombobox.h> +#include <ntqslider.h> +#include <ntqlabel.h> +#include <ntqheader.h> +#include <ntqlayout.h> +#include <ntqtooltip.h> +#include <ntqwhatsthis.h> #include <klistview.h> #include <klocale.h> @@ -27,90 +27,90 @@ #include "widgets/categorycombobox.h" #include "backends/recipedb.h" -SimilarCategoriesDialog::SimilarCategoriesDialog( ElementList &list, QWidget* parent ) - : QDialog( parent, "SimilarCategoriesDialog", true ), +SimilarCategoriesDialog::SimilarCategoriesDialog( ElementList &list, TQWidget* parent ) + : TQDialog( parent, "SimilarCategoriesDialog", true ), m_elementList(list) { - SimilarCategoriesDialogLayout = new QVBoxLayout( this, 11, 6, "SimilarCategoriesDialogLayout"); + SimilarCategoriesDialogLayout = new TQVBoxLayout( this, 11, 6, "SimilarCategoriesDialogLayout"); - layout6 = new QHBoxLayout( 0, 0, 6, "layout6"); + layout6 = new TQHBoxLayout( 0, 0, 6, "layout6"); - layout4 = new QGridLayout( 0, 1, 1, 0, 6, "layout4"); + layout4 = new TQGridLayout( 0, 1, 1, 0, 6, "layout4"); categoriesBox = new KLineEdit( this ); layout4->addWidget( categoriesBox, 0, 1 ); - thresholdSlider = new QSlider( this, "thresholdSlider" ); + thresholdSlider = new TQSlider( this, "thresholdSlider" ); thresholdSlider->setValue( 40 ); - thresholdSlider->setOrientation( QSlider::Horizontal ); + thresholdSlider->setOrientation( TQSlider::Horizontal ); layout4->addWidget( thresholdSlider, 1, 1 ); - thresholdLabel = new QLabel( this, "thresholdLabel" ); + thresholdLabel = new TQLabel( this, "thresholdLabel" ); layout4->addWidget( thresholdLabel, 1, 0 ); - categoryLabel = new QLabel( this, "categoryLabel" ); + categoryLabel = new TQLabel( this, "categoryLabel" ); layout4->addWidget( categoryLabel, 0, 0 ); layout6->addLayout( layout4 ); - layout5 = new QVBoxLayout( 0, 0, 6, "layout5"); + layout5 = new TQVBoxLayout( 0, 0, 6, "layout5"); - searchButton = new QPushButton( this, "searchButton" ); + searchButton = new TQPushButton( this, "searchButton" ); layout5->addWidget( searchButton ); - spacer4 = new QSpacerItem( 20, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); + spacer4 = new TQSpacerItem( 20, 51, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); layout5->addItem( spacer4 ); layout6->addLayout( layout5 ); SimilarCategoriesDialogLayout->addLayout( layout6 ); - layout9 = new QHBoxLayout( 0, 0, 6, "layout9"); + layout9 = new TQHBoxLayout( 0, 0, 6, "layout9"); - layout8 = new QVBoxLayout( 0, 0, 6, "layout8"); + layout8 = new TQVBoxLayout( 0, 0, 6, "layout8"); - allLabel = new QLabel( this, "allLabel" ); + allLabel = new TQLabel( this, "allLabel" ); layout8->addWidget( allLabel ); allListView = new KListView( this, "allListView" ); - allListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, allListView->sizePolicy().hasHeightForWidth() ) ); + allListView->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7, (TQSizePolicy::SizeType)7, 0, 1, allListView->sizePolicy().hasHeightForWidth() ) ); layout8->addWidget( allListView ); layout9->addLayout( layout8 ); - layout1 = new QVBoxLayout( 0, 0, 6, "layout1"); + layout1 = new TQVBoxLayout( 0, 0, 6, "layout1"); - removeButton = new QPushButton( this, "removeButton" ); + removeButton = new TQPushButton( this, "removeButton" ); layout1->addWidget( removeButton ); - addButton = new QPushButton( this, "addButton" ); + addButton = new TQPushButton( this, "addButton" ); layout1->addWidget( addButton ); - spacer1 = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding ); + spacer1 = new TQSpacerItem( 20, 61, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); layout1->addItem( spacer1 ); layout9->addLayout( layout1 ); - layout7 = new QVBoxLayout( 0, 0, 6, "layout7"); + layout7 = new TQVBoxLayout( 0, 0, 6, "layout7"); - toMergeLabel = new QLabel( this, "toMergeLabel" ); + toMergeLabel = new TQLabel( this, "toMergeLabel" ); layout7->addWidget( toMergeLabel ); toMergeListView = new KListView( this, "toMergeListView" ); - toMergeListView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 1, toMergeListView->sizePolicy().hasHeightForWidth() ) ); + toMergeListView->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7, (TQSizePolicy::SizeType)7, 0, 1, toMergeListView->sizePolicy().hasHeightForWidth() ) ); layout7->addWidget( toMergeListView ); layout9->addLayout( layout7 ); SimilarCategoriesDialogLayout->addLayout( layout9 ); - layout10 = new QHBoxLayout( 0, 0, 6, "layout10"); - spacer2 = new QSpacerItem( 310, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + layout10 = new TQHBoxLayout( 0, 0, 6, "layout10"); + spacer2 = new TQSpacerItem( 310, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum ); layout10->addItem( spacer2 ); - mergeButton = new QPushButton( this, "mergeButton" ); + mergeButton = new TQPushButton( this, "mergeButton" ); layout10->addWidget( mergeButton ); - cancelButton = new QPushButton( this, "cancelButton" ); + cancelButton = new TQPushButton( this, "cancelButton" ); layout10->addWidget( cancelButton ); SimilarCategoriesDialogLayout->addLayout( layout10 ); languageChange(); - resize( QSize(573, 429).expandedTo(minimumSizeHint()) ); + resize( TQSize(573, 429).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); connect( searchButton, SIGNAL(clicked()), this, SLOT(findMatches()) ); @@ -125,7 +125,7 @@ SimilarCategoriesDialog::SimilarCategoriesDialog( ElementList &list, QWidget* pa */ SimilarCategoriesDialog::~SimilarCategoriesDialog() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, TQt does it all for us } /* @@ -214,9 +214,9 @@ int minimum(int a,int b,int c) } /** @return an array of adjacent letter pairs contained in the input string */ -QStringList letterPairs(const QString& str) { +TQStringList letterPairs(const TQString& str) { int numPairs = str.length()-1; - QStringList pairs; + TQStringList pairs; for (int i=0; i<numPairs; i++) { pairs << str.mid(i,2); } @@ -224,14 +224,14 @@ QStringList letterPairs(const QString& str) { } /** @return an ArrayList of 2-character Strings. */ -QValueList<QStringList> wordLetterPairs(const QString &str) { - QValueList<QStringList> allPairs; +TQValueList<TQStringList> wordLetterPairs(const TQString &str) { + TQValueList<TQStringList> allPairs; // Tokenize the string and put the tokens/words into an array - QStringList words = QStringList::split("\\s",str); + TQStringList words = TQStringList::split("\\s",str); // For each word for (uint w=0; w < words.count(); w++) { // Find the pairs of characters - QStringList pairsInWord = letterPairs(words[w]); + TQStringList pairsInWord = letterPairs(words[w]); for (uint p=0; p < pairsInWord.count(); p++) { allPairs.append(pairsInWord[p]); } @@ -240,15 +240,15 @@ QValueList<QStringList> wordLetterPairs(const QString &str) { } /** @return lexical similarity value in the range [0,1] */ -double compareStrings(const QString &str1, const QString &str2) { - QValueList<QStringList> pairs1 = wordLetterPairs(str1.upper()); - QValueList<QStringList> pairs2 = wordLetterPairs(str2.upper()); +double compareStrings(const TQString &str1, const TQString &str2) { + TQValueList<TQStringList> pairs1 = wordLetterPairs(str1.upper()); + TQValueList<TQStringList> pairs2 = wordLetterPairs(str2.upper()); int intersection = 0; int size_union = pairs1.count() + pairs2.count(); for (uint i=0; i<pairs1.count(); i++) { - QStringList pair1=pairs1[i]; + TQStringList pair1=pairs1[i]; for(uint j=0; j<pairs2.count(); j++) { - QStringList pair2=pairs2[j]; + TQStringList pair2=pairs2[j]; if (pair1 == pair2) { intersection++; pairs2.remove( pairs2.at(j) ); @@ -266,12 +266,12 @@ double compareStrings(const QString &str1, const QString &str2) { #if 0 void RecipeActionsHandler::mergeSimilar() { - QPtrList<QListViewItem> items = parentListView->selectedItems(); + TQPtrList<TQListViewItem> items = parentListView->selectedItems(); if ( items.count() > 1 ) - KMessageBox::sorry( kapp->mainWidget(), i18n("Please select only one category."), QString::null ); + KMessageBox::sorry( kapp->mainWidget(), i18n("Please select only one category."), TQString::null ); else if ( items.count() == 1 && items.at(0)->rtti() == 1001 ) { CategoryListItem * cat_it = ( CategoryListItem* ) items.at(0); - QString name = cat_it->categoryName(); + TQString name = cat_it->categoryName(); const double max_allowed_distance = 0.60; const int length = name.length(); ElementList categories; @@ -280,7 +280,7 @@ void RecipeActionsHandler::mergeSimilar() ElementList matches; for ( ElementList::const_iterator it = categories.begin(); it != categories.end(); ++it ) { #if 0 - if ( levenshtein_distance(name.latin1(),(*it).name.latin1())/double(QMAX(length,(*it).name.length())) >= max_allowed_distance ) { + if ( levenshtein_distance(name.latin1(),(*it).name.latin1())/double(TQMAX(length,(*it).name.length())) >= max_allowed_distance ) { #else if ( compareStrings(name,(*it).name) >= max_allowed_distance ) { #endif @@ -307,19 +307,19 @@ void SimilarCategoriesDialog::findMatches() toMergeListView->clear(); const double threshold = (100 - thresholdSlider->value())/100.0; - const QString name = categoriesBox->text(); + const TQString name = categoriesBox->text(); for ( ElementList::const_iterator it = m_elementList.begin(); it != m_elementList.end(); ++it ) { //kdDebug()<<(*it).name<<" (result/threshold): "<<compareStrings(name,(*it).name)<<"/"<<threshold<<endl; #if 0 - if ( levenshtein_distance(name.latin1(),(*it).name.latin1())/double(QMAX(length,(*it).name.length())) >= max_allowed_distance ) { + if ( levenshtein_distance(name.latin1(),(*it).name.latin1())/double(TQMAX(length,(*it).name.length())) >= max_allowed_distance ) { #else if ( compareStrings(name,(*it).name) >= threshold ) { #endif kdDebug()<<(*it).name<<" matches"<<endl; //if ( id != (*it).id ) { - (void) new QListViewItem(allListView,(*it).name,QString::number((*it).id)); - (void) new QListViewItem(toMergeListView,(*it).name,QString::number((*it).id)); + (void) new TQListViewItem(allListView,(*it).name,TQString::number((*it).id)); + (void) new TQListViewItem(toMergeListView,(*it).name,TQString::number((*it).id)); //} } } @@ -328,54 +328,54 @@ void SimilarCategoriesDialog::findMatches() void SimilarCategoriesDialog::mergeMatches() { if ( !toMergeListView->firstChild() ) { - KMessageBox::sorry( this, i18n("No categories selected to merge."), QString::null ); + KMessageBox::sorry( this, i18n("No categories selected to merge."), TQString::null ); return; } //const int id = categoriesBox->id(categoriesBox->currentItem()); - //for ( QListViewItem *item = toMergeListView->firstChild(); item; item = item->nextSibling() ) { + //for ( TQListViewItem *item = toMergeListView->firstChild(); item; item = item->nextSibling() ) { // m_database->mergeCategories(id,item->text(1).toInt()); //} allListView->clear(); //toMergeListView->clear(); - QDialog::accept(); + TQDialog::accept(); } -QValueList<int> SimilarCategoriesDialog::matches() const +TQValueList<int> SimilarCategoriesDialog::matches() const { - QValueList<int> ids; - for ( QListViewItem *item = toMergeListView->firstChild(); item; item = item->nextSibling() ) { + TQValueList<int> ids; + for ( TQListViewItem *item = toMergeListView->firstChild(); item; item = item->nextSibling() ) { ids << item->text(1).toInt(); } return ids; } -QString SimilarCategoriesDialog::element() const +TQString SimilarCategoriesDialog::element() const { return categoriesBox->text(); } void SimilarCategoriesDialog::addCategory() { - QListViewItem *item = allListView->selectedItem(); + TQListViewItem *item = allListView->selectedItem(); if ( item ) { //make sure it isn't already in the list - for ( QListViewItem *search_it = toMergeListView->firstChild(); search_it; search_it = search_it->nextSibling() ) { + for ( TQListViewItem *search_it = toMergeListView->firstChild(); search_it; search_it = search_it->nextSibling() ) { if ( search_it->text(0) == item->text(0) ) return; } - (void) new QListViewItem(toMergeListView,item->text(0),item->text(1)); + (void) new TQListViewItem(toMergeListView,item->text(0),item->text(1)); } } void SimilarCategoriesDialog::removeCategory() { - QListViewItem *item = toMergeListView->selectedItem(); + TQListViewItem *item = toMergeListView->selectedItem(); if ( item ) delete item; } |