mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-26 05:50:26 -06:00
Initial implementation of "conditional formatting" (#1503)
After setting a filter, the user can select from the context menu in the filter line a new option "Use for Conditional Format", that assigns automatically a colour to the background of cells fulfilling that condition. The formatting is preserved after the user has removed the filter. Several conditional formats can be successively added to a column using different filters. The conditional formats of a column can be cleared when the filter is empty selecting "Clear All Conditional Formats" from the filter line context menu. The conditional formats are saved and loaded in project files as other browse table settings. A new class Palette has been added for reusing the automatic colour assignment of the Plot Dock. It takes into account the theme kind of the application (dark, light) for the colour selection. A new class CondFormat for using the conditional formatting settings from several classes. The conversion of a filter string from our format to an SQL condition has been moved here for reuse in filters and conditional formatting. Whether the conditional format applies is resolved by SQLite, so filters and conditional formats give the same exact results. Code for getting a pragma value has been reused for getting the condition result, and consequently renamed to selectSingleCell. Possible future improvement: - New dialog for editing the conditional formatting (at least colour and application order of conditions, but maybe too: adding new conditions and editing the condition itself).
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
#include <QVector>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QColor>
|
||||
#include <memory>
|
||||
|
||||
#include "sqlitetypes.h"
|
||||
#include "RowCache.h"
|
||||
#include "CondFormat.h"
|
||||
|
||||
struct sqlite3;
|
||||
class DBBrowserDB;
|
||||
@@ -109,6 +111,9 @@ public:
|
||||
// Helper function for removing all comments from a SQL query
|
||||
static void removeCommentsFromQuery(QString& query);
|
||||
|
||||
void addCondFormat(int column, const CondFormat& condFormat);
|
||||
void setCondFormats(int column, const QVector<CondFormat>& condFormats);
|
||||
|
||||
public slots:
|
||||
void updateFilter(int column, const QString& value, bool applyQuery = true);
|
||||
|
||||
@@ -175,6 +180,7 @@ private:
|
||||
QMap<int, QString> m_mWhere;
|
||||
QVector<QString> m_vDisplayFormat;
|
||||
QVector<int> m_vDataTypes;
|
||||
QMap<int, QVector<CondFormat>> m_mCondFormats;
|
||||
|
||||
/**
|
||||
* @brief m_chunkSize Size of the next chunk fetch more will try to fetch.
|
||||
|
||||
Reference in New Issue
Block a user