mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
enable multiple selection in file list
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
02d5300821
commit
46c8025215
@ -483,6 +483,17 @@ void VDirectoryTree::mousePressEvent(QMouseEvent *event)
|
||||
QTreeWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void VDirectoryTree::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Return) {
|
||||
QTreeWidgetItem *item = currentItem();
|
||||
if (item) {
|
||||
item->setExpanded(!item->isExpanded());
|
||||
}
|
||||
}
|
||||
QTreeWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
bool VDirectoryTree::copyDirectory(VDirectory *p_destDir, const QString &p_destName,
|
||||
VDirectory *p_srcDir, bool p_cut)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ private slots:
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
void updateDirectoryTreeOne(QTreeWidgetItem *p_parent, int depth);
|
||||
|
@ -20,6 +20,7 @@ void VFileList::setupUI()
|
||||
{
|
||||
fileList = new QListWidget(this);
|
||||
fileList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
fileList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(fileList);
|
||||
@ -27,7 +28,7 @@ void VFileList::setupUI()
|
||||
|
||||
connect(fileList, &QListWidget::customContextMenuRequested,
|
||||
this, &VFileList::contextMenuRequested);
|
||||
connect(fileList, &QListWidget::itemClicked,
|
||||
connect(fileList, &QListWidget::itemActivated,
|
||||
this, &VFileList::handleItemClicked);
|
||||
|
||||
setLayout(mainLayout);
|
||||
@ -221,9 +222,11 @@ QVector<QListWidgetItem *> VFileList::updateFileListAdded()
|
||||
// Delete the file related to current item
|
||||
void VFileList::deleteFile()
|
||||
{
|
||||
QListWidgetItem *curItem = fileList->currentItem();
|
||||
Q_ASSERT(curItem);
|
||||
deleteFile(getVFile(curItem));
|
||||
QList<QListWidgetItem *> items = fileList->selectedItems();
|
||||
Q_ASSERT(!items.isEmpty());
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
deleteFile(getVFile(items.at(i)));
|
||||
}
|
||||
}
|
||||
|
||||
// @p_file may or may not be listed in VFileList
|
||||
@ -274,7 +277,7 @@ void VFileList::contextMenuRequested(QPoint pos)
|
||||
menu.addAction(pasteAct);
|
||||
}
|
||||
|
||||
if (item) {
|
||||
if (item && fileList->selectedItems().size() == 1) {
|
||||
menu.addSeparator();
|
||||
menu.addAction(fileInfoAct);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user