[Companion] Work in progress - QTreeView in MdiChild (#4197)

[Companion] QTreeView in MdiChild, Horus and X7 support added, fixes for #4224
This commit is contained in:
Bertrand Songis
2017-01-15 17:45:57 +01:00
committed by GitHub
parent d6b84371a9
commit a65aa3d6c7
60 changed files with 3539 additions and 3153 deletions
+77 -7
View File
@@ -21,8 +21,8 @@
#ifndef _MODELSLIST_H_
#define _MODELSLIST_H_
#include <QtWidgets>
#include "eeprominterface.h"
#include <QtWidgets>
struct CurrentSelection
{
@@ -30,13 +30,84 @@ struct CurrentSelection
bool selected[CPN_MAX_MODELS+1];
};
class ModelsListWidget : public QTreeWidget
class TreeItem
{
public:
explicit TreeItem(const QVector<QVariant> & itemData);
explicit TreeItem(TreeItem * parent, int modelIndex = -1);
~TreeItem();
TreeItem *child(int number);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
TreeItem * appendChild(int modelIndex);
TreeItem * parent();
bool removeChildren(int position, int count);
int childNumber() const;
bool setData(int column, const QVariant &value);
int getModelIndex() const { return modelIndex; }
private:
QList<TreeItem*> childItems;
QVector<QVariant> itemData;
TreeItem * parentItem;
int modelIndex;
};
class TreeModel : public QAbstractItemModel
{
// Q_OBJECT
public:
TreeModel(RadioData * radioData, QObject *parent = 0);
~TreeModel();
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole) Q_DECL_OVERRIDE;
bool removeRows(int position, int rows,
const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
void refresh();
int getAvailableEEpromSize() { return availableEEpromSize; }
int getModelIndex(const QModelIndex & index) const {
return getItem(index)->getModelIndex();
}
private:
TreeItem * getItem(const QModelIndex & index) const;
TreeItem * rootItem;
RadioData * radioData;
int availableEEpromSize;
};
#if 0
class ModelsListWidget : public QTreeView
{
Q_OBJECT
public:
ModelsListWidget(QWidget * parent = 0);
void setRadioData(RadioData * radioData);
bool hasSelection();
void keyPressEvent(QKeyEvent * event);
bool hasPasteData();
@@ -56,18 +127,16 @@ protected:
public slots:
void refreshList();
void ShowContextMenu(const QPoint& pos);
void cut();
void copy();
void paste();
void print();
void EditModel();
void OpenEditWindow();
void LoadBackup();
void OpenWizard();
void simulate();
void duplicate();
void setdefault();
void deleteSelected(bool ask);
void confirmDelete();
void onCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
@@ -79,12 +148,13 @@ private:
void saveSelection();
void restoreSelection();
RadioData *radioData;
RadioData * radioData;
QPoint dragStartPosition;
CurrentSelection currentSelection;
QColor active_highlight_color;
};
#endif
#endif // _MODELSLIST_H_