Use a better heuristic to determine model canCut()
This commit is contained in:
parent
12f81a1dba
commit
92fc7f140b
@ -136,6 +136,11 @@ QVariant ArpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions ArpStatusModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
void ArpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
void ArpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
void setDeviceIndex(Port *port, int deviceIndex);
|
void setDeviceIndex(Port *port, int deviceIndex);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -242,6 +242,11 @@ QVariant DeviceModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions DeviceModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceModel::setPort(Port *port)
|
void DeviceModel::setPort(Port *port)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
void setPort(Port *port);
|
void setPort(Port *port);
|
||||||
QAbstractItemModel* detailModel(const QModelIndex &index);
|
QAbstractItemModel* detailModel(const QModelIndex &index);
|
||||||
|
|
||||||
|
@ -140,6 +140,11 @@ QVariant NdpStatusModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions NdpStatusModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
void NdpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
void NdpStatusModel::setDeviceIndex(Port *port, int deviceIndex)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
void setDeviceIndex(Port *port, int deviceIndex);
|
void setDeviceIndex(Port *port, int deviceIndex);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -243,3 +243,9 @@ QVariant PacketModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions PacketModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
QModelIndex index (int row, int col, const QModelIndex & parent = QModelIndex() ) const;
|
QModelIndex index (int row, int col, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
private:
|
private:
|
||||||
typedef union _IndexId
|
typedef union _IndexId
|
||||||
{
|
{
|
||||||
|
@ -200,6 +200,11 @@ QVariant PortModel::headerData(int /*section*/, Qt::Orientation orientation, int
|
|||||||
return QString("Name");
|
return QString("Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions PortModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex PortModel::index (int row, int col,
|
QModelIndex PortModel::index (int row, int col,
|
||||||
const QModelIndex & parent) const
|
const QModelIndex & parent) const
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,8 @@ public:
|
|||||||
const QModelIndex &parent = QModelIndex()) const;
|
const QModelIndex &parent = QModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
bool isPortGroup(const QModelIndex& index);
|
bool isPortGroup(const QModelIndex& index);
|
||||||
bool isPort(const QModelIndex& index);
|
bool isPort(const QModelIndex& index);
|
||||||
quint32 portGroupId(const QModelIndex& index);
|
quint32 portGroupId(const QModelIndex& index);
|
||||||
|
@ -297,6 +297,11 @@ QVariant PortStatsModel::headerData(int section, Qt::Orientation orientation, in
|
|||||||
return PortStatName.at(section);
|
return PortStatName.at(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions PortStatsModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
void PortStatsModel::portListFromIndex(QModelIndexList indices,
|
void PortStatsModel::portListFromIndex(QModelIndexList indices,
|
||||||
QList<PortGroupAndPortList> &portList)
|
QList<PortGroupAndPortList> &portList)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,8 @@ class PortStatsModel : public QAbstractTableModel
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
class PortGroupAndPortList {
|
class PortGroupAndPortList {
|
||||||
public:
|
public:
|
||||||
uint portGroupId;
|
uint portGroupId;
|
||||||
|
@ -156,6 +156,11 @@ QVariant StreamStatsModel::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions StreamStatsModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::IgnoreAction; // read-only model, doesn't accept any data
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------- //
|
// --------------------------------------------- //
|
||||||
// Slots
|
// Slots
|
||||||
// --------------------------------------------- //
|
// --------------------------------------------- //
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
int role = Qt::DisplayRole) const;
|
int role = Qt::DisplayRole) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearStats();
|
void clearStats();
|
||||||
void appendStreamStatsList(quint32 portGroupId,
|
void appendStreamStatsList(quint32 portGroupId,
|
||||||
|
@ -22,9 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
#include "devicegroupmodel.h"
|
|
||||||
#include "streammodel.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -41,10 +38,8 @@ public:
|
|||||||
|
|
||||||
void setModel(QAbstractItemModel *model)
|
void setModel(QAbstractItemModel *model)
|
||||||
{
|
{
|
||||||
// XXX: yes, this is hacky; but there's no way to figure out
|
// This is only a heuristic, but works for us
|
||||||
// if a model allows removeRows() or not
|
if (model && model->supportedDropActions() != Qt::IgnoreAction)
|
||||||
if (dynamic_cast<StreamModel*>(model)
|
|
||||||
|| dynamic_cast<DeviceGroupModel*>(model))
|
|
||||||
_modelAllowsRemove = true;
|
_modelAllowsRemove = true;
|
||||||
else
|
else
|
||||||
_modelAllowsRemove = false;
|
_modelAllowsRemove = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user