QTfrontend/ui/widget/about.cpp
changeset 14429 e64b9ea24cd8
parent 14428 fbe5e49462aa
child 14430 5b5aff91cebb
equal deleted inserted replaced
14428:fbe5e49462aa 14429:e64b9ea24cd8
    58 QString About::getCreditsHtml()
    58 QString About::getCreditsHtml()
    59 {
    59 {
    60     // Open the credits file
    60     // Open the credits file
    61 
    61 
    62     /* *** FILE FORMAT OF CREDITS FILE ***
    62     /* *** FILE FORMAT OF CREDITS FILE ***
    63     The credits file is an RFC-4180-compliant CSV file with 3 columns:
    63     The credits file is an RFC-4180-compliant CSV file with 4 columns.
    64     * Task/contribution
    64     The first colum is always 1 letter long and is the row type.
    65     * Contributor name
    65     The row type determines the meaning of the other columns.
    66     * Contributor e-mail
    66     The following row types are supported:
    67 
    67 
    68     The first and last columns are optional.
    68     * E: Credits entry
    69 
    69         * Column 2: Task/contribution
    70     There are special rows, which are marked by putting a "!__" in the
    70         * Column 3: Contributor name
    71     beginning of the first. The following special rows are supported:
    71         * Column 4: Contributor e-mail
    72 
    72     * M: Alternative credits entry that is a placeholder for other or unknown authors
    73     !__SECTION: Section. Column 1 is the section name
    73         * Columns 2-4: Unused
    74     !__SUBSECTION: Subsection. Column 1 is the subsection name
    74     * S: Section
    75     !__MISC: Placeholder for other or unknown authors
    75         * Column 2: Section name
       
    76         * Columns 3-4: Unused
       
    77     * U: Subsection
       
    78         * Column 2: Subsection name
       
    79         * Columns 3-4: Unused
    76     */
    80     */
    77     QFile creditsFile(":/res/credits.csv");
    81     QFile creditsFile(":/res/credits.csv");
    78     if (!creditsFile.open(QIODevice::ReadOnly))
    82     if (!creditsFile.open(QIODevice::ReadOnly))
    79     {
    83     {
    80         qWarning("ERROR: Credits file could not be opened!");
    84         qWarning("ERROR: Credits file could not be opened!");
    81         return "<p>ERROR: Credits file could not be opened!</p>";
    85         return "<p>ERROR: Credits file could not be opened!</p>";
    82     }
    86     }
    83     QString creditsString = creditsFile.readAll();
    87     QString creditsString = creditsFile.readAll();
    84     QString out = QString("<h1>" + tr("Credits") + "</h1>\n");
    88     QString out = QString("<h1>" + tr("Credits") + "</h1>\n");
    85     QStringList cells = QStringList() << QString("") << QString("") << QString("");
    89     QStringList cells = QStringList() << QString("") << QString("") << QString("") << QString("");
    86     bool firstSection = true;
    90     bool firstSection = true;
    87     unsigned long int column = 0;
    91     unsigned long int column = 0;
    88     unsigned long int charInCell = 0;
    92     unsigned long int charInCell = 0;
    89     bool isInQuote = false;
    93     bool isInQuote = false;
    90     bool ignoreChar = false;
    94     bool ignoreChar = false;
    92     QChar currChar;
    96     QChar currChar;
    93     QChar prevChar;
    97     QChar prevChar;
    94     for(long long int i = 0; i<creditsString.length(); i++)
    98     for(long long int i = 0; i<creditsString.length(); i++)
    95     {
    99     {
    96         currChar = creditsString.at(i);
   100         currChar = creditsString.at(i);
    97         QString task, name, mail;
   101         QString type, task, name, mail;
    98         if(currChar == '"')
   102         if(currChar == '"')
    99         {
   103         {
   100             if(charInCell == 0)
   104             if(charInCell == 0)
   101             {
   105             {
   102                 isInQuote = true;
   106                 isInQuote = true;
   135         }
   139         }
   136         ignoreChar = false;
   140         ignoreChar = false;
   137 
   141 
   138         if(lineComplete)
   142         if(lineComplete)
   139         {
   143         {
   140             task = cells[0];
   144             type = cells[0];
   141             name = cells[1];
   145             task = cells[1];
   142             mail = cells[2];
   146             name = cells[2];
   143 
   147             mail = cells[3];
   144             if(task == "!__SECTION")
   148 
   145             {
   149             if(type == "S")
       
   150             {
       
   151                 // section
   146                 if (!firstSection)
   152                 if (!firstSection)
   147                     out = out + "</ul>\n";
   153                     out = out + "</ul>\n";
   148                 out = out + "<h2>" + name + "</h2>\n<ul>\n";
   154                 out = out + "<h2>" + task + "</h2>\n<ul>\n";
   149                 firstSection = false;
   155                 firstSection = false;
   150             }
   156             }
   151             else if(task == "!__SUBSECTION")
   157             else if(type == "U")
   152             {
   158             {
       
   159                 // subsection
   153                 out = out + "</ul>\n";
   160                 out = out + "</ul>\n";
   154                 out = out + "<h3>" + name + "</h3>\n<ul>\n";
   161                 out = out + "<h3>" + task + "</h3>\n<ul>\n";
   155             }
   162             }
   156             else if(task == "!__MISC")
   163             else if(type == "M")
   157             {
   164             {
       
   165                 // other people
   158                 out = out + "<li>" + tr("Other people") + "</li>" + "\n";
   166                 out = out + "<li>" + tr("Other people") + "</li>" + "\n";
   159             }
   167             }
   160             else
   168             else if(type == "E")
   161             {
   169             {
       
   170                 // credits list entry
   162                 QString mailLink = QString("<a href=\"mailto:%1\">%1</a>").arg(mail);
   171                 QString mailLink = QString("<a href=\"mailto:%1\">%1</a>").arg(mail);
   163                 if(task.isEmpty() && mail.isEmpty())
   172                 if(task.isEmpty() && mail.isEmpty())
   164                 {
   173                 {
   165                     // Name only
   174                     // Name only
   166                     out = out + "<li>" + name + "</li>\n";
   175                     out = out + "<li>" + name + "</li>\n";
   189                         .arg(name)
   198                         .arg(name)
   190                         .arg(mailLink)
   199                         .arg(mailLink)
   191                         + "</li>\n";
   200                         + "</li>\n";
   192                 }
   201                 }
   193             }
   202             }
       
   203             else
       
   204             {
       
   205                 qWarning("Invalid row type in credits.csv: %s", qPrintable(type));
       
   206             }
   194             lineComplete = false;
   207             lineComplete = false;
   195             column = 0;
   208             column = 0;
   196             cells[0] = "";
   209             cells[0] = "";
   197             cells[1] = "";
   210             cells[1] = "";
   198             cells[2] = "";
   211             cells[2] = "";
       
   212             cells[3] = "";
   199             charInCell = 0;
   213             charInCell = 0;
   200         }
   214         }
   201 
   215 
   202         prevChar = currChar;
   216         prevChar = currChar;
   203     }
   217     }