mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
use itemClicked signal instead of currentItemChanged to trigger opening a file
This will handle the corner case: when user open file "f" and close it, this file is still current item, so if user want to re-open it by clicking on it, it won't work. Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
3f8c87a325
commit
b55ebe8f91
@ -12,8 +12,8 @@ VFileList::VFileList(QWidget *parent)
|
|||||||
|
|
||||||
connect(this, &VFileList::customContextMenuRequested,
|
connect(this, &VFileList::customContextMenuRequested,
|
||||||
this, &VFileList::contextMenuRequested);
|
this, &VFileList::contextMenuRequested);
|
||||||
connect(this, &VFileList::currentItemChanged,
|
connect(this, &VFileList::itemClicked,
|
||||||
this, &VFileList::currentFileItemChanged);
|
this, &VFileList::handleItemClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::initActions()
|
void VFileList::initActions()
|
||||||
@ -260,15 +260,15 @@ void VFileList::deleteFileAndUpdateList(QListWidgetItem *item)
|
|||||||
removeFileListItem(item);
|
removeFileListItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::currentFileItemChanged(QListWidgetItem *currentItem)
|
void VFileList::handleItemClicked(QListWidgetItem *currentItem)
|
||||||
{
|
{
|
||||||
if (!currentItem) {
|
if (!currentItem) {
|
||||||
emit currentFileChanged(QJsonObject());
|
emit fileClicked(QJsonObject());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject itemJson = currentItem->data(Qt::UserRole).toJsonObject();
|
QJsonObject itemJson = currentItem->data(Qt::UserRole).toJsonObject();
|
||||||
Q_ASSERT(!itemJson.isEmpty());
|
Q_ASSERT(!itemJson.isEmpty());
|
||||||
itemJson["path"] = QDir::cleanPath(QDir(rootPath).filePath(relativePath));
|
itemJson["path"] = QDir::cleanPath(QDir(rootPath).filePath(relativePath));
|
||||||
qDebug() << "click file:" << itemJson;
|
qDebug() << "click file:" << itemJson;
|
||||||
emit currentFileChanged(itemJson);
|
emit fileClicked(itemJson);
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ public:
|
|||||||
explicit VFileList(QWidget *parent = 0);
|
explicit VFileList(QWidget *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentFileChanged(QJsonObject fileJson);
|
void fileClicked(QJsonObject fileJson);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void newFile();
|
void newFile();
|
||||||
void deleteFile();
|
void deleteFile();
|
||||||
void contextMenuRequested(QPoint pos);
|
void contextMenuRequested(QPoint pos);
|
||||||
void currentFileItemChanged(QListWidgetItem *currentItem);
|
void handleItemClicked(QListWidgetItem *currentItem);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setDirectory(QJsonObject dirJson);
|
void setDirectory(QJsonObject dirJson);
|
||||||
|
@ -67,7 +67,7 @@ void VMainWindow::setupUI()
|
|||||||
SLOT(setTreePath(const QString&)));
|
SLOT(setTreePath(const QString&)));
|
||||||
connect(directoryTree, &VDirectoryTree::currentDirectoryChanged,
|
connect(directoryTree, &VDirectoryTree::currentDirectoryChanged,
|
||||||
fileList, &VFileList::setDirectory);
|
fileList, &VFileList::setDirectory);
|
||||||
connect(fileList, &VFileList::currentFileChanged,
|
connect(fileList, &VFileList::fileClicked,
|
||||||
tabs, &VTabWidget::openFile);
|
tabs, &VTabWidget::openFile);
|
||||||
|
|
||||||
setCentralWidget(mainSplitter);
|
setCentralWidget(mainSplitter);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user