mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
commit missing files to notify plugin folder
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1135 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
f1d7c604c1
commit
cd85935f9e
135
ground/src/plugins/notify/notifytablemodel.cpp
Normal file
135
ground/src/plugins/notify/notifytablemodel.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file notifytablemodel.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup notifyplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 3 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "notifytablemodel.h"
|
||||
|
||||
bool NotifyTableModel::setData(const QModelIndex &index,
|
||||
const QVariant &value, int role)
|
||||
{
|
||||
if (index.isValid() && role == Qt::EditRole) {
|
||||
if(index.column()==1)
|
||||
_list->at(index.row())->setRepeatFlag(value.toString());
|
||||
else
|
||||
if(index.column()==2)
|
||||
_list->at(index.row())->setExpireTimeout(value.toInt());
|
||||
|
||||
emit dataChanged(index, index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant NotifyTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (index.row() >= _list->size())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
switch(index.column())
|
||||
{
|
||||
case 0:
|
||||
return _list->at(index.row())->parseNotifyMessage();
|
||||
|
||||
case 1:
|
||||
return _list->at(index.row())->getRepeatFlag();
|
||||
|
||||
case 2:
|
||||
return _list->at(index.row())->getExpireTimeout();
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Qt::SizeHintRole == role){
|
||||
//QVariant size = data(index, Qt::SizeHintRole);
|
||||
return QVariant(10);
|
||||
}
|
||||
// if(role == Qt::DecorationRole)
|
||||
// if (index.column() == 0)
|
||||
// return defectsIcons[defectList->at(index.row()).id-1];
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant NotifyTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
return headerStrings.at(section);
|
||||
else
|
||||
if(orientation == Qt::Vertical)
|
||||
return QString("%1").arg(section);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool NotifyTableModel::insertRows(int position, int rows, const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
beginInsertRows(QModelIndex(), position, position+rows-1);
|
||||
|
||||
// for (int row=0; row < rows; ++row) {
|
||||
// _list->append(position);
|
||||
// }
|
||||
|
||||
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NotifyTableModel::removeRows(int position, int rows, const QModelIndex &index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
beginRemoveRows(QModelIndex(), position, position+rows-1);
|
||||
|
||||
for (int row=0; row < rows; ++row) {
|
||||
_list->removeAt(position);
|
||||
}
|
||||
|
||||
endRemoveRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotifyTableModel::entryUpdated(int offset)
|
||||
{
|
||||
QModelIndex idx = index(offset, 0);
|
||||
emit dataChanged(idx, idx);
|
||||
}
|
||||
|
||||
void NotifyTableModel::entryAdded(int position)
|
||||
{
|
||||
insertRows(position, 1,QModelIndex());
|
||||
}
|
79
ground/src/plugins/notify/notifytablemodel.h
Normal file
79
ground/src/plugins/notify/notifytablemodel.h
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file notifytablemodel.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup notifyplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 3 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, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef NOTIFYTABLEMODEL_H
|
||||
#define NOTIFYTABLEMODEL_H
|
||||
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QList>
|
||||
#include "NotifyPluginConfiguration.h"
|
||||
|
||||
class NotifyTableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NotifyTableModel(QList<NotifyPluginConfiguration*> *parentList, const QStringList& parentHeaderList, QObject *parent = 0)
|
||||
: QAbstractTableModel(parent),
|
||||
_list(parentList),
|
||||
headerStrings(parentHeaderList)
|
||||
{ }
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const
|
||||
{
|
||||
return _list->count();
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return Qt::ItemIsEnabled;
|
||||
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
bool insertRows(int position, int rows, const QModelIndex &index);
|
||||
bool removeRows(int position, int rows, const QModelIndex &index);
|
||||
|
||||
private slots:
|
||||
void entryUpdated(int offset);
|
||||
void entryAdded(int position);
|
||||
private:
|
||||
QList<NotifyPluginConfiguration*> *_list;
|
||||
QStringList headerStrings;
|
||||
};
|
||||
|
||||
|
||||
#endif // NOTIFYTABLEMODEL_H
|
Loading…
Reference in New Issue
Block a user