diff --git a/skgbasegui/skgfilteredtableview.h b/skgbasegui/skgfilteredtableview.h index 9ec4c11e1..78aa2667e 100644 --- a/skgbasegui/skgfilteredtableview.h +++ b/skgbasegui/skgfilteredtableview.h @@ -1,129 +1,125 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGFILTEREDTABLEVIEW_H #define SKGFILTEREDTABLEVIEW_H /** @file * A filetered SKGTableView. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include #include "skgbasegui_export.h" #include "ui_skgfilteredtableview.h" class SKGShow; class SKGObjectModelBase; /** * This file is a filetered SKGTableView */ class SKGBASEGUI_EXPORT SKGFilteredTableView : public QWidget { Q_OBJECT - /** - * State of the object - */ - Q_PROPERTY(QString state READ getState WRITE setState USER true CONSTANT) public: /** * Default Constructor * @param iParent the parent */ explicit SKGFilteredTableView(QWidget* iParent); /** * Default Destructor */ ~SKGFilteredTableView() override; /** * Get the current state * @return a string containing all activated item identifiers (separated by ;) */ virtual QString getState(); /** * Set the current state * @param iState a string containing all activated item identifiers (separated by ;) */ virtual void setState(const QString& iState); /** * @brief Get show widget * * @return SKGShow **/ virtual SKGShow* getShowWidget() const; /** * @brief Get table or tree view * * @return SKGTreeView **/ virtual SKGTreeView* getView() const; /** * @brief Get the search field * * @return QLineEdit **/ virtual QLineEdit* getSearchField() const; /** * @brief Set model * * @param iModel the model * @return void **/ virtual void setModel(SKGObjectModelBase* iModel); public Q_SLOTS: /** * @brief Set the filter. This filter disable the "show" menu * * @param iIcon the icon * @param iText the text to display * @param iWhereClause the where clause * @return void **/ virtual void setFilter(const QIcon& iIcon, const QString& iText, const QString& iWhereClause); /** * @brief Reset the filter * @return void **/ virtual void resetFilter(); private Q_SLOTS: void pageChanged(); void onFilterChanged(); void onTextFilterChanged(); void dataModified(const QString& iTableName, int iIdTransaction); private: Q_DISABLE_COPY(SKGFilteredTableView) Ui::skgfilteredtableview_base ui{}; SKGObjectModelBase* m_objectModel; bool m_refreshNeeded; QTimer m_timer; }; #endif // SKGFILTEREDTABLEVIEW_H diff --git a/skgbasegui/skggraphicsview.h b/skgbasegui/skggraphicsview.h index 5ef81bfd4..2d3bccc43 100644 --- a/skgbasegui/skggraphicsview.h +++ b/skgbasegui/skggraphicsview.h @@ -1,194 +1,186 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGGRAPHICSVIEW_H #define SKGGRAPHICSVIEW_H /** @file * A Graphic view with more functionalities. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include #include "skgbasegui_export.h" #include "ui_skggraphicsview.h" class QGraphicsScene; class QGraphicsView; class QMenu; class QAction; /** * This file is a Graphic view with more functionalities */ class SKGBASEGUI_EXPORT SKGGraphicsView : public QWidget { Q_OBJECT - /** - * State of the view - */ - Q_PROPERTY(QString state READ getState WRITE setState USER true CONSTANT) - /** - * To set the toolbar visible or not - */ - Q_PROPERTY(bool m_toolBarVisible READ isToolBarVisible WRITE setToolBarVisible NOTIFY toolBarVisiblyChanged) public: /** * Default Constructor * @param iParent the parent */ explicit SKGGraphicsView(QWidget* iParent); /** * Default Destructor */ ~SKGGraphicsView() override; /** * Set current scene * @param iScene The scene */ void setScene(QGraphicsScene* iScene); /** * Get the internal Graphic view * @return the internal Graphic view */ QGraphicsView* graphicsView(); /** * Set the visibility of the ToolBar * @param iVisibility visibility */ void setToolBarVisible(bool iVisibility); /** * Get the visibility of the ToolBar * @return visibility */ bool isToolBarVisible() const; /** * Add a widget in the toolbar * @param iWidget widget */ void addToolbarWidget(QWidget* iWidget); /** * Get the current state * @return a string containing all information needed to set the same state. * Could be an XML stream */ QString getState() const; /** * Set the current state * MUST BE OVERWRITTEN * @param iState must be interpreted to set the state of the widget */ void setState(const QString& iState); /** * Get a pointer on the contextual menu * @return contextual menu */ QMenu* getContextualMenu() const; public Q_SLOTS: /** * Set the zoom */ void onZoom(); /** * Print */ void onPrint(); /** * Export to a file * @param iFileName the file name */ void exportInFile(const QString& iFileName); /** * Export */ void onExport(); /** * Copy */ void onCopy(); /** * Swith tool bar visibility */ void onSwitchToolBarVisibility(); /** * Set antialiasing * @param iAntialiasing enabled or disabled */ void setAntialiasing(bool iAntialiasing); /** * Reinitialize zoom */ void initializeZoom(); Q_SIGNALS: /** * View is resized */ void resized(); /** * The tool bar visibily changed */ void toolBarVisiblyChanged(); protected: /** * Event filtering * @param iObject object * @param iEvent event * @return In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false. */ bool eventFilter(QObject* iObject, QEvent* iEvent) override; private Q_SLOTS: void showMenu(QPoint iPos); private: Q_DISABLE_COPY(SKGGraphicsView) Ui::skggraphicview_base ui{}; double m_oscale; QMenu* m_mainMenu{}; QAction* m_actZoomOriginal{}; QAction* m_actShowToolBar; QAction* m_actAntialiasing{}; bool m_toolBarVisible; QTimer m_timer; }; #endif // SKGGRAPHICSVIEW_H diff --git a/skgbasegui/skgshow.h b/skgbasegui/skgshow.h index b99b8f9bc..6b8c1d1d1 100644 --- a/skgbasegui/skgshow.h +++ b/skgbasegui/skgshow.h @@ -1,281 +1,277 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGSHOW_H #define SKGSHOW_H /** @file * A widget to select what to show. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include #include #include "skgbasegui_export.h" class QMenu; class QAction; class QActionGroup; /** * This file is a widget to select what to show */ class SKGBASEGUI_EXPORT SKGShow : public QToolButton { Q_OBJECT - /** - * State of the object - */ - Q_PROPERTY(QString state READ getState WRITE setState NOTIFY stateChanged USER true) /** * Mode */ Q_PROPERTY(OperatorMode mode READ getMode WRITE setMode NOTIFY modified) /** * Display Title */ Q_PROPERTY(bool displayTitle READ getDisplayTitle WRITE setDisplayTitle NOTIFY modified) public: /** * This enumerate defines type of operator */ enum OperatorMode {AND, /**< AND*/ OR /**< OR*/ }; /** * This enumerate defines type of operator */ Q_ENUM(OperatorMode) /** * Default Constructor * @param iParent the parent */ explicit SKGShow(QWidget* iParent); /** * Default Destructor */ ~SKGShow() override; /** * Get the current state * @return a string containing all activated item identifiers (separated by ;) */ virtual QString getState(); /** * Set the current state * @param iState a string containing all activated item identifiers (separated by ;) */ virtual void setState(const QString& iState); /** * Get the current mode * @return the mode */ virtual OperatorMode getMode(); /** * Set the current mode * @param iMode the mode */ virtual void setMode(OperatorMode iMode); /** * Set the default state * @param iState a string containing all activated item identifiers (separated by ;) */ virtual void setDefaultState(const QString& iState); /** * Get the current display mode * @return true of false */ virtual bool getDisplayTitle(); /** * Set the current display mode * @param iDisplay true if you want to see the selected filter of false */ virtual void setDisplayTitle(bool iDisplay); /** * Get the current where clause * @return a where clause string */ virtual QString getWhereClause() const; /** * Remove all items */ virtual void clear(); /** * @brief Get the number of items * * @return the number of items **/ virtual int count(); /** * @brief Get the action for an identifier * * @param iIdentifier unique identifier of the item * @return the action **/ virtual QAction* getAction(const QString& iIdentifier) const; /** * @brief Add an item to the menu * * @param iIdentifier unique identifier of the item * @param iText text * @param iIcon icon Defaults to "". * @param iWhereClose icon Defaults to "". * @param iListIdToCheckWhenChecked list of item identifiers (separated by ;) to check when checked Defaults to "". * @param iListIdToUncheckWhenChecked list of item identifiers (separated by ;) to uncheck when unchecked Defaults to "". * @param iListIdToCheckWhenUnchecked list of item identifiers (separated by ;) to check when checked Defaults to "". * @param iListIdToUncheckWhenUnchecked list of item identifiers (separated by ;) to uncheck when unchecked Defaults to "". * @param iShortcut the associated shortcut. * @return the index of the new item **/ virtual int addItem(const QString& iIdentifier, const QString& iText, const QString& iIcon = QString(), const QString& iWhereClose = QString(), const QString& iListIdToCheckWhenChecked = QString(), const QString& iListIdToUncheckWhenChecked = QString(), const QString& iListIdToCheckWhenUnchecked = QString(), const QString& iListIdToUncheckWhenUnchecked = QString(), const QKeySequence& iShortcut = QKeySequence()); /** * @brief Add a period item to the menu * * @param iIdentifier unique identifier of the item * @return the index of the new item **/ virtual int addPeriodItem(const QString& iIdentifier); /** * @brief Add an item to the menu * * @param iIdentifier unique identifier of the item * @param iText text * @param iIcon icon Defaults to "". * @param iWhereClose icon Defaults to "". * @param iGroup the group of actions. * @param iShortcut the associated shortcut. * @return the index of the new item **/ virtual int addGroupedItem(const QString& iIdentifier, const QString& iText, const QString& iIcon = QString(), const QString& iWhereClose = QString(), const QString& iGroup = QString(), const QKeySequence& iShortcut = QKeySequence()); /** * @brief Set the list of items to check when iIndex is checked * * @param iIndex index of the item (@see addItem) * @param iIds list of item identifiers (separated by ;) **/ virtual void setListIdToCheckWhenChecked(int iIndex, const QString& iIds); /** * @brief Set the list of items to uncheck when iIndex is checked * * @param iIndex index of the item (@see addItem) * @param iIds list of item identifiers (separated by ;) **/ virtual void setListIdToUncheckWhenChecked(int iIndex, const QString& iIds); /** * @brief Set the list of items to check when iIndex is unchecked * * @param iIndex index of the item (@see addItem) * @param iIds list of item identifiers (separated by ;) **/ virtual void setListIdToCheckWhenUnchecked(int iIndex, const QString& iIds); /** * @brief Set the list of items to uncheck when iIndex is unchecked * * @param iIndex index of the item (@see addItem) * @param iIds list of item identifiers (separated by ;) **/ virtual void setListIdToUncheckWhenUnchecked(int iIndex, const QString& iIds); /** * @brief Add a separator * * @return void **/ virtual void addSeparator(); Q_SIGNALS: /** * @brief Emitted when an item is changed * * @return void **/ void stateChanged(); /** * This signal is launched when the error is modified */ void modified(); private Q_SLOTS: /** * @brief trigger **/ void trigger(); /** * @brief trigger **/ void triggerRefreshOnly(); private: Q_DISABLE_COPY(SKGShow) QString getTitle() const; void refreshTitle(); QMenu* m_menu; QTimer m_timer; QString m_defaultState; OperatorMode m_mode; bool m_inTrigger; bool m_displayTitle; QList m_actions; QStringList m_icons; QMap m_check_to_check; QMap m_uncheck_to_check; QMap m_check_to_uncheck; QMap m_uncheck_to_uncheck; QMap m_whereclause; QMap m_groups; }; #endif // SKGSHOW_H diff --git a/skgbasegui/skgtablewithgraph.h b/skgbasegui/skgtablewithgraph.h index 96bfeace7..f964797e3 100644 --- a/skgbasegui/skgtablewithgraph.h +++ b/skgbasegui/skgtablewithgraph.h @@ -1,518 +1,515 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGTABLEWITHGRAPH_H #define SKGTABLEWITHGRAPH_H /** @file * A table with graph with more features. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include "skgbasegui_export.h" #include "skgcombobox.h" #include "skgservices.h" #include "ui_skgtablewithgraph.h" class SKGGraphicsScene; class QMenu; class QTimer; class QWidgetAction; class QGraphicsItem; /** * This file is a table with graph with more features */ class SKGBASEGUI_EXPORT SKGTableWithGraph : public QWidget { Q_OBJECT public: /** * Graph type */ enum GraphType {STACK, HISTOGRAM, PIE, CONCENTRICPIE, POINT, LINE, STACKAREA, BUBBLE, STACKCOLUMNS, TREEMAP }; /** * Graph type */ Q_ENUM(GraphType) /** * Additional information to display */ enum DisplayAdditional {NONE = 0x0, SUM = 0x1, AVERAGE = 0x2, LIMITS = 0x4, ALL = 255 }; /** * Additional information to display */ Q_ENUM(DisplayAdditional) /** * Additional information to display */ Q_DECLARE_FLAGS(DisplayAdditionalFlag, DisplayAdditional) - /** - * State of the view - */ - Q_PROPERTY(QString state READ getState WRITE setState CONSTANT) + /** * Graph Type widget visibility */ Q_PROPERTY(bool graphTypeSelectorVisible READ isGraphTypeSelectorVisible WRITE setGraphTypeSelectorVisible NOTIFY modified) /** * Items selectable or not */ Q_PROPERTY(bool selectable READ isSelectable WRITE setSelectable NOTIFY modified) /** * Items with shadow or not */ Q_PROPERTY(bool shadow READ isShadowVisible WRITE setShadowVisible NOTIFY modified) /** * Graph Type */ Q_PROPERTY(GraphType graphType READ getGraphType WRITE setGraphType NOTIFY modified) /** * Default Constructor */ SKGTableWithGraph(); /** * Constructor * @param iParent the parent */ explicit SKGTableWithGraph(QWidget* iParent); /** * Default Destructor */ ~SKGTableWithGraph() override; /** * Get the current state * MUST BE OVERWRITTEN * @return a string containing all information needed to set the same state. * Could be an XML stream */ QString getState(); /** * Returns the table. * @return table */ QTableWidget* table() const; /** * Returns the graph. * @return graph */ SKGGraphicsView* graph() const; /** * Returns the text report. * @return text report */ SKGWebView* textReport() const; /** * Get the mode for the additional display * @return the mode */ SKGTableWithGraph::DisplayAdditionalFlag getAdditionalDisplayMode() const; /** * Get the table content * @return the table content */ SKGStringListList getTable(); /** * Get a pointer on the contextual menu of the table * @return contextual menu */ QMenu* getTableContextualMenu() const; /** * Get a pointer on the contextual menu of the graph * @return contextual menu */ QMenu* getGraphContextualMenu() const; /** * Get the visibility of the graph type selector zone * @return the visibility */ bool isGraphTypeSelectorVisible() const; /** * Get the selectability of items * @return the selectability */ bool isSelectable() const; /** * Get the shadows visibility * @return the visibility */ bool isShadowVisible() const; /** * Get the graph type * @return the type of graph */ SKGTableWithGraph::GraphType getGraphType() const; /** * Get the number of columns * @param iWithComputed with compute columns (average, sum, forecast, ...) or not * @return the number of columns */ int getNbColumns(bool iWithComputed = false) const; /** * @brief Get show widget * * @return SKGShow* **/ SKGShow* getShowWidget() const; /** * To know if the table is visible * @return the visibility */ bool isTableVisible() const; /** * To know if the graph is visible * @return the visibility */ bool isGraphVisible() const; /** * To know if the text report is visible * @return the visibility */ bool isTextReportVisible() const; public Q_SLOTS: /** * Set the current state * MUST BE OVERWRITTEN * @param iState must be interpreted to set the state of the widget */ void setState(const QString& iState); /** * Set Data * @param iData the data * @param iPrimaryUnit the primary unit * @param iSecondaryUnit the secondary unit * @param iAdditionalInformation show sum and average columns * @param iNbVirtualColumn number of columns */ void setData(const SKGStringListList& iData, const SKGServices::SKGUnitInfo& iPrimaryUnit, const SKGServices::SKGUnitInfo& iSecondaryUnit, SKGTableWithGraph::DisplayAdditionalFlag iAdditionalInformation = SKGTableWithGraph::ALL, int iNbVirtualColumn = 0); /** * Set the visibility of the graph type selector zone * @param iVisible the visibility */ void setGraphTypeSelectorVisible(bool iVisible); /** * Enable / disable the selectability of items * @param iSelectable the selectability */ void setSelectable(bool iSelectable); /** * Enable / disable the shadows * @param iShadow the shadows */ void setShadowVisible(bool iShadow); /** * Set the graph type * @param iType the type of graph */ void setGraphType(SKGTableWithGraph::GraphType iType); /** * Set tool bar visibility * @param iVisibility the visibility */ void setFilterVisibility(bool iVisibility) const; /** * Set the axis color * @param iColor the color */ void setAxisColor(const QColor& iColor = Qt::gray); /** * Set the grid color * @param iColor the color */ void setGridColor(const QColor& iColor = Qt::lightGray); /** * Set the min color * @param iColor the color */ void setMinColor(const QColor& iColor = Qt::red); /** * Set the max color * @param iColor the color */ void setMaxColor(const QColor& iColor = Qt::green); /** * Set the pareto color * @param iColor the color */ void setParetoColor(const QColor& iColor = Qt::darkRed); /** * Set the average color * @param iColor the color */ void setAverageColor(const QColor& iColor = Qt::blue); /** * Set the tendency color * @param iColor the color */ void setTendencyColor(const QColor& iColor = Qt::darkYellow); /** * Set the outline color * @param iColor the color */ void setOutlineColor(const QColor& iColor = Qt::black); /** * Set the background color * @param iColor the color */ void setBackgroundColor(const QColor& iColor = Qt::white); /** * Set the text color * @param iColor the color */ void setTextColor(const QColor& iColor = Qt::black); /** * Set antialiasing * @param iAntialiasing enabled or disabled */ void setAntialiasing(bool iAntialiasing = true); /** * Redraw the graph after some milliseconds */ void redrawGraphDelayed(); /** * Switch the limits visibility * @return the new visibility */ bool switchLimitsVisibility(); /** * Switch the average visibility * @return the new visibility */ bool switchAverageVisibility(); /** * Switch the linear regression visibility * @return the new visibility */ bool switchLinearRegressionVisibility(); /** * Switch the pareto curve visibility * @return the new visibility */ bool switchParetoVisibility(); /** * Switch the legend visibility * @return the new visibility */ bool switchLegendVisibility(); /** * Switch the origin visibility * @return the new visibility */ bool swithOriginVisibility(); /** * Switch the decimals visibility * @return the new visibility */ bool swithDecimalsVisibility(); /** * Reset the colors */ void resetColors(); /** * Export to a file * @param iFileName the file name * @return an object managing the error * @see SKGError */ SKGError exportInFile(const QString& iFileName); Q_SIGNALS: /** * Emitted when a cell is double clicked * @param row row of the cell * @param column column of the cell */ void cellDoubleClicked(int row, int column); /** * Selection changed */ void selectionChanged(); /** * The object is modified */ void modified(); private Q_SLOTS: void onExport(); void onSelectionChanged(); void onSelectionChangedInGraph(); void onDoubleClick(int row, int column); void onDoubleClickGraph(); void onLinkClicked(const QUrl& url); void onFilterModified(); void onDisplayModeChanged(); void onChangeColor(); void onHorizontalScrollBarChanged(int /*iValue*/); void refresh(); void redrawText(); void redrawGraph(); void showMenu(QPoint iPos); private: Q_DISABLE_COPY(SKGTableWithGraph) double computeStepSize(double iRange, double iTargetSteps); void addArrow(QPointF iPeak, double iSize, double iArrowAngle = 45, double iDegree = 90); void addLegend(QPointF iPosition, double iSize, double iScaleText, double iMaxY); QGraphicsItem* drawPoint(qreal iX, qreal iY, qreal iRadius, int iMode, const QBrush& iBrush); int getAverageColumnIndex() const; int getMinColumnIndex() const; QStringList getSumItems(const QString& iString) const; void addSums(SKGStringListList& ioTable, int& iNblines); Ui::skgtablewithgraph_base ui{}; SKGGraphicsScene* m_scene; SKGStringListList m_data; QList m_sumRows; SKGServices::SKGUnitInfo m_primaryUnit; SKGServices::SKGUnitInfo m_secondaryUnit; DisplayAdditionalFlag m_additionalInformation; int m_nbVirtualColumns; bool m_selectable; bool m_toolBarVisible; bool m_graphTypeVisible; bool m_limitVisible; bool m_averageVisible; bool m_linearRegressionVisible; bool m_paretoVisible; bool m_legendVisible; bool m_graphVisible; bool m_tableVisible; bool m_textVisible; bool m_zeroVisible; bool m_decimalsVisible; bool m_shadow; QMenu* m_mainMenu; QTimer m_timer; QTimer m_timerRedraw; QAction* m_actShowLimits; QAction* m_actShowAverage; QAction* m_actShowLinearRegression; QAction* m_actShowPareto; QAction* m_actShowLegend; QAction* m_actShowZero; QAction* m_actShowDecimal; QAction* m_allPositiveMenu; QWidgetAction* m_displayModeWidget{}; int m_indexSum; int m_indexAverage; int m_indexMin; int m_indexLinearRegression; QMap m_mapTitleColor; QMap m_mapItemGraphic{}; QColor m_axisColor; QColor m_backgroundColor; QColor m_textColor; QColor m_gridColor; QColor m_minColor; QColor m_maxColor; QColor m_paretoColor; QColor m_averageColor; QColor m_tendencyColor; QColor m_outlineColor; QBrush m_NegativeColor; QBrush m_WhiteColor; SKGComboBox* m_displayMode{}; Qt::SortOrder m_sortOrder; int m_sortColumn; }; Q_DECLARE_OPERATORS_FOR_FLAGS(SKGTableWithGraph::DisplayAdditionalFlag) #endif // SKGTABLEWITHGRAPH_H diff --git a/skgbasegui/skgtreeview.h b/skgbasegui/skgtreeview.h index 2cf2b0bfc..d054d6f9c 100644 --- a/skgbasegui/skgtreeview.h +++ b/skgbasegui/skgtreeview.h @@ -1,361 +1,358 @@ /*************************************************************************** * Copyright (C) 2008 by S. MANKOWSKI / G. DE BURE support@mankowski.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see * ***************************************************************************/ #ifndef SKGTREEVIEW_H #define SKGTREEVIEW_H /** @file * A tree view with more features. * * @author Stephane MANKOWSKI / Guillaume DE BURE */ #include #include #include #include "skgbasegui_export.h" #include "skgmainpanel.h" #include "skgobjectbase.h" #include "skgservices.h" #include "skgtraces.h" class SKGObjectModelBase; class SKGDocument; class QTextBrowser; class SKGSortFilterProxyModel; class QTimer; /** * This file is a tab widget used by plugins */ class SKGBASEGUI_EXPORT SKGTreeView : public QTreeView { Q_OBJECT - /** - * State of the view - */ - Q_PROPERTY(QString state READ getState WRITE setState USER true CONSTANT) + /** * Text resizable by CTRL+wheel */ Q_PROPERTY(bool textResizable READ isTextResizable WRITE setTextResizable NOTIFY modified) /** * Auto resize mode of the view */ Q_PROPERTY(bool autoResized READ isAutoResized CONSTANT) public: /** * Default Constructor * @param iParent the parent */ explicit SKGTreeView(QWidget* iParent); /** * Default Destructor */ ~SKGTreeView() override; /** * Get the current state * @return a string containing all information needed to set the same state. * Could be an XML stream */ virtual QString getState(); /** * Set the current state * MUST BE OVERWRITTEN * @param iState must be interpreted to set the state of the widget */ virtual void setState(const QString& iState); /** * To know if the autoresized mode is enable */ virtual bool isAutoResized(); /** * Set parameter to activate and save default state of this table * @param iDocument document pointer * @param iParameterName parameter name in this document */ virtual void setDefaultSaveParameters(SKGDocument* iDocument, const QString& iParameterName); /** * Get the table content as QTextBrowser * @return the table content (MUST BE DELETED) */ virtual QTextBrowser* getTextBrowser() const; /** * Get the table content * @param iIndex the line index * @return the table content */ virtual SKGStringListList getTable(const QModelIndex& iIndex = QModelIndex()) const; /** * Get the current selection * @return selected objects */ virtual SKGObjectBase::SKGListSKGObjectBase getSelectedObjects(); /** * Get the first selected object * @return first selected object */ virtual SKGObjectBase getFirstSelectedObject(); /** * Get the number of selected object * @return number of selected objects */ virtual int getNbSelectedObjects(); /** * Sets the current selection model to the given selectionModel. * @param iSelectionModel the selection model */ void setSelectionModel(QItemSelectionModel* iSelectionModel) override; /** * Insert a registered action * @see SKGMainPanel::registerGlobalAction * @param iRegisteredAction the registered action. "" means separator */ virtual void insertGlobalAction(const QString& iRegisteredAction = QString()); /** * @brief Set model * * @param iModel the model * @return void **/ void setModel(QAbstractItemModel* iModel) override; /** * @brief Get the header menu * @return the header menu **/ virtual QMenu* getHeaderMenu() const; /** * Export to a file * @param iFileName the file name * @return an object managing the error * @see SKGError */ virtual SKGError exportInFile(const QString& iFileName); /** * Get the current schema * @return the current schema */ virtual QStringList getCurrentSchema() const; /** * Get the property to know if text is resizable * @return the property */ virtual bool isTextResizable() const; public Q_SLOTS: /** * This property holds whether to autorize text size modification by CTRL+wheel. * @param resizable true of false */ virtual void setTextResizable(bool resizable); /** * Set the zoom position. * @param iZoomPosition zoom position (-10<=zoom position<=10) */ virtual void setZoomPosition(int iZoomPosition); /** * Get zoom position * @return zoom position (-10<=zoom position<=10) */ virtual int zoomPosition(); /** * Save the selection */ virtual void saveSelection(); /** * Reset the selection */ virtual void resetSelection(); /** * Scroll on selected lines. */ virtual void scroolOnSelection(); /** * Select an object and focus on it * @param iUniqueID unique ID of the object */ virtual void selectObject(const QString& iUniqueID); /** * Select objects and focus on the first one * @param iUniqueIDs unique IDs of objects * @param iFocusOnFirstOne set the focus on the first one */ virtual void selectObjects(const QStringList& iUniqueIDs, bool iFocusOnFirstOne = false); /** * This property holds whether to draw the background using alternating colors. * @param enable true of false */ virtual void setAlternatingRowColors(bool enable); /** * Reset columns order */ virtual void resetColumnsOrder(); /** * Resizes all columns based on the size hints of the delegate used to render each item in the columns. */ virtual void resizeColumnsToContents(); /** * Resizes all columns based on the size hints of the delegate used to render each item in the columns. */ virtual void resizeColumnsToContentsDelayed(); /** * When the selection changed */ virtual void onSelectionChanged(); /** * Expand all and resize columns if needed */ virtual void expandAll(); /** * Copy selection in clipboard */ virtual void copy(); /** * Switch auto resize */ virtual void switchAutoResize(); protected: /** * This function is called with the given event when a mouse button is pressed while the cursor is inside the widget. * If a valid item is pressed on it is made into the current item. This function emits the pressed() signal. * @param iEvent the event */ void mousePressEvent(QMouseEvent* iEvent) override; Q_SIGNALS: /** * Emitted when the empty area */ void clickEmptyArea(); /** * Emitted 300ms after selection changed */ void selectionChangedDelayed(); /** * Emitted when zoom changed * @param iZoomPosition zoom position (-10<=zoom position<=10) */ void zoomChanged(int iZoomPosition); /** * When properties are modified */ void modified(); protected: /** * Event filtering * @param iObject object * @param iEvent event * @return In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false. */ bool eventFilter(QObject* iObject, QEvent* iEvent) override; private Q_SLOTS: void onExport(); void setupHeaderMenu(); void showHeaderMenu(); void showHeaderMenu(QPoint iPos); void showHideColumn(); void respanFirstColumns(); void refreshExpandCollapse(); void changeSchema(); void saveDefaultClicked(); void groupByChanged(QAction* /*iAction*/); void onSortChanged(int /*iIndex*/, Qt::SortOrder /*iOrder*/); void onExpand(const QModelIndex& index); void onCollapse(const QModelIndex& index); void onClick(const QModelIndex& index); void onActionTriggered(int action); void onRangeChanged(); void rebuildContextualMenu(); private: Q_DISABLE_COPY(SKGTreeView) QMenu* m_headerMenu; bool m_autoResize; bool m_autoResizeDone; QAction* m_actAutoResize; QAction* m_actCopy; QAction* m_actExpandAll; QAction* m_actCollapseAll; SKGDocument* m_document; QString m_parameterName; QStringList m_selection; QStringList m_expandedNodes; QString m_groupby; QTimer m_timerDelayedResize; QTimer m_timerSelectionChanged; QTimer m_timerScrollSelection; bool m_textResizable; int m_fontOriginalPointSize; int m_iconOriginalSize; SKGObjectModelBase* m_model; SKGSortFilterProxyModel* m_proxyModel; QAction* m_actGroupByNone; SKGObjectBase::SKGListSKGObjectBase m_lastSelection; SKGObjectBase::SKGListSKGObjectBase m_lastSelection_if_deleted; QString m_lastSelection_previous; bool stickH; bool stickV; }; #endif // SKGTREEVIEW_H