mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
The new toolbar is hidden by default and can be toggled using a button in the main Data Browser toolbar. Margins and spacing have been updated to improve appearance of the two toolbars. These tool buttons apply the format to the columns which are contained in the selection. This is done by updating or adding a new condition-less format to the list of conditional formats of those columns. New style icons from the Silk icon set. Changed existent ones for coherence. See issue #1976.
104 lines
3.4 KiB
C++
104 lines
3.4 KiB
C++
#ifndef EXTENDEDTABLEWIDGET_H
|
|
#define EXTENDEDTABLEWIDGET_H
|
|
|
|
#include <QTableView>
|
|
#include <QStyledItemDelegate>
|
|
#include <QSortFilterProxyModel>
|
|
#include <unordered_set>
|
|
|
|
#include "sql/Query.h"
|
|
|
|
class QMenu;
|
|
class QMimeData;
|
|
class QDropEvent;
|
|
class QDragMoveEvent;
|
|
|
|
class FilterTableHeader;
|
|
namespace sqlb { class ObjectIdentifier; }
|
|
|
|
// Filter proxy model that only accepts distinct non-empty values.
|
|
class UniqueFilterModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit UniqueFilterModel(QObject* parent = nullptr);
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
|
private:
|
|
std::unordered_set<std::string> m_uniqueValues;
|
|
};
|
|
|
|
// We use this class to provide editor widgets for the ExtendedTableWidget. It's used for every cell in the table view.
|
|
class ExtendedTableWidgetEditorDelegate : public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ExtendedTableWidgetEditorDelegate(QObject* parent = nullptr);
|
|
|
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
|
|
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
|
|
void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
};
|
|
|
|
class ExtendedTableWidget : public QTableView
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ExtendedTableWidget(QWidget* parent = nullptr);
|
|
|
|
FilterTableHeader* filterHeader() { return m_tableHeader; }
|
|
|
|
public:
|
|
std::unordered_set<int> selectedCols() const;
|
|
int numVisibleRows() const;
|
|
|
|
void sortByColumns(const std::vector<sqlb::SortedColumn>& columns);
|
|
|
|
public slots:
|
|
void reloadSettings();
|
|
void selectTableLine(int lineToSelect);
|
|
void selectTableLines(int firstLine, int count);
|
|
void selectAll() override;
|
|
void openPrintDialog();
|
|
|
|
signals:
|
|
void foreignKeyClicked(const sqlb::ObjectIdentifier& table, const QString& column, const QByteArray& value);
|
|
void switchTable(bool next); // 'next' parameter is set to true if next table should be selected and to false if previous table should be selected
|
|
void openFileFromDropEvent(QString);
|
|
void selectedRowsToBeDeleted();
|
|
void editCondFormats(int column);
|
|
// Make the inherited protected signal public
|
|
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
|
|
|
private:
|
|
void copyMimeData(const QModelIndexList& fromIndices, QMimeData* mimeData, const bool withHeaders, const bool inSQL);
|
|
void copy(const bool withHeaders, const bool inSQL);
|
|
void paste();
|
|
|
|
void useAsFilter(const QString& filterOperator, bool binary = false, const QString& operatorSuffix = "");
|
|
void duplicateUpperCell();
|
|
|
|
static std::vector<std::vector<QByteArray>> m_buffer;
|
|
static QString m_generatorStamp;
|
|
|
|
private slots:
|
|
void vscrollbarChanged(int value);
|
|
void cellClicked(const QModelIndex& index);
|
|
|
|
protected:
|
|
void keyPressEvent(QKeyEvent* event) override;
|
|
void updateGeometries() override;
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
|
void dropEvent(QDropEvent* event) override;
|
|
|
|
FilterTableHeader* m_tableHeader;
|
|
QMenu* m_contextMenu;
|
|
ExtendedTableWidgetEditorDelegate* m_editorDelegate;
|
|
};
|
|
|
|
#endif
|