mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
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).
122 lines
3.0 KiB
C++
122 lines
3.0 KiB
C++
#ifndef PLOTDOCK_H
|
|
#define PLOTDOCK_H
|
|
|
|
#include "Palette.h"
|
|
|
|
#include <QDialog>
|
|
#include <QVariant>
|
|
#include <QMenu>
|
|
|
|
class SqliteTableModel;
|
|
class QTreeWidgetItem;
|
|
class QPrinter;
|
|
struct BrowseDataTableSettings;
|
|
|
|
namespace Ui {
|
|
class PlotDock;
|
|
}
|
|
|
|
class PlotDock : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit PlotDock(QWidget* parent = nullptr);
|
|
~PlotDock() override;
|
|
|
|
struct PlotSettings
|
|
{
|
|
int lineStyle;
|
|
int pointShape;
|
|
QColor colour;
|
|
bool active;
|
|
|
|
PlotSettings() :
|
|
lineStyle(0),
|
|
pointShape(0),
|
|
active(false)
|
|
{}
|
|
|
|
PlotSettings(int _lineStyle, int _pointShape, QColor _colour, bool _active) :
|
|
lineStyle(_lineStyle),
|
|
pointShape(_pointShape),
|
|
colour(_colour),
|
|
active(_active)
|
|
{}
|
|
|
|
friend QDataStream& operator<<(QDataStream& stream, const PlotDock::PlotSettings& object)
|
|
{
|
|
stream << object.lineStyle;
|
|
stream << object.pointShape;
|
|
stream << object.colour;
|
|
stream << object.active;
|
|
|
|
return stream;
|
|
}
|
|
friend QDataStream& operator>>(QDataStream& stream, PlotDock::PlotSettings& object)
|
|
{
|
|
stream >> object.lineStyle;
|
|
stream >> object.pointShape;
|
|
stream >> object.colour;
|
|
|
|
if(!stream.atEnd())
|
|
stream >> object.active;
|
|
|
|
return stream;
|
|
}
|
|
};
|
|
|
|
public slots:
|
|
void updatePlot(SqliteTableModel* model, BrowseDataTableSettings* settings = nullptr, bool update = true, bool keepOrResetSelection = true);
|
|
void fetchAllData();
|
|
void resetPlot();
|
|
void reject() override;
|
|
|
|
signals:
|
|
void pointsSelected(int firstIndex, int count);
|
|
|
|
private:
|
|
enum PlotColumns
|
|
{
|
|
PlotColumnField = 0,
|
|
PlotColumnX = 1,
|
|
PlotColumnY = 2,
|
|
PlotColumnType = 3,
|
|
};
|
|
|
|
Ui::PlotDock* ui;
|
|
|
|
SqliteTableModel* m_currentPlotModel;
|
|
BrowseDataTableSettings* m_currentTableSettings;
|
|
QMenu* m_contextMenu;
|
|
bool m_showLegend;
|
|
bool m_stackedBars;
|
|
Palette m_graphPalette;
|
|
|
|
/*!
|
|
* \brief guessdatatype try to parse the first 10 rows and decide the datatype
|
|
* \param model model to check the data
|
|
* \param column index of the column to check
|
|
* \return the guessed datatype
|
|
*/
|
|
QVariant::Type guessDataType(SqliteTableModel* model, int column);
|
|
void adjustBars();
|
|
|
|
private slots:
|
|
void on_treePlotColumns_itemChanged(QTreeWidgetItem* item, int column);
|
|
void on_treePlotColumns_itemDoubleClicked(QTreeWidgetItem* item, int column);
|
|
void on_butSavePlot_clicked();
|
|
void on_comboLineType_currentIndexChanged(int index);
|
|
void on_comboPointShape_currentIndexChanged(int index);
|
|
void selectionChanged();
|
|
void mousePress();
|
|
void mouseWheel();
|
|
void copy();
|
|
void toggleLegendVisible(bool visible);
|
|
void toggleStackedBars(bool stacked);
|
|
void openPrintDialog();
|
|
void renderPlot(QPrinter* printer);
|
|
};
|
|
|
|
#endif
|