Hello community, here is the log from the commit of package parley5 for openSUSE:Factory checked in at 2015-03-11 09:56:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/parley5 (Old) and /work/SRC/openSUSE:Factory/.parley5.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "parley5" Changes: -------- --- /work/SRC/openSUSE:Factory/parley5/parley5.changes 2015-02-11 16:43:52.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.parley5.new/parley5.changes 2015-03-11 09:56:37.000000000 +0100 @@ -1,0 +2,7 @@ +Tue Mar 3 10:50:53 UTC 2015 - [email protected] + +- Update to KDE Applications 14.12.3 + * KDE Applications 14.12.3 + * See https://www.kde.org/announcements/announce-applications-14.12.3.php + +------------------------------------------------------------------- Old: ---- parley-14.12.2.tar.xz New: ---- parley-14.12.3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ parley5.spec ++++++ --- /var/tmp/diff_new_pack.qH8akL/_old 2015-03-11 09:56:38.000000000 +0100 +++ /var/tmp/diff_new_pack.qH8akL/_new 2015-03-11 09:56:38.000000000 +0100 @@ -17,7 +17,7 @@ Name: parley5 -Version: 14.12.2 +Version: 14.12.3 Release: 0 Summary: Vocabulary Trainer License: GPL-2.0+ ++++++ parley-14.12.2.tar.xz -> parley-14.12.3.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/parley.appdata.xml new/parley-14.12.3/parley.appdata.xml --- old/parley-14.12.2/parley.appdata.xml 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/parley.appdata.xml 2015-02-22 12:05:47.000000000 +0100 @@ -4,6 +4,7 @@ <metadata_license>CC0-1.0</metadata_license> <project_license>GPL-2.0+</project_license> <name>Parley</name> + <name xml:lang="bs">Parley</name> <name xml:lang="ca">Parley</name> <name xml:lang="cs">Parley</name> <name xml:lang="de">Parley</name> @@ -23,8 +24,10 @@ <name xml:lang="sv">Parley</name> <name xml:lang="uk">Parley</name> <name xml:lang="x-test">xxParleyxx</name> + <name xml:lang="zh-CN">Parley</name> <name xml:lang="zh-TW">語言_Parley</name> <summary>Vocabulary Trainer</summary> + <summary xml:lang="bs">Trener riječnika</summary> <summary xml:lang="ca">Entrenador de vocabulari</summary> <summary xml:lang="cs">Učitel slovní zásoby</summary> <summary xml:lang="de">Vokabeltrainer</summary> @@ -47,6 +50,7 @@ <summary xml:lang="zh-TW">字彙訓練師</summary> <description> <p>Parley is a vocabulary trainer. It helps you to memorize your vocabulary, for example when you are trying to learn a foreign language. It supports many language specific features, but can be used for other learning tasks as well. It uses the spaced repetition learning method, which makes learning optimal. Vocabulary collections can be downloaded by "Get Hot New Stuff" or created with the built-in editor.</p> + <p xml:lang="bs">Parlej je trener rječnika. Pomaže vam da zapamtite svoj rječnik, na primer, kada pokušavate da naučite strani jezik. On podržava mnoge jezičke specifičnosti, ali se može koristiti za druge zadatke učenja jednako dobro. On koristi raspoređeni metod ponavljanja učenja , što čini učenje optimalno. Vokabular kolekcije možete preuzeti sa "Dobavi nove dobre stvari" ili kreirati sa ugrađenim urednikom.</p> <p xml:lang="ca">El Parley és un entrenador de vocabulari. Us ajuda a memoritzar vocabulari, per exemple quan esteu intentant aprendre un idioma estranger. Accepta moltes funcionalitats específiques d'idioma, però també es pot utilitzar per altres tasques d'aprenentatge. Utilitza el mètode d'aprenentatge de repetició espaiada, que optimitza l'aprenentatge. Les col·leccions dels vocabularis es poden baixar amb «Obtén les novetats» (Get Hot New Stuff) o es poden crear amb l'editor integrat.</p> <p xml:lang="en-GB">Parley is a vocabulary trainer. It helps you to memorise your vocabulary, for example when you are trying to learn a foreign language. It supports many language specific features, but can be used for other learning tasks as well. It uses the spaced repetition learning method, which makes learning optimal. Vocabulary collections can be downloaded by "Get Hot New Stuff" or created with the built-in editor.</p> <p xml:lang="es">Parley es un entrenador de vocabulario. Ayuda a memorizar vocabulario, por ejemplo, cuando se está intentando aprender un idioma extranjero. Cuenta con muchas funcionalidades específicas para los idiomas, pero también se puede utilizar para otras tareas de aprendizaje. Utiliza el método de repetición espaciada, que proporciona un aprendizaje óptimo. Las colecciones de vocabulario se pueden descargar mediante la opción «Obtener nuevo material» o crear mediante el editor incorporado.</p> @@ -65,6 +69,7 @@ <p xml:lang="x-test">xxParley is a vocabulary trainer. It helps you to memorize your vocabulary, for example when you are trying to learn a foreign language. It supports many language specific features, but can be used for other learning tasks as well. It uses the spaced repetition learning method, which makes learning optimal. Vocabulary collections can be downloaded by "Get Hot New Stuff" or created with the built-in editor.xx</p> <p xml:lang="zh-TW">Parley 是一套字彙訓練程式。它能協助您在學習外語時記憶字彙。它支援多種語言功能,也可以用於其他領域的訓練。字彙可以從「取得新禮物」中下載,或是自行透過內建編輯器建立。</p> <p>Training Modes:</p> + <p xml:lang="bs">Režimi treninga</p> <p xml:lang="ca">Modes d'entrenament:</p> <p xml:lang="de">Übungsmodi:</p> <p xml:lang="en-GB">Training Modes:</p> @@ -85,6 +90,7 @@ <p xml:lang="zh-TW">訓練模式:</p> <ul> <li>Flash Cards</li> + <li xml:lang="bs">Memorijske kartice</li> <li xml:lang="ca">Fitxes ràpides</li> <li xml:lang="cs">Kartičky</li> <li xml:lang="de">Karteikarten</li> @@ -106,6 +112,7 @@ <li xml:lang="x-test">xxFlash Cardsxx</li> <li xml:lang="zh-TW">閃卡</li> <li>Mixed Letters (order the letters of a word)</li> + <li xml:lang="bs">Miješana slova (redoslijed slova riječi)</li> <li xml:lang="ca">Lletres barrejades (ordre de les lletres d'una paraula)</li> <li xml:lang="de">Gemischte Buchstaben (Buchstaben in der richtigen Reihenfolge anordnen)</li> <li xml:lang="en-GB">Mixed Letters (order the letters of a word)</li> @@ -125,6 +132,7 @@ <li xml:lang="x-test">xxMixed Letters (order the letters of a word)xx</li> <li xml:lang="zh-TW">混合字母(單字字母順序)</li> <li>Multiple Choice</li> + <li xml:lang="bs">Višestruki izbor</li> <li xml:lang="ca">Elecció múltiple</li> <li xml:lang="cs">S nabídkou možností</li> <li xml:lang="de">Mehrfachauswahl</li> @@ -146,6 +154,7 @@ <li xml:lang="x-test">xxMultiple Choicexx</li> <li xml:lang="zh-TW">多重選擇</li> <li>Written</li> + <li xml:lang="bs">Napisano</li> <li xml:lang="ca">Escrita</li> <li xml:lang="cs">Písemný</li> <li xml:lang="de">Schriftlich</li> @@ -167,6 +176,7 @@ <li xml:lang="x-test">xxWrittenxx</li> <li xml:lang="zh-TW">已寫入</li> <li>Language specific trainings: article, comparison forms, conjugations, synonymes/antonyms/paraphrases</li> + <li xml:lang="bs">Jezički posebna obuka: članovi, oblici poređenja, konjugacija, sinonimi/antonimi/parafraze</li> <li xml:lang="ca">Entrenaments específics d'idioma: article, formes de comparació, conjugacions, sinònims/antònims/paràfrasis</li> <li xml:lang="en-GB">Language specific trainings: article, comparison forms, conjugations, synonymes/antonyms/paraphrases</li> <li xml:lang="es">Entrenamiento específico para idiomas: artículo, formas comparativas, conjugaciones, sinónimos, antónimos y paráfrasis.</li> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/CMakeLists.txt new/parley-14.12.3/src/CMakeLists.txt --- old/parley-14.12.2/src/CMakeLists.txt 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/CMakeLists.txt 2015-02-22 12:05:47.000000000 +0100 @@ -10,6 +10,7 @@ parleyactions.cpp parleydocument.cpp parleymainwindow.cpp + utils.cpp collection/collection.cpp collection/testentry.cpp collection/entryfilter.cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/collection/collection.cpp new/parley-14.12.3/src/collection/collection.cpp --- old/parley-14.12.2/src/collection/collection.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/collection/collection.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -31,51 +31,11 @@ // Parley #include "../config-parley.h" +#include "../utils.h" #include "prefs.h" #include "entryfilter.h" -WordCount::WordCount() -{ - clear(); -} - -void WordCount::clear() -{ - for (int i = 0; i <= KV_MAX_GRADE; ++i) { - grades[i] = 0; - pregrades[i] = 0; - } - invalid = 0; - - initialWords = 0; - totalWords = 0; -} - -int WordCount::percentageCompleted() const -{ - // To calculate the percentage done we add: - // * 1..KV_MAX_GRADE points for words in the initial phase (grade = 0, pregrade > 0) - // * KV_MAX_GRADE * (1..KV_MAX_GRADE) points for words in the long-term phase (grade>0) - // So the maximum number of points is KV_MAX_GRADE^2 per word. - // - // In the final calculation, we exclude all invalid words from the percentage. - int points = 0; - for (int i = 0; i <= KV_MAX_GRADE + 1; ++i) { - points += pregrades[i] * i; - points += grades[i] * KV_MAX_GRADE * i; - } - - if (totalWords - invalid == 0) { - // Don't divide by 0. - return 0; - } - else { - return 100 * points / ((totalWords - invalid) * KV_MAX_GRADE * KV_MAX_GRADE); - } -} - - // ---------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/collection/collection.h new/parley-14.12.3/src/collection/collection.h --- old/parley-14.12.2/src/collection/collection.h 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/collection/collection.h 2015-02-22 12:05:47.000000000 +0100 @@ -28,24 +28,7 @@ class QTimer; - - -// The WordCount struct contains the number of words in each category. -// This could be used for number of words due, total number of words, etc. -struct WordCount { - WordCount(); - void clear(); - int percentageCompleted() const; - - int grades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 - int pregrades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 - int invalid; // Number of invalid entries (not always applicable); - - int initialWords; // Number of entries in initial phase (grade=0, pregrade>0) - // This is the sum of the numbers in pregrades[]. - int totalWords; // Total number of words - // This is the sum of grades[], pregrades[] and invalid -}; +class WordCount; class Collection : public QObject diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/collection/entryfilter.cpp new/parley-14.12.3/src/collection/entryfilter.cpp --- old/parley-14.12.2/src/collection/entryfilter.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/collection/entryfilter.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -110,7 +110,7 @@ m_toTranslation = Prefs::knownLanguage(); } - qDebug() << "Filter for " << m_fromTranslation << " to " << m_toTranslation; + //qDebug() << "Filter for " << m_fromTranslation << " to " << m_toTranslation; expireEntries(pass); collectEntries(pass); @@ -596,7 +596,7 @@ } // switch ++i; } // while - qDebug() << "Invalid items removed. Remaining: " << m_entries[setNo].count(); + //qDebug() << "Invalid items removed. Remaining: " << m_entries[setNo].count(); } QList< TestEntry* > EntryFilter::conjugationTestEntries(bool ignoreBlocked) const diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/collection/readonlycontainermodel.cpp new/parley-14.12.3/src/collection/readonlycontainermodel.cpp --- old/parley-14.12.2/src/collection/readonlycontainermodel.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/collection/readonlycontainermodel.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -45,9 +45,9 @@ beginResetModel(); m_doc = doc; if (m_doc) { - qDebug() << "Set Document: " << m_doc->url(); + //qDebug() << "Set Document: " << m_doc->url(); } else { - qDebug() << "Set Invalid Document"; + //qDebug() << "Set Invalid Document"; } endResetModel(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/dashboard/barwidget.cpp new/parley-14.12.3/src/dashboard/barwidget.cpp --- old/parley-14.12.2/src/dashboard/barwidget.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/dashboard/barwidget.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -29,8 +29,8 @@ #include "collectionwidget.h" // for COLLWIDTH, etc -QColor gradeColor[11]; - +// FIXME: Find a better home for this variable. +ConfidenceColors globalColors = ConfidenceColors(); BarWidget::BarWidget(QWidget *parent) @@ -122,7 +122,7 @@ color = QColor(0, 0, 0, 128); } else { - color = gradeColor[i]; + color = globalColors.longTermColors[i]; } painter.setBrush(QBrush(color)); painter.drawPath(barElementIntersectedPath); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/dashboard/barwidget.h new/parley-14.12.3/src/dashboard/barwidget.h --- old/parley-14.12.2/src/dashboard/barwidget.h 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/dashboard/barwidget.h 2015-02-22 12:05:47.000000000 +0100 @@ -20,13 +20,12 @@ #include <QPaintEvent> #include <QWidget> -#include "collection.h" // For struct WordCount - -class WordCount; +#include "utils.h" +#include "collection.h" // For struct WordCount -extern QColor gradeColor[11]; +extern ConfidenceColors globalColors; class BarWidget : public QWidget diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/dashboard/collectionwidget.cpp new/parley-14.12.3/src/dashboard/collectionwidget.cpp --- old/parley-14.12.2/src/dashboard/collectionwidget.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/dashboard/collectionwidget.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -31,6 +31,7 @@ #include <QtWidgets/QLabel> // Parley +#include "utils.h" #include "collection.h" @@ -98,8 +99,6 @@ : QWidget(parent) , m_collection(collection) { - qDebug() << collection->eduVocDocument()->title(); - setupWidget(dueWords); fillWidget(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/dashboard/dashboard.cpp new/parley-14.12.3/src/dashboard/dashboard.cpp --- old/parley-14.12.2/src/dashboard/dashboard.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/dashboard/dashboard.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -23,6 +23,7 @@ //#include <KMimeType> #include <KActionCollection> +#include "../utils.h" #include "dashboard.h" #include "buttondelegate.h" #include "parleymainwindow.h" @@ -71,22 +72,6 @@ m_practiceSignalMapper = new QSignalMapper(this); m_removeSignalMapper = new QSignalMapper(this); - // Need 8 colors for confidence 0..7. - // FIXME: Find a better color than gray for confidence 1. - // FIXME: Add a color for pregrades. - gradeColor[0] = QColor(25,38,41); - gradeColor[1] = QColor(25,38,41,64); - gradeColor[2] = QColor(237,21,21); - gradeColor[3] = QColor(246,116,0); - gradeColor[4] = QColor(201,206,59); - gradeColor[5] = QColor(28,220,154); - gradeColor[6] = QColor(17,209,22); - gradeColor[7] = QColor(61,174,253); - - // These two are placeholders for the wordcloud background color. - gradeColor[8] = QColor(255,221,217); - gradeColor[9] = QColor(238,232,213); - QTime time = QTime::currentTime(); qsrand((uint)time.msec()); @@ -327,7 +312,7 @@ void Dashboard::slotPracticeButtonClicked(const QString& urlString) { - qDebug() << urlString; + //qDebug() << urlString; QUrl url( QUrl::fromLocalFile(urlString) ); m_openUrl = url; QTimer::singleShot(0, this, SLOT(slotDoubleClickOpen())); @@ -359,7 +344,12 @@ if (!m_mainWindow->parleyDocument()->open(url)) { return; } + + // This used to go to the practice configuration but both I and + //some users wanted to go directly to the practice so I'm testing + //out this for a while. m_mainWindow->showPracticeConfiguration(); + //m_mainWindow->showPractice(); } void Dashboard::backgroundChanged(const QPixmap &pixmap) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/dashboard/gradereferencewidget.cpp new/parley-14.12.3/src/dashboard/gradereferencewidget.cpp --- old/parley-14.12.2/src/dashboard/gradereferencewidget.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/dashboard/gradereferencewidget.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -26,7 +26,7 @@ #include <klocalizedstring.h> // Parley -#include "barwidget.h" // for gradeColor +#include "barwidget.h" // for gradeColor^WglobalColors GradeReferenceWidget::GradeReferenceWidget(QWidget *parent) @@ -55,7 +55,7 @@ QPainterPath barElementPath; barElementPath.addRect(barElement); QPainterPath barElementIntersectedPath = roundedPath.intersected(barElementPath); - QColor color = gradeColor[i]; + QColor color = globalColors.longTermColors[i]; painter.setBrush(QBrush(color)); painter.drawPath(barElementIntersectedPath); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/parleydocument.cpp new/parley-14.12.3/src/parleydocument.cpp --- old/parley-14.12.2/src/parleydocument.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/parleydocument.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -269,7 +269,6 @@ void ParleyDocument::close() { - qDebug() << "Close Document"; enableAutoBackup(false); if (m_doc) { emit documentChanged(0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/statistics/lessonstatisticsview.cpp new/parley-14.12.3/src/statistics/lessonstatisticsview.cpp --- old/parley-14.12.2/src/statistics/lessonstatisticsview.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/statistics/lessonstatisticsview.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -33,9 +33,12 @@ #include "statisticslegendwidget.h" #include "statisticsmodel.h" #include "keduvoclesson.h" -#include "prefs.h" +#include "utils.h" +// GradeDelegate shows the graphic colored bar in the statistics, +// showing how far the student has come on the way to enlightenment. + class GradeDelegate: public QItemDelegate { public: @@ -48,22 +51,23 @@ { QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0); - // empty lesson + // empty lesson? If so, paint nothing. if (!index.data(StatisticsModel::TotalCount).toInt()) { return; } - drawBackground(painter, option, index); + + // Draw the colored bar. + KEduVocContainer *container = index.data(StatisticsModel::Container).value<KEduVocContainer*>(); + WordCount wordCount; + wordCount.fillFromContainer(*container, index.column() - ContainerModel::FirstDataColumn); + ConfidenceColors colors(ConfidenceColors::ProgressiveColorScheme); + + paintColorBar(*painter, option.rect, wordCount, colors); // in utils + + // Draw the text telling the percentage on top of the bar. painter->drawText(option.rect, Qt::AlignCenter, QString("%1%").arg(index.data(StatisticsModel::TotalPercent).toInt())); } - -protected: - void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const - { - QList<QVariant> fractions = index.data(StatisticsModel::LegendFractions).toList(); - StatisticsLegendWidget::paintStatisticsBar(*painter, option.rect, fractions); - } }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/statistics/statisticslegendwidget.cpp new/parley-14.12.3/src/statistics/statisticslegendwidget.cpp --- old/parley-14.12.2/src/statistics/statisticslegendwidget.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/statistics/statisticslegendwidget.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -31,128 +31,27 @@ // Parley #include <keduvocexpression.h> -#include "prefs.h" +#include "utils.h" StatisticsLegendWidget::StatisticsLegendWidget(QWidget * parent) : QWidget(parent) { + ConfidenceColors colors(ConfidenceColors::ProgressiveColorScheme); + QString tooltip; tooltip += "<table><tr><td>"+i18n("Progress gradients")+"</td><td bgcolor=\"" - + gradeColor(KV_MAX_GRADE - 1).name()+"\"><nobr> </nobr></td></tr>" + + colors.longTermColors[KV_MAX_GRADE].name()+"\"><nobr> </nobr></td></tr>" + "<tr><td>"+i18n("Early progress")+"</td><td bgcolor=\"" - + preGradeColor().name()+"\"><nobr> </nobr></td></tr>" + + colors.initialTermColor.name()+"\"><nobr> </nobr></td></tr>" + "<tr><td>"+i18n("Not Practiced")+"</td><td bgcolor=\"" - + unpracticedColor().name()+"\"><nobr> </nobr></td></tr>" + + colors.longTermColors[0].name()+"\"><nobr> </nobr></td></tr>" + "<tr><td>"+i18n("Invalid Entries")+"</td><td bgcolor=\"" - + invalidColor().name()+"\" width=\"15%\"><nobr> </nobr></td></tr></table>"; + + colors.invalidColor.name()+"\" width=\"15%\"><nobr> </nobr></td></tr></table>"; setToolTip(tooltip); } -QColor StatisticsLegendWidget::gradeColor(int grade) -{ - QColor color(Prefs::gradeColor()); - color.setAlpha(alphaMax - (KV_MAX_GRADE - grade - 1) * alphaStep); - return color; -} - -QColor StatisticsLegendWidget::preGradeColor() -{ - QColor color(Prefs::preGradeColor()); - color.setAlpha(alphaMax); - return color; -} - -QColor StatisticsLegendWidget::unpracticedColor() -{ - QColor color("#FFFFFF"); - color.setAlpha(alphaMax); - return color; -} - -QColor StatisticsLegendWidget::invalidColor() -{ - return Prefs::invalidUnitColor(); -} - -QList< QVariant > StatisticsLegendWidget::legendFractions(KEduVocContainer & container, int index) -{ - QVector<double> sums(KV_MAX_GRADE + fractionsOffset + 1, 0); - double count(0); - - // 'index' is the index of the translation inside the KEduVocExpression. - foreach (KEduVocExpression *entry, container.entries(KEduVocContainer::Recursive)) { - KEduVocTranslation & trans(*entry->translation(index)); - ++count; - if (!trans.isEmpty()) { - if (trans.grade() != 0) { - sums[trans.grade() + fractionsOffset - 1] += 1; - } else { - if (trans.preGrade() != 0) { - sums[2] += 1; - } else { - sums[1] += 1; //unpracticed - } - } - } else { - sums[0] += 1; //invalid - } - } - - QList< QVariant > fractions; - for (int ii = 0 ;ii < KV_MAX_GRADE + fractionsOffset; ++ii) { - fractions.push_back((double) (sums[ii] / count)); - } - - return fractions; -} - -void StatisticsLegendWidget::paintStatisticsBar(QPainter &painter, const QRect &rect, - const QList< QVariant> &fractions) -{ - QRect roundedRect(rect); - roundedRect.adjust(1, 1, -1, -1); - QPainterPath roundedPath; - roundedPath.addRoundedRect(roundedRect, 2.0, 2.0); - - QColor color; - int xPosition = 0; - for (int ii = KV_MAX_GRADE + fractionsOffset - 1; ii >= 0; --ii) { - double fraction(fractions[ii].toDouble()); - int barElementWidth = fraction * rect.width(); - QRectF barElement(rect.x() + xPosition, rect.y(), barElementWidth, rect.height()); - QPainterPath barElementPath; - barElementPath.addRect(barElement); - xPosition += barElementWidth; - - // Intersect the QPainterPath of inner rectangle with outer, - // so that the inner rectangle takes the shape of the outer rounded rectangle. - QPainterPath barElementIntersectedPath = roundedPath.intersected(barElementPath); - - if (ii >= fractionsOffset) { - color = StatisticsLegendWidget::gradeColor(ii - fractionsOffset); - } else { - switch (ii) { - case 2: - color = StatisticsLegendWidget::preGradeColor(); - break; - case 1: - color = StatisticsLegendWidget::unpracticedColor(); - break; - case 0: - default: - color = StatisticsLegendWidget::invalidColor(); - break; - } - } - - painter.setBrush(QBrush(color)); - painter.drawPath(barElementIntersectedPath); - } -} - - void StatisticsLegendWidget::paintEvent(QPaintEvent *) { const int legendWidth = 320; @@ -189,13 +88,20 @@ rightRect.moveBottomLeft(QPoint(legendOffsetX + legendWidth + horizontalDistanceFromLegend, legendOffsetY + legendHeight)); + // Draw the legend color bar. QRect rect(x() + legendOffsetX, legendOffsetY, legendWidth, legendHeight); - QList<QVariant> fractions( - QList<QVariant>::fromVector( - QVector<QVariant>(KV_MAX_GRADE + fractionsOffset + 1, - (double) 1.0 / (KV_MAX_GRADE + fractionsOffset)))); - paintStatisticsBar(painter, rect, fractions); + WordCount wordCount; + for (int i = 0; i <= KV_MAX_GRADE; ++i) { + wordCount.grades[i] = 1; + } + wordCount.invalid = 1; + wordCount.initialWords = 1; + wordCount.totalWords = 10; + + ConfidenceColors colors(ConfidenceColors::ProgressiveColorScheme); + paintColorBar(painter, rect, wordCount, colors); + // Draw the legend texts painter.setPen(Qt::black); painter.drawText(leftRect, Qt::AlignRight | Qt::AlignVCenter, leftString); painter.drawText(rightRect, Qt::AlignLeft | Qt::AlignVCenter, rightString); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/statistics/statisticslegendwidget.h new/parley-14.12.3/src/statistics/statisticslegendwidget.h --- old/parley-14.12.2/src/statistics/statisticslegendwidget.h 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/statistics/statisticslegendwidget.h 2015-02-22 12:05:47.000000000 +0100 @@ -38,40 +38,11 @@ /// constructor StatisticsLegendWidget(QWidget * parent = 0); - /**@brief the color of the @p grade - @param grade - @returns the color **/ - static QColor gradeColor(int grade); - /**@returns the color of the preGrade stats - **/ - static QColor preGradeColor(); - /**@returns the color of the unpracticed entries**/ - static QColor unpracticedColor(); - /**@returns the color of the invalid entries**/ - static QColor invalidColor(); - - /** Calculate the fractions passed to paintStatisticsBar - of late/early/unpracticed and invalid types. - @returns calculated fractions practice statistics for @p container at @p index .**/ - static QList<QVariant> legendFractions(KEduVocContainer &container, int index); - - /** With a @p painter draw the stats bar with @p fractions within @p rect - @param painter supplied painter - @param rect bounding box - @param fractions the fractional widths of each of the grade categories - **/ - static void paintStatisticsBar(QPainter &painter, const QRect &rect, - const QList< QVariant> &fractions); protected: /// paintEvent @p e event void paintEvent(QPaintEvent *e); -private: - static const int alphaMax = 255; ///< full brightness - /// steps small enought that the last is still visible - static const int alphaStep = ((alphaMax - 10) / KV_MAX_GRADE); - /// offset of table for unpracticed, invalid and preGrade types - static const int fractionsOffset = 3; }; + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/statistics/statisticsmodel.cpp new/parley-14.12.3/src/statistics/statisticsmodel.cpp --- old/parley-14.12.2/src/statistics/statisticsmodel.cpp 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/statistics/statisticsmodel.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -41,10 +41,12 @@ { if (index.column() >= FirstDataColumn) { KEduVocContainer *container = static_cast<KEduVocContainer*>(index.internalPointer()); + QVariant var; switch (role) { - case LegendFractions: - // Calculate the percent each grade and pregrade occupies. - return StatisticsLegendWidget::legendFractions(*container ,index.column() - FirstDataColumn); + case Container: + // Return a pointer to the container we are working on. + var.setValue(container); + return var; case TotalPercent: // Average grade return container->averageGrade(index.column() - FirstDataColumn, KEduVocContainer::Recursive); case TotalCount: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/statistics/statisticsmodel.h new/parley-14.12.3/src/statistics/statisticsmodel.h --- old/parley-14.12.2/src/statistics/statisticsmodel.h 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/statistics/statisticsmodel.h 2015-02-22 12:05:47.000000000 +0100 @@ -35,7 +35,7 @@ Grade5, Grade6, Grade7, - LegendFractions + Container }; explicit StatisticsModel(QObject *parent = 0); @@ -53,5 +53,8 @@ KEduVocContainer * rootContainer() const; }; +// For index.data() +Q_DECLARE_METATYPE(KEduVocContainer*) + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/utils.cpp new/parley-14.12.3/src/utils.cpp --- old/parley-14.12.2/src/utils.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/parley-14.12.3/src/utils.cpp 2015-02-22 12:05:47.000000000 +0100 @@ -0,0 +1,222 @@ +/*************************************************************************** + Copyright 2015 Inge Wallin + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +// Own +#include "utils.h" + +// Qt +#include <QPainter> +#include <QRect> + +// KEduVocDocument library +#include <keduvocdocument.h> +#include <keduvocexpression.h> + +// Parley +#include "prefs.h" + +// ---------------------------------------------------------------- +// class WordCount + + +WordCount::WordCount() +{ + clear(); +} + + +void WordCount::clear() +{ + for (int i = 0; i <= KV_MAX_GRADE; ++i) { + grades[i] = 0; + pregrades[i] = 0; + } + invalid = 0; + + initialWords = 0; + totalWords = 0; +} + +int WordCount::percentageCompleted() const +{ + // To calculate the percentage done we add: + // * 1..KV_MAX_GRADE points for words in the initial phase (grade = 0, pregrade > 0) + // * KV_MAX_GRADE * (1..KV_MAX_GRADE) points for words in the long-term phase (grade>0) + // So the maximum number of points is KV_MAX_GRADE^2 per word. + // + // In the final calculation, we exclude all invalid words from the percentage. + int points = 0; + for (int i = 0; i <= KV_MAX_GRADE + 1; ++i) { + points += pregrades[i] * i; + points += grades[i] * KV_MAX_GRADE * i; + } + + if (totalWords - invalid == 0) { + // Don't divide by 0. + return 0; + } + else { + return 100 * points / ((totalWords - invalid) * KV_MAX_GRADE * KV_MAX_GRADE); + } +} + + +void WordCount::fillFromContainer(KEduVocContainer &container, int translationIndex, + KEduVocContainer::EnumEntriesRecursive recursive) +{ + clear(); + + foreach (KEduVocExpression *entry, container.entries(recursive)) { + KEduVocTranslation &translation(*entry->translation(translationIndex)); + + ++totalWords; + if (translation.isEmpty()) { + ++invalid; + } else if (translation.preGrade() > 0) { + // Initial phase (we assume correctness, i.e. if pregrade>0 then grade = 0) + ++initialWords; + ++pregrades[translation.preGrade()]; + } else { + // Long term or unpracticed + ++grades[translation.grade()]; + } + } +} + + +// ---------------------------------------------------------------- +// class confidenceColors + + +ConfidenceColors::ConfidenceColors(ColorScheme colorScheme) +{ + initColors(colorScheme); +} + + +void ConfidenceColors::initColors(ColorScheme colorScheme) +{ + switch (colorScheme) { + case MultiColorScheme: + default: // Not default at the last line. Hope this works... + + longTermColors[0] = QColor(25,38,41); + //longTermColors[1] = QColor(Qt::yellow); + longTermColors[1] = QColor(25,38,41,64); + longTermColors[2] = QColor(237,21,21); + longTermColors[3] = QColor(246,116,0); + longTermColors[4] = QColor(201,206,59); + longTermColors[5] = QColor(28,220,154); + longTermColors[6] = QColor(17,209,22); + longTermColors[7] = QColor(61,174,253); + + initialTermColor = QColor(25,38,41,64); // Find something else + + invalidColor = QColor(Qt::red); + break; + + case ProgressiveColorScheme: + { + static const int AlphaMax = 255; + static const int AlphaStep = ((AlphaMax - 10) / KV_MAX_GRADE); + + QColor color; + + // Confidence 1..max + for (int grade = 1; grade <= KV_MAX_GRADE; ++grade) { + color = Prefs::gradeColor(); + color.setAlpha(AlphaMax - (KV_MAX_GRADE - grade) * AlphaStep); + + longTermColors[grade] = color; + } + + // Unpracticed (confidence 0) + color = QColor("#FFFFFF"); + color.setAlpha(AlphaMax); + longTermColors[0] = color; + + // Use one color for all initial phase values + color = Prefs::preGradeColor(); + color.setAlpha(AlphaMax); + initialTermColor = color; + + // Invalid + invalidColor = Prefs::invalidUnitColor(); + + break; + } + } + + // These two are placeholders for the wordcloud background color. + frontEndColors[0] = QColor(255,221,217); + frontEndColors[1] = QColor(238,232,213); +} + + +// ---------------------------------------------------------------- +// Various utility functions + + +void paintColorBar(QPainter &painter, const QRect &rect, + const WordCount &wordCount, const ConfidenceColors &colors) +{ + // The outline of the total bar. + QRect roundedRect(rect); + roundedRect.adjust(1, 1, -1, -1); + QPainterPath roundedPath; + roundedPath.addRoundedRect(roundedRect, 2.0, 2.0); + + int xPosition = 0; + + // >0: grade, 0: initial, -1: untrained, -2: invalid + for (int i = KV_MAX_GRADE; i >= -2; --i) { + qreal fraction; + QColor color; + + // Get the fraction and the color + if (i > 0) { + // long term + fraction = qreal(wordCount.grades[i]) / qreal(wordCount.totalWords); + color = colors.longTermColors[i]; + } else if (i == 0) { + // initial term + fraction = qreal(wordCount.initialWords) / qreal(wordCount.totalWords); + color = colors.initialTermColor; + } else if (i == -1) { + // untrained (stored in longterm[0]) + fraction = qreal(wordCount.grades[0]) / qreal(wordCount.totalWords); + color = colors.longTermColors[0]; + } else { + fraction = qreal(wordCount.invalid) / qreal(wordCount.totalWords); + color = colors.invalidColor; + } + + // Create a rect from the current fraction and + // adjust the rect to the outer limits. + int barElementWidth = fraction * rect.width(); + //int barElementWidth = fraction * roundedRect.width(); <-- Use this instead? + QRectF barElement(rect.x() + xPosition, rect.y(), barElementWidth, rect.height()); + QPainterPath barElementPath; + barElementPath.addRect(barElement); + + // Intersect the QPainterPath of inner rectangle with outer, + // so that the inner rectangle takes the shape of the outer rounded rectangle. + QPainterPath barElementIntersectedPath = roundedPath.intersected(barElementPath); + xPosition += barElementWidth; + + // Paint! + painter.setBrush(QBrush(color)); + painter.drawPath(barElementIntersectedPath); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/utils.h new/parley-14.12.3/src/utils.h --- old/parley-14.12.2/src/utils.h 1970-01-01 01:00:00.000000000 +0100 +++ new/parley-14.12.3/src/utils.h 2015-02-22 12:05:47.000000000 +0100 @@ -0,0 +1,71 @@ +/*************************************************************************** + Copyright 2015 Inge Wallin + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#ifndef UTILS_H +#define UTILS_H + +// Qt +#include <QtGui> + +// KEduVocDocument library +#include <keduvoccontainer.h> + + +class QPainter; +class QRect; + +// The WordCount struct contains the number of words in each category. +// This could be used for number of words due, total number of words, etc. +struct WordCount { + WordCount(); + void clear(); + int percentageCompleted() const; + + // Fill the WordCount data from the container. + void fillFromContainer(KEduVocContainer &container, int translationIndex, + KEduVocContainer::EnumEntriesRecursive recursive = KEduVocContainer::Recursive); + + int grades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 + int pregrades[KV_MAX_GRADE + 1]; // Number of entries in each grade including grade=0, pregrade=0 + int invalid; // Number of invalid entries (not always applicable); + + int initialWords; // Number of entries in initial phase (grade=0, pregrade>0) + // This is the sum of the numbers in pregrades[]. + int totalWords; // Total number of words + // This is the sum of grades[], pregrades[] and invalid +}; + + +struct ConfidenceColors { + enum ColorScheme { + MultiColorScheme, //< The color scheme from the dashboard + ProgressiveColorScheme //< The color scheme from the practice component + }; + + ConfidenceColors(ColorScheme colorScheme = MultiColorScheme); + + void initColors(ColorScheme colorScheme); + + QColor longTermColors[KV_MAX_GRADE + 1]; + QColor initialTermColor; + QColor invalidColor; + QColor frontEndColors[2]; // Placeholders for the wordcloud background colors +}; + + +void paintColorBar(QPainter &painter, const QRect &rect, + const WordCount &wordCount, const ConfidenceColors &colors); + + +#endif // UTILS_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parley-14.12.2/src/version.h new/parley-14.12.3/src/version.h --- old/parley-14.12.2/src/version.h 2015-01-29 18:10:01.000000000 +0100 +++ new/parley-14.12.3/src/version.h 2015-02-22 12:05:47.000000000 +0100 @@ -1,4 +1,4 @@ #ifndef VERSION_H #define VERSION_H -#define PARLEY_VERSION_STRING "2.0.2" +#define PARLEY_VERSION_STRING "2.0.3" #endif -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
