diff --git a/src/about/aboutpage.cpp b/src/about/aboutpage.cpp index 2101e22e..f8af6f83 100644 --- a/src/about/aboutpage.cpp +++ b/src/about/aboutpage.cpp @@ -1,323 +1,323 @@ /* This file is part of the KDE project Copyright (C) 2009, 2011 Dag Andersen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "aboutpage.h" #include "kptproject.h" #include #include #include #include #include #include #include #include #include #include #include KPlatoAboutPage::KPlatoAboutPage() : m_project(0) { } KPlatoAboutPage::~KPlatoAboutPage() { } QString KPlatoAboutPage::main() { KIconLoader *iconloader = KIconLoader::global(); QString res = loadFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "calligraplan/about/main.html")); if (res.isEmpty()) { return res; } const char *const up_icon_id = koIconNameCStr("go-up"); const QString up_icon_path = iconloader->iconPath(up_icon_id, KIconLoader::Small); const char *const continue_icon_id = (QApplication::isRightToLeft() ? koIconNameCStr("go-previous") : koIconNameCStr("go-next")); const QString continue_icon_path = iconloader->iconPath(continue_icon_id, KIconLoader::Small); QString icon_up = ""; QString icon_path = ""; res = res.arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage.css")); if (qApp->layoutDirection() == Qt::RightToLeft) res = res.arg("@import \"%1\";").arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage_rtl.css")); else res = res.arg(""); res = res.arg(i18n("Plan")) - .arg(i18nc("KDE 4 tag line, see http://kde.org/img/kde40.png", "Be free.")) + .arg(i18nc("KDE 4 tag line", "Be free.")) .arg(i18n("Plan is a Project Planning and Management application.")) .arg(i18n("Welcome to Plan.")) .arg(i18n("These introductory pages should give you an idea of how to use Plan and what you can use it for.")) .arg(icon_path).arg(i18n("A short introduction.")) .arg(icon_path).arg(i18n("Tips on how to manipulate and inspect data.")) .arg(icon_path).arg(i18n("A small tutorial to get you started.")) .arg(icon_up).arg(i18n("Close")) .arg(i18n( "Note: To view these pages when you are in other parts of Plan, choose the menu option Help -> Introduction to Plan." )) ; return res; } QString KPlatoAboutPage::intro() { KIconLoader *iconloader = KIconLoader::global(); QString res = loadFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "calligraplan/about/intro.html")); if (res.isEmpty()) { return res; } const char *const up_icon_id = koIconNameCStr("go-up"); const QString up_icon_path = iconloader->iconPath(up_icon_id, KIconLoader::Small); QString icon_up = ""; const char *const prev_icon_id = koIconNameCStr("go-previous"); const QString prev_icon_path = iconloader->iconPath(prev_icon_id, KIconLoader::Small); const char *const next_icon_id = koIconNameCStr("go-next"); const QString next_icon_path = iconloader->iconPath(next_icon_id, KIconLoader::Small); const QString continue_icon_path = QApplication::isRightToLeft() ? prev_icon_path : next_icon_path; const QString back_icon_path = QApplication::isRightToLeft() ? next_icon_path : prev_icon_path; res = res.arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage.css")); if (qApp->layoutDirection() == Qt::RightToLeft) res = res.arg("@import \"%1\";").arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage_rtl.css")); else res = res.arg(""); res = res.arg(i18n("Plan is a Project Planning and Management application.")) .arg(i18n( "Plan is intended for managing moderately large projects with multiple resources. To enable you to model your project adequately, Plan offers different types of task dependencies and timing constraints. Usually you will define your tasks, estimate the effort needed to perform each task, allocate resources and then schedule the project according to the dependency network and resource availability." "

You can find more information online at https://userbase.kde.org/Plan

" )) .arg(icon_up) .arg(i18n("Close")) .arg("").arg(continue_icon_path) .arg(i18n("Next: Tips")) ; return res; } QString KPlatoAboutPage::tips() { QString res = loadFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "calligraplan/about/tips.html")); if (res.isEmpty()) { return res; } KIconLoader *iconloader = KIconLoader::global(); QString viewmag_icon_path = iconloader->iconPath(koIconNameCStr("zoom-in"), KIconLoader::Small); QString history_icon_path = iconloader->iconPath(koIconNameCStr("view-history"), KIconLoader::Small); QString openterm_icon_path = iconloader->iconPath(koIconNameCStr("utilities-terminal"), KIconLoader::Small); QString locationbar_erase_rtl_icon_path = iconloader->iconPath(koIconNameCStr("edit-clear-locationbar-rtl"), KIconLoader::Small); QString locationbar_erase_icon_path = iconloader->iconPath(koIconNameCStr("edit-clear-locationbar-ltr"), KIconLoader::Small); QString window_fullscreen_icon_path = iconloader->iconPath(koIconNameCStr("view-fullscreen"), KIconLoader::Small); QString view_left_right_icon_path = iconloader->iconPath(koIconNameCStr("view-split-left-right"), KIconLoader::Small); const char *const up_icon_id = koIconNameCStr("go-up"); const QString up_icon_path = iconloader->iconPath(up_icon_id, KIconLoader::Small); QString icon_up = ""; const char *const prev_icon_id = koIconNameCStr("go-previous"); const QString prev_icon_path = iconloader->iconPath(prev_icon_id, KIconLoader::Small); const char *const next_icon_id = koIconNameCStr("go-next"); const QString next_icon_path = iconloader->iconPath(next_icon_id, KIconLoader::Small); const QString continue_icon_path = QApplication::isRightToLeft() ? prev_icon_path : next_icon_path; const QString back_icon_path = QApplication::isRightToLeft() ? next_icon_path : prev_icon_path; res = res.arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage.css")); if (qApp->layoutDirection() == Qt::RightToLeft) res = res.arg("@import \"%1\";").arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage_rtl.css")); else res = res.arg(""); res = res.arg(i18n("Editing tips.")) .arg(i18n( "
To edit project data, different views and editors can be selected in the View Selector docker." "
The views are generally used to inspect data after the project has been scheduled. No data will appear in the views if the project has not been scheduled. Scheduling is done in the Schedules editor." "
You can edit attributes in the various editors by selecting the item you want to edit (doubleclick or press F2), or open a dialog using the context menu." "" )) .arg(icon_up) .arg(i18n("Close")) .arg("").arg(continue_icon_path) .arg(i18n("Next: Create a simple project")) ; return res; } QString KPlatoAboutPage::tutorial(const QString &header, const QString &text, const QString &nextpage, const QString &nexttext) { QString res = loadFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "calligraplan/about/tutorial.html")); if (res.isEmpty()) { return res; } KIconLoader *iconloader = KIconLoader::global(); const char *const up_icon_id = koIconNameCStr("go-up"); const QString up_icon_path = iconloader->iconPath(up_icon_id, KIconLoader::Small); QString icon_up = ""; const char *const prev_icon_id = koIconNameCStr("go-previous"); const QString prev_icon_path = iconloader->iconPath(prev_icon_id, KIconLoader::Small); const char *const next_icon_id = koIconNameCStr("go-next"); const QString next_icon_path = iconloader->iconPath(next_icon_id, KIconLoader::Small); const QString continue_icon_path = QApplication::isRightToLeft() ? prev_icon_path : next_icon_path; const QString back_icon_path = QApplication::isRightToLeft() ? next_icon_path : prev_icon_path; res = res.arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage.css")); if (qApp->layoutDirection() == Qt::RightToLeft) res = res.arg("@import \"%1\";").arg(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kf5/infopage/kde_infopage_rtl.css")); else res = res.arg(""); res = res.arg(header) .arg(text) .arg("about:close") .arg(icon_up) .arg(i18n("Close")) .arg("about:plan/" + nextpage) .arg("").arg(continue_icon_path) .arg(nexttext) ; return res; } QString KPlatoAboutPage::tutorial1() { return tutorial( i18n("Create the simplest project ever."), i18nc("1=datetime", "Select the task editor Editors->Tasks:" "
    " "
  • Create a task by selecting Add Task in the toolbar.
  • " "
  • Set Type to Duration.
  • " "
  • Set Estimate to 8 hours.
  • " "
  • Set Constraint to As Soon As Possible.
  • " "
" "Select the schedules editor Editors->Schedules:" "
    " "
  • Create a schedule by selecting Add Schedule in the toolbar.
  • " "
  • Calculate the schedule by selecting Calculate in the toolbar.
  • " "
" "The task should now have been scheduled to start %1 with a duration of 8 hours. You can check this by selecting the Gantt chart Views->Gantt." , KFormat().formatRelativeDateTime(m_project->startTime(), QLocale::LongFormat)), "tutorial2", i18n("Next: Resource allocation") ); } QString KPlatoAboutPage::tutorial2() { DateTime dt = m_project->constraintStartTime(); if (m_project->defaultCalendar()) { dt = m_project->defaultCalendar()->firstAvailableAfter(dt, m_project->constraintEndTime()); } return tutorial( i18n("Allocate a resource to the task."), i18nc("1=datetime", "Select the task editor Editors->Tasks:" "
    " "
  • Enter a name (e.g. 'John') in the Allocation column." " (Plan will automatically create a resource with name 'John' under resource group 'Resources'.
  • " "
  • Set Type to Effort.
  • " "
" "Now you need to schedule the project again with the new allocation:" "
Select the schedules editor Editors->Schedules and calculate the schedule by selecting Calculate in the toolbar." "

The task should be scheduled to start %1 with a duration of 8 hours. You can check this by selecting the Gantt chart Views->Gantt.

" , KFormat().formatRelativeDateTime(dt, QLocale::LongFormat)), "main", i18n("Next: Introduction") ); } void KPlatoAboutPage::generatePage(KHTMLPart &part, const QUrl &url) { QString html; if (url.url() == "about:plan/main") html = main(); else if (url.url() == "about:plan/intro") html = intro(); else if (url.url() == "about:plan/tips") html = tips(); else if (url.url() == "about:plan/tutorial") html = tutorial1(); else if (url.url() == "about:plan/tutorial1") html = tutorial1(); else if (url.url() == "about:plan/tutorial2") html = tutorial2(); else html = main(); part.begin(); part.write(html); part.end(); } QString KPlatoAboutPage::loadFile(const QString& file) { QString res; if (file.isEmpty()) return res; QFile f(file); if (!f.open(QIODevice::ReadOnly)) return res; QTextStream t(&f); res = t.readAll(); // otherwise all embedded objects are referenced as about:/... QString basehref = QLatin1String("\n"); res.replace("", "\n\t" + basehref, Qt::CaseInsensitive); return res; } diff --git a/src/libs/kundo2/kundo2magicstring.h b/src/libs/kundo2/kundo2magicstring.h index 62c20725..81abefc5 100644 --- a/src/libs/kundo2/kundo2magicstring.h +++ b/src/libs/kundo2/kundo2magicstring.h @@ -1,319 +1,319 @@ /* * Copyright (c) 2014 Dmitry Kazakov * Copyright (c) 2014 Alexander Potashev * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KUNDO2MAGICSTRING_H #define KUNDO2MAGICSTRING_H #include #include #include #include "kundo2_export.h" /** * \class KUndo2MagicString * \brief A special wrapper for a string that is * going to passed to a KUndo2Command and be later shown in the undo * history and undo action in menu. The strings like that must have * (qtundo-format) context to let translators know that they are * allowed to use magic split in them. * * Magic split is used in some languages to split the message in the * undo history docker (which is either verb or noun in + * href="https://en.wikipedia.org/wiki/Nominative_case">noun in * nominative) and the message in undo/redo actions (which is - * usually a noun + * usually a noun * in accusative). When the translator needs it he, splits two * translations with '\n' symbol and the magic string will recognize * it. * * \note KUndo2MagicString will never support concatenation operators, * because in many languages you cannot combine words without * knowing the proper case. */ class KUNDO2_EXPORT KUndo2MagicString { public: /** * Construct an empty string. Note that you cannot create a * non-empy string without special functions, all the calls to which * are processed by xgettext. */ KUndo2MagicString(); /** * Fetch the main translated string. That is the one that goes to * undo history and resembles the action name in verb/nominative */ QString toString() const; /** * Fetch the secondary string which will go to the undo/redo * action. This is usually a noun in accusative. If the * translator didn't provide a secondary string, toString() and * toSecondaryString() return the same values. */ QString toSecondaryString() const; /** * \return true if the contained string is empty */ bool isEmpty() const; bool operator==(const KUndo2MagicString &rhs) const; bool operator!=(const KUndo2MagicString &rhs) const; private: /** * Construction of a magic string is allowed only with the means * of special macros which resemble their kde-wide counterparts */ explicit KUndo2MagicString(const QString &text); friend KUndo2MagicString kundo2_noi18n(const QString &text); template friend KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1); template friend KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2); template friend KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3); template friend KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4); friend KUndo2MagicString kundo2_i18n(const char *text); template friend KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1); template friend KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2); template friend KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3); template friend KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4); friend KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text); template friend KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1); template friend KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1, const A2 &a2); template friend KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1, const A2 &a2, const A3 &a3); template friend KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1); template friend KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1, const A2 &a2); template friend KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3); template friend KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1); template friend KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1, const A2 &a2); template friend KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3); private: QString m_text; }; inline QDebug operator<<(QDebug dbg, const KUndo2MagicString &v) { if (v.toString() != v.toSecondaryString()) { dbg.nospace() << v.toString() << "(" << v.toSecondaryString() << ")"; } else { dbg.nospace() << v.toString(); } return dbg.space(); } /** * This is a special wrapper to a string which tells explicitly * that we don't need a translation for a given string. It is used * either in testing or internal commands, which don't go to the * stack directly. */ inline KUndo2MagicString kundo2_noi18n(const QString &text) { return KUndo2MagicString(text); } template inline KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1) { return KUndo2MagicString(QString(text).arg(a1)); } template inline KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2) { return KUndo2MagicString(QString(text).arg(a1).arg(a2)); } template inline KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return KUndo2MagicString(QString(text).arg(a1).arg(a2).arg(a3)); } template inline KUndo2MagicString kundo2_noi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return KUndo2MagicString(QString(text).arg(a1).arg(a2).arg(a3).arg(a4)); } /** * Same as ki18n, but is supposed to work with strings going to * undo stack */ inline KUndo2MagicString kundo2_i18n(const char *text) { return KUndo2MagicString(i18nc("(qtundo-format)", text)); } template inline KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1) { return KUndo2MagicString(i18nc("(qtundo-format)", text, a1)); } template inline KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2) { return KUndo2MagicString(i18nc("(qtundo-format)", text, a1, a2)); } template inline KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return KUndo2MagicString(i18nc("(qtundo-format)", text, a1, a2, a3)); } template inline KUndo2MagicString kundo2_i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return KUndo2MagicString(i18nc("(qtundo-format)", text, a1, a2, a3, a4)); } inline QString prependContext(const char *ctxt) { return QString("(qtundo-format) %1").arg(ctxt); } /** * Same as ki18nc, but is supposed to work with strings going to * undo stack */ inline KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text) { return KUndo2MagicString(i18nc(prependContext(ctxt).toLatin1().data(), text)); } template inline KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1) { return KUndo2MagicString(i18nc(prependContext(ctxt).toLatin1().data(), text, a1)); } template inline KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1, const A2 &a2) { return KUndo2MagicString(i18nc(prependContext(ctxt).toLatin1().data(), text, a1, a2)); } template inline KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return KUndo2MagicString(i18nc(prependContext(ctxt).toLatin1().data(), text, a1, a2, a3)); } template inline KUndo2MagicString kundo2_i18nc(const char *ctxt, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return KUndo2MagicString(i18nc(prependContext(ctxt).toLatin1().data(), text, a1, a2, a3, a4)); } /** * Same as ki18np, but is supposed to work with strings going to * undo stack */ template inline KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1) { return KUndo2MagicString(i18ncp("(qtundo-format)", sing, plur, a1)); } template inline KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1, const A2 &a2) { return i18ncp("(qtundo-format)", sing, plur, a1, a2); } template inline KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3) { return i18ncp("(qtundo-format)", sing, plur, a1, a2, a3); } template inline KUndo2MagicString kundo2_i18np(const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return i18ncp("(qtundo-format)", sing, plur, a1, a2, a3, a4); } /** * Same as ki18ncp, but is supposed to work with strings going to * undo stack */ template inline KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1) { return KUndo2MagicString(i18ncp(prependContext(ctxt).toLatin1().data(), sing, plur, a1)); } template inline KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1, const A2 &a2) { return i18ncp(prependContext(ctxt).toLatin1().data(), sing, plur, a1, a2); } template inline KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3) { return i18ncp(prependContext(ctxt).toLatin1().data(), sing, plur, a1, a2, a3); } template inline KUndo2MagicString kundo2_i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return i18ncp(prependContext(ctxt).toLatin1().data(), sing, plur, a1, a2, a3, a4); } #endif /* KUNDO2MAGICSTRING_H */ diff --git a/src/libs/models/kcalendar/kdatepicker.cpp b/src/libs/models/kcalendar/kdatepicker.cpp index 8a637cc1..5f74d915 100644 --- a/src/libs/models/kcalendar/kdatepicker.cpp +++ b/src/libs/models/kcalendar/kdatepicker.cpp @@ -1,674 +1,674 @@ /* -*- C++ -*- This file is part of the KDE libraries Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) (C) 1998-2001 Mirko Boehm (mirko@kde.org) (C) 2007 John Layt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "kdatepicker.h" #include "kdatepicker_p.h" #include "kdatetable.h" #include "kptdebug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace KPlato { static QDate parseDateString(const QString &text) { QLocale::FormatType formats[] = { QLocale::LongFormat, QLocale::ShortFormat, QLocale::NarrowFormat }; QLocale locale; QDate date; for (int i = 0; i < 3; i++) { date = locale.toDate(text, formats[i]); if (date.isValid()) { break; } } return date; } class DatePickerValidator : public QValidator { public: DatePickerValidator(KDatePicker *parent) : QValidator(parent), picker(parent) {} State validate(QString &text, int &) const Q_DECL_OVERRIDE { return parseDateString(text).isValid() ? QValidator::Acceptable : QValidator::Intermediate; } private: KDatePicker *picker; }; // Week numbers are defined by ISO 8601 -// See http://www.merlyn.demon.co.uk/weekinfo.htm for details +// See https://people.cs.nctu.edu.tw/~tsaiwn/sisc/runtime_error_200_div_by_0/www.merlyn.demon.co.uk/weekinfo.htm for details KDatePickerPrivateYearSelector::KDatePickerPrivateYearSelector( const QDate ¤tDate, QWidget *parent) : QLineEdit(parent), val(new QIntValidator(this)), result(0) { oldDate = currentDate; setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont)); setFrame(false); // TODO: Find a way to get that from QLocale //val->setRange(calendar->year(calendar->earliestValidDate()), // calendar->year(calendar->latestValidDate())); setValidator(val); connect(this, &QLineEdit::returnPressed, this, &KDatePickerPrivateYearSelector::yearEnteredSlot); } void KDatePickerPrivateYearSelector::yearEnteredSlot() { bool ok; int newYear; // check if entered value is a number newYear = text().toInt(&ok); if (!ok) { KNotification::beep(); return; } // check if new year will lead to a valid date if (QDate(newYear, oldDate.month(), oldDate.day()).isValid()) { result = newYear; emit closeMe(1); } else { KNotification::beep(); } } int KDatePickerPrivateYearSelector::year() { return result; } void KDatePickerPrivateYearSelector::setYear(int year) { setText(QString::number(year)); } class KDatePicker::KDatePickerPrivate { public: KDatePickerPrivate(KDatePicker *q) : q(q), closeButton(0L), selectWeek(0L), todayButton(0), navigationLayout(0) { } void fillWeeksCombo(); QDate validDateInYearMonth(int year, int month); /// the date table KDatePicker *q; QToolButton *closeButton; QComboBox *selectWeek; QToolButton *todayButton; QBoxLayout *navigationLayout; /// the year forward button QToolButton *yearForward; /// the year backward button QToolButton *yearBackward; /// the month forward button QToolButton *monthForward; /// the month backward button QToolButton *monthBackward; /// the button for selecting the month directly QToolButton *selectMonth; /// the button for selecting the year directly QToolButton *selectYear; /// the line edit to enter the date directly QLineEdit *line; /// the validator for the line edit: DatePickerValidator *val; /// the date table KDateTable *table; /// the widest month string in pixels: QSize maxMonthRect; /// the font size for the widget int fontsize; }; void KDatePicker::KDatePickerPrivate::fillWeeksCombo() { // every year can have a different number of weeks // it could be that we had 53,1..52 and now 1..53 which is the same number but different // so always fill with new values // We show all week numbers for all weeks between first day of year to last day of year // This of course can be a list like 53,1,2..52 const QDate thisDate = q->date(); const int thisYear = thisDate.year(); QDate day(thisDate.year(), 1, 1); const QDate lastDayOfYear = QDate(thisDate.year() + 1, 1, 1).addDays(-1); selectWeek->clear(); // Starting from the first day in the year, loop through the year a week at a time // adding an entry to the week combo for each week in the year for (; day.isValid() && day <= lastDayOfYear; day = day.addDays(7)) { // Get the ISO week number for the current day and what year that week is in // e.g. 1st day of this year may fall in week 53 of previous year int weekYear = thisYear; const int week = day.weekNumber(&weekYear); QString weekString = i18n("Week %1", week); // show that this is a week from a different year if (weekYear != thisYear) { weekString += QLatin1Char('*'); } // when the week is selected, go to the same weekday as the one // that is currently selected in the date table QDate targetDate = day.addDays(thisDate.dayOfWeek() - day.dayOfWeek()); selectWeek->addItem(weekString, targetDate); // make sure that the week of the lastDayOfYear is always inserted: in Chinese calendar // system, this is not always the case if (day < lastDayOfYear && day.daysTo(lastDayOfYear) < 7 && lastDayOfYear.weekNumber() != day.weekNumber()) { day = lastDayOfYear.addDays(-7); } } } QDate KDatePicker::KDatePickerPrivate::validDateInYearMonth(int year, int month) { QDate newDate; // Try to create a valid date in this year and month // First try the first of the month, then try last of month if (QDate(year, month, 1).isValid()) { newDate = QDate(year, month, 1); } else if (QDate(year, month + 1, 1).isValid()) { newDate = QDate(year, month + 1, 1).addDays(-1); } else { newDate = QDate::fromJulianDay(0); } return newDate; } KDatePicker::KDatePicker(QWidget *parent) : QFrame(parent), d(new KDatePickerPrivate(this)) { initWidget(QDate::currentDate()); } KDatePicker::KDatePicker(const QDate &date_, QWidget *parent) : QFrame(parent), d(new KDatePickerPrivate(this)) { initWidget(date_); } void KDatePicker::initWidget(const QDate &date_) { const int spacingHint = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); QBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setSpacing(0); topLayout->setMargin(0); d->navigationLayout = new QHBoxLayout(); d->navigationLayout->setSpacing(0); d->navigationLayout->setMargin(0); topLayout->addLayout(d->navigationLayout); d->navigationLayout->addStretch(); d->yearBackward = new QToolButton(this); d->yearBackward->setAutoRaise(true); d->navigationLayout->addWidget(d->yearBackward); d->monthBackward = new QToolButton(this); d->monthBackward ->setAutoRaise(true); d->navigationLayout->addWidget(d->monthBackward); d->navigationLayout->addSpacing(spacingHint); d->selectMonth = new QToolButton(this); d->selectMonth ->setAutoRaise(true); d->navigationLayout->addWidget(d->selectMonth); d->selectYear = new QToolButton(this); d->selectYear->setCheckable(true); d->selectYear->setAutoRaise(true); d->navigationLayout->addWidget(d->selectYear); d->navigationLayout->addSpacing(spacingHint); d->monthForward = new QToolButton(this); d->monthForward ->setAutoRaise(true); d->navigationLayout->addWidget(d->monthForward); d->yearForward = new QToolButton(this); d->yearForward ->setAutoRaise(true); d->navigationLayout->addWidget(d->yearForward); d->navigationLayout->addStretch(); d->line = new QLineEdit(this); d->val = new DatePickerValidator(this); d->table = new KDateTable(this); setFocusProxy(d->table); d->fontsize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize(); if (d->fontsize == -1) { d->fontsize = QFontInfo(QFontDatabase::systemFont(QFontDatabase::GeneralFont)).pointSize(); } d->fontsize++; // Make a little bigger d->selectWeek = new QComboBox(this); // read only week selection d->selectWeek->setFocusPolicy(Qt::NoFocus); d->todayButton = new QToolButton(this); d->todayButton->setIcon(koIcon("go-jump-today")); d->yearForward->setToolTip(i18n("Next year")); d->yearBackward->setToolTip(i18n("Previous year")); d->monthForward->setToolTip(i18n("Next month")); d->monthBackward->setToolTip(i18n("Previous month")); d->selectWeek->setToolTip(i18n("Select a week")); d->selectMonth->setToolTip(i18n("Select a month")); d->selectYear->setToolTip(i18n("Select a year")); d->todayButton->setToolTip(i18n("Select the current day")); // ----- setFontSize(d->fontsize); d->line->setValidator(d->val); d->line->installEventFilter(this); if (QApplication::isRightToLeft()) { d->yearForward->setIcon(koIcon("arrow-left-double")); d->yearBackward->setIcon(koIcon("arrow-right-double")); d->monthForward->setIcon(koIcon("arrow-left")); d->monthBackward->setIcon(koIcon("arrow-right")); } else { d->yearForward->setIcon(koIcon("arrow-right-double")); d->yearBackward->setIcon(koIcon("arrow-left-double")); d->monthForward->setIcon(koIcon("arrow-right")); d->monthBackward->setIcon(koIcon("arrow-left")); } connect(d->table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); connect(d->table, &KDateTable::tableClicked, this, &KDatePicker::tableClickedSlot); connect(d->monthForward, &QAbstractButton::clicked, this, &KDatePicker::monthForwardClicked); connect(d->monthBackward, &QAbstractButton::clicked, this, &KDatePicker::monthBackwardClicked); connect(d->yearForward, &QAbstractButton::clicked, this, &KDatePicker::yearForwardClicked); connect(d->yearBackward, &QAbstractButton::clicked, this, &KDatePicker::yearBackwardClicked); connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int))); connect(d->todayButton, &QAbstractButton::clicked, this, &KDatePicker::todayButtonClicked); connect(d->selectMonth, &QAbstractButton::clicked, this, &KDatePicker::selectMonthClicked); connect(d->selectYear, &QAbstractButton::toggled, this, &KDatePicker::selectYearClicked); connect(d->line, &QLineEdit::returnPressed, this, &KDatePicker::lineEnterPressed); topLayout->addWidget(d->table); QBoxLayout *bottomLayout = new QHBoxLayout(); bottomLayout->setMargin(0); bottomLayout->setSpacing(0); topLayout->addLayout(bottomLayout); bottomLayout->addWidget(d->todayButton); bottomLayout->addWidget(d->line); bottomLayout->addWidget(d->selectWeek); d->table->setDate(date_); dateChangedSlot(date_); // needed because table emits changed only when newDate != oldDate } KDatePicker::~KDatePicker() { delete d; } bool KDatePicker::eventFilter(QObject *o, QEvent *e) { if (e->type() == QEvent::KeyPress) { QKeyEvent *k = (QKeyEvent *)e; if ((k->key() == Qt::Key_PageUp) || (k->key() == Qt::Key_PageDown) || (k->key() == Qt::Key_Up) || (k->key() == Qt::Key_Down)) { QApplication::sendEvent(d->table, e); d->table->setFocus(); return true; // eat event } } return QFrame::eventFilter(o, e); } void KDatePicker::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); } void KDatePicker::dateChangedSlot(const QDate &date_) { QLocale locale; d->line->setText(locale.toString(date_, QLocale::ShortFormat)); d->selectMonth->setText(locale.standaloneMonthName(date_.month(), QLocale::LongFormat)); d->fillWeeksCombo(); // calculate the item num in the week combo box; normalize selected day so as if 1.1. is the first day of the week QDate firstDay(date_.year(), 1, 1); // If we cannot successfully create the 1st of the year, this can only mean that // the 1st is before the earliest valid date in the current calendar system, so use // the earliestValidDate as the first day. // In particular covers the case of Gregorian where 1/1/-4713 is not a valid QDate d->selectWeek->setCurrentIndex((date_.dayOfYear() + firstDay.dayOfWeek() - 2) / 7); d->selectYear->setText(QString::number(date_.year()).rightJustified(4, QLatin1Char('0'))); emit dateChanged(date_); } void KDatePicker::tableClickedSlot() { emit dateSelected(date()); emit tableClicked(); } const QDate &KDatePicker::date() const { return d->table->date(); } bool KDatePicker::setDate(const QDate &date_) { // the table setDate does validity checking for us // this also emits dateChanged() which then calls our dateChangedSlot() return d->table->setDate(date_); } void KDatePicker::monthForwardClicked() { if (! setDate(date().addMonths(1))) { KNotification::beep(); } d->table->setFocus(); } void KDatePicker::monthBackwardClicked() { if (! setDate(date().addMonths(-1))) { KNotification::beep(); } d->table->setFocus(); } void KDatePicker::yearForwardClicked() { if (! setDate(d->table->date().addYears(1))) { KNotification::beep(); } d->table->setFocus(); } void KDatePicker::yearBackwardClicked() { if (! setDate(d->table->date().addYears(-1))) { KNotification::beep(); } d->table->setFocus(); } void KDatePicker::weekSelected(int index) { QDate targetDay = d->selectWeek->itemData(index).toDateTime().date(); if (! setDate(targetDay)) { KNotification::beep(); } d->table->setFocus(); } void KDatePicker::selectMonthClicked() { QDate thisDate(date()); d->table->setFocus(); QMenu popup(d->selectMonth); // Populate the pick list with all the month names, this may change by year // JPL do we need to do something here for months that fall outside valid range? const int monthsInYear = QDate(thisDate.year() + 1, 1, 1).addDays(-1).month(); QLocale locale; for (int m = 1; m <= monthsInYear; m++) { popup.addAction(locale.standaloneMonthName(m))->setData(m); } QAction *item = popup.actions().value(thisDate.month() - 1); // if this happens the above should already given an assertion if (item) { popup.setActiveAction(item); } // cancelled if ((item = popup.exec(d->selectMonth->mapToGlobal(QPoint(0, 0)), item)) == 0) { return; } // We need to create a valid date in the month selected so we can find out how many days are // in the month. QDate newDate(thisDate.year(), item->data().toInt(), 1); // If we have succeeded in creating a date in the new month, then try to create the new date, // checking we don't set a day after the last day of the month newDate.setDate(newDate.year(), newDate.month(), qMin(thisDate.day(), newDate.daysInMonth())); // Set the date, if it's invalid in any way then alert user and don't update if (! setDate(newDate)) { KNotification::beep(); } } void KDatePicker::selectYearClicked() { if (!d->selectYear->isChecked()) { return; } QDate thisDate(date()); KPopupFrame *popup = new KPopupFrame(this); KDatePickerPrivateYearSelector *picker = new KDatePickerPrivateYearSelector(date(), popup); picker->resize(picker->sizeHint()); picker->setYear(thisDate.year()); picker->selectAll(); popup->setMainWidget(picker); connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); picker->setFocus(); if (popup->exec(d->selectYear->mapToGlobal(QPoint(0, d->selectMonth->height())))) { // We need to create a valid date in the year/month selected so we can find out how many // days are in the month. QDate newDate(picker->year(), thisDate.month(), 1); // If we have succeeded in creating a date in the new month, then try to create the new // date, checking we don't set a day after the last day of the month newDate = QDate(newDate.year(), newDate.month(), qMin(thisDate.day(), newDate.daysInMonth())); // Set the date, if it's invalid in any way then alert user and don't update if (! setDate(newDate)) { KNotification::beep(); } } delete popup; d->selectYear->setChecked(false); } void KDatePicker::uncheckYearSelector() { d->selectYear->setChecked(false); d->selectYear->update(); } void KDatePicker::changeEvent(QEvent *event) { if (event && event->type() == QEvent::EnabledChange) { if (isEnabled()) { d->table->setFocus(); } } } KDateTable *KDatePicker::dateTable() const { return d->table; } void KDatePicker::lineEnterPressed() { QDate newDate = parseDateString(d->line->text()); if (newDate.isValid()) { emit dateEntered(newDate); setDate(newDate); d->table->setFocus(); } else { KNotification::beep(); } } void KDatePicker::todayButtonClicked() { setDate(QDate::currentDate()); d->table->setFocus(); } QSize KDatePicker::sizeHint() const { return QWidget::sizeHint(); } void KDatePicker::setFontSize(int s) { QWidget *const buttons[] = { d->selectMonth, d->selectYear, }; const int NoOfButtons = sizeof(buttons) / sizeof(buttons[0]); int count; QFont font; QRect r; // ----- d->fontsize = s; for (count = 0; count < NoOfButtons; ++count) { font = buttons[count]->font(); font.setPointSize(s); buttons[count]->setFont(font); } d->table->setFontSize(s); QFontMetrics metrics(d->selectMonth->fontMetrics()); QString longestMonth; QLocale locale; for (int i = 1;; ++i) { QString str = locale.standaloneMonthName(i, QLocale::LongFormat); if (str.isNull()) { break; } r = metrics.boundingRect(str); if (r.width() > d->maxMonthRect.width()) { d->maxMonthRect.setWidth(r.width()); longestMonth = str; } if (r.height() > d->maxMonthRect.height()) { d->maxMonthRect.setHeight(r.height()); } } QStyleOptionToolButton opt; opt.initFrom(d->selectMonth); opt.text = longestMonth; // stolen from QToolButton QSize textSize = metrics.size(Qt::TextShowMnemonic, longestMonth); textSize.setWidth(textSize.width() + metrics.width(QLatin1Char(' ')) * 2); int w = textSize.width(); int h = textSize.height(); opt.rect.setHeight(h); // PM_MenuButtonIndicator depends on the height QSize metricBound = style()->sizeFromContents( QStyle::CT_ToolButton, &opt, QSize(w, h), d->selectMonth ).expandedTo(QApplication::globalStrut()); d->selectMonth->setMinimumSize(metricBound); } int KDatePicker::fontSize() const { return d->fontsize; } void KDatePicker::setCloseButton(bool enable) { if (enable == (d->closeButton != 0L)) { return; } if (enable) { d->closeButton = new QToolButton(this); d->closeButton->setAutoRaise(true); const int spacingHint = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); d->navigationLayout->addSpacing(spacingHint); d->navigationLayout->addWidget(d->closeButton); d->closeButton->setToolTip(i18n("Close")); d->closeButton->setIcon(koIcon("window-close")); connect(d->closeButton, &QAbstractButton::clicked, topLevelWidget(), &QWidget::close); } else { delete d->closeButton; d->closeButton = 0L; } updateGeometry(); } bool KDatePicker::hasCloseButton() const { return (d->closeButton); } } //namespace KPlato diff --git a/src/libs/odf/KoOdfNumberDefinition.cpp b/src/libs/odf/KoOdfNumberDefinition.cpp index 54f14f9e..72b699af 100644 --- a/src/libs/odf/KoOdfNumberDefinition.cpp +++ b/src/libs/odf/KoOdfNumberDefinition.cpp @@ -1,414 +1,414 @@ /* This file is part of the KDE project Copyright (C) 2010 Boudewijn Rempt Copyright (C) 2011 Mojtaba Shahi Senobari This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "KoOdfNumberDefinition.h" #include "KoXmlNS.h" #include "KoXmlWriter.h" class Q_DECL_HIDDEN KoOdfNumberDefinition::Private { public: QString prefix; QString suffix; KoOdfNumberDefinition::FormatSpecification formatSpecification; bool letterSynchronization; }; KoOdfNumberDefinition::KoOdfNumberDefinition() : d(new Private()) { d->formatSpecification = Numeric; d->letterSynchronization = false; } KoOdfNumberDefinition::KoOdfNumberDefinition(const KoOdfNumberDefinition &other) : d(new Private()) { d->prefix = other.d->prefix; d->suffix = other.d->suffix; d->formatSpecification = other.d->formatSpecification; d->letterSynchronization = other.d->letterSynchronization; } KoOdfNumberDefinition &KoOdfNumberDefinition::operator=(const KoOdfNumberDefinition &other) { d->prefix = other.d->prefix; d->suffix = other.d->suffix; d->formatSpecification = other.d->formatSpecification; d->letterSynchronization = other.d->letterSynchronization; return *this; } KoOdfNumberDefinition::~KoOdfNumberDefinition() { delete d; } QStringList KoOdfNumberDefinition::userFormatDescriptions() { QStringList list; list << "1, 2, 3, ..." << "a, b, c, ..." << "A, B, C, ..." << "i, ii, iii, ..." << "I, II, III, ..." << "أ, ب, ت, ..." << "ก, ข, ค, ..." << "౧, ౨, ౩, ..." << "௧, ௨, ௪, ..." << "୧, ୨, ୩, ..." << "൧, ൨, ൩, ..." << "೧, ೨, ೩, ..." << "੧, ੨, ੩, ..." << "૧, ૨, ૩, ..." << "১, ২, ৩, ..."; return list; } void KoOdfNumberDefinition::loadOdf(const KoXmlElement &element) { const QString format = element.attributeNS(KoXmlNS::style, "num-format", QString()); if (format.isEmpty()) { //do nothing fall back to what we had. } else if (format[0] == '1') { d->formatSpecification = Numeric; } else if (format[0] == 'a') { d->formatSpecification = AlphabeticLowerCase; } else if (format[0] == 'A') { d->formatSpecification = AlphabeticUpperCase; } else if (format[0] == 'i') { d->formatSpecification = RomanLowerCase; } else if (format[0] == 'I') { d->formatSpecification = RomanUpperCase; } else if (format == QString::fromUtf8("أ, ب, ت, ...")){ d->formatSpecification = ArabicAlphabet; } else if (format == QString::fromUtf8("ก, ข, ค, ...")){ d->formatSpecification = Thai; } else if (format == QString::fromUtf8("أ, ب, ج, ...")) { d->formatSpecification = Abjad; } else if (format == QString::fromUtf8("ﺃ,ﺏ, ﺝ, ... ")) { d->formatSpecification = AbjadMinor; } else if (format == QString::fromUtf8("౧, ౨, ౩, ...")) { d->formatSpecification = Telugu; } else if (format == QString::fromUtf8("௧, ௨, ௪, ...")) { d->formatSpecification = Tamil; } else if (format == QString::fromUtf8("୧, ୨, ୩, ...")) { d->formatSpecification = Oriya; } else if (format == QString::fromUtf8("൧, ൨, ൩, ...")) { d->formatSpecification = Malayalam; } else if (format == QString::fromUtf8("೧, ೨, ೩, ...")) { d->formatSpecification = Kannada; } else if (format == QString::fromUtf8("੧, ੨, ੩, ...")) { d->formatSpecification = Gurumukhi; } else if (format == QString::fromUtf8("૧, ૨, ૩, ...")) { d->formatSpecification = Gujarati; } else if (format == QString::fromUtf8("১, ২, ৩, ...")) { d->formatSpecification = Bengali; } else { d->formatSpecification = Numeric; } //The style:num-prefix and style:num-suffix attributes specify what to display before and after the number. d->prefix = element.attributeNS(KoXmlNS::style, "num-prefix", d->prefix); d->suffix = element.attributeNS(KoXmlNS::style, "num-suffix", d->suffix); d->letterSynchronization = (element.attributeNS(KoXmlNS::style, "num-letter-sync", d->letterSynchronization ? "true" : "false") == "true"); } void KoOdfNumberDefinition::saveOdf(KoXmlWriter *writer) const { if (!d->prefix.isNull()) { writer->addAttribute("style:num-prefix", d->prefix); } if (!d->suffix.isNull()) { writer->addAttribute("style:num-suffix", d->suffix); } QByteArray format; switch(d->formatSpecification) { case Numeric: format = "1"; break; case AlphabeticLowerCase: format = "a"; break; case AlphabeticUpperCase: format = "A"; break; case RomanLowerCase: format = "i"; break; case RomanUpperCase: format = "I"; break; case ArabicAlphabet: format = "أ, ب, ت, ..."; break; case Thai: format = "ก, ข, ค, ..."; break; case Telugu: format = "౧, ౨, ౩, ..."; break; case Tamil: format = "௧, ௨, ௪, ..."; break; case Oriya: format = "୧, ୨, ୩, ..."; break; case Malayalam: format = "൧, ൨, ൩, ..."; break; case Kannada: format = "೧, ೨, ೩, ..."; break; case Gurumukhi: format = "੧, ੨, ੩, ..."; break; case Gujarati: format = "૧, ૨, ૩, ..."; break; case Bengali: format = "১, ২, ৩, ..."; break; case Empty: default: ; }; if (!format.isNull()) { writer->addAttribute("style:num-format", format); } if (d->letterSynchronization) { writer->addAttribute("style:num-letter-sync", "true"); } } static QString intToRoman(int n) { static const QString RNUnits[] = {"", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"}; static const QString RNTens[] = {"", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc"}; static const QString RNHundreds[] = {"", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm"}; static const QString RNThousands[] = {"", "m", "mm", "mmm", "mmmm", "mmmmm", "mmmmmm", "mmmmmmm", "mmmmmmmm", "mmmmmmmmm"}; if (n <= 0) { return QString::number(n); } return RNThousands[(n / 1000)] + RNHundreds[(n / 100) % 10 ] + RNTens[(n / 10) % 10 ] + RNUnits[(n) % 10 ]; } static QString intToAlpha(int n, bool letterSynchronization) { QString answer; if (letterSynchronization) { int digits = 1; for (; n > 26; n -= 26) digits += 1; for (int i = 0; i < digits; i++) answer.prepend(QChar('a' + n - 1)); return answer; } else { char bottomDigit; while (n > 26) { bottomDigit = (n - 1) % 26; n = (n - 1) / 26; answer.prepend(QChar('a' + bottomDigit)); } } answer.prepend(QChar('a' + n - 1)); return answer; } static QString intToScript(int n, int offset) { // 10-base QString answer; while (n > 0) { answer.prepend(QChar(offset + n % 10)); n = n / 10; } return answer; } static QString intToScriptList(int n, KoOdfNumberDefinition::FormatSpecification formatSpecification) { // 1 time Sequences // note; the leading X is to make these 1 based. static const char* const Abjad[] = { "أ", "ب", "ج", "د", "ﻫ", "و", "ز", "ح", "ط", "ي", "ك", "ل", "م", "ن", "س", "ع", "ف", "ص", "ق", "ر", "ش", "ت", "ث", "خ", "ذ", "ض", "ظ", "غ" }; static const char* const Abjad2[] = { "ﺃ", "ﺏ", "ﺝ", "ﺩ", "ﻫ", "ﻭ", "ﺯ", "ﺡ", "ﻁ", "ﻱ", "ﻙ", "ﻝ", "ﻡ", "ﻥ", "ﺹ", "ﻉ", "ﻑ", "ﺽ", "ﻕ", "ﺭ", "ﺱ", "ﺕ", "ﺙ", "ﺥ", "ﺫ", "ﻅ", "ﻍ", "ﺵ" }; static const char* const ArabicAlphabet[] = {"ا", "ب", "ت", "ث", "ج", "ح", "خ", "د", "ذ", "ر", "ز", "س", "ش", "ص", "ض", "ط", "ظ", "ع", "غ", "ف", "ق", "ك", "ل", "م", "ن", "ه", "و", "ي" }; /* // see this page for the 10, 100, 1000 etc http://en.wikipedia.org/wiki/Chinese_numerals static const char* const chinese1[] = { '零','壹','貳','叄','肆','伍','陸','柒','捌','玖' }; static const char* const chinese2[] = { '〇','一','二','三','四','五','六','七','八','九' }; - TODO: http://en.wikipedia.org/wiki/Korean_numerals - http://en.wikipedia.org/wiki/Japanese_numerals - 'http://en.wikipedia.org/wiki/Hebrew_numerals' - 'http://en.wikipedia.org/wiki/Armenian_numerals' - 'http://en.wikipedia.org/wiki/Greek_numerals' - 'http://en.wikipedia.org/wiki/Cyrillic_numerals' - 'http://en.wikipedia.org/wiki/Sanskrit_numerals' - 'http://en.wikipedia.org/wiki/Ge%27ez_alphabet#Numerals' - 'http://en.wikipedia.org/wiki/Abjad_numerals' + TODO: https://en.wikipedia.org/wiki/Korean_numerals + https://en.wikipedia.org/wiki/Japanese_numerals + 'https://en.wikipedia.org/wiki/Hebrew_numerals' + 'https://en.wikipedia.org/wiki/Armenian_numerals' + 'https://en.wikipedia.org/wiki/Greek_numerals' + 'https://en.wikipedia.org/wiki/Cyrillic_numerals' + 'https://en.wikipedia.org/wiki/Sanskrit_numerals' + 'https://en.wikipedia.org/wiki/Ge%27ez_alphabet#Numerals' + 'https://en.wikipedia.org/wiki/Abjad_numerals' */ switch (formatSpecification) { case KoOdfNumberDefinition::Abjad: if (n > 22) return "*"; return QString::fromUtf8(Abjad[n-1]); case KoOdfNumberDefinition::AbjadMinor: if (n > 22) return "*"; return QString::fromUtf8(Abjad2[n-1]); case KoOdfNumberDefinition::ArabicAlphabet: if (n > 28) return "*"; return QString::fromUtf8(ArabicAlphabet[n-1]); default: return QString::number(n); } } QString KoOdfNumberDefinition::formattedNumber(int number, KoOdfNumberDefinition *defaultDefinition) const { switch(d->formatSpecification) { case Numeric: return QString::number(number); break; case AlphabeticLowerCase: return intToAlpha(number, d->letterSynchronization); case AlphabeticUpperCase: return intToAlpha(number, d->letterSynchronization).toUpper(); case RomanLowerCase: return intToRoman(number); case RomanUpperCase: return intToRoman(number).toUpper(); case Thai: return intToScript(number, 0xe50); case Tibetan: return intToScript(number, 0xf20); case Telugu: return intToScript(number, 0xc66); case Tamil: return intToScript(number, 0x0be6); case Oriya: return intToScript(number, 0xb66); case Malayalam: return intToScript(number, 0xd66); case Kannada: return intToScript(number, 0xce6); case Gurumukhi: return intToScript(number, 0xa66); case Gujarati: return intToScript(number, 0xae6); case Bengali: return intToScript(number, 0x9e6); case Abjad: case AbjadMinor: case ArabicAlphabet: return intToScriptList(number, d->formatSpecification); case Empty: if (defaultDefinition) { return defaultDefinition->formattedNumber(number); } break; default: ; }; return ""; } QString KoOdfNumberDefinition::prefix() const { return d->prefix; } void KoOdfNumberDefinition::setPrefix(const QString &prefix) { d->prefix = prefix; } QString KoOdfNumberDefinition::suffix() const { return d->suffix; } void KoOdfNumberDefinition::setSuffix(const QString &suffix) { d->suffix = suffix; } KoOdfNumberDefinition::FormatSpecification KoOdfNumberDefinition::formatSpecification() const { return d->formatSpecification; } void KoOdfNumberDefinition::setFormatSpecification(FormatSpecification formatSpecification) { d->formatSpecification = formatSpecification; } bool KoOdfNumberDefinition::letterSynchronization() const { return d->letterSynchronization; } void KoOdfNumberDefinition::setLetterSynchronization(bool letterSynchronization) { d->letterSynchronization = letterSynchronization; } diff --git a/src/libs/odf/KoPageFormat.cpp b/src/libs/odf/KoPageFormat.cpp index 7be9a51f..566649be 100644 --- a/src/libs/odf/KoPageFormat.cpp +++ b/src/libs/odf/KoPageFormat.cpp @@ -1,189 +1,189 @@ /* This file is part of the KDE project Copyright (C) 1998, 1999 Torben Weis Copyright 2002, 2003 David Faure Copyright 2003 Nicolas GOUTTE Copyright 2007 Thomas Zander This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "KoPageFormat.h" #include #include // paper formats (mm) #define PG_A3_WIDTH 297.0 #define PG_A3_HEIGHT 420.0 #define PG_A4_WIDTH 210.0 #define PG_A4_HEIGHT 297.0 #define PG_A5_WIDTH 148.0 #define PG_A5_HEIGHT 210.0 #define PG_B5_WIDTH 182.0 #define PG_B5_HEIGHT 257.0 #define PG_US_LETTER_WIDTH 216.0 #define PG_US_LETTER_HEIGHT 279.0 #define PG_US_LEGAL_WIDTH 216.0 #define PG_US_LEGAL_HEIGHT 356.0 #define PG_US_EXECUTIVE_WIDTH 191.0 #define PG_US_EXECUTIVE_HEIGHT 254.0 // To ignore the clang warning we get because we have a // for (int i = 0; pageFormatInfo[i].format != -1 ;i++) // construct and pageFormatInfo has (KoPageFormat::Format) - 1 #if defined(__clang__) #pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare" #endif struct PageFormatInfo { KoPageFormat::Format format; QPrinter::PageSize qprinter; const char* shortName; // Short name const char* descriptiveName; // Full name, which will be translated qreal width; // in mm qreal height; // in mm }; // NOTES: // - the width and height of non-ISO formats are rounded -// http://en.wikipedia.org/wiki/Paper_size can help +// https://en.wikipedia.org/wiki/Paper_size can help // - the comments "should be..." indicates the exact values if the inch sizes would be multiplied by 25.4 mm/inch const PageFormatInfo pageFormatInfo[] = { { KoPageFormat::IsoA3Size, QPrinter::A3, "A3", I18N_NOOP2("Page size", "ISO A3"), 297.0, 420.0 }, { KoPageFormat::IsoA4Size, QPrinter::A4, "A4", I18N_NOOP2("Page size", "ISO A4"), 210.0, 297.0 }, { KoPageFormat::IsoA5Size, QPrinter::A5, "A5", I18N_NOOP2("Page size", "ISO A5"), 148.0, 210.0 }, { KoPageFormat::UsLetterSize, QPrinter::Letter, "Letter", I18N_NOOP2("Page size", "US Letter"), 215.9, 279.4 }, { KoPageFormat::UsLegalSize, QPrinter::Legal, "Legal", I18N_NOOP2("Page size", "US Legal"), 215.9, 355.6 }, { KoPageFormat::ScreenSize, QPrinter::A4, "Screen", I18N_NOOP2("Page size", "Screen"), PG_A4_HEIGHT, PG_A4_WIDTH }, // Custom, so fall back to A4 { KoPageFormat::CustomSize, QPrinter::A4, "Custom", I18N_NOOP2("Page size", "Custom"), PG_A4_WIDTH, PG_A4_HEIGHT }, // Custom, so fall back to A4 { KoPageFormat::IsoB5Size, QPrinter::B5, "B5", I18N_NOOP2("Page size", "ISO B5"), 182.0, 257.0 }, { KoPageFormat::UsExecutiveSize, QPrinter::Executive, "Executive", I18N_NOOP2("Page size", "US Executive"), 191.0, 254.0 }, // should be 190.5 mm x 254.0 mm { KoPageFormat::IsoA0Size, QPrinter::A0, "A0", I18N_NOOP2("Page size", "ISO A0"), 841.0, 1189.0 }, { KoPageFormat::IsoA1Size, QPrinter::A1, "A1", I18N_NOOP2("Page size", "ISO A1"), 594.0, 841.0 }, { KoPageFormat::IsoA2Size, QPrinter::A2, "A2", I18N_NOOP2("Page size", "ISO A2"), 420.0, 594.0 }, { KoPageFormat::IsoA6Size, QPrinter::A6, "A6", I18N_NOOP2("Page size", "ISO A6"), 105.0, 148.0 }, { KoPageFormat::IsoA7Size, QPrinter::A7, "A7", I18N_NOOP2("Page size", "ISO A7"), 74.0, 105.0 }, { KoPageFormat::IsoA8Size, QPrinter::A8, "A8", I18N_NOOP2("Page size", "ISO A8"), 52.0, 74.0 }, { KoPageFormat::IsoA9Size, QPrinter::A9, "A9", I18N_NOOP2("Page size", "ISO A9"), 37.0, 52.0 }, { KoPageFormat::IsoB0Size, QPrinter::B0, "B0", I18N_NOOP2("Page size", "ISO B0"), 1030.0, 1456.0 }, { KoPageFormat::IsoB1Size, QPrinter::B1, "B1", I18N_NOOP2("Page size", "ISO B1"), 728.0, 1030.0 }, { KoPageFormat::IsoB10Size, QPrinter::B10, "B10", I18N_NOOP2("Page size", "ISO B10"), 32.0, 45.0 }, { KoPageFormat::IsoB2Size, QPrinter::B2, "B2", I18N_NOOP2("Page size", "ISO B2"), 515.0, 728.0 }, { KoPageFormat::IsoB3Size, QPrinter::B3, "B3", I18N_NOOP2("Page size", "ISO B3"), 364.0, 515.0 }, { KoPageFormat::IsoB4Size, QPrinter::B4, "B4", I18N_NOOP2("Page size", "ISO B4"), 257.0, 364.0 }, { KoPageFormat::IsoB6Size, QPrinter::B6, "B6", I18N_NOOP2("Page size", "ISO B6"), 128.0, 182.0 }, { KoPageFormat::IsoC5Size, QPrinter::C5E, "C5", I18N_NOOP2("Page size", "ISO C5"), 163.0, 229.0 }, // Some sources tells: 162 mm x 228 mm { KoPageFormat::UsComm10Size, QPrinter::Comm10E, "Comm10", I18N_NOOP2("Page size", "US Common 10"), 105.0, 241.0 }, // should be 104.775 mm x 241.3 mm { KoPageFormat::IsoDLSize, QPrinter::DLE, "DL", I18N_NOOP2("Page size", "ISO DL"), 110.0, 220.0 }, { KoPageFormat::UsFolioSize, QPrinter::Folio, "Folio", I18N_NOOP2("Page size", "US Folio"), 210.0, 330.0 }, // should be 209.54 mm x 330.2 mm { KoPageFormat::UsLedgerSize, QPrinter::Ledger, "Ledger", I18N_NOOP2("Page size", "US Ledger"), 432.0, 279.0 }, // should be 431.8 mm x 297.4 mm { KoPageFormat::UsTabloidSize, QPrinter::Tabloid, "Tabloid", I18N_NOOP2("Page size", "US Tabloid"), 279.0, 432.0 }, // should be 297.4 mm x 431.8 mm {(KoPageFormat::Format) - 1, (QPrinter::PageSize) - 1, "", "", -1, -1 } }; QPrinter::PageSize KoPageFormat::printerPageSize(KoPageFormat::Format format) { if (format == ScreenSize) { warnOdf << "You use the page layout SCREEN. Printing in ISO A4 Landscape."; return QPrinter::A4; } if (format == CustomSize) { warnOdf << "The used page layout (Custom) is not supported by KQPrinter. Printing in A4."; return QPrinter::A4; } return pageFormatInfo[ format ].qprinter; } qreal KoPageFormat::width(Format format, Orientation orientation) { if (orientation == Landscape) return height(format, Portrait); return pageFormatInfo[ format ].width; } qreal KoPageFormat::height(Format format, Orientation orientation) { if (orientation == Landscape) return width(format, Portrait); return pageFormatInfo[ format ].height; } KoPageFormat::Format KoPageFormat::guessFormat(qreal width, qreal height) { for (int i = 0; pageFormatInfo[i].format != -1 ;i++) { // We have some tolerance. 1pt is a third of a mm, this is // barely noticeable for a page size. if (qAbs(width - pageFormatInfo[i].width) < 1.0 && qAbs(height - pageFormatInfo[i].height) < 1.0) return pageFormatInfo[i].format; } return CustomSize; } QString KoPageFormat::formatString(Format format) { return QString::fromLatin1(pageFormatInfo[ format ].shortName); } KoPageFormat::Format KoPageFormat::formatFromString(const QString & string) { for (int i = 0; pageFormatInfo[i].format != -1 ;i++) { if (string == QString::fromLatin1(pageFormatInfo[ i ].shortName)) return pageFormatInfo[ i ].format; } // We do not know the format name, so we have a custom format return CustomSize; } KoPageFormat::Format KoPageFormat::defaultFormat() { int qprinter; if (QLocale().measurementSystem() == QLocale::ImperialSystem) { qprinter = (int)QPageSize::Letter; } else { qprinter = (int)QPageSize::A4; } for (int i = 0; pageFormatInfo[i].format != -1 ;i++) { if (pageFormatInfo[ i ].qprinter == qprinter) return static_cast(i); } return IsoA4Size; } QString KoPageFormat::name(Format format) { return i18nc("Page size", pageFormatInfo[ format ].descriptiveName); } QStringList KoPageFormat::localizedPageFormatNames() { QStringList lst; for (int i = 0; pageFormatInfo[i].format != -1 ;i++) { lst << i18nc("Page size", pageFormatInfo[ i ].descriptiveName); } return lst; } QStringList KoPageFormat::pageFormatNames() { QStringList lst; for (int i = 0; pageFormatInfo[i].format != -1 ;i++) { lst << pageFormatInfo[ i ].shortName; } return lst; } diff --git a/src/libs/ui/locale/localemon.cpp b/src/libs/ui/locale/localemon.cpp index 514a4972..5c2dc991 100644 --- a/src/libs/ui/locale/localemon.cpp +++ b/src/libs/ui/locale/localemon.cpp @@ -1,134 +1,134 @@ /* * localemon.cpp * * Copyright (c) 1999-2003 Hans Petter Bieker * Copyright (c) 2009, 2012 Dag Andersen * Copyright (C) 2016 Dag Andersen * * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ + * https://qt.io/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg //#include "toplevel.h" #include "localemon.h" #include "kptlocale.h" #include "kptcommand.h" #include "kptdebug.h" #include #include #include #include #include #include namespace KPlato { LocaleConfigMoney::LocaleConfigMoney(Locale *locale, QWidget *parent) : QWidget(parent), m_locale(locale) { setupUi(this); // Money m_labMonCurSym->setObjectName(I18N_NOOP("Currency symbol:")); m_labMonFraDig->setObjectName(I18N_NOOP("Fract digits:")); connect(m_edMonCurSym,&QLineEdit::textChanged,this, &LocaleConfigMoney::slotMonCurSymChanged); connect(m_inMonFraDig,SIGNAL(valueChanged(int)),SLOT(slotMonFraDigChanged(int))); m_inMonFraDig->setRange(0, 10); m_inMonFraDig->setSingleStep(1); slotTranslate(); slotLocaleChanged(); } LocaleConfigMoney::~LocaleConfigMoney() { } void LocaleConfigMoney::slotLocaleChanged() { m_edMonCurSym->setText(m_locale->currencySymbolExplicit()); m_inMonFraDig->setValue(m_locale->monetaryDecimalPlaces()); } void LocaleConfigMoney::slotMonCurSymChanged(const QString &/*t*/) { emit localeChanged(); } void LocaleConfigMoney::slotMonFraDigChanged(int /*value*/) { emit localeChanged(); } void LocaleConfigMoney::slotMonPosPreCurSymChanged() { emit localeChanged(); } void LocaleConfigMoney::slotMonNegPreCurSymChanged() { emit localeChanged(); } void LocaleConfigMoney::slotMonPosMonSignPosChanged(int /*i*/) { emit localeChanged(); } void LocaleConfigMoney::slotMonNegMonSignPosChanged(int /*i*/) { emit localeChanged(); } void LocaleConfigMoney::slotTranslate() { QString str; str = i18n("Here you can enter your usual currency " "symbol, e.g. $ or €."); m_labMonCurSym->setWhatsThis(str); m_edMonCurSym->setWhatsThis(str); } MacroCommand *LocaleConfigMoney::buildCommand() { MacroCommand *m = new MacroCommand(); if (m_locale->currencySymbolExplicit() != m_edMonCurSym->text()) { m->addCommand(new ModifyCurrencySymolCmd(m_locale, m_edMonCurSym->text())); } if (m_locale->monetaryDecimalPlaces() != m_inMonFraDig->value()) { m->addCommand(new ModifyCurrencyFractionalDigitsCmd(m_locale, m_inMonFraDig->value())); } debugPlan<<"buildCommand:"<isEmpty(); if (m->isEmpty()) { delete m; return 0; } return m; } } // namespace KPlato diff --git a/src/libs/ui/locale/localemon.h b/src/libs/ui/locale/localemon.h index 0721cc90..dff808b8 100644 --- a/src/libs/ui/locale/localemon.h +++ b/src/libs/ui/locale/localemon.h @@ -1,81 +1,81 @@ /* * localemon.h * * Copyright (c) 1999-2003 Hans Petter Bieker * Copyright (c) 2007 Dag Andersen * Copyright (C) 2016 Dag Andersen * * Requires the Qt widget libraries, available at no cost at - * http://www.troll.no/ + * https://qt.io/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPLATO_LOCALEMON_H #define KPLATO_LOCALEMON_H #include "planui_export.h" #include "ui_localemon.h" namespace KPlato { class MacroCommand; class Locale; class PLANUI_EXPORT LocaleConfigMoney : public QWidget, Ui::LocaleConfigMoney { Q_OBJECT public: LocaleConfigMoney(Locale *locale, QWidget *parent); ~LocaleConfigMoney() override; /// Save all changes MacroCommand *buildCommand(); public Q_SLOTS: /** * Loads all settings from the current locale into the current widget. */ void slotLocaleChanged(); /** * Retranslate all objects owned by this object using the current locale. */ void slotTranslate(); Q_SIGNALS: void localeChanged(); private Q_SLOTS: // Money void slotMonCurSymChanged(const QString &t); /* void slotMonDecSymChanged(const QString &t); void slotMonThoSepChanged(const QString &t);*/ void slotMonFraDigChanged(int value); void slotMonPosPreCurSymChanged(); void slotMonNegPreCurSymChanged(); void slotMonPosMonSignPosChanged(int i); void slotMonNegMonSignPosChanged(int i); // void slotMonDigSetChanged(int i); private: Locale *m_locale; }; } // namespace KPlato #endif // LOCALEMON_H diff --git a/src/main.cpp b/src/main.cpp index 3b807381..d6315893 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,58 +1,58 @@ /* This file is part of the KDE project Copyright (C) 2001 Thomas zander This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "kptaboutdata.h" #include "kptmaindocument.h" #include #include #include #include extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) { /** * Disable debug output by default, only log warnings. * Debug logs can be controlled by the environment variable QT_LOGGING_RULES. * * For example, to get full debug output, run the following: * QT_LOGGING_RULES="calligra.*=true" calligraplan * - * See: http://doc.qt.io/qt-5/qloggingcategory.html + * See: https://doc.qt.io/qt-5/qloggingcategory.html */ QLoggingCategory::setFilterRules("calligra.*.debug=false\n" "calligra.*.warning=true"); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); KoApplication app(PLAN_MIME_TYPE, QStringLiteral("calligraplan"), KPlato::newAboutData, argc, argv); // Migrate data from kde4 to kf5 locations Calligra2Migration m("calligraplan", "plan"); m.setConfigFiles(QStringList() << QStringLiteral("planrc")); m.setUiFiles(QStringList() << QStringLiteral("plan.rc") << QStringLiteral("plan_readonly.rc")); m.migrate(); if (!app.start()) { return 1; } return app.exec(); } diff --git a/src/org.kde.calligraplan.desktop b/src/org.kde.calligraplan.desktop index ebc76607..9cc34060 100644 --- a/src/org.kde.calligraplan.desktop +++ b/src/org.kde.calligraplan.desktop @@ -1,53 +1,53 @@ [Desktop Entry] Name=Plan Name[ca]=Plan Name[ca@valencia]=Plan Name[cs]=Plan Name[de]=Plan Name[en_GB]=Plan Name[es]=Plan Name[fr]=Plan Name[gl]=Plan Name[id]=Plan Name[it]=Plan Name[nl]=Plan Name[pl]=Plan Name[pt]=Plan Name[pt_BR]=Plan Name[ru]=Plan Name[sk]=Plan Name[sv]=Plan Name[uk]=Plan Name[x-test]=xxPlanxx Name[zh_CN]=Plan GenericName=Project Management GenericName[ca]=Gestió de projectes GenericName[ca@valencia]=Gestió de projectes GenericName[cs]=Správa projektů GenericName[de]=Projektmanagement GenericName[en_GB]=Project Management GenericName[es]=Gestión de proyectos GenericName[fr]=Gestion de projets GenericName[gl]=Xestión de proxectos GenericName[id]=Pengelolaan Projek GenericName[it]=Gestione dei progetti GenericName[nl]=Projectbeheer GenericName[pl]=Zarządzanie projektami GenericName[pt]=Gestão de Projectos GenericName[pt_BR]=Gerenciamento de projetos GenericName[ru]=Управление проектами GenericName[sk]=Správa projektov GenericName[sv]=Projekthantering GenericName[uk]=Керування проєктами GenericName[x-test]=xxProject Managementxx GenericName[zh_CN]=工程管理 Exec=calligraplan %U MimeType=application/x-vnd.kde.plan; Type=Application Icon=calligraplan -DocPath=http://userbase.kde.org/Special:MyLanguage/Plan/Manual +DocPath=https://userbase.kde.org/Special:MyLanguage/Plan/Manual X-KDE-NativeMimeType=application/x-vnd.kde.plan Categories=Qt;KDE;Office;ProjectManagement; X-KDE-StartupNotify=true X-DBUS-StartupType=Multi X-DBUS-ServiceName=org.kde.calligraplan diff --git a/src/workpackage/main.cpp b/src/workpackage/main.cpp index 12af06e1..1e0f4ea4 100644 --- a/src/workpackage/main.cpp +++ b/src/workpackage/main.cpp @@ -1,66 +1,66 @@ /* This file is part of the KDE project Copyright (C) 2001 Thomas zander This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "commandlineparser.h" #include #include #include #include #include extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) { QApplication app(argc, argv); #ifdef Q_OS_MACOS // app.applicationName() will return "Plan Work" because of the nice name // set in the Info.plist. DBus doesn't like the resulting space in the // service name, so reset the application name: app.setApplicationName("calligraplanwork"); #endif KDBusService service(KDBusService::Unique); // we come here only once... /** * Disable debug output by default, only log warnings. * Debug logs can be controlled by the environment variable QT_LOGGING_RULES. * * For example, to get full debug output, run the following: * QT_LOGGING_RULES="calligra.planwork=true" calligraplan * - * See: http://doc.qt.io/qt-5/qloggingcategory.html + * See: https://doc.qt.io/qt-5/qloggingcategory.html */ QLoggingCategory::setFilterRules("calligra.plan*.debug=false\n" "calligra.plan*.warning=true"); // Migrate data from kde4 to kf5 locations Calligra2Migration m("calligraplanwork", "planwork"); m.setConfigFiles(QStringList() << QStringLiteral("planworkrc")); m.setUiFiles(QStringList() << QStringLiteral("planwork.rc") << QStringLiteral("planwork_readonly.rc") << QStringLiteral("planworkui.rc")); m.migrate(); CommandLineParser cmd; QObject::connect(&service, &KDBusService::activateRequested, &cmd, &CommandLineParser::handleActivateRequest); cmd.handleCommandLine(QDir::current()); return app.exec(); }