Commit de7f3d06 authored by Laurent Montel's avatar Laurent Montel 😁

Fix coding style

parent f1d61fb4
......@@ -157,4 +157,3 @@ void ContactPrintThemeConfigureDialog::writeConfig()
group.writeEntry("defaultTemplate", mDefaultTemplate->toPlainText());
mConfigureWidget->writeConfig();
}
......@@ -22,18 +22,15 @@
#include <QDialog>
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class ConfigureWidget;
}
namespace Akonadi
{
namespace Akonadi {
class ContactEditor;
}
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class PlainTextEditorWidget;
}
class ContactPrintThemeConfigureDialog : public QDialog
......
......@@ -21,7 +21,6 @@
ContactPrintThemeEditorutil::ContactPrintThemeEditorutil()
{
}
QString ContactPrintThemeEditorutil::defaultContact() const
......@@ -43,16 +42,16 @@ QString ContactPrintThemeEditorutil::defaultContact() const
QString ContactPrintThemeEditorutil::defaultTemplate() const
{
const QString templateStr = QStringLiteral("<html>\n"
"{% if contacts %}\n"
"{% for contact in contacts %}\n"
"<h1>{{ contact.realName|safe }}</h1>\n"
"<p>{{ contact.emails|safe }}</p>\n"
"<p>{{ contact.note|safe }}</p>\n"
"<br>\n"
"<br>\n"
"{% endfor %}\n"
"{% endif %}\n"
"</html>");
"{% if contacts %}\n"
"{% for contact in contacts %}\n"
"<h1>{{ contact.realName|safe }}</h1>\n"
"<p>{{ contact.emails|safe }}</p>\n"
"<p>{{ contact.note|safe }}</p>\n"
"<br>\n"
"<br>\n"
"{% endfor %}\n"
"{% endif %}\n"
"</html>");
return templateStr;
}
......@@ -44,7 +44,6 @@ ContactPrintThemePreview::ContactPrintThemePreview(const QString &projectDirecto
ContactPrintThemePreview::~ContactPrintThemePreview()
{
}
void ContactPrintThemePreview::updateViewer()
......@@ -91,4 +90,3 @@ void ContactPrintThemePreview::loadConfig()
}
}
}
......@@ -24,8 +24,7 @@
#include <KContacts/Addressee>
#include "grantleethemeeditor/previewwidget.h"
namespace KAddressBookGrantlee
{
namespace KAddressBookGrantlee {
class GrantleePrint;
}
class QWebEngineView;
......
......@@ -22,8 +22,7 @@
#include <QStringList>
namespace DefaultCompletion
{
namespace DefaultCompletion {
QStringList defaultCompetion();
QStringList defaultOptions();
}
......
......@@ -36,9 +36,9 @@
#include <KSharedConfig>
EditorPage::EditorPage(GrantleeThemeEditor::EditorPage::PageType type, const QString &projectDirectory, QWidget *parent)
: GrantleeThemeEditor::EditorPage(type, parent),
mPreview(nullptr),
mWidgetSplitter(nullptr)
: GrantleeThemeEditor::EditorPage(type, parent)
, mPreview(nullptr)
, mWidgetSplitter(nullptr)
{
QVBoxLayout *lay = new QVBoxLayout(this);
lay->setMargin(0);
......@@ -77,7 +77,9 @@ EditorPage::EditorPage(GrantleeThemeEditor::EditorPage::PageType type, const QSt
if (mType == MainPage) {
KConfigGroup group(KSharedConfig::openConfig(), "EditorPage");
const QList<int> size{400, 100};
const QList<int> size {
400, 100
};
mMainSplitter->setSizes(group.readEntry("mainSplitter", size));
mWidgetSplitter->setSizes(group.readEntry("widgetSplitter", size));
}
......@@ -96,4 +98,3 @@ ContactPrintThemePreview *EditorPage::preview() const
{
return mPreview;
}
......@@ -26,8 +26,7 @@ class ThemeTemplateWidget;
class EditorWidget;
class QSplitter;
class ContactPrintThemePreview;
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class EditorWidget;
}
......
......@@ -29,4 +29,3 @@ QVector<PimCommon::defaultTemplate> ThemeDefaultTemplate::defaultTemplates()
return lst;
}
......@@ -22,11 +22,8 @@
#include <PimCommon/TemplateListWidget>
namespace ThemeDefaultTemplate
{
namespace ThemeDefaultTemplate {
QVector<PimCommon::defaultTemplate> defaultTemplates();
}
#endif // THEMEDEFAULTTEMPLATE_H
......@@ -42,8 +42,8 @@
#include <QStandardPaths>
ThemeEditorMainWindow::ThemeEditorMainWindow()
: KXmlGuiWindow(),
mThemeEditor(nullptr)
: KXmlGuiWindow()
, mThemeEditor(nullptr)
{
setupActions();
setupGUI();
......@@ -133,7 +133,6 @@ void ThemeEditorMainWindow::setupActions()
actionCollection()->setDefaultShortcut(mUpdateView, QKeySequence(Qt::Key_F5));
connect(mUpdateView, &QAction::triggered, this, &ThemeEditorMainWindow::slotUpdateView);
actionCollection()->addAction(QStringLiteral("update_view"), mUpdateView);
}
void ThemeEditorMainWindow::slotManageTheme()
......@@ -254,11 +253,11 @@ bool ThemeEditorMainWindow::saveCurrentProject(ActionSaveTheme act)
switch (act) {
case SaveOnly:
break;
case SaveAndCloseTheme: {
case SaveAndCloseTheme:
closeThemeEditor();
break;
}
case SaveAndCreateNewTheme: {
case SaveAndCreateNewTheme:
{
delete mThemeEditor;
mThemeEditor = nullptr;
QPointer<GrantleeThemeEditor::NewThemeDialog> dialog = new GrantleeThemeEditor::NewThemeDialog(this);
......@@ -340,4 +339,3 @@ void ThemeEditorMainWindow::slotSaveAsTheme()
}
}
}
......@@ -41,9 +41,9 @@
#include <QFileDialog>
ThemeEditorPage::ThemeEditorPage(const QString &projectDir, const QString &themeName, QWidget *parent)
: QWidget(parent),
mThemeSession(new GrantleeThemeEditor::ThemeSession(projectDir, QStringLiteral("headerthemeeditor"))),
mChanged(false)
: QWidget(parent)
, mThemeSession(new GrantleeThemeEditor::ThemeSession(projectDir, QStringLiteral("headerthemeeditor")))
, mChanged(false)
{
QHBoxLayout *lay = new QHBoxLayout;
mTabWidget = new GrantleeThemeEditor::ThemeEditorTabWidget;
......@@ -174,7 +174,7 @@ void ThemeEditorPage::uploadTheme()
lst << previewFileName;
mEditorPage->preview()->createScreenShot(lst);
const bool fileAdded = zip->addLocalFile(previewFileName, themename + QLatin1Char('/') + QLatin1String("theme_preview.png"));
const bool fileAdded = zip->addLocalFile(previewFileName, themename + QLatin1Char('/') + QLatin1String("theme_preview.png"));
if (!fileAdded) {
KMessageBox::error(this, i18n("We cannot add preview file in zip file"), i18n("Failed to add file."));
delete zip;
......@@ -298,4 +298,3 @@ void ThemeEditorPage::saveThemeAs(const QString &directory)
{
storeTheme(directory);
}
......@@ -22,8 +22,7 @@
#include <QWidget>
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class ThemeEditorTabWidget;
class ThemeSession;
class DesktopFilePage;
......
......@@ -38,4 +38,3 @@ void ThemeEditorWidget::createCompleterList(const QStringList &extraCompletion)
listWord << extraCompletion;
GrantleeThemeEditor::EditorWidget::createCompleterList(listWord);
}
......@@ -55,4 +55,3 @@ ThemeTemplateWidget::ThemeTemplateWidget(const QString &title, QWidget *parent)
ThemeTemplateWidget::~ThemeTemplateWidget()
{
}
......@@ -155,4 +155,3 @@ void ContactConfigureDialog::writeConfig()
group.writeEntry("defaultTemplate", mDefaultTemplate->toPlainText());
mConfigureWidget->writeConfig();
}
......@@ -21,18 +21,15 @@
#include <QDialog>
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class ConfigureWidget;
}
namespace Akonadi
{
namespace Akonadi {
class ContactEditor;
}
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class PlainTextEditorWidget;
}
class ContactConfigureDialog : public QDialog
......
......@@ -27,4 +27,3 @@ QVector<PimCommon::defaultTemplate> ContactDefaultTemplate::contactTemplates()
lst << tmp;
*/
}
......@@ -21,11 +21,8 @@
#include <PimCommon/TemplateListWidget>
namespace ContactDefaultTemplate
{
namespace ContactDefaultTemplate {
QVector<PimCommon::defaultTemplate> contactTemplates();
}
#endif // CONTACTDEFAULTTEMPLATE_H
......@@ -40,8 +40,8 @@
#include <QStandardPaths>
ContactEditorMainWindow::ContactEditorMainWindow()
: KXmlGuiWindow(),
mContactEditor(nullptr)
: KXmlGuiWindow()
, mContactEditor(nullptr)
{
setupActions();
setupGUI();
......@@ -249,11 +249,11 @@ bool ContactEditorMainWindow::saveCurrentProject(ActionSaveTheme act)
switch (act) {
case SaveOnly:
break;
case SaveAndCloseTheme: {
case SaveAndCloseTheme:
closeThemeEditor();
break;
}
case SaveAndCreateNewTheme: {
case SaveAndCreateNewTheme:
{
delete mContactEditor;
mContactEditor = nullptr;
QPointer<GrantleeThemeEditor::NewThemeDialog> dialog = new GrantleeThemeEditor::NewThemeDialog(this);
......@@ -334,4 +334,3 @@ void ContactEditorMainWindow::slotSaveAsTheme()
}
}
}
......@@ -42,9 +42,9 @@
#include <QFileDialog>
ContactEditorPage::ContactEditorPage(const QString &projectDir, const QString &themeName, QWidget *parent)
: QWidget(parent),
mThemeSession(new GrantleeThemeEditor::ThemeSession(projectDir, QStringLiteral("contactthemeeditor"))),
mChanged(false)
: QWidget(parent)
, mThemeSession(new GrantleeThemeEditor::ThemeSession(projectDir, QStringLiteral("contactthemeeditor")))
, mChanged(false)
{
QHBoxLayout *lay = new QHBoxLayout;
mTabWidget = new GrantleeThemeEditor::ThemeEditorTabWidget;
......@@ -168,7 +168,6 @@ void ContactEditorPage::uploadTheme()
const QString zipFileName = tmp.path() + QDir::separator() + themename + QLatin1String(".zip");
KZip *zip = new KZip(zipFileName);
if (zip->open(QIODevice::WriteOnly)) {
//TODO reactivate it when we will be able to create a preview
const QString previewContactFileName = tmp.path() + QDir::separator() + themename + QLatin1String("contact_preview.png");
const QString previewContactGroupFileName = tmp.path() + QDir::separator() + themename + QLatin1String("contactgroup_preview.png");
......@@ -177,13 +176,13 @@ void ContactEditorPage::uploadTheme()
mEditorPage->preview()->createScreenShot(lst);
bool fileAdded = zip->addLocalFile(previewContactFileName, themename + QLatin1Char('/') + QLatin1String("contact_preview.png"));
bool fileAdded = zip->addLocalFile(previewContactFileName, themename + QLatin1Char('/') + QLatin1String("contact_preview.png"));
if (!fileAdded) {
KMessageBox::error(this, i18n("We cannot add preview file in zip file"), i18n("Failed to add file."));
delete zip;
return;
}
fileAdded = zip->addLocalFile(previewContactGroupFileName, themename + QLatin1Char('/') + QLatin1String("contactgroup_preview.png"));
fileAdded = zip->addLocalFile(previewContactGroupFileName, themename + QLatin1Char('/') + QLatin1String("contactgroup_preview.png"));
if (!fileAdded) {
KMessageBox::error(this, i18n("We cannot add preview file in zip file"), i18n("Failed to add file."));
delete zip;
......@@ -337,4 +336,3 @@ void ContactEditorPage::saveThemeAs(const QString &directory)
{
storeTheme(directory);
}
......@@ -21,8 +21,7 @@
#include <QWidget>
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class ThemeEditorTabWidget;
class ThemeSession;
class DesktopFilePage;
......
......@@ -20,12 +20,10 @@
ContactEditorUtil::ContactEditorUtil()
{
}
QString ContactEditorUtil::defaultContact() const
{
const QString contact = QStringLiteral("BEGIN:VCARD\n"
"ADR;TYPE=home:;;10 street Eiffel Tower\n;Paris;;75016;France\n"
"EMAIL:test@kde.org\n"
......@@ -39,4 +37,3 @@ QString ContactEditorUtil::defaultContact() const
"END:VCARD");
return contact;
}
......@@ -34,4 +34,3 @@ void ContactEditorWidget::createCompleterList(const QStringList &extraCompletion
const QStringList listWord = QStringList() << DefaultCompletion::defaultCompetion() << DefaultCompletion::defaultOptions() << extraCompletion;
GrantleeThemeEditor::EditorWidget::createCompleterList(listWord);
}
......@@ -138,4 +138,3 @@ void ContactPreviewWidget::setThemePath(const QString &projectDirectory)
mGroupFormatter->setAbsoluteThemePath(projectDirectory);
mFormatter->setAbsoluteThemePath(projectDirectory);
}
......@@ -25,14 +25,12 @@
class QTabWidget;
namespace Akonadi
{
namespace Akonadi {
class ContactViewer;
class ContactGroupViewer;
}
namespace KAddressBookGrantlee
{
namespace KAddressBookGrantlee {
class GrantleeContactFormatter;
class GrantleeContactGroupFormatter;
}
......
......@@ -54,4 +54,3 @@ ContactTemplateWidget::ContactTemplateWidget(const QString &title, QWidget *pare
ContactTemplateWidget::~ContactTemplateWidget()
{
}
......@@ -75,6 +75,8 @@ QStringList DefaultCompletion::defaultCompetion()
QStringList DefaultCompletion::defaultOptions()
{
const QStringList lst{QStringLiteral("Safe")};
const QStringList lst {
QStringLiteral("Safe")
};
return lst;
}
......@@ -21,8 +21,7 @@
#include <QStringList>
namespace DefaultCompletion
{
namespace DefaultCompletion {
QStringList defaultCompetion();
QStringList defaultOptions();
}
......
......@@ -34,8 +34,8 @@
#include <QVBoxLayout>
EditorPage::EditorPage(GrantleeThemeEditor::EditorPage::PageType type, const QString &projectDirectory, QWidget *parent)
: GrantleeThemeEditor::EditorPage(type, parent),
mWidgetSplitter(nullptr)
: GrantleeThemeEditor::EditorPage(type, parent)
, mWidgetSplitter(nullptr)
{
QVBoxLayout *lay = new QVBoxLayout(this);
lay->setMargin(0);
......@@ -73,7 +73,9 @@ EditorPage::EditorPage(GrantleeThemeEditor::EditorPage::PageType type, const QSt
if (mType == MainPage) {
KConfigGroup group(KSharedConfig::openConfig(), "EditorPage");
const QList<int> size{400, 100};
const QList<int> size {
400, 100
};
mMainSplitter->setSizes(group.readEntry("mainSplitter", size));
mWidgetSplitter->setSizes(group.readEntry("widgetSplitter", size));
}
......@@ -92,4 +94,3 @@ GrantleeThemeEditor::PreviewWidget *EditorPage::preview() const
{
return mPreview;
}
......@@ -24,8 +24,7 @@
class ContactTemplateWidget;
class EditorWidget;
class QSplitter;
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class EditorWidget;
class PreviewWidget;
}
......
......@@ -56,4 +56,3 @@ void PreviewWidget::setThemePath(const QString &projectDirectory, const QString
mPreview->setThemePath(projectDirectory);
updateViewer();
}
......@@ -26,8 +26,8 @@
using namespace GrantleeThemeEditor;
ConfigureWidget::ConfigureWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::ConfigureWidget)
: QWidget(parent)
, ui(new Ui::ConfigureWidget)
{
ui->setupUi(this);
}
......@@ -67,4 +67,3 @@ void ConfigureWidget::setDefault()
ui->authorEmail->clear();
ui->author->clear();
}
......@@ -23,13 +23,11 @@
#include "grantleethemeeditor_export.h"
#include <QWidget>
namespace Ui
{
namespace Ui {
class ConfigureWidget;
}
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class GRANTLEETHEMEEDITOR_EXPORT ConfigureWidget : public QWidget
{
Q_OBJECT
......
......@@ -37,9 +37,9 @@
using namespace GrantleeThemeEditor;
DesktopFilePage::DesktopFilePage(const QString &defaultFileName, DesktopFilePage::DesktopFileOptions options, QWidget *parent)
: QWidget(parent),
mFilename(nullptr),
mExtraDisplayHeaders(nullptr)
: QWidget(parent)
, mFilename(nullptr)
, mExtraDisplayHeaders(nullptr)
{
QGridLayout *lay = new QGridLayout;
QLabel *lab = new QLabel(i18n("Name:"), this);
......@@ -94,7 +94,10 @@ DesktopFilePage::DesktopFilePage(const QString &defaultFileName, DesktopFilePage
lay->addWidget(lab, row, 0);
++row;
lab = new QLabel(QStringLiteral("<qt><b>") + i18n("Be careful, Grantlee does not support '-' in variable name. So when you want to add extra header as \"X-Original-To\" add \"X-Original-To\" in list, but use \"XOriginalTo\" as variable in Grantlee (remove '-' in name).") + QStringLiteral("</b></qt>"), this);
lab
= new QLabel(QStringLiteral("<qt><b>") + i18n(
"Be careful, Grantlee does not support '-' in variable name. So when you want to add extra header as \"X-Original-To\" add \"X-Original-To\" in list, but use \"XOriginalTo\" as variable in Grantlee (remove '-' in name).")
+ QStringLiteral("</b></qt>"), this);
lab->setWordWrap(true);
lay->addWidget(lab, row, 0, 1, 2);
......@@ -137,7 +140,7 @@ void DesktopFilePage::createZip(const QString &themeName, KZip *zip)
QTemporaryFile tmp;
tmp.open();
saveAsFilename(tmp.fileName());
const bool fileAdded = zip->addLocalFile(tmp.fileName(), themeName + QLatin1Char('/') + mDefaultDesktopName);
const bool fileAdded = zip->addLocalFile(tmp.fileName(), themeName + QLatin1Char('/') + mDefaultDesktopName);
if (!fileAdded) {
KMessageBox::error(this, i18n("Failed to add file into ZIP archive."),
i18nc("@title:window", "Failed to add file"));
......@@ -222,4 +225,3 @@ QString DesktopFilePage::description() const
{
return mDescription->toPlainText();
}
......@@ -24,12 +24,10 @@
class QLineEdit;
class KZip;
class KEditListWidget;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class PlainTextEditorWidget;
}
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class GRANTLEETHEMEEDITOR_EXPORT DesktopFilePage : public QWidget
{
Q_OBJECT
......
......@@ -31,16 +31,15 @@
using namespace GrantleeThemeEditor;
EditorPage::EditorPage(PageType type, QWidget *parent)
: QWidget(parent),
mType(type),
mPreview(nullptr),
mEditor(nullptr)
: QWidget(parent)
, mType(type)
, mPreview(nullptr)
, mEditor(nullptr)
{
}
EditorPage::~EditorPage()
{
}
EditorPage::PageType EditorPage::pageType() const
......@@ -114,7 +113,7 @@ void EditorPage::createZip(const QString &themeName, KZip *zip)
QTemporaryFile tmp;
tmp.open();
saveAsFilename(tmp.fileName());
const bool fileAdded = zip->addLocalFile(tmp.fileName(), themeName + QLatin1Char('/') + mPageFileName);
const bool fileAdded = zip->addLocalFile(tmp.fileName(), themeName + QLatin1Char('/') + mPageFileName);
if (!fileAdded) {
KMessageBox::error(this, i18n("Failed to add file into ZIP archive."),
i18nc("@title:window", "Failed to add file"));
......@@ -126,4 +125,3 @@ void EditorPage::installTheme(const QString &themePath)
const QString filename = themePath + QDir::separator() + mPageFileName;
saveAsFilename(filename);
}
......@@ -24,8 +24,7 @@
class KZip;
namespace GrantleeThemeEditor
{
namespace GrantleeThemeEditor {
class EditorWidget;
class PreviewWidget;
class GRANTLEETHEMEEDITOR_EXPORT EditorPage : public QWidget
......