Remember plot settings for each table (#819)

Store and restore the plot settings for each table - just like the
filter values or the column widths. This way you can have multiple
plots, one for each table.

Also, save these settings in the project files.
This commit is contained in:
Martin Kleusberg
2016-10-14 13:24:06 +02:00
committed by GitHub
parent c25119ed4e
commit d5c6b7bb0e
2 changed files with 113 additions and 21 deletions

View File

@@ -33,6 +33,30 @@ public:
DBBrowserDB& getDb() { return db; }
struct PlotSettings
{
int lineStyle;
int pointShape;
QColor colour;
friend QDataStream& operator<<(QDataStream& stream, const MainWindow::PlotSettings& object)
{
stream << object.lineStyle;
stream << object.pointShape;
stream << object.colour;
return stream;
}
friend QDataStream& operator>>(QDataStream& stream, MainWindow::PlotSettings& object)
{
stream >> object.lineStyle;
stream >> object.pointShape;
stream >> object.colour;
return stream;
}
};
struct BrowseDataTableSettings
{
int sortOrderIndex;
@@ -42,6 +66,8 @@ public:
QMap<int, QString> displayFormats;
bool showRowid;
QString encoding;
QString plotXAxis;
QMap<QString, PlotSettings> plotYAxes;
friend QDataStream& operator<<(QDataStream& stream, const MainWindow::BrowseDataTableSettings& object)
{
@@ -52,6 +78,8 @@ public:
stream << object.displayFormats;
stream << object.showRowid;
stream << object.encoding;
stream << object.plotXAxis;
stream << object.plotYAxes;
return stream;
}
@@ -67,6 +95,15 @@ public:
stream >> object.showRowid;
stream >> object.encoding;
// Versions pre 3.10.0 didn't store the following information in their project files.
// To be absolutely sure that nothing strange happens when we read past the stream for
// those cases, check for the end of the stream here.
if(stream.atEnd())
return stream;
stream >> object.plotXAxis;
stream >> object.plotYAxes;
return stream;
}
};
@@ -218,7 +255,7 @@ private slots:
void loadExtension();
void reloadSettings();
void httpresponse(QNetworkReply* reply);
void updatePlot(SqliteTableModel* model, bool update = true);
void updatePlot(SqliteTableModel* model, bool update = true, bool keepOrResetSelection = true);
void on_treePlotColumns_itemChanged(QTreeWidgetItem *item, int column);
void on_treePlotColumns_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_butSavePlot_clicked();