From f64f15df32139a33ebba679fde406ab319c5e7c5 Mon Sep 17 00:00:00 2001 From: pixhawk Date: Fri, 30 Apr 2010 09:09:02 +0200 Subject: [PATCH] Temporarily removed flite, fixed crash caused by tree view --- qgroundcontrol.pri | 8 ++++---- src/GAudioOutput.cc | 2 +- src/GAudioOutput.h | 4 ++-- src/ui/ParameterInterface.cc | 2 +- src/ui/param/ParamTreeItem.cc | 33 +++++++++++++++++++++------------ src/ui/param/ParamTreeModel.cc | 12 +++++++++--- src/ui/param/ParamTreeModel.h | 1 + 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 927072e12..0b8fb287d 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -116,10 +116,10 @@ linux-g++ { LIBS += -lm \ #-lflite_cmu_us_rms \ #-lflite_cmu_us_slt \ - -lflite_usenglish \ - -lflite_cmulex \ - -lflite_cmu_us_kal16 \ - -lflite \ + #-lflite_cmu_us_kal16 \ + #-lflite_usenglish \ + #-lflite_cmulex \ + #-lflite \ -lSDL \ -lSDLmain } diff --git a/src/GAudioOutput.cc b/src/GAudioOutput.cc index 0fb7fa821..fd468bcc7 100644 --- a/src/GAudioOutput.cc +++ b/src/GAudioOutput.cc @@ -91,7 +91,7 @@ GAudioOutput::GAudioOutput(QObject* parent) : QObject(parent), voiceIndex(0), emergency(false) { -#ifdef Q_OS_LINUX +#ifdef Q_OS_LINUX2 flite_init(); #endif // Initialize audio output diff --git a/src/GAudioOutput.h b/src/GAudioOutput.h index 896a01661..366af9e33 100644 --- a/src/GAudioOutput.h +++ b/src/GAudioOutput.h @@ -39,7 +39,7 @@ This file is part of the PIXHAWK project #include #endif #ifdef Q_OS_LINUX -#include +//#include #include #endif #ifdef Q_OS_WIN @@ -52,7 +52,7 @@ This file is part of the PIXHAWK project #endif */ -#ifdef Q_OS_LINUX +#ifdef Q_OS_LINUX2 extern "C" { cst_voice *REGISTER_VOX(const char *voxdir); void UNREGISTER_VOX(cst_voice *vox); diff --git a/src/ui/ParameterInterface.cc b/src/ui/ParameterInterface.cc index cbc161dc9..4dc21b333 100644 --- a/src/ui/ParameterInterface.cc +++ b/src/ui/ParameterInterface.cc @@ -17,7 +17,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) : tree = new ParamTreeModel(); treeView = new QTreeView(this); - //treeView->setModel(tree); + treeView->setModel(tree); QStackedWidget* stack = m_ui->stackedWidget; stack->addWidget(treeView); diff --git a/src/ui/param/ParamTreeItem.cc b/src/ui/param/ParamTreeItem.cc index f59055c93..29cd8815b 100644 --- a/src/ui/param/ParamTreeItem.cc +++ b/src/ui/param/ParamTreeItem.cc @@ -37,6 +37,8 @@ ParamTreeItem::ParamTreeItem(QString name, float value, ParamTreeItem* parent) parentItem = parent; paramName = name; paramValue = value; + // Initialize empty itemData + itemData = QList(); } ParamTreeItem::ParamTreeItem(const QList &data, ParamTreeItem *parent) @@ -82,20 +84,27 @@ float ParamTreeItem::getParamValue() QVariant ParamTreeItem::data(int column) const { - QVariant ret; - switch (column) + if (itemData.empty()) { - case 0: - ret.setValue(paramName); - break; - case 1: - ret.setValue(paramValue); - break; - default: - ret.setValue(QString("")); - break; + QVariant ret; + switch (column) + { + case 0: + ret.setValue(paramName); + break; + case 1: + ret.setValue(paramValue); + break; + default: + ret.setValue(QString("")); + break; + } + return ret; + } + else + { + return itemData.value(column, QVariant(QString(""))); } - //return itemData.value(column); } ParamTreeItem *ParamTreeItem::parent() diff --git a/src/ui/param/ParamTreeModel.cc b/src/ui/param/ParamTreeModel.cc index 797f85cb3..b3484ff81 100644 --- a/src/ui/param/ParamTreeModel.cc +++ b/src/ui/param/ParamTreeModel.cc @@ -40,8 +40,9 @@ ParamTreeModel::ParamTreeModel(QObject *parent) QList rootData; rootData << tr("Parameter") << tr("Value"); rootItem = new ParamTreeItem(rootData); - QString data = "IMU\n ROLL_K_I\t1.255\n PITCH_K_P\t0.621\n PITCH_K_I\t2.5545\n"; - setupModelData(data.split(QString("\n")), rootItem); + + //String data = "IMU\n ROLL_K_I\t1.255\n PITCH_K_P\t0.621\n PITCH_K_I\t2.5545\n"; + //setupModelData(data.split(QString("\n")), rootItem); } ParamTreeModel::ParamTreeModel(const QString &data, QObject *parent) @@ -80,12 +81,17 @@ QVariant ParamTreeModel::data(const QModelIndex &index, int role) const return item->data(index.column()); } +bool ParamTreeModel::setData (const QModelIndex & index, const QVariant & value, int role) +{ + +} + Qt::ItemFlags ParamTreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) return 0; - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; } QVariant ParamTreeModel::headerData(int section, Qt::Orientation orientation, diff --git a/src/ui/param/ParamTreeModel.h b/src/ui/param/ParamTreeModel.h index b0a190287..1852c16ef 100644 --- a/src/ui/param/ParamTreeModel.h +++ b/src/ui/param/ParamTreeModel.h @@ -47,6 +47,7 @@ public: ~ParamTreeModel(); QVariant data(const QModelIndex &index, int role) const; + bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; -- 2.22.0