Skip to content

Commit

Permalink
WIP 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dragotin committed Nov 1, 2024
1 parent 2ffcd73 commit 66461d0
Show file tree
Hide file tree
Showing 54 changed files with 228 additions and 213 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}/)
Expand Down
8 changes: 2 additions & 6 deletions src/addressprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
Expand Down
9 changes: 5 additions & 4 deletions src/addressprovider_akonadi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Akonadi::ContactSearchJob*>( job );
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions src/addressselectorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/addresstemplateprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions src/alldocsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QAction *, 4> actions)
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/catalogselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: " ) );
Expand Down Expand Up @@ -76,7 +76,7 @@ void CatalogSelection::setupCatalogList()

void CatalogSelection::slotCatalogDoubleClicked( QModelIndex )
{
emit actionAppendPosition();
Q_EMIT actionAppendPosition();
}

CatalogTemplateList CatalogSelection::currentSelectedPositions()
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/catalogtemplateprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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());
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/dbtoxmlconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ QMap<QByteArray, int> 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<QByteArray, int> 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];
Expand All @@ -79,22 +79,22 @@ QMap<QByteArray, int> DbToXMLConverter::convert(const QString& dBase)
// FIXME Check for errors and set ok flag
}

emit conversionOut(i18n("<br/><b>Overall document conversion result:</b>"));
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("<br/><b>Overall document conversion result:</b>"));
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("<br/>Transformed %1 numbercycle(s) successfully.").arg(nc_cnt));
Q_EMIT conversionOut(i18n("<br/>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("<br/>Converted manual created identity successfully"));
Q_EMIT conversionOut(i18n("<br/>Converted manual created identity successfully"));
}

if (nc_cnt == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/docassistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/docidentgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/docpostcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/doctypeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -482,7 +482,7 @@ void DocTypeEdit::saveDocTypes()
removeTypeFromDb( *it );
mOrigDocTypes.remove( *it );
mChangedDocTypes.remove( *it );
emit removedType( *it );
Q_EMIT removedType( *it );
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/documentman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 42 additions & 7 deletions src/documentsaverxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include <QDebug>
#include <QSqlQuery>
#include <QDir>
#include <QXmlSchemaValidator>
#include <QXmlSchema>
#include <QDomDocument>
#include <QFileDevice>
#include <QSaveFile>
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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 <xercesc/parsers/DOMParser.hpp>
#include <xercesc/util/XMLString.hpp>

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)) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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"<<pe.errorLine;
file.close();
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/exportxrechnung.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void ExporterXRechnung::slotAddresseeFound(const QString& uid, const KContacts::
const QString expanded = templateEngine->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;
}
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 66461d0

Please sign in to comment.