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