Skip to content

Commit

Permalink
Make kraft compile against Qt6 - all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dragotin committed Nov 5, 2024
1 parent 66461d0 commit 03f18c3
Show file tree
Hide file tree
Showing 33 changed files with 267 additions and 277 deletions.
4 changes: 2 additions & 2 deletions src/addressselectorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool AddressSortProxyModel::filterAcceptsRow(int row, const QModelIndex &parent)
if( contact.isEmpty() ) {
return true;
} else {
const QString p = filterRegExp().pattern();
const QString p = filterRegularExpression().pattern();
return contactMatchesFilter(contact, p );
}

Expand Down Expand Up @@ -232,7 +232,7 @@ KraftContactViewer::KraftContactViewer(QWidget *parent)
#endif
{
QVBoxLayout *lay = new QVBoxLayout;
lay->setMargin(0);
lay->setContentsMargins(0,0,0,0);
setLayout(lay);
#ifdef HAVE_AKONADI
#if AKONADICONTACT_VERSION >= QT_VERSION_CHECK(5, 24, 0)
Expand Down
4 changes: 2 additions & 2 deletions src/alldocsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ AllDocsView::AllDocsView( QWidget *parent )
QVBoxLayout *box = new QVBoxLayout;
setLayout( box );

box->setMargin( 0 );
box->setContentsMargins(0,0,0,0);
box->setSpacing( 0 );

_searchLine = new QLineEdit(this);
Expand Down Expand Up @@ -140,7 +140,7 @@ QWidget* AllDocsView::initializeTreeWidget()

//Add treewidgets to the toolbox: All docs view
QVBoxLayout *vb1 = new QVBoxLayout;
vb1->setMargin(0);
vb1->setContentsMargins(0,0,0,0);
_stack = new QStackedWidget(this);
_stack->addWidget(_tableView);
_stack->addWidget(_dateView);
Expand Down
2 changes: 1 addition & 1 deletion src/defaultprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ QString DefaultProvider::createV2BaseDir(const QString& base)
}

if (v2base.isEmpty()) {
v2base = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
v2base = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
v2base.append("/v2");

currV2Dir.setPath(v2base);
Expand Down
5 changes: 2 additions & 3 deletions src/docassistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "headertemplateprovider.h"
#include "footertemplateprovider.h"
#include "catalogtemplateprovider.h"
#include "addresstemplateprovider.h"

DocAssistant::DocAssistant( QWidget *parent ):
QSplitter( parent ), mFullPreview( true ),
Expand All @@ -43,7 +42,7 @@ DocAssistant::DocAssistant( QWidget *parent ):

QWidget *topWidget = new QWidget;
QVBoxLayout *topVBox = new QVBoxLayout;
topVBox->setMargin(0);
topVBox->setContentsMargins(0,0,0,0);
topWidget->setLayout( topVBox );

QHBoxLayout *buttonLayout = new QHBoxLayout;
Expand All @@ -68,7 +67,7 @@ DocAssistant::DocAssistant( QWidget *parent ):

mTemplatePane = new QWidget;
QVBoxLayout *bottomVBox = new QVBoxLayout;
bottomVBox->setMargin(0);
bottomVBox->setContentsMargins(0,0,0,0);

mTemplatePane->setLayout( bottomVBox );
addWidget( mTemplatePane );
Expand Down
2 changes: 1 addition & 1 deletion src/docdigestdetailview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ DocDigestDetailView::DocDigestDetailView(QWidget *parent) :
_leftDetails->setWordWrap(true);

// --- The middle HTML based view
hbox->setMargin(0);
hbox->setContentsMargins(0,0,0,0);
setLayout( hbox );
mHtmlCanvas = new DocDigestHtmlView( this );
mHtmlCanvas->setFrameStyle(0);
Expand Down
2 changes: 1 addition & 1 deletion src/flostempldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ void FlosTemplDialog::slSetNewText()
longest = p;
}
QFontMetrics fm(m_textDispFix->font());
int w = 10+fm.width(longest);
int w = 10+fm.boundingRect(longest).width();

if( m_textDispTime) {
m_textDispTime->setText(t);
Expand Down
7 changes: 5 additions & 2 deletions src/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ QString localeDoubleToString(double val, const QLocale& loc)

QString toDateString( const QDate& date, const QString& format )
{
QLocale locale;
if (format == Format::DateFormatIso) {
return date.toString(Qt::ISODate);
}
if (format == DateFormatShort || format.isEmpty()) {
return date.toString(Qt::DefaultLocaleShortDate);
const QString shortDateFormat = locale.dateFormat(QLocale::ShortFormat);
return date.toString(shortDateFormat);
}
if (format == DateFormatLong) {
return date.toString(Qt::DefaultLocaleLongDate);
const QString longDateFormat = locale.dateFormat(QLocale::LongFormat);
return date.toString(longDateFormat);
}
if (format == DateFormatRFC) {
return date.toString(Qt::RFC2822Date);
Expand Down
23 changes: 11 additions & 12 deletions src/grantleetemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#include <QDebug>

#include <QFileInfo>
#include <string.h>

#include <grantlee/engine.h>
#include <grantlee/context.h>
#include <grantlee/template.h>
#include <grantlee/templateloader.h>
#include <KTextTemplate/Engine>
#include <KTextTemplate/Context>
#include <KTextTemplate/Template>
#include <KTextTemplate/TemplateLoader>

// make this class a QObject to parent the created QObjects in addToMappingHash()
// to it. That way, the allocated objects are automatically freed by the Qt mechanism
Expand Down Expand Up @@ -69,25 +68,25 @@ void GrantleeFileTemplate::addToObjMapping(const QString& key, QObject *obj)

QString GrantleeFileTemplate::render(bool &ok) const
{
QScopedPointer<Grantlee::Engine> engine(new Grantlee::Engine());
QScopedPointer<KTextTemplate::Engine> engine(new KTextTemplate::Engine());

QFileInfo fi(_tmplFileName);
ok = true; // assume all goes well.

auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>::create();
auto loader = QSharedPointer<KTextTemplate::FileSystemTemplateLoader>::create();
loader->setTemplateDirs( {fi.absolutePath()} );
engine->addTemplateLoader( loader );

QString output;
auto t = engine->loadByName(fi.fileName());
if (t->error() != Grantlee::Error::NoError) {
if (t->error() != KTextTemplate::Error::NoError) {
ok = false;
output = t->errorString();
qDebug() << "Grantlee template load failed:" << output;
qDebug() << "TextTemplate template load failed:" << output;
}

if (ok) {
Grantlee::Context c;
KTextTemplate::Context c;

QHash<QString, QObject*>::const_iterator i = _objs.constBegin();
while (i != _objs.constEnd()) {
Expand All @@ -98,11 +97,11 @@ QString GrantleeFileTemplate::render(bool &ok) const
}

output = t->render(&c);
if (t->error() != Grantlee::Error::NoError) {
if (t->error() != KTextTemplate::Error::NoError) {
ok = false;
// Rendering error.
output = t->errorString();
qDebug() << "Grantlee template err:" << output;
qDebug() << "TextTemplate template err:" << output;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/grantleetemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#ifndef GRANTLEETEMPLATE_H
#define GRANTLEETEMPLATE_H

#include <qobject.h>
#include <qmap.h>
#include <qstring.h>
#include <QObject>
#include <QHash>
#include <QString>

class GrantleeFileTemplate : public QObject
{
Expand Down
Loading

0 comments on commit 03f18c3

Please sign in to comment.