File locations are internal to LML so they can actually be removed very easily.
MyList::instance()->database()->addRequest(r);
}
+void MainWindow::on_myListView_removeFileLocationRequested(int id)
+{
+ myListModel->removeFileLocation(id);
+}
+
void MainWindow::on_filterInput_textChanged(const QString &filter)
{
switch (ui->filterType->currentIndex())
void on_myListView_openFileRequested(const QModelIndex &index);
void on_myListView_renameFilesRequested(const QModelIndex &index);
void on_myListView_dataRequested(const QModelIndex &index);
+ void on_myListView_removeFileLocationRequested(int id);
void on_filterInput_textChanged(const QString &filter);
void on_filterType_currentIndexChanged(int);
connect(renameTestAction, SIGNAL(triggered()), this, SLOT(renameTest()));
requestDataAction = new QAction(tr("Request Data"), this);
connect(requestDataAction, SIGNAL(triggered()), this, SLOT(requestData()));
+ removeFileLocationAction = new QAction(tr("Remove this File Location"), this);
+ connect(removeFileLocationAction, SIGNAL(triggered()), this, SLOT(removeFileLocation()));
if (!LocalMyList::MyList::isUdpClientAvailable())
{
aniDBLinkAction->setText(tr("Open AniDB Page (%1%2)").arg('f').arg(node->id()));
actions << aniDBLinkAction
<< renameTestAction
- << renameFilesAction;
+ << renameFilesAction
+ << removeFileLocationAction;
break;
default:
break;
{
emit dataRequested(customContextMenuIndex);
}
+
+void MyListView::removeFileLocation()
+{
+ int id = myListFilterModel()->node(customContextMenuIndex)->id();
+ if (id)
+ emit removeFileLocationRequested(id);
+}
void renameFilesRequested(const QModelIndex &index);
void dataRequested(const QModelIndex &index);
void renameTest(int fid);
+ void removeFileLocationRequested(int locationId);
private slots:
MyListFilterModel *myListFilterModel() const;
void requestFileRename();
void renameTest();
void requestData();
+ void removeFileLocation();
private:
QModelIndex customContextMenuIndex;
QAction *renameTestAction;
QAction *renameFilesAction;
QAction *requestDataAction;
+ QAction *removeFileLocationAction;
};
#endif // MYLISTVIEW_H
return index(node);
}
+void MyListModel::removeFileLocation(int id)
+{
+ auto it = fileLocationSet.find(id);
+
+ if (it != fileLocationSet.end())
+ {
+ MyListFileLocationNode *node = it->node;
+ MyListNode *parent = node->parent();
+
+ parent->childRemoved(node);
+ }
+
+ MyList::instance()->database()->removeFileLocation(id);
+}
+
+void MyListModel::removeFileLocation(const QModelIndex &index)
+{
+ MyListNode *node = static_cast<MyListNode *>(index.internalPointer());
+
+ if (node->type() != MyListNode::FileLocationNode)
+ return;
+
+ removeFileLocation(node->id());
+}
+
QVariant MyListModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal)
FileLocation fileLocation(int id) const;
FileLocation fileLocation(const QModelIndex &index) const;
QModelIndex fileLocationIndex(int id) const;
+ void removeFileLocation(int id);
+ void removeFileLocation(const QModelIndex &index);
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
++m_totalRowCount;
}
+void MyListNode::childRemoved(MyListNode *child)
+{
+ const int row = child->row();
+
+ Q_ASSERT(childItems.contains(child));
+
+ model->beginRemoveRows(model->index(this), row, row + 1);
+ childItems.removeAt(row);
+ --m_totalRowCount;
+ model->endRemoveRows();
+ delete child;
+}
+
bool MyListNode::updated(Operation type)
{
Q_UNUSED(type)
virtual int id() const;
virtual void childAdded(int id);
+ virtual void childRemoved(MyListNode *child);
virtual bool updated(Operation type);
virtual void childUpdate(const EpisodeData &oldData, const EpisodeData &newData, Operation type);
virtual void childUpdate(const FileData &oldData, const FileData &newData, Operation type);