Skip to content
This repository
Browse code

Show display options in the assembly record item categories table

  • Loading branch information...
commit db8293348ef139dce69658a4196463186608c9ce 1 parent 37924e3
Matúš Tomlein authored February 02, 2012
4  rc/i18n/Leaklog-Slovak.ts
@@ -3544,6 +3544,10 @@ Na odstránenie všetkých údajov o oprave "%1" napíšte ODSTRÁNIŤ
3544 3544
         <source>Date:</source>
3545 3545
         <translation>Dátum:</translation>
3546 3546
     </message>
  3547
+    <message>
  3548
+        <source>Show</source>
  3549
+        <translation>Zobraziť</translation>
  3550
+    </message>
3547 3551
 </context>
3548 3552
 <context>
3549 3553
     <name>Navigation</name>
3  src/main_window.h
@@ -29,6 +29,7 @@ class Warnings;
29 29
 class MTTextStream;
30 30
 class HTMLTable;
31 31
 class HTMLTableCell;
  32
+class HTMLTableRow;
32 33
 class HTMLDiv;
33 34
 class QPushButton;
34 35
 class QCloseEvent;
@@ -248,6 +249,8 @@ private slots:
248 249
     void showVariableInInspectionTable(VariableEvaluation::Variable *, VariableEvaluation::EvaluationContext &, QVariantMap &, HTMLTable *);
249 250
     HTMLTable * writeInspectionsTable(const QVariantMap &, const QVariantMap &, ListOfVariantMaps &, VariableEvaluation::EvaluationContext &);
250 251
 
  252
+    void addDisplayOptionsCellToCategoriesTable(HTMLTableRow *, int, int);
  253
+
251 254
     QSet<int> years_expanded_in_service_company_view;
252 255
     QMap<Navigation::View, QString> dict_html;
253 256
     QMap<QString, int> dict_fieldtypes;
54  src/view.cpp
@@ -2063,7 +2063,6 @@ QString MainWindow::viewAllAssemblyRecordItemTypes(const QString & highlighted_i
2063 2063
 
2064 2064
 QString MainWindow::viewAllAssemblyRecordItemCategories(const QString & highlighted_id)
2065 2065
 {
2066  
-    QString html; MTTextStream out(&html);
2067 2066
     AssemblyRecordItemCategory all_items("");
2068 2067
     if (!navigation->isFilterEmpty()) {
2069 2068
         all_items.addFilter(navigation->filterColumn(), navigation->filterKeyword());
@@ -2073,32 +2072,51 @@ QString MainWindow::viewAllAssemblyRecordItemCategories(const QString & highligh
2073 2072
         items = all_items.listAll();
2074 2073
     else
2075 2074
         items = all_items.listAll("*", m_settings.lastLink()->orderBy());
2076  
-    out << "<table cellspacing=\"0\" cellpadding=\"4\" style=\"width:100%;\" class=\"highlight\">";
2077  
-    QString thead = "<tr>"; int thead_colspan = 2;
  2075
+
  2076
+    HTMLTable table("cellspacing=\"0\" cellpadding=\"4\" style=\"width:100%;\" class=\"highlight\"");
  2077
+    int thead_colspan = 5;
  2078
+    HTMLTableRow * row = new HTMLTableRow();
2078 2079
     for (int n = 0; n < AssemblyRecordItemCategory::attributes().count(); ++n) {
2079  
-        thead.append("<th><a href=\"assemblyrecorditemcategory:/order_by:"
2080  
-                     + AssemblyRecordItemCategory::attributes().key(n) + "\">"
2081  
-                     + AssemblyRecordItemCategory::attributes().value(n) + "</a></th>");
  2080
+        *(row->addHeaderCell("rowspan=\"2\"")->link("assemblyrecorditemcategory:/order_by:"
  2081
+                                  + AssemblyRecordItemCategory::attributes().key(n)))
  2082
+                << AssemblyRecordItemCategory::attributes().value(n);
2082 2083
         thead_colspan++;
2083 2084
     }
2084  
-    thead.append("</tr>");
2085  
-    out << "<tr><th colspan=\"" << thead_colspan << "\" style=\"font-size: medium;\">"
2086  
-        << tr("List of Assembly Record Item Categories") << "</th></tr>";
2087  
-    out << thead;
  2085
+    *(row->addHeaderCell("colspan=\"5\"")) << tr("Show");
  2086
+    *(table.addRow()->addHeaderCell("colspan=\"" + QString::number(thead_colspan) + "\" style=\"font-size: medium;\""))
  2087
+        << tr("List of Assembly Record Item Categories");
  2088
+    table << row;
  2089
+    row = table.addRow();
  2090
+    *(row->addHeaderCell()) << tr("Value");
  2091
+    *(row->addHeaderCell()) << tr("Acquisition price");
  2092
+    *(row->addHeaderCell()) << tr("List price");
  2093
+    *(row->addHeaderCell()) << tr("Discount");
  2094
+    *(row->addHeaderCell()) << tr("Total");
  2095
+
2088 2096
     QString id;
2089 2097
     for (int i = 0; i < items.count(); ++i) {
2090 2098
         id = items.at(i).value("id").toString();
2091  
-        out << QString("<tr id=\"%1\" onclick=\"executeLink(this, '%1');\"").arg("assemblyrecorditemcategory:" + id);
2092  
-        if (highlighted_id == id)
2093  
-            out << " class=\"selected\"";
2094  
-        out << " style=\"cursor: pointer;\"><td><a href=\"\">" << id << "</a></td>";
  2099
+        row = table.addRow(QString("id=\"%1\" onclick=\"executeLink(this, '%1');\"%2 style=\"cursor: pointer;\"")
  2100
+                           .arg("assemblyrecorditemcategory:" + id)
  2101
+                           .arg(highlighted_id == id ? " class=\"selected\"" : ""));
  2102
+        *(row->addCell()->link(""))
  2103
+                << id;
2095 2104
         for (int n = 1; n < AssemblyRecordItemCategory::attributes().count(); ++n) {
2096  
-            out << "<td>" << escapeString(items.at(i).value(AssemblyRecordItemCategory::attributes().key(n)).toString()) << "</td>";
  2105
+            *(row->addCell())
  2106
+                    << escapeString(items.at(i).value(AssemblyRecordItemCategory::attributes().key(n)).toString());
2097 2107
         }
2098  
-        out << "</tr>";
  2108
+        addDisplayOptionsCellToCategoriesTable(row, items.at(i).value("display_options").toInt(), AssemblyRecordItemCategory::ShowValue);
  2109
+        addDisplayOptionsCellToCategoriesTable(row, items.at(i).value("display_options").toInt(), AssemblyRecordItemCategory::ShowAcquisitionPrice);
  2110
+        addDisplayOptionsCellToCategoriesTable(row, items.at(i).value("display_options").toInt(), AssemblyRecordItemCategory::ShowListPrice);
  2111
+        addDisplayOptionsCellToCategoriesTable(row, items.at(i).value("display_options").toInt(), AssemblyRecordItemCategory::ShowDiscount);
  2112
+        addDisplayOptionsCellToCategoriesTable(row, items.at(i).value("display_options").toInt(), AssemblyRecordItemCategory::ShowTotal);
2099 2113
     }
2100  
-    out << "</table>";
2101  
-    return dict_html.value(Navigation::ListOfAssemblyRecordItemCategories).arg(html);
  2114
+    return dict_html.value(Navigation::ListOfAssemblyRecordItemCategories).arg(table.html());
  2115
+}
  2116
+
  2117
+void MainWindow::addDisplayOptionsCellToCategoriesTable(HTMLTableRow * row, int display_options, int value)
  2118
+{
  2119
+    *(row->addCell()) << (display_options & value ? tr("Yes") : tr("No"));
2102 2120
 }
2103 2121
 
2104 2122
 QString MainWindow::viewAssemblyRecord(const QString & customer_id, const QString & circuit_id, const QString & inspection_date)

0 notes on commit db82933

Please sign in to comment.
Something went wrong with that request. Please try again.