Remove drag&drop support for now. It will be probably re-introduced after the plugin system is fully stable.
This commit is contained in:
parent
fd94a1bd8f
commit
54f17741ae
@ -138,96 +138,6 @@ void FeedsModel::updateAutoUpdateStatus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData *FeedsModel::mimeData(const QModelIndexList &indexes) const {
|
|
||||||
QMimeData *mime_data = new QMimeData();
|
|
||||||
QByteArray encoded_data;
|
|
||||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
|
||||||
|
|
||||||
foreach (const QModelIndex &index, indexes) {
|
|
||||||
if (index.column() != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
RootItem *item_for_index = itemForIndex(index);
|
|
||||||
|
|
||||||
if (item_for_index->kind() != RootItem::Root) {
|
|
||||||
stream << (quintptr) item_for_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mime_data->setData(MIME_TYPE_ITEM_POINTER, encoded_data);
|
|
||||||
return mime_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList FeedsModel::mimeTypes() const {
|
|
||||||
return QStringList() << MIME_TYPE_ITEM_POINTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) {
|
|
||||||
Q_UNUSED(row)
|
|
||||||
Q_UNUSED(column)
|
|
||||||
|
|
||||||
if (action == Qt::IgnoreAction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (action != Qt::MoveAction) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray dragged_items_data = data->data(MIME_TYPE_ITEM_POINTER);
|
|
||||||
|
|
||||||
if (dragged_items_data.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QDataStream stream(&dragged_items_data, QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
|
||||||
quintptr pointer_to_item;
|
|
||||||
stream >> pointer_to_item;
|
|
||||||
|
|
||||||
// We have item we want to drag, we also determine the target item.
|
|
||||||
RootItem *dragged_item = (RootItem*) pointer_to_item;
|
|
||||||
RootItem *target_item = itemForIndex(parent);
|
|
||||||
|
|
||||||
if (dragged_item == target_item || dragged_item->parent() == target_item) {
|
|
||||||
qDebug("Dragged item is equal to target item or its parent is equal to target item. Cancelling drag-drop action.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dragged_item->kind() == RootItem::Feeed) {
|
|
||||||
qDebug("Drag-drop action for feed '%s' detected, editing the feed.", qPrintable(dragged_item->title()));
|
|
||||||
|
|
||||||
StandardFeed *actual_feed = dragged_item->toFeed();
|
|
||||||
StandardFeed *feed_new = new StandardFeed(*actual_feed);
|
|
||||||
|
|
||||||
feed_new->setParent(target_item);
|
|
||||||
editFeed(actual_feed, feed_new);
|
|
||||||
|
|
||||||
emit requireItemValidationAfterDragDrop(indexForItem(actual_feed));
|
|
||||||
}
|
|
||||||
else if (dragged_item->kind() == RootItem::Cattegory) {
|
|
||||||
qDebug("Drag-drop action for category '%s' detected, editing the feed.", qPrintable(dragged_item->title()));
|
|
||||||
|
|
||||||
StandardCategory *actual_category = dragged_item->toCategory();
|
|
||||||
StandardCategory *category_new = new StandardCategory(*actual_category);
|
|
||||||
|
|
||||||
category_new->clearChildren();
|
|
||||||
category_new->setParent(target_item);
|
|
||||||
editCategory(actual_category, category_new);
|
|
||||||
|
|
||||||
emit requireItemValidationAfterDragDrop(indexForItem(actual_category));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::DropActions FeedsModel::supportedDropActions() const {
|
|
||||||
return Qt::MoveAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags FeedsModel::flags(const QModelIndex &index) const {
|
Qt::ItemFlags FeedsModel::flags(const QModelIndex &index) const {
|
||||||
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
Qt::ItemFlags base_flags = QAbstractItemModel::flags(index);
|
||||||
RootItem *item_for_index = itemForIndex(index);
|
RootItem *item_for_index = itemForIndex(index);
|
||||||
|
@ -55,10 +55,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
return itemForIndex(index)->data(index.column(), role);
|
return itemForIndex(index)->data(index.column(), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
|
||||||
QStringList mimeTypes() const;
|
|
||||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
|
||||||
Qt::DropActions supportedDropActions() const;
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||||
@ -196,8 +192,6 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
void assembleFeeds(FeedAssignment feeds);
|
void assembleFeeds(FeedAssignment feeds);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requireItemValidationAfterDragDrop(const QModelIndex &source_index);
|
|
||||||
|
|
||||||
// Emitted when model requests update of some feeds.
|
// Emitted when model requests update of some feeds.
|
||||||
void feedsUpdateRequested(const QList<Feed*> feeds);
|
void feedsUpdateRequested(const QList<Feed*> feeds);
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ FeedsView::FeedsView(QWidget *parent)
|
|||||||
m_sourceModel = m_proxyModel->sourceModel();
|
m_sourceModel = m_proxyModel->sourceModel();
|
||||||
|
|
||||||
// Connections.
|
// Connections.
|
||||||
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
|
||||||
connect(m_sourceModel, SIGNAL(feedsUpdateRequested(QList<Feed*>)), this, SIGNAL(feedsUpdateRequested(QList<Feed*>)));
|
connect(m_sourceModel, SIGNAL(feedsUpdateRequested(QList<Feed*>)), this, SIGNAL(feedsUpdateRequested(QList<Feed*>)));
|
||||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user