226 lines
7.2 KiB
C++
Executable File
226 lines
7.2 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* LtsDataView is the exported View, which contains and manages a Custom View and a Table View
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2016-06-15
|
|
*/
|
|
#pragma once
|
|
|
|
|
|
#include <LtsDataView/lts_data_view_export.h>
|
|
#include <LtsDataView/lts_columns_setting.h>
|
|
|
|
#include <QWidget>
|
|
#include <QAbstractItemView>
|
|
#include <QLineEdit>
|
|
#include <functional>
|
|
|
|
|
|
class QListView;
|
|
class QTreeView;
|
|
|
|
namespace Ui
|
|
{
|
|
class LtsDataView;
|
|
}
|
|
namespace LtsWidgets
|
|
{
|
|
class LtsColumnFilterProxyModel;
|
|
struct ColumnOrganiserInfo;
|
|
}
|
|
|
|
// TODO: doxy doku
|
|
|
|
namespace LtsDataView
|
|
{
|
|
class AbstractDisplayWidget;
|
|
class SearchModel;
|
|
|
|
|
|
class SearchLineEdit final : public QLineEdit
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit SearchLineEdit(QWidget *parent)
|
|
: QLineEdit(parent)
|
|
{
|
|
setProperty("isSearchLineEdit", true);
|
|
}
|
|
};
|
|
|
|
|
|
class LTSDATAVIEW_EXPORT LtsDataView : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
|
|
Q_PROPERTY(bool showColumnCount READ showColumnCount WRITE setColumnCountVisible)
|
|
Q_PROPERTY(bool toolButtonsVisible READ toolButtonsVisible WRITE setToolButtonsVisible)
|
|
Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
|
|
Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
|
|
Q_PROPERTY(bool autoResizeToContent READ autoResizeToContent WRITE setAutoResizeToContent)
|
|
Q_PROPERTY(QAbstractItemView::SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
|
|
|
|
public:
|
|
enum Page
|
|
{
|
|
TABLE = 0,
|
|
CUSTOM = 1,
|
|
};
|
|
|
|
explicit LtsDataView(QWidget *parent = nullptr);
|
|
~LtsDataView();
|
|
|
|
/** once you set the model without a ADW, the view cannot switch back to double-view mode!
|
|
*
|
|
*/
|
|
void setModel(QAbstractItemModel *model, const std::function<AbstractDisplayWidget*()> &customDisplayWidgetCreator = nullptr);
|
|
QAbstractItemModel *sourceModel() const;
|
|
LtsWidgets::LtsColumnFilterProxyModel *proxyModel() const;
|
|
QItemSelectionModel *selectionModel() const;
|
|
SearchModel *searchModel() const;
|
|
|
|
QTreeView *treeView();
|
|
const QTreeView *treeView() const;
|
|
QTreeView *searchView();
|
|
const QTreeView *searchView() const;
|
|
QListView *getCustomView();
|
|
QWidget *customWidget() const;
|
|
void setCustomWidget(QWidget *customWidget); // not visible in seamless mode
|
|
|
|
QModelIndexList selectedRows(int column = 0) const; // TODO: returns indexes instead of rows if in custom view ... change naming?
|
|
void selectRow(const QModelIndex &idxSource);
|
|
void clearSelection();
|
|
void setSelectionMode(QAbstractItemView::SelectionMode selectionMode);
|
|
QAbstractItemView::SelectionMode selectionMode() const;
|
|
QModelIndex currentIndex() const;
|
|
void setCurrentIndex(const QModelIndex &idx); // also makes sure that the current index is visible (QAIV::scrollTo())
|
|
void scrollTo(const QModelIndex &idxSource);
|
|
|
|
void moveSection(int from, int to);
|
|
void seamless();
|
|
|
|
void setViewHeaderMovable(bool state);
|
|
void moveSections(const QMap<int, int> &list); /// logicalIndex (key) visualIndex(value)
|
|
|
|
void saveTableSettings(bool defaultSetting = false);/// if defaultSetting true, the default order of the table will be restore and save
|
|
bool restoreTableSettings();
|
|
QString getOperatorColIdentifier() const;
|
|
QVector<ColumnOrganiserInfo> getColumnOrganiserSetting();
|
|
QString columnOrganiserGroup() const;
|
|
void setColumnViewFromSetting();
|
|
void setColumnsOrganiserEnabled(const QString &tableIdentifier, bool enable = false);
|
|
|
|
void setRootIsDecorated(bool isDecorated);
|
|
bool rootIsDecorated() const;
|
|
void setAlternatingRowColors(bool enable);
|
|
bool alternatingRowColors() const;
|
|
|
|
void setColumnCountVisible(bool bVisible);
|
|
bool showColumnCount() const;
|
|
void setToolButtonsVisible(bool bVisible);
|
|
bool toolButtonsVisible() const;
|
|
void setAllColumnsShowFocus(bool enable);
|
|
bool allColumnsShowFocus() const;
|
|
void hideColumn(int column, bool debugMode = false);
|
|
void showColumn(int column);
|
|
bool isColumnHidden(int column) const;
|
|
void setColumnHidden(int column, bool hide);
|
|
|
|
void setAutoResizeToContent(bool enable);
|
|
bool autoResizeToContent() const;
|
|
void resizeSection(int logicalIndex, int size);
|
|
void resizeHeadersByContent();
|
|
void resizeColumnsToContent();
|
|
void syncSearchHeaderAndTableContentColumnSize();
|
|
void setRootIndex(const QModelIndex &srcIndex);
|
|
|
|
/**
|
|
* @brief See QHeaderview::setSortIndicator
|
|
*/
|
|
void setSortIndicator(int logicalIndex, Qt::SortOrder order);
|
|
void setSortIndicatorShown(bool show = true);
|
|
|
|
Qt::ContextMenuPolicy contextMenuPolicyPerView(Page page) const;
|
|
void setContextMenuPolicyPerView(Page page, Qt::ContextMenuPolicy policy);
|
|
|
|
QModelIndex mapFromSource(const QModelIndex &mi) const;
|
|
QModelIndex mapToSource(const QModelIndex &mi) const;
|
|
QModelIndexList mapToSource(const QModelIndexList &mil) const;
|
|
QItemSelection mapSelectionToSource(const QItemSelection &is) const;
|
|
|
|
bool setInitialSearchContent(int section, const QVariant &filterData);
|
|
void setIconSize(const QSize &size);
|
|
|
|
QByteArray saveState() const;
|
|
bool restoreState(const QByteArray &headerState);
|
|
|
|
private:
|
|
Ui::LtsDataView *m_ui;
|
|
LtsWidgets::LtsColumnFilterProxyModel *m_columnFilterProxy;
|
|
SearchModel *m_searchModel;
|
|
bool m_bOwnProxy;
|
|
bool m_autoResizeToConent{true};
|
|
QString m_tableObjIdentifier; // identifier for column Organiser
|
|
bool m_userChangedColumnPos = false;
|
|
QSet<int> m_DebugModeColIds; /// column which are only visible in debug mode
|
|
|
|
QString createCsv() const;
|
|
void addTouchScroll(QWidget *widget);
|
|
QAbstractItemView *currentView() const;
|
|
|
|
protected:
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
public slots:
|
|
void selectTableView();
|
|
void selectCustomView();
|
|
void selectView(Page page);
|
|
void slotCopyToClipboard();
|
|
void collapseAll();
|
|
void expandAll();
|
|
void expand(const QModelIndex &index);
|
|
void setSortingEnabled(bool enable);
|
|
void slotSetHorizontalRange(int, int);
|
|
void updateColumnsVisibility(const QVector<ColumnOrganiserInfo> &data);
|
|
void slotSetColumnsDefaultOrder();
|
|
private slots:
|
|
void slotSetSortIndicator(int logicalIndex, Qt::SortOrder order);
|
|
void slotRowCountChanged();
|
|
void slotSetHorizontalValue(int);
|
|
void slotSetVerticalRange(int x = 0, int y = 0);
|
|
void slotSetVerticalValue(int);
|
|
void slotSectionResized(int, int, int);
|
|
void slotHeaderMoved(int, int, int);
|
|
void slotCsvExport();
|
|
void slotResizeColumn(int columnIndex);
|
|
void onCustomContextMenuRequested(const QPoint &pos);
|
|
void slotColumnOrganiserDialog();
|
|
|
|
|
|
signals:
|
|
void signalEnterPressed();
|
|
void signalEntered(const QModelIndex &index);
|
|
|
|
// These are only emitted from the TableView
|
|
void clicked(const QModelIndex &index);
|
|
void doubleClicked(const QModelIndex &index);
|
|
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
|
void activated(const QModelIndex &index);
|
|
|
|
// These are emitted from both
|
|
void signalSelectionChanged();
|
|
void signalDoubleClicked();
|
|
// signalContextMenuRequested requires setContextMenuPolicyPerView to be set
|
|
void signalContextMenuRequested(const QPoint &globalPos, const QModelIndex &indexSrc);
|
|
|
|
// custom signals (@Filip)
|
|
void filterChanged();
|
|
void sortOrderChanged(const int &column, const Qt::SortOrder &order);
|
|
|
|
};
|
|
} // namespace LtsDataView
|