|
27 | 27 | #include "RemoteDatabase.h" |
28 | 28 | #include "FindReplaceDialog.h" |
29 | 29 | #include "Data.h" |
| 30 | +#include "CondFormat.h" |
30 | 31 |
|
31 | 32 | #include <QFile> |
32 | 33 | #include <QApplication> |
@@ -127,6 +128,8 @@ void MainWindow::init() |
127 | 128 |
|
128 | 129 | // Set up filters |
129 | 130 | connect(ui->dataTable->filterHeader(), SIGNAL(filterChanged(int,QString)), this, SLOT(updateFilter(int,QString))); |
| 131 | + connect(ui->dataTable->filterHeader(), SIGNAL(addCondFormat(int,QString)), this, SLOT(addCondFormat(int,QString))); |
| 132 | + connect(ui->dataTable->filterHeader(), SIGNAL(clearAllCondFormats(int)), this, SLOT(clearAllCondFormats(int))); |
130 | 133 | connect(m_browseTableModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex))); |
131 | 134 |
|
132 | 135 | // Select in table the rows correspoding to the selected points in plot |
@@ -716,7 +719,12 @@ void MainWindow::applyBrowseTableSettings(BrowseDataTableSettings storedData, bo |
716 | 719 | bool oldState = filterHeader->blockSignals(true); |
717 | 720 | for(auto filterIt=storedData.filterValues.constBegin();filterIt!=storedData.filterValues.constEnd();++filterIt) |
718 | 721 | filterHeader->setFilter(filterIt.key(), filterIt.value()); |
719 | | - filterHeader->blockSignals(oldState); |
| 722 | + |
| 723 | + // Conditional formats |
| 724 | + for(auto formatIt=storedData.condFormats.constBegin(); formatIt!=storedData.condFormats.constEnd(); ++formatIt) |
| 725 | + m_browseTableModel->setCondFormats(formatIt.key(), formatIt.value()); |
| 726 | + |
| 727 | + filterHeader->blockSignals(oldState); |
720 | 728 | } |
721 | 729 |
|
722 | 730 | // Encoding |
@@ -2438,6 +2446,21 @@ static void loadBrowseDataTableSettings(BrowseDataTableSettings& settings, QXmlS |
2438 | 2446 | xml.skipCurrentElement(); |
2439 | 2447 | } |
2440 | 2448 | } |
| 2449 | + } else if(xml.name() == "conditional_formats") { |
| 2450 | + while(xml.readNext() != QXmlStreamReader::EndElement && xml.name() != "conditional_formats") { |
| 2451 | + if (xml.name() == "column") { |
| 2452 | + int index = xml.attributes().value("index").toInt(); |
| 2453 | + while(xml.readNext() != QXmlStreamReader::EndElement && xml.name() != "column") { |
| 2454 | + if(xml.name() == "format") { |
| 2455 | + CondFormat newCondFormat(xml.attributes().value("condition").toString(), |
| 2456 | + QColor(xml.attributes().value("color").toString()), |
| 2457 | + settings.encoding); |
| 2458 | + settings.condFormats[index].append(newCondFormat); |
| 2459 | + xml.skipCurrentElement(); |
| 2460 | + } |
| 2461 | + } |
| 2462 | + } |
| 2463 | + } |
2441 | 2464 | } else if(xml.name() == "display_formats") { |
2442 | 2465 | while(xml.readNext() != QXmlStreamReader::EndElement && xml.name() != "display_formats") { |
2443 | 2466 | if (xml.name() == "column") { |
@@ -2700,6 +2723,19 @@ static void saveBrowseDataTableSettings(const BrowseDataTableSettings& object, Q |
2700 | 2723 | xml.writeEndElement(); |
2701 | 2724 | } |
2702 | 2725 | xml.writeEndElement(); |
| 2726 | + xml.writeStartElement("conditional_formats"); |
| 2727 | + for(auto iter=object.condFormats.constBegin(); iter!=object.condFormats.constEnd(); ++iter) { |
| 2728 | + xml.writeStartElement("column"); |
| 2729 | + xml.writeAttribute("index", QString::number(iter.key())); |
| 2730 | + for(auto format : iter.value()) { |
| 2731 | + xml.writeStartElement("format"); |
| 2732 | + xml.writeAttribute("condition", format.filter()); |
| 2733 | + xml.writeAttribute("color", format.color().name()); |
| 2734 | + xml.writeEndElement(); |
| 2735 | + } |
| 2736 | + xml.writeEndElement(); |
| 2737 | + } |
| 2738 | + xml.writeEndElement(); |
2703 | 2739 | xml.writeStartElement("display_formats"); |
2704 | 2740 | for(auto iter=object.displayFormats.constBegin(); iter!=object.displayFormats.constEnd(); ++iter) { |
2705 | 2741 | xml.writeStartElement("column"); |
@@ -2872,6 +2908,20 @@ void MainWindow::updateFilter(int column, const QString& value) |
2872 | 2908 | applyBrowseTableSettings(settings, true); |
2873 | 2909 | } |
2874 | 2910 |
|
| 2911 | +void MainWindow::addCondFormat(int column, const QString& value) |
| 2912 | +{ |
| 2913 | + CondFormat newCondFormat(value, m_condFormatPalette.nextSerialColor(Palette::appHasDarkTheme()), m_browseTableModel->encoding()); |
| 2914 | + m_browseTableModel->addCondFormat(column, newCondFormat); |
| 2915 | + browseTableSettings[currentlyBrowsedTableName()].condFormats[column].append(newCondFormat); |
| 2916 | +} |
| 2917 | + |
| 2918 | +void MainWindow::clearAllCondFormats(int column) |
| 2919 | +{ |
| 2920 | + QVector<CondFormat> emptyCondFormatVector = QVector<CondFormat>(); |
| 2921 | + m_browseTableModel->setCondFormats(column, emptyCondFormatVector); |
| 2922 | + browseTableSettings[currentlyBrowsedTableName()].condFormats[column].clear(); |
| 2923 | +} |
| 2924 | + |
2875 | 2925 | void MainWindow::editEncryption() |
2876 | 2926 | { |
2877 | 2927 | #ifdef ENABLE_SQLCIPHER |
|
0 commit comments