From 66461d0f109766004a8473f701b392a525cbe840 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Fri, 1 Nov 2024 12:06:39 +0100 Subject: [PATCH] WIP 2 --- CMakeLists.txt | 4 +- src/addressprovider.cpp | 8 +-- src/addressprovider_akonadi.cpp | 9 +-- src/addressselectorwidget.cpp | 5 +- src/addresstemplateprovider.cpp | 2 +- src/alldocsview.cpp | 8 +-- src/catalogselection.cpp | 6 +- src/catalogtemplateprovider.cpp | 4 +- src/dbtoxmlconverter.cpp | 16 +++--- src/docassistant.cpp | 4 +- src/docidentgenerator.cpp | 2 +- src/docpostcard.cpp | 2 +- src/doctypeedit.cpp | 4 +- src/documentman.cpp | 3 +- src/documentsaverxml.cpp | 49 +++++++++++++--- src/exportxrechnung.cpp | 4 +- src/filterheader.cpp | 2 +- src/fixcalcdialog.cpp | 2 +- src/flostempldialog.cpp | 6 +- src/footertemplateprovider.cpp | 10 ++-- src/headertemplateprovider.cpp | 10 ++-- src/importfilter.cpp | 14 ++--- src/inserttempldialog.cpp | 2 +- src/itemtagdialog.cpp | 2 +- src/katalog.cpp | 4 +- src/kataloglistview.cpp | 8 +-- src/katalogman.h | 7 --- src/kraftdb.cpp | 6 +- src/kraftdoc.cpp | 89 +++++++++++++++--------------- src/kraftdocedit.cpp | 2 +- src/kraftdocpositionsedit.cpp | 2 +- src/kraftview.cpp | 4 +- src/kraftview_ro.cpp | 6 +- src/matcalcdialog.cpp | 2 +- src/materialselectdialog.cpp | 2 +- src/materialtempldialog.cpp | 6 +- src/models/datemodel.cpp | 6 +- src/models/documentmodel.cpp | 2 +- src/models/documentproxymodels.cpp | 2 +- src/myidentity.cpp | 4 +- src/numbercycle.cpp | 8 +-- src/pdfconverter.cpp | 22 ++++---- src/portalhtmlview.cpp | 2 +- src/positionviewwidget.cpp | 13 +++-- src/prefsdialog.cpp | 5 +- src/reportgenerator.cpp | 28 ++++------ src/setupassistant.cpp | 3 +- src/tagman.cpp | 4 +- src/tagtemplatesdialog.cpp | 3 +- src/templkatalog.cpp | 4 +- src/templkataloglistview.cpp | 2 +- src/textselection.cpp | 8 +-- src/timecalcdialog.cpp | 3 +- src/unitmanager.cpp | 6 +- 54 files changed, 228 insertions(+), 213 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7dd3796..8c92ea09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,8 +104,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override") -set(QT_DEFINITIONS "${Qt6Core_DEFINITIONS} ${Qt6Gui_DEFINITIONS} ${Qt6Widgets_DEFINITIONS}") -add_definitions(${QT_DEFINITIONS} ) +# set(QT_DEFINITIONS "${Qt6Core_DEFINITIONS} ${Qt6Gui_DEFINITIONS} ${Qt6Widgets_DEFINITIONS}") +# add_definitions(${QT_DEFINITIONS} ) # include_directories( /usr/include/${AKO_PREFIX}/AkonadiCore ) # include_directories(/usr/include/${AKO_PREFIX}/) diff --git a/src/addressprovider.cpp b/src/addressprovider.cpp index 0d3a213e..8c5c9aa6 100644 --- a/src/addressprovider.cpp +++ b/src/addressprovider.cpp @@ -54,14 +54,14 @@ void AddressProvider::slotAddresseeFound( const QString& uid, const KContacts::A } _addressCache[uid] = contact; _addressCache[uid].insertCustom(CUSTOM_ADDRESS_MARKER, "addressbook"); - emit lookupResult(uid, _addressCache[uid]); + Q_EMIT lookupResult(uid, _addressCache[uid]); } void AddressProvider::slotAddresseeNotFound( const QString& uid ) { KContacts::Addressee contact; // Empty for not found. _notFoundUids.insert(uid); - emit lookupResult(uid, contact); + Q_EMIT lookupResult(uid, contact); } void AddressProvider::slotResetNotFoundCache() @@ -152,12 +152,8 @@ QString AddressProvider::formattedAddress( const KContacts::Addressee& contact ) if( address.isEmpty() ) { re = contact.realName(); } else { -#if KContacts_VERSION >= QT_VERSION_CHECK(5, 92, 0) re = address.formatted( KContacts::AddressFormatStyle::MultiLineDomestic, contact.realName(), contact.organization() ); -#else - re = address.formattedAddress( contact.realName(), contact.organization() ); -#endif } return re; } diff --git a/src/addressprovider_akonadi.cpp b/src/addressprovider_akonadi.cpp index 51dfa3c8..d70f7899 100644 --- a/src/addressprovider_akonadi.cpp +++ b/src/addressprovider_akonadi.cpp @@ -151,7 +151,7 @@ void AddressProviderPrivate::searchResult( KJob* job ) if( job->error() ) { // both uid and err message can be empty const QString errMsg = job->errorString(); - emit lookupError(uid, errMsg ); + Q_EMIT lookupError(uid, errMsg ); // qDebug () << "Address Search job failed: " << job->errorString(); } else { Akonadi::ContactSearchJob *searchJob = qobject_cast( job ); @@ -163,10 +163,10 @@ void AddressProviderPrivate::searchResult( KJob* job ) if( contacts.size() > 0 ) { contact = contacts[0]; // qDebug() << "Found uid search job for UID " << uid << " = " << contact.realName(); - emit addresseeFound(uid, contact); + Q_EMIT addresseeFound(uid, contact); } else { // qDebug() << "No search result for UID" << uid; - emit addresseeNotFound(uid); + Q_EMIT addresseeNotFound(uid); } } @@ -260,7 +260,8 @@ QString AddressProviderPrivate::formattedAddress( const KContacts::Addressee& co if( address.isEmpty() ) { re = contact.realName(); } else { - re = address.formattedAddress( contact.realName(), contact.organization() ); + re = address.formatted( KContacts::AddressFormatStyle::MultiLineDomestic, + contact.realName(), contact.organization() ); } return re; } diff --git a/src/addressselectorwidget.cpp b/src/addressselectorwidget.cpp index 26900ae6..d6a1b392 100644 --- a/src/addressselectorwidget.cpp +++ b/src/addressselectorwidget.cpp @@ -340,8 +340,7 @@ void AddressSelectorWidget::setupUi() void AddressSelectorWidget::slotFilterTextChanged( const QString& filter) { // qDebug() << "Filter: " << filter; - mProxyModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::RegExp)); - // mProxyModel.setFilterFixedString(filter); + mProxyModel->setFilterRegularExpression(filter); } void AddressSelectorWidget::restoreState() @@ -393,7 +392,7 @@ void AddressSelectorWidget::slotAddresseeSelected(QModelIndex index) qDebug() << "----------- " << contact.formattedName() << contact.uid(); _contactViewer->setContact(contact); - emit addressSelected(contact); + Q_EMIT addressSelected(contact); mButEditContact->setEnabled( true ); } else { diff --git a/src/addresstemplateprovider.cpp b/src/addresstemplateprovider.cpp index 32a08b4c..0a8b2bd9 100644 --- a/src/addresstemplateprovider.cpp +++ b/src/addresstemplateprovider.cpp @@ -68,7 +68,7 @@ void AddressTemplateProvider::slotTemplateToDocument() } // qDebug () << "Moving address of " << mCurrentAddress.realName() << " to document"; - emit addressToDocument( mCurrentAddress ); + Q_EMIT addressToDocument( mCurrentAddress ); } void AddressTemplateProvider::slotInsertTemplateToDocument() diff --git a/src/alldocsview.cpp b/src/alldocsview.cpp index 0ee7c462..722af9eb 100644 --- a/src/alldocsview.cpp +++ b/src/alldocsview.cpp @@ -117,8 +117,8 @@ void AllDocsView::slotAmountFilterChanged(int entryNo) void AllDocsView::slotSearchTextChanged(const QString& newStr ) { - mTableModel->setFilterRegExp(newStr); - mDateModel->setFilterRegExp(newStr); + mTableModel->setFilterRegularExpression(newStr); + mDateModel->setFilterRegularExpression(newStr); } void AllDocsView::initDetailViewActions(const std::array actions) @@ -383,7 +383,7 @@ void AllDocsView::slotCurrentChanged( QModelIndex index, QModelIndex previous ) /* get the corresponding document id */ if( isDoc ) { const DocDigest& digest = model->digest( mCurrentlySelected ); - emit docSelected(digest.uuid()); + Q_EMIT docSelected(digest.uuid()); mAllViewDetails->slotShowDocDetails( digest ); } else { const QModelIndex idIndx = model->index(mCurrentlySelected.row(), @@ -411,7 +411,7 @@ void AllDocsView::slotCurrentChanged( QModelIndex index, QModelIndex previous ) } } else { // qDebug () << "Got invalid index, clearing digest view."; - emit docSelected( QString() ); + Q_EMIT docSelected( QString() ); mAllViewDetails->slotClearView(); } //// qDebug () << "Supposed row: " << sourceIndex.row() << " Supposed ID: " << DocumentModel::self()->data(sourceIndex, Qt::DisplayRole); diff --git a/src/catalogselection.cpp b/src/catalogselection.cpp index f4cf91d0..38def3e7 100644 --- a/src/catalogselection.cpp +++ b/src/catalogselection.cpp @@ -44,7 +44,7 @@ CatalogSelection::CatalogSelection( QWidget *parent ) mWidgets(nullptr) { QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); + // layout->setMargin(0); Qt6 port FIXME QHBoxLayout *hb = new QHBoxLayout; layout->addLayout(hb); QLabel *l = new QLabel( i18n( "Selected &catalog: " ) ); @@ -76,7 +76,7 @@ void CatalogSelection::setupCatalogList() void CatalogSelection::slotCatalogDoubleClicked( QModelIndex ) { - emit actionAppendPosition(); + Q_EMIT actionAppendPosition(); } CatalogTemplateList CatalogSelection::currentSelectedPositions() @@ -174,7 +174,7 @@ void CatalogSelection::slotSelectCatalog( const QString& katName ) if ( katListView ) { mWidgets->setCurrentWidget(katListView); mListSearchLine->setListView(katListView); - emit selectionChanged(katListView->currentItem(), nullptr); + Q_EMIT selectionChanged(katListView->currentItem(), nullptr); } } } diff --git a/src/catalogtemplateprovider.cpp b/src/catalogtemplateprovider.cpp index 656389b9..800d50a6 100644 --- a/src/catalogtemplateprovider.cpp +++ b/src/catalogtemplateprovider.cpp @@ -57,7 +57,7 @@ void CatalogTemplateProvider::slotNewTemplate() CatalogTemplateList list; const QString currKat = mCatalogSelection->currentSelectedKatChapter(); - emit templatesToDocument(catalog, list, currKat); + Q_EMIT templatesToDocument(catalog, list, currKat); } } @@ -78,7 +78,7 @@ void CatalogTemplateProvider::slotTemplateToDocument() if ( mCatalogSelection ) { Katalog *catalog = mCatalogSelection->currentSelectedKat(); - emit templatesToDocument(catalog, mCatalogSelection->currentSelectedPositions(), + Q_EMIT templatesToDocument(catalog, mCatalogSelection->currentSelectedPositions(), QString()); } } diff --git a/src/dbtoxmlconverter.cpp b/src/dbtoxmlconverter.cpp index 98341417..6c83375e 100644 --- a/src/dbtoxmlconverter.cpp +++ b/src/dbtoxmlconverter.cpp @@ -66,11 +66,11 @@ QMap DbToXMLConverter::convert(const QString& dBase) for (int year : keys) { int amount = years.value(year); - emit conversionOut(i18n("Transforming %1 documents for year %2...").arg(amount).arg(year)); + Q_EMIT conversionOut(i18n("Transforming %1 documents for year %2...").arg(amount).arg(year)); QMap results; convertDocsOfYear(year, dBase, results); - emit conversionOut(i18n(" result: %1 ok, %2 fails, %3 PDF fails").arg(results[okStr]).arg(results[failsStr]).arg(results[pdfFailsStr])); + Q_EMIT conversionOut(i18n(" result: %1 ok, %2 fails, %3 PDF fails").arg(results[okStr]).arg(results[failsStr]).arg(results[pdfFailsStr])); overallResults[okStr] += results[okStr]; overallResults[failsStr] += results[failsStr]; @@ -79,22 +79,22 @@ QMap DbToXMLConverter::convert(const QString& dBase) // FIXME Check for errors and set ok flag } - emit conversionOut(i18n("
Overall document conversion result:")); - emit conversionOut(i18n(" Successfully transformed documents: %1").arg(overallResults[okStr])); - emit conversionOut(i18n(" Failed transformed documents: %1").arg(overallResults[failsStr])); - emit conversionOut(i18n(" PDF transformed fails: %1").arg(overallResults[pdfFailsStr])); + Q_EMIT conversionOut(i18n("
Overall document conversion result:")); + Q_EMIT conversionOut(i18n(" Successfully transformed documents: %1").arg(overallResults[okStr])); + Q_EMIT conversionOut(i18n(" Failed transformed documents: %1").arg(overallResults[failsStr])); + Q_EMIT conversionOut(i18n(" PDF transformed fails: %1").arg(overallResults[pdfFailsStr])); // -- Convert the numbercycles int nc_cnt = convertNumbercycles(dBase); overallResults["numberCyclesOk"] = nc_cnt; - emit conversionOut(i18n("
Transformed %1 numbercycle(s) successfully.").arg(nc_cnt)); + Q_EMIT conversionOut(i18n("
Transformed %1 numbercycle(s) successfully.").arg(nc_cnt)); for( const auto& k : overallResults.keys()) { qDebug() << "Tranformation result" << k << ":" << overallResults[k]; } if (convertOwnIdentity(dBase)) { qDebug() << "manual own Identity converted"; - emit conversionOut(i18n("
Converted manual created identity successfully")); + Q_EMIT conversionOut(i18n("
Converted manual created identity successfully")); } if (nc_cnt == 0) { diff --git a/src/docassistant.cpp b/src/docassistant.cpp index 776da571..f7c0426e 100644 --- a/src/docassistant.cpp +++ b/src/docassistant.cpp @@ -359,7 +359,7 @@ void DocAssistant::slotToggleShowTemplates( bool on ) // hide the details setFullPreview( true, mActivePage ); } - emit toggleShowTemplates( on ); + Q_EMIT toggleShowTemplates( on ); } DocPostCard *DocAssistant::postCard() @@ -385,7 +385,7 @@ void DocAssistant::slotSelectDocPart( KraftDoc::Part p ) } else { // qDebug () << "Alert: Unknown document part id: " << p; } - emit selectPage( p ); + Q_EMIT selectPage( p ); slotToggleShowTemplates( !mFullPreview ); slotTemplateSelectionChanged( ); // hide the add, edit- and del buttons } diff --git a/src/docidentgenerator.cpp b/src/docidentgenerator.cpp index 22df6504..09829ba2 100644 --- a/src/docidentgenerator.cpp +++ b/src/docidentgenerator.cpp @@ -42,7 +42,7 @@ bool DocIdentGenerator::generate(KraftDoc *doc) const QString ident = NumberCycles::generateIdent(ncName, dt.name(), doc->date(), doc->addressUid()); - emit newIdent(ident); + Q_EMIT newIdent(ident); return true; } diff --git a/src/docpostcard.cpp b/src/docpostcard.cpp index a94f17bc..a951773e 100644 --- a/src/docpostcard.cpp +++ b/src/docpostcard.cpp @@ -296,7 +296,7 @@ void DocPostCard::slotUrlSelected( const QUrl& kurl) // qDebug () << "Footer selected!" << endl; id = KraftDoc::Part::Footer; } - emit selectPage( id ); + Q_EMIT selectPage( id ); } } diff --git a/src/doctypeedit.cpp b/src/doctypeedit.cpp index 95c8f3ee..01d71236 100644 --- a/src/doctypeedit.cpp +++ b/src/doctypeedit.cpp @@ -280,7 +280,7 @@ void DocTypeEdit::slotRemoveDocType() delete currItem; // qDebug () << "removed type: " << mRemovedTypes; - emit removedType( currName ); + Q_EMIT removedType( currName ); } void DocTypeEdit::slotDocTypeSelected( const QString& newValue ) @@ -482,7 +482,7 @@ void DocTypeEdit::saveDocTypes() removeTypeFromDb( *it ); mOrigDocTypes.remove( *it ); mChangedDocTypes.remove( *it ); - emit removedType( *it ); + Q_EMIT removedType( *it ); } } diff --git a/src/documentman.cpp b/src/documentman.cpp index 7fb244f0..a36497de 100644 --- a/src/documentman.cpp +++ b/src/documentman.cpp @@ -141,8 +141,9 @@ DocGuardedPtr DocumentMan::openDocumentByUuid(const QString& uuid) bool DocumentMan::loadMetaFromFilename(const QString& xmlFile, KraftDoc *doc) { DocumentSaverXML docLoad; + QFileInfo fi(xmlFile); - if (doc && docLoad.loadFromFile(xmlFile, doc, true)) { + if (doc && docLoad.loadFromFile(fi, doc, true)) { return true; } qDebug() << "Failed to load file" << xmlFile; diff --git a/src/documentsaverxml.cpp b/src/documentsaverxml.cpp index f306814e..07203145 100644 --- a/src/documentsaverxml.cpp +++ b/src/documentsaverxml.cpp @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include #include @@ -116,7 +114,7 @@ QDomDocument xmlDocument(KraftDoc *doc) meta.appendChild(textElement(xmldoc, "docType", doc->docType())); meta.appendChild(textElement(xmldoc, "docDesc", doc->whiteboard())); meta.appendChild(textElement(xmldoc, "currency", DefaultProvider::self()->locale()->currencySymbol(QLocale::CurrencyIsoCode))); - meta.appendChild(textElement(xmldoc, "country", DefaultProvider::self()->locale()->countryToString(DefaultProvider::self()->locale()->country()))); + meta.appendChild(textElement(xmldoc, "country", DefaultProvider::self()->locale()->territoryToString(DefaultProvider::self()->locale()->territory()))); meta.appendChild(textElement(xmldoc, "locale", DefaultProvider::self()->locale()->languageToString(DefaultProvider::self()->locale()->language()))); meta.appendChild(textElement(xmldoc, "ident", doc->ident() ) ); if (doc->uuid().isEmpty()) @@ -509,10 +507,40 @@ DocumentSaverXML::DocumentSaverXML() } + bool DocumentSaverXML::verifyXmlFile(const QUrl& schemaFile, const QString& xmlFile) { - QFile file( xmlFile ); bool re{false}; + // FIXME use alternative implementation + +#if 0 +#include +#include + +int main() { + // Create a DOM parser instance + XercesDOMParser parser; + + // Set the schema location and namespace + parser.setSchemaLocation("http://example.com/schema.xsd"); + parser.setNamespace("http://example.com/namespace"); + + // Parse and validate an XML document + XMLCh* xmlDoc = parser.parse("example.xml"); + + // Check if the validation was successful + if (parser.getValidationFailed()) { + // Handle validation errors + } else { + // XML document is valid according to the schema + } + + return 0; +} + +=========================================================== + + QFile file( xmlFile ); QXmlSchema schema; if (!schema.load(schemaFile)) { @@ -528,6 +556,12 @@ bool DocumentSaverXML::verifyXmlFile(const QUrl& schemaFile, const QString& xmlF } } } +#else + Q_UNUSED(xmlFile) + Q_UNUSED(schemaFile) + re = true; +#endif + return re; } @@ -633,7 +667,7 @@ bool DocumentSaverXML::loadByIdent(const QString& id, KraftDoc *doc) return false; } - const QFileInfo xmlFile = xmlDocFileNameFromIdent(id); + const QFileInfo xmlFile{xmlDocFileNameFromIdent(id)}; return loadFromFile(xmlFile, doc); } @@ -660,8 +694,9 @@ bool DocumentSaverXML::loadFromFile(const QFileInfo& xmlFile, KraftDoc *doc, boo const QByteArray arr = file.readAll(); QString errMsg; - if (!_domDoc.setContent(arr, &errMsg)) { - qDebug() << "Unable to set file content as xml:" << errMsg; + QDomDocument::ParseResult pe = _domDoc.setContent(arr); + if (!pe) { + qDebug() << "Unable to set file content as xml:" << pe.errorMessage << "in line"<expand(uuid, myContact, contact); if (expanded.isEmpty()) { - // emit failure(i18n("The template expansion failed.")); + // Q_EMIT failure(i18n("The template expansion failed.")); qDebug() << "Expansion failed, empty result"; return; } @@ -148,7 +148,7 @@ void ExporterXRechnung::slotAddresseeFound(const QString& uid, const KContacts:: outStream << expanded; tempFile.close(); - emit xRechnungTmpFile(fName); + Q_EMIT xRechnungTmpFile(fName); #if 0 if (_validateWithSchema && _schema.isValid()) { QFile file(fName); diff --git a/src/filterheader.cpp b/src/filterheader.cpp index 2cb51fb3..89ee966c 100644 --- a/src/filterheader.cpp +++ b/src/filterheader.cpp @@ -80,7 +80,7 @@ void FilterHeader::slotTextChanged( const QString& filter ) } } if (filter.isEmpty()) { - for( auto item : _openedItems.uniqueKeys()) { + for( auto item : _openedItems.keys()) { item->setExpanded(false); } _openedItems.clear(); diff --git a/src/fixcalcdialog.cpp b/src/fixcalcdialog.cpp index 51727527..e3ab442a 100644 --- a/src/fixcalcdialog.cpp +++ b/src/fixcalcdialog.cpp @@ -56,7 +56,7 @@ void FixCalcDialog::accept() } if( m_part && m_part->isDirty() ) { - emit fixCalcPartChanged(m_part); + Q_EMIT fixCalcPartChanged(m_part); } CalcDialogBase::accept(); diff --git a/src/flostempldialog.cpp b/src/flostempldialog.cpp index c2e99148..cb541056 100644 --- a/src/flostempldialog.cpp +++ b/src/flostempldialog.cpp @@ -154,7 +154,7 @@ void FlosTemplDialog::setTemplate( FloskelTemplate *t, const QString& katalognam QList chapters = m_katalog->getKatalogChapters( ); QStringList chapNames; - foreach( CatalogChapter chap, chapters ) { + for(const CatalogChapter& chap: chapters ) { chapNames.append( chap.name() ); } cbChapter->insertItems(-1, chapNames ); @@ -382,7 +382,7 @@ void FlosTemplDialog::accept() _calcPartsModified = false; if( m_template->save() ) { - emit( editAccepted( m_template ) ); + Q_EMIT( editAccepted( m_template ) ); KatalogMan::self()->notifyKatalogChange( m_katalog, m_template->getTemplID() ); } else { QMessageBox::warning(0, i18n("Template Error"), i18n("Saving of this template failed, sorry")); @@ -434,7 +434,7 @@ bool FlosTemplDialog::confirmClose() if ( m_templateIsNew ) { // remove the listview item if it was created newly - emit editRejected(); + Q_EMIT editRejected(); } return true; diff --git a/src/footertemplateprovider.cpp b/src/footertemplateprovider.cpp index 48b7a0bd..ee70f158 100644 --- a/src/footertemplateprovider.cpp +++ b/src/footertemplateprovider.cpp @@ -48,7 +48,7 @@ void FooterTemplateProvider::slotNewTemplate() dbID newId = DefaultProvider::self()->saveDocumentText( dt ); dt.setDbId( newId ); - emit newFooterText( dt ); + Q_EMIT newFooterText( dt ); } } @@ -76,24 +76,24 @@ void FooterTemplateProvider::slotEditTemplate() /* save to database */ DefaultProvider::self()->saveDocumentText( dt ); // this ends up in the footerselection, slot updateDocText - emit updateFooterText( dt ); + Q_EMIT updateFooterText( dt ); } } void FooterTemplateProvider::slotDeleteTemplate() { DocText dt = currentText(); - emit deleteFooterText( dt ); + Q_EMIT deleteFooterText( dt ); DefaultProvider::self()->deleteDocumentText( dt ); } void FooterTemplateProvider::slotTemplateToDocument() { // qDebug () << "Moving template to document"; - emit footerTextToDocument(currentText(), true); + Q_EMIT footerTextToDocument(currentText(), true); } void FooterTemplateProvider::slotInsertTemplateToDocument() { - emit footerTextToDocument(currentText(), false); + Q_EMIT footerTextToDocument(currentText(), false); } diff --git a/src/headertemplateprovider.cpp b/src/headertemplateprovider.cpp index d03bc060..017a3fd4 100644 --- a/src/headertemplateprovider.cpp +++ b/src/headertemplateprovider.cpp @@ -48,7 +48,7 @@ void HeaderTemplateProvider::slotNewTemplate() dbID newId = DefaultProvider::self()->saveDocumentText( dt ); dt.setDbId( newId ); - emit newHeaderText( dt ); + Q_EMIT newHeaderText( dt ); } } @@ -76,7 +76,7 @@ void HeaderTemplateProvider::slotEditTemplate() /* save to database */ DefaultProvider::self()->saveDocumentText( dt ); - emit updateHeaderText( dt ); + Q_EMIT updateHeaderText( dt ); } } @@ -84,17 +84,17 @@ void HeaderTemplateProvider::slotEditTemplate() void HeaderTemplateProvider::slotDeleteTemplate() { DefaultProvider::self()->deleteDocumentText( currentText() ); - emit deleteHeaderText( currentText() ); + Q_EMIT deleteHeaderText( currentText() ); } void HeaderTemplateProvider::slotTemplateToDocument() { // qDebug () << "Moving template to document"; - emit headerTextToDocument(currentText(), true); + Q_EMIT headerTextToDocument(currentText(), true); } void HeaderTemplateProvider::slotInsertTemplateToDocument() { - emit headerTextToDocument(currentText(), false); + Q_EMIT headerTextToDocument(currentText(), false); } diff --git a/src/importfilter.cpp b/src/importfilter.cpp index 053f20e5..d27368d9 100644 --- a/src/importfilter.cpp +++ b/src/importfilter.cpp @@ -17,7 +17,7 @@ // include files for QT #include -#include +#include #include #include #include @@ -60,7 +60,6 @@ bool ImportFilter::readDefinition( const QString& name ) } QTextStream t( &f ); - t.setCodec("UTF-8"); while ( !t.atEnd() ) { mDefinition << t.readLine(); @@ -201,9 +200,7 @@ DocPositionList DocPositionImportFilter::import( const QUrl &inFile ) } if ( ok ) { QTextStream t( &f ); - t.setCodec("UTF-8"); - int cnt = 0; while ( !t.atEnd() ) { cnt++; QString l = t.readLine().trimmed(); @@ -226,7 +223,7 @@ DocPositionList DocPositionImportFilter::import( const QUrl &inFile ) // creates a DocPosition from one line of the imported file DocPosition DocPositionImportFilter::importDocPosition( const QString& l, bool& ok ) { - QStringList parts = l.split( mSeparator, QString::KeepEmptyParts ); + QStringList parts = l.split( mSeparator, Qt::KeepEmptyParts ); // qDebug () << "Importing raw line " << l; QString h; @@ -269,11 +266,10 @@ DocPosition DocPositionImportFilter::importDocPosition( const QString& l, bool& } if ( !mTags.isEmpty() ) { - QStringList tags = mTags.split(QRegExp( "\\s*,\\s*" )); + QStringList tags = mTags.split(QRegularExpression( "\\s*,\\s*" )); - for ( QStringList::Iterator it = tags.begin(); it != tags.end(); ++it ) { - QString t = ( *it ).trimmed(); - pos.addTag( t ); + for (const QString& t : tags) { + pos.addTag(t); } } diff --git a/src/inserttempldialog.cpp b/src/inserttempldialog.cpp index 79c34146..cfecc32a 100644 --- a/src/inserttempldialog.cpp +++ b/src/inserttempldialog.cpp @@ -77,7 +77,7 @@ InsertTemplDialog::InsertTemplDialog( QWidget *parent ) groupLay->addStretch(); QVBoxLayout *lay = new QVBoxLayout(this); - lay->setMargin(0); + lay->setContentsMargins(0, 0, 0, 0); lay->addWidget(w); setLayout(lay); diff --git a/src/itemtagdialog.cpp b/src/itemtagdialog.cpp index cd486f44..d8d2dc39 100644 --- a/src/itemtagdialog.cpp +++ b/src/itemtagdialog.cpp @@ -129,7 +129,7 @@ void ItemTagDialog::setPositionTags( const QStringList& checkedTags ) { QStringList allTags = TagTemplateMan::self()->allTagTemplates(); - foreach( QString string, allTags ) { + for( const QString& string: allTags ) { TagTemplate templ = TagTemplateMan::self()->getTagTemplate( string ); QStringList contents; diff --git a/src/katalog.cpp b/src/katalog.cpp index 497801a6..22d0d772 100644 --- a/src/katalog.cpp +++ b/src/katalog.cpp @@ -129,7 +129,7 @@ QList Katalog::getKatalogChapters( bool freshup ) QString Katalog::chapterName(const dbID& id) { - foreach( CatalogChapter chapter, mChapters ) { + for(const CatalogChapter& chapter: mChapters) { if( chapter.id() == id ) { return chapter.name(); } @@ -139,7 +139,7 @@ QString Katalog::chapterName(const dbID& id) dbID Katalog::chapterID( const QString& name ) { - foreach( CatalogChapter chapter, mChapters ) { + for(const CatalogChapter& chapter: mChapters) { if( chapter.name() == name ) { return chapter.id(); } diff --git a/src/kataloglistview.cpp b/src/kataloglistview.cpp index a1e3d721..10bb1f91 100644 --- a/src/kataloglistview.cpp +++ b/src/kataloglistview.cpp @@ -567,7 +567,7 @@ void KatalogListView::updateSort(QTreeWidgetItem *chapter) int childrenCnt = chapter->childCount(); - emit sequenceUpdateMaximum(childrenCnt); + Q_EMIT sequenceUpdateMaximum(childrenCnt); QSqlQuery chapQuery; chapQuery.prepare("UPDATE CatalogChapters SET sortKey = :sk WHERE chapterID = :id"); @@ -577,7 +577,7 @@ void KatalogListView::updateSort(QTreeWidgetItem *chapter) for (int indx = 0; indx < childrenCnt; indx++) { QTreeWidgetItem *item = chapter->child(indx); - emit sequenceUpdateProgress(indx); + Q_EMIT sequenceUpdateProgress(indx); if (isChapter(item)) { CatalogChapter *chapter = static_cast(itemData(item)); @@ -591,7 +591,7 @@ void KatalogListView::updateSort(QTreeWidgetItem *chapter) } } endUpdateItemSequence(); - emit sequenceUpdateProgress(childrenCnt); + Q_EMIT sequenceUpdateProgress(childrenCnt); } void KatalogListView::slotItemEntered( QTreeWidgetItem *item, int ) @@ -605,7 +605,7 @@ void KatalogListView::slotItemEntered( QTreeWidgetItem *item, int ) } else { CatalogTemplate *tmpl = static_cast(itemData(item)); // qDebug () << "hoovering this template: " << tmpl; - emit templateHoovered( tmpl ); + Q_EMIT templateHoovered( tmpl ); } } diff --git a/src/katalogman.h b/src/katalogman.h index ba35b6c9..560409e5 100644 --- a/src/katalogman.h +++ b/src/katalogman.h @@ -24,13 +24,6 @@ #include "kataloglistview.h" #include "kraftcat_export.h" -// include files - -/** - * - */ -class QStringList; - class KRAFTCAT_EXPORT KatalogMan : public QObject { diff --git a/src/kraftdb.cpp b/src/kraftdb.cpp index 6c511ca7..6d1775d2 100644 --- a/src/kraftdb.cpp +++ b/src/kraftdb.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -465,7 +465,7 @@ int KraftDB::processSqlCommands( const SqlCommandList& commands ) foreach( SqlCommand cmd, commands ) { if( !cmd.message().isEmpty() ) { - emit statusMessage( cmd.message() ); + Q_EMIT statusMessage( cmd.message() ); } if( !cmd.command().isEmpty() ) { @@ -483,7 +483,7 @@ int KraftDB::processSqlCommands( const SqlCommandList& commands ) qDebug () << "###### Failed SQL Command " << cmd.command() << ": " << err.text(); } q.clear(); - emit processedSqlCommand( res ); + Q_EMIT processedSqlCommand( res ); } } diff --git a/src/kraftdoc.cpp b/src/kraftdoc.cpp index 58984f9f..069ba274 100644 --- a/src/kraftdoc.cpp +++ b/src/kraftdoc.cpp @@ -219,7 +219,7 @@ KraftDoc& KraftDoc::operator=( KraftDoc& origDoc ) _state.setState(KraftDocState::State::New); KraftObj::operator=(origDoc); - _uuid = QString(); // clear the Uuid + _uuid = QUuid(); // clear the Uuid mAddressUid = origDoc.mAddressUid; mProjectLabel = origDoc.mProjectLabel; @@ -307,7 +307,7 @@ bool KraftDoc::saveDocument(DocumentSaverBase& saver) _modified = false; } - emit saved(result); + Q_EMIT saved(result); // FIXME - add this check // if (res) { @@ -412,7 +412,7 @@ void KraftDoc::slotRemovePosition( int pos ) { // qDebug () << "Removing position " << pos; - foreach( DocPositionBase *dp, mPositions ) { + for( DocPositionBase *dp: mPositions ) { // qDebug () << "Comparing " << pos << " with " << dp->dbId().toString(); if( dp->dbId() == pos ) { if( ! mPositions.removeAll( dp ) ) { @@ -440,7 +440,7 @@ void KraftDoc::slotMoveUpPosition( int dbid ) // qDebug () << "Found: "<< curPos << ", count: " << mPositions.count(); if( curPos < mPositions.size()-1 ) { - mPositions.swap( curPos, curPos+1 ); + mPositions.swapItemsAt( curPos, curPos+1 ); } } @@ -459,7 +459,7 @@ void KraftDoc::slotMoveDownPosition( int dbid ) // qDebug () << "Found: "<< curPos << ", count: " << mPositions.count(); if( curPos > 0 ) { - mPositions.swap( curPos, curPos-1 ); + mPositions.swapItemsAt( curPos, curPos-1 ); } } @@ -569,7 +569,7 @@ QString KraftDoc::reducedTaxPercentStr() const QString KraftDoc::country() const { QLocale *loc = DefaultProvider::self()->locale(); - return loc->countryToString(loc->country()); + return loc->territoryToString(loc->territory()); } QString KraftDoc::language() const @@ -667,7 +667,6 @@ void KraftDoc::slotNewIdent(const QString& ident) delete generator; } - /** * @brief KraftDoc::resolveMacros * @param txtWithMacros - the string that might contain any macros @@ -688,58 +687,59 @@ void KraftDoc::slotNewIdent(const QString& ident) QString myStr{txtWithMacros}; QMap seenTags; - QRegExp rxIf("\\s{1}IF_ANY_HAS_TAG\\(\\s*(\\w+)\\s*\\)"); - QRegExp rxEndif("\\s{1}END_HAS_TAG"); - QRegExp rxAmount("ITEM_COUNT_WITH_TAG\\(\\s*(\\w+)\\s*\\)"); - QRegExp rxAddDate("DATE_ADD_DAYS\\(\\s*(\\-{0,1}\\d+)\\s*\\)"); + QRegularExpression rxIf("\\s{1}IF_ANY_HAS_TAG\\(\\s*(\\w+)\\s*\\)"); + QRegularExpression rxEndif("\\s{1}END_HAS_TAG"); + QRegularExpression rxAmount("ITEM_COUNT_WITH_TAG\\(\\s*(\\w+)\\s*\\)"); + QRegularExpression rxAddDate("DATE_ADD_DAYS\\(\\s*(\\-{0,1}\\d+)\\s*\\)"); // look for tag SUM_PER_TAG( HNDL ) - QRegExp rx("NETTO_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); - QRegExp rxBrutto("BRUTTO_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); - QRegExp rxVat("VAT_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); + QRegularExpression rx("NETTO_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); + QRegularExpression rxBrutto("BRUTTO_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); + QRegularExpression rxVat("VAT_SUM_PER_TAG\\(\\s*(\\w+)\\s*\\)"); int pos{0}; QMap bruttoSums; QMap vatSums; Geld nettoSum; + QRegularExpressionMatch match; + + while((pos = myStr.indexOf(rx, pos, &match)) > -1) { + const QString lookupTag = match.captured(1); + bruttoSums[lookupTag] = Geld(); + vatSums[lookupTag] = Geld(); + + for (DocPositionBase *pb : dposList) { + DocPosition *p = static_cast(pb); + if (!p->toDelete() && p->hasTag(lookupTag)) { + Geld netto = p->overallPrice(); + + Geld tax; + if (p->taxType() == DocPositionBase::TaxType::TaxFull) + tax = netto.percent(fullTax); + else if (p->taxType() == DocPositionBase::TaxType::TaxReduced) + tax = netto.percent(redTax); + + bruttoSums[lookupTag] += netto; + bruttoSums[lookupTag] += tax; + vatSums[lookupTag] += tax; + nettoSum += netto; + } + } - while ((pos = rx.indexIn(myStr, pos)) != -1) { - - const QString lookupTag = rx.cap(1); - bruttoSums[lookupTag] = Geld(); - vatSums[lookupTag] = Geld(); - - for (DocPositionBase *pb : dposList) { - DocPosition *p = static_cast(pb); - if (!p->toDelete() && p->hasTag(lookupTag)) { - Geld netto = p->overallPrice(); - - Geld tax; - if (p->taxType() == DocPositionBase::TaxType::TaxFull) - tax = netto.percent(fullTax); - else if (p->taxType() == DocPositionBase::TaxType::TaxReduced) - tax = netto.percent(redTax); - - bruttoSums[lookupTag] += netto; - bruttoSums[lookupTag] += tax; - vatSums[lookupTag] += tax; - nettoSum += netto; - } - } - - myStr.replace(pos, rx.matchedLength(), nettoSum.toLocaleString()); - } + myStr.replace(pos, match.captured().length(), nettoSum.toLocaleString()); + } - // replace the Brutto- and vat tags if exist + // replace the Brutto- and vat tags if exist pos = 0; - while ((pos = rxBrutto.indexIn(myStr, pos)) != -1) { - const QString lookupTag = rxBrutto.cap(1); + while ((pos = myStr.indexOf(rxBrutto, pos, &match)) > -1) { + const QString lookupTag = match.captured(1); if (bruttoSums.contains(lookupTag)) { - myStr.replace(pos, rxBrutto.matchedLength(), bruttoSums[lookupTag].toLocaleString()); + myStr.replace(pos, match.captured().length(), bruttoSums[lookupTag].toLocaleString()); } else { qDebug() << "No Brutto sums computed for" << lookupTag; } } +#if 0 // vat tags pos = 0; while ((pos = rxVat.indexIn(myStr, pos)) != -1) { @@ -799,6 +799,7 @@ void KraftDoc::slotNewIdent(const QString& ident) myStr.remove(pos, len); } } +#endif return myStr; } diff --git a/src/kraftdocedit.cpp b/src/kraftdocedit.cpp index 00c8b270..db061885 100644 --- a/src/kraftdocedit.cpp +++ b/src/kraftdocedit.cpp @@ -29,6 +29,6 @@ QColor KraftDocEdit::color() const void KraftDocEdit::slotModified() { - emit modified(); + Q_EMIT modified(); } diff --git a/src/kraftdocpositionsedit.cpp b/src/kraftdocpositionsedit.cpp index 88d77dfa..b6b2248d 100644 --- a/src/kraftdocpositionsedit.cpp +++ b/src/kraftdocpositionsedit.cpp @@ -83,7 +83,7 @@ KraftDocPositionsEdit::KraftDocPositionsEdit( QWidget *parent ) : KraftDocEdit( parent ) { QBoxLayout *topLayout = new QVBoxLayout(); - topLayout->setMargin( 0 ); + topLayout->setContentsMargins(0, 0, 0, 0); //TODO PORT QT5 topLayout->setSpacing( 0 ); // QDialog::spacingHint() ); QHBoxLayout *upperHBoxLayout = new QHBoxLayout; diff --git a/src/kraftview.cpp b/src/kraftview.cpp index 87d514e9..ea3d7e59 100644 --- a/src/kraftview.cpp +++ b/src/kraftview.cpp @@ -284,7 +284,7 @@ void KraftView::slotLinkClicked(const QString& link) } qDebug() << "Link clicked to open document " << uuid; if (!uuid.isEmpty()) { - emit openROView(uuid); + Q_EMIT openROView(uuid); } } } @@ -1374,7 +1374,7 @@ void KraftView::done( int r ) //Closed using the OK button .. it can be closed, but data needs saved if( doSave) saveChanges(); - emit viewClosed( r == 1, m_doc, mModified ); + Q_EMIT viewClosed( r == 1, m_doc, mModified ); } // remember the sizes of the docassistant splitter if visible. mAssistant->saveSplitterSizes(); diff --git a/src/kraftview_ro.cpp b/src/kraftview_ro.cpp index bcbc3250..59f1ce1e 100644 --- a/src/kraftview_ro.cpp +++ b/src/kraftview_ro.cpp @@ -132,7 +132,7 @@ void KraftViewRO::setup( DocGuardedPtr doc ) // check the tax settings: If all items have the same settings, its not individual. bool individualTax = false; int ttype = -1; - foreach( DocPositionBase *dp, positions ) { + for(DocPositionBase *dp: positions) { if( ttype == -1 ) { ttype = dp->taxType(); } else { @@ -151,7 +151,7 @@ void KraftViewRO::setup( DocGuardedPtr doc ) QString docType = doc->docType(); DocType dt(docType); - foreach( DocPositionBase *dpb, positions ) { + for(DocPositionBase *dpb: positions) { DocPosition *dp = static_cast(dpb); tmpl.createDictionary( "ITEMS" ); @@ -262,7 +262,7 @@ void KraftViewRO::done( int r ) return; } - emit viewClosed( true, m_doc, false); + Q_EMIT viewClosed( true, m_doc, false); KraftViewBase::done(r); } diff --git a/src/matcalcdialog.cpp b/src/matcalcdialog.cpp index 32879263..c253a54a 100644 --- a/src/matcalcdialog.cpp +++ b/src/matcalcdialog.cpp @@ -46,7 +46,7 @@ void MatCalcDialog::accept() { double val = _matWidget->m_inpMenge->value(); m_mc->setCalcAmount(val); - emit( matCalcPartChanged(m_mc)); + Q_EMIT( matCalcPartChanged(m_mc)); CalcDialogBase::accept(); } diff --git a/src/materialselectdialog.cpp b/src/materialselectdialog.cpp index 1861dbe1..273fdbb5 100644 --- a/src/materialselectdialog.cpp +++ b/src/materialselectdialog.cpp @@ -77,7 +77,7 @@ void MaterialSelectDialog::accept() if( !( mKatalogListView->isChapter( item ) || mKatalogListView->isRoot( item ))) { StockMaterial *mat = static_cast( mKatalogListView->itemData( item ) ); if ( mat ) { - emit materialSelected( mat->getID(), 1 ); + Q_EMIT materialSelected( mat->getID(), 1 ); } } ++it; diff --git a/src/materialtempldialog.cpp b/src/materialtempldialog.cpp index 6e590477..766bba83 100644 --- a/src/materialtempldialog.cpp +++ b/src/materialtempldialog.cpp @@ -154,7 +154,7 @@ void MaterialTemplDialog::setMaterial( StockMaterial *t, const QString& katalogn // chapter settings QStringList chapterNames; - foreach( CatalogChapter chap, m_katalog->getKatalogChapters() ) { + for( const CatalogChapter& chap: m_katalog->getKatalogChapters() ) { chapterNames.append( chap.name() ); } mCbChapter->insertItems(-1, chapterNames ); @@ -225,7 +225,7 @@ void MaterialTemplDialog::accept() mSaveMaterial->save(); - emit editAccepted( mSaveMaterial ); + Q_EMIT editAccepted( mSaveMaterial ); KatalogMan::self()->notifyKatalogChange( m_katalog, mSaveMaterial->getID() ); } @@ -236,7 +236,7 @@ void MaterialTemplDialog::reject() { if ( m_templateIsNew ) { // remove the listview item if it was created newly - emit editRejected(); + Q_EMIT editRejected(); } QDialog::reject(); } diff --git a/src/models/datemodel.cpp b/src/models/datemodel.cpp index 63bfd670..95690ab8 100644 --- a/src/models/datemodel.cpp +++ b/src/models/datemodel.cpp @@ -351,7 +351,7 @@ TreeItem *DateModel::findYearItem(int year) TreeItem *yearItem = NULL; QList yearitems = rootItem->children(); - foreach( TreeItem *item, yearitems ) { + for( TreeItem *item: yearitems ) { AbstractIndx *indx = item->payload(); if( indx->year() == year ) { yearItem = item; @@ -368,7 +368,7 @@ TreeItem *DateModel::findMonthItem(int year, int month) if( yearItem ) { QList monthItems = yearItem->children(); - foreach( TreeItem *item, monthItems ) { + for( TreeItem *item: monthItems ) { AbstractIndx *indx = static_cast(item->payload()); if( indx->month() == month ) { monthItem = item; @@ -514,7 +514,7 @@ void DateModel::updateData(const DocDigest& digest) QModelIndex monthIdx = index(month, 0, yearIdx); QModelIndex rIdx = index(r, 0, monthIdx); - emit dataChanged(rIdx, rIdx); + Q_EMIT dataChanged(rIdx, rIdx); } } diff --git a/src/models/documentmodel.cpp b/src/models/documentmodel.cpp index ef15e0f5..909d625a 100644 --- a/src/models/documentmodel.cpp +++ b/src/models/documentmodel.cpp @@ -80,7 +80,7 @@ void DocumentModel::updateData(const DocDigest& digest) _digests[r] = digest; QModelIndex indx1 = index(r, 0, QModelIndex()); QModelIndex indx2 = index(r+1, 0, QModelIndex()); - emit dataChanged(indx1, indx2); + Q_EMIT dataChanged(indx1, indx2); } // for (const DocDigest& d) diff --git a/src/models/documentproxymodels.cpp b/src/models/documentproxymodels.cpp index 0970e962..0d62e760 100644 --- a/src/models/documentproxymodels.cpp +++ b/src/models/documentproxymodels.cpp @@ -83,7 +83,7 @@ bool DocumentFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou bool accepted = false; // filter works on the document ID, the client name and the document type. - const QRegExp filter = filterRegExp(); + const QRegularExpression filter = filterRegularExpression(); if( filter.pattern().isEmpty() ) { accepted = true; } else { diff --git a/src/myidentity.cpp b/src/myidentity.cpp index ea83b265..66bf06a5 100644 --- a/src/myidentity.cpp +++ b/src/myidentity.cpp @@ -129,7 +129,7 @@ void MyIdentity::load() void MyIdentity::slotAddresseeFound(const QString& uid, const KContacts::Addressee& contact) { _myContact = contact; - emit myIdentityLoaded(uid, contact); + Q_EMIT myIdentityLoaded(uid, contact); } KContacts::Addressee MyIdentity::contact() const @@ -166,7 +166,7 @@ void MyIdentity::save(const QString& uuid, const KContacts::Addressee& contact) QFile::remove(file); // remove a maybe existing file } - // emit the signal for consumers of the address + // Q_EMIT the signal for consumers of the address slotAddresseeFound(uuid, contact); // update the settings - clear the user name as it is deprecated anyway diff --git a/src/numbercycle.cpp b/src/numbercycle.cpp index 999a4e83..6a6d4653 100644 --- a/src/numbercycle.cpp +++ b/src/numbercycle.cpp @@ -309,11 +309,11 @@ QMap NumberCycles::load() } QDomDocument domDoc; - const QByteArray arr = file.readAll(); - QString errMsg; - if (!domDoc.setContent(arr, &errMsg)) { - qDebug() << "Unable to set file content as xml:" << errMsg; + QDomDocument::ParseResult pr = domDoc.setContent(arr); + + if (!pr) { + qDebug() << "Unable to set file content as xml:" << pr.errorMessage << "at line" <locatePythonTool("erml2pdf.py"); if ( ! rmlbin.size() ) { - emit converterError(ConvError::TrmlToolFail); + Q_EMIT converterError(ConvError::TrmlToolFail); } QApplication::setOverrideCursor( QCursor( Qt::BusyCursor ) ); @@ -90,7 +90,7 @@ void ReportLabPDFConverter::convert(const QString& sourceFile, const QString &ou mProcess->start( ); if (!mProcess->waitForStarted(1000)) { - emit converterError(ConvError::TrmlToolFail); + Q_EMIT converterError(ConvError::TrmlToolFail); } } } @@ -116,22 +116,22 @@ void ReportLabPDFConverter::trml2pdfFinished( int exitCode, QProcess::ExitStatus if ( exitCode == 0 ) { QFileInfo fi(mFile.fileName()); if( fi.exists() ) { - emit docAvailable( mFile.fileName() ); + Q_EMIT docAvailable( mFile.fileName() ); if( mProcess) { const QString rmlFile = mProcess->arguments().last(); // the file name of the temp rmlfile QFile::remove(rmlFile); // remove the rmlFile } } else { - emit converterError(ConvError::TargetFileMissing); + Q_EMIT converterError(ConvError::TargetFileMissing); } } else { if( mErrors.contains(QLatin1String("No module named 'reportlab"))) { - emit converterError(ConvError::NoReportLabMod); + Q_EMIT converterError(ConvError::NoReportLabMod); } else if (mErrors.contains("No module named 'PyPDF2")){ - emit converterError(ConvError::NoPyPDFMod); + Q_EMIT converterError(ConvError::NoPyPDFMod); } else { qDebug() << "Trml2Pdf Error:" << mErrors; - emit converterError(ConvError::UnknownError); + Q_EMIT converterError(ConvError::UnknownError); } } mProcess->deleteLater(); @@ -161,7 +161,7 @@ void WeasyPrintPDFConverter::convert(const QString& sourceFile, const QString& o QFileInfo prgInfo(prg); if ( ! prgInfo.exists() || ! prgInfo.isExecutable() ) { - emit converterError(ConvError::WeasyPrintNotFound); + Q_EMIT converterError(ConvError::WeasyPrintNotFound); return; } @@ -216,17 +216,17 @@ void WeasyPrintPDFConverter::weasyPrintFinished( int exitCode, QProcess::ExitSta if ( exitCode == 0 ) { QFileInfo fi(mFile.fileName()); if( fi.exists() ) { - emit docAvailable( mFile.fileName() ); + Q_EMIT docAvailable( mFile.fileName() ); if(mProcess) { const QString htmlFile = mProcess->arguments().first(); // the file name of the temp rmlfile QFile::remove(htmlFile); // remove the rmlFile } } else { - emit converterError(ConvError::TargetFileMissing); + Q_EMIT converterError(ConvError::TargetFileMissing); } } else { qDebug() << "Weasyprint failed: " << mProcess->arguments(); - emit converterError(ConvError::UnknownError); + Q_EMIT converterError(ConvError::UnknownError); } mProcess->deleteLater(); mProcess = nullptr; diff --git a/src/portalhtmlview.cpp b/src/portalhtmlview.cpp index 71c2cd1a..1a09a274 100644 --- a/src/portalhtmlview.cpp +++ b/src/portalhtmlview.cpp @@ -31,7 +31,7 @@ void PortalHtmlView::slotLinkClicked(const QUrl& url) const QString action = q.queryItemValue(QLatin1String("action")); if ( action == QLatin1String("open") ) { // qDebug () << "open catalog " << katName; - emit( openCatalog( katName ) ); + Q_EMIT openCatalog( katName ); } else { if( url.isValid() ) { QDesktopServices::openUrl(url); diff --git a/src/positionviewwidget.cpp b/src/positionviewwidget.cpp index f008314f..870bb79b 100644 --- a/src/positionviewwidget.cpp +++ b/src/positionviewwidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -136,17 +137,17 @@ PositionViewWidget::PositionViewWidget() connect(this, &PositionViewWidget::positionStateNormal, this, [this]() { slotSetPositionKind(Normal, true); slotRefreshPrice(); - emit positionModified(); + Q_EMIT positionModified(); } ); connect(this, &PositionViewWidget::positionStateAlternative, this, [this]() { slotSetPositionKind(Alternative, true); slotRefreshPrice(); - emit positionModified(); + Q_EMIT positionModified(); } ); connect(this, &PositionViewWidget::positionStateDemand, this, [this]() { slotSetPositionKind(Demand, true); slotRefreshPrice(); - emit positionModified(); + Q_EMIT positionModified(); } ); connect(this, &PositionViewWidget::lockPosition, this, &PositionViewWidget::slotLockPosition); @@ -335,7 +336,7 @@ void PositionViewWidget::slotSetTax( DocPosition::TaxType tt ) } mTaxSubmenu->setIcon( DefaultProvider::self()->icon( icon )); - emit positionModified(); + Q_EMIT positionModified(); } void PositionViewWidget::slotAllowIndividualTax( bool allow ) @@ -516,7 +517,7 @@ void PositionViewWidget::slotRefreshPrice() { const Geld sum = currentPrice(); slotSetOverallPrice( sum ); - emit priceChanged( sum ); + Q_EMIT priceChanged( sum ); } void PositionViewWidget::slotSetOverallPrice( Geld g ) @@ -537,7 +538,7 @@ void PositionViewWidget::slotModified() m_labelPosition->setStyleSheet("font-weight: bold; color: red"); - emit positionModified(); + Q_EMIT positionModified(); } PositionViewWidget::~PositionViewWidget() diff --git a/src/prefsdialog.cpp b/src/prefsdialog.cpp index f6b348bf..6630d72f 100644 --- a/src/prefsdialog.cpp +++ b/src/prefsdialog.cpp @@ -346,10 +346,11 @@ QWidget* PrefsDialog::docTab() const QDate d = QDate::currentDate(); mCbDateFormats->setToolTip( i18n( "The default date format for documents." ) ); QString formattedDate = d.toString(Qt::ISODate); + QLocale locale; mCbDateFormats->insertItem( 0, i18n("ISO-Format: %1", formattedDate)); - formattedDate = d.toString(Qt::DefaultLocaleShortDate); + formattedDate = d.toString(locale.dateFormat(QLocale::ShortFormat)); mCbDateFormats->insertItem( 1, i18n("Short-Date: %1", formattedDate)); - formattedDate = d.toString(Qt::DefaultLocaleLongDate); + formattedDate = d.toString(locale.dateFormat(QLocale::LongFormat)); mCbDateFormats->insertItem( 2, i18n("Long-Date: %1", formattedDate)); formattedDate = d.toString(Qt::RFC2822Date); mCbDateFormats->insertItem( 3, i18n("RFC 2822-Format: %1", formattedDate)); diff --git a/src/reportgenerator.cpp b/src/reportgenerator.cpp index 577bdddc..d4949c81 100644 --- a/src/reportgenerator.cpp +++ b/src/reportgenerator.cpp @@ -19,11 +19,10 @@ #include #include #include -#include +#include #include #include #include -#include #include #include #include @@ -53,13 +52,6 @@ QString saveToTempFile( const QString& doc ) if ( temp.open() ) { QTextStream s(&temp); - - // The following explicit coding settings were needed for Qt 4.7.3, former Qt versions - // seemed to default on UTF-8. Try to comment the following two lines for older Qt versions - // if needed and see if the trml file on the disk still is UTF-8 encoded. - QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - s.setCodec( codec ); - s << doc; temp.close(); } else { @@ -111,7 +103,7 @@ void ReportGenerator::createDocument( ReportFormat format, const QString& uuid) if( mProcess && mProcess->state() != QProcess::NotRunning ) { qDebug() << "===> WRN: Process still running, try again later."; - emit failure(uuid, i18n("Document generation process is still running."), ""); + Q_EMIT failure(uuid, i18n("Document generation process is still running."), ""); _uuid.clear(); return; } @@ -164,7 +156,7 @@ void ReportGenerator::slotAddresseeFound( const QString&, const KContacts::Addre QFileInfo fi(_tmplFile); if (!fi.exists()) { - emit failure(_uuid, i18n("Template file is not accessible."), ""); + Q_EMIT failure(_uuid, i18n("Template file is not accessible."), ""); _uuid.clear(); return; } @@ -191,7 +183,7 @@ void ReportGenerator::slotAddresseeFound( const QString&, const KContacts::Addre _cleanupFiles = templateEngine->tempFilesCreated(); if (expanded.isEmpty()) { - emit failure(_uuid, i18n("The template conversion failed."), templateEngine->error()); + Q_EMIT failure(_uuid, i18n("The template conversion failed."), templateEngine->error()); delete converter; _uuid.clear(); return; @@ -200,7 +192,7 @@ void ReportGenerator::slotAddresseeFound( const QString&, const KContacts::Addre const QString tempFile = saveToTempFile(expanded); if (tempFile.isEmpty()) { - emit failure(_uuid, i18n("Saving to temporar file failed."), ""); + Q_EMIT failure(_uuid, i18n("Saving to temporar file failed."), ""); delete converter; _uuid.clear(); return; @@ -331,7 +323,7 @@ void ReportGenerator::pdfMergeFinished(int exitCode, QProcess::ExitStatus exitSt } mProcess->deleteLater(); mProcess = nullptr; - emit docAvailable(_requestedFormat, _uuid, mCustomerContact); + Q_EMIT docAvailable(_requestedFormat, _uuid, mCustomerContact); } else { slotConverterError(PDFConverter::ConvError::PDFMergerError); } @@ -382,7 +374,7 @@ void ReportGenerator::slotConverterError(PDFConverter::ConvError err) errMsg = i18n("The PDF merger utility failed."); break; } - emit failure(_uuid, errMsg, errors); + Q_EMIT failure(_uuid, errMsg, errors); _uuid.clear(); converter->deleteLater(); } @@ -401,16 +393,16 @@ QString ReportGenerator::findTemplateFile( const QString& type ) const QString tmplFile = dType.templateFile(); if ( tmplFile.isEmpty() ) { - emit failure(_uuid, i18n("There is not template defined for %1.").arg(dType.name()), ""); + Q_EMIT failure(_uuid, i18n("There is not template defined for %1.").arg(dType.name()), ""); } else { // a few file checks QFileInfo fi(tmplFile); if (!fi.isFile()) { - emit failure(_uuid, i18n("The template file %1 for document type %2 does not exist.").arg(tmplFile).arg(dType.name()), ""); + Q_EMIT failure(_uuid, i18n("The template file %1 for document type %2 does not exist.").arg(tmplFile).arg(dType.name()), ""); return QString(); } if (!fi.isReadable()) { - emit failure(_uuid, i18n("The template file %1 for document type %2 can not be read.").arg(tmplFile).arg(dType.name()), ""); + Q_EMIT failure(_uuid, i18n("The template file %1 for document type %2 can not be read.").arg(tmplFile).arg(dType.name()), ""); return QString(); } } diff --git a/src/setupassistant.cpp b/src/setupassistant.cpp index e7025291..3cd9c7e6 100644 --- a/src/setupassistant.cpp +++ b/src/setupassistant.cpp @@ -560,7 +560,7 @@ void SetupAssistant::finalizePage() txt += ""; txt += i18n("

If you press Finish now, the new database configuration is stored in Krafts configuration.

"); } else { - foreach( QString err, mErrors ) { + for(const QString& err: mErrors ) { txt += "

" + err + "

"; } } @@ -616,7 +616,6 @@ void SetupAssistant::startDatabaseUpdate() connect( KraftDB::self(), SIGNAL( processedSqlCommand( bool ) ), mUpgradeDbPage, SLOT( slotCountFillProgress( bool ) ) ); - int doneOverallCmds = 0; bool errors = false; currentVer = KraftDB::self()->currentSchemaVersion(); diff --git a/src/tagman.cpp b/src/tagman.cpp index 8e59538f..f3a86d87 100644 --- a/src/tagman.cpp +++ b/src/tagman.cpp @@ -44,8 +44,8 @@ TagTemplate::TagTemplate( const dbID& id, const QString& name, const QString& de QPalette TagTemplate::palette() const { QPalette palette; - palette.setColor( QPalette::Light, mColor.light() ); - palette.setColor( QPalette::Dark, mColor.dark() ); + palette.setColor( QPalette::Light, mColor.lighter() ); + palette.setColor( QPalette::Dark, mColor.darker() ); palette.setColor( QPalette::Mid, mColor ); return palette; } diff --git a/src/tagtemplatesdialog.cpp b/src/tagtemplatesdialog.cpp index e0db5583..dc6adc44 100644 --- a/src/tagtemplatesdialog.cpp +++ b/src/tagtemplatesdialog.cpp @@ -36,7 +36,6 @@ #include #include "tagtemplatesdialog.h" -#include "defaultprovider.h" #include "tagman.h" TagTemplateEditor::TagTemplateEditor( QWidget *parent ) @@ -258,7 +257,7 @@ void TagTemplatesDialog::setTags() mListView->clear(); QStringList tags = TagTemplateMan::self()->allTagTemplates(); - foreach( const QString t, tags ) { + for( const QString& t: tags ) { TagTemplate templ = TagTemplateMan::self()->getTagTemplate( t ); // TagItem *item = new QListViewItem( mListView, templ.name(), QCheckListItem::CheckBox ); diff --git a/src/templkatalog.cpp b/src/templkatalog.cpp index 8e0ed799..85c001f3 100644 --- a/src/templkatalog.cpp +++ b/src/templkatalog.cpp @@ -391,8 +391,8 @@ QDomDocument TemplKatalog::toXML() } QList chaps = getKatalogChapters(); - foreach( CatalogChapter theChapter, chaps ) { - QString chapter = theChapter.name(); + for(const CatalogChapter& theChapter: chaps ) { + const QString chapter = theChapter.name(); QDomElement chapElem = doc.createElement("chapter"); QDomElement chapName = doc.createElement("chaptername"); text = doc.createTextNode(chapter); diff --git a/src/templkataloglistview.cpp b/src/templkataloglistview.cpp index d4b24397..7f67e432 100644 --- a/src/templkataloglistview.cpp +++ b/src/templkataloglistview.cpp @@ -73,7 +73,7 @@ void TemplKatalogListView::addCatalogDisplay( const QString& katName ) setupChapters(); const QList chapters = catalog->getKatalogChapters(); - foreach( CatalogChapter chap, chapters ) { + for( const CatalogChapter& chap: chapters ) { if( mChapterDict.contains( chap.id().toInt() ) ) { int chapId = chap.id().toInt(); QTreeWidgetItem *katItem = mChapterDict[chapId]; diff --git a/src/textselection.cpp b/src/textselection.cpp index 8061ca4c..a6745d02 100644 --- a/src/textselection.cpp +++ b/src/textselection.cpp @@ -120,7 +120,7 @@ void TextSelection::slotTemplateNameSelected( const QModelIndex& current, const } else { mCurrTemplateName.clear(); } - emit validTemplateSelected( ); + Q_EMIT validTemplateSelected( ); } void TextSelection::showDocText( DocText dt ) @@ -146,7 +146,7 @@ void TextSelection::slotSelectDocType( const QString& doctype ) showHelp( i18n("There is no %1 template text available for document type %2.
" "Click the add-button below to create one.", partStr, doctype ) ); } else { - foreach( DocText dt, dtList ) { + for( const DocText& dt: dtList ) { templNames << dt.name(); } showHelp(); @@ -168,7 +168,7 @@ void TextSelection::addNewDocText( const DocText& dt ) } else { // qDebug () << "Unable to find the new item named " << dt.name(); } - emit validTemplateSelected(); + Q_EMIT validTemplateSelected(); } /* requires the QListViewItem set as a member in the doctext */ @@ -230,7 +230,7 @@ void TextSelection::showHelp( const QString& help ) DocText TextSelection::currentDocText() const { DocTextList dtList = DefaultProvider::self()->documentTexts( mDocType, mPart ); - foreach( DocText dt, dtList ) { + for( const DocText& dt: dtList ) { if( dt.name() == mCurrTemplateName ) { return dt; } diff --git a/src/timecalcdialog.cpp b/src/timecalcdialog.cpp index 799c5968..d8657b38 100644 --- a/src/timecalcdialog.cpp +++ b/src/timecalcdialog.cpp @@ -16,6 +16,7 @@ ***************************************************************************/ // include files for Qt +#include #include #include #include @@ -63,7 +64,7 @@ void TimeCalcDialog::accept() } if( _part && _part->isDirty() ) { - emit timeCalcPartChanged(_part); + Q_EMIT timeCalcPartChanged(_part); } CalcDialogBase::accept(); diff --git a/src/unitmanager.cpp b/src/unitmanager.cpp index 09bd65c2..5f3446b0 100644 --- a/src/unitmanager.cpp +++ b/src/unitmanager.cpp @@ -112,7 +112,7 @@ int UnitManager::nextFreeId() if( mUnits.size() == 0 ) { load(); } - foreach( Einheit u, mUnits ) { + for( Einheit u: mUnits ) { if( u.id() > id ) { id = u.id(); } @@ -125,7 +125,7 @@ QStringList UnitManager::allUnits() QStringList list; if(mUnits.size() == 0 ) load(); - foreach( Einheit e, mUnits ) { + for( Einheit e: mUnits ) { QString uSing = e.einheitSingular(); if( !uSing.isEmpty()) list << uSing; @@ -168,7 +168,7 @@ int UnitManager::getUnitIDSingular( const QString& einheitStr ) { if( mUnits.size() == 0 ) load(); - foreach( Einheit tmp, mUnits ) { + for( Einheit tmp: mUnits ) { if( tmp.einheitSingular() == einheitStr || tmp.einheitPlural() == einheitStr ) {