Skip to content

Commit

Permalink
界面:
Browse files Browse the repository at this point in the history
删除一个无用按钮

功能:
优化重命名按钮的逻辑
  • Loading branch information
pkhubpp8 committed Apr 20, 2024
1 parent 7177651 commit 38b95ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
22 changes: 17 additions & 5 deletions widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,27 @@ void Widget::on_renameButton_clicked()
if (sourceItem and destItem and resultItem)
{
QFileInfo srcFile(sourceItem->text());
bool result = QFile::rename(sourceItem->text(), srcFile.dir().filePath(destItem->text()));
// qDebug() << "src: " << sourceItem->text() << ", dst " << destItem->text();
if (result)
if (sourceItem->text() == srcFile.dir().filePath(destItem->text()))
{
resultItem->setText("修改成功");
resultItem->setText("无需修改");
continue;
}
if (QFile::exists(srcFile.dir().filePath(destItem->text())))
{
resultItem->setText("文件名冲突");
}
else
{
resultItem->setText("修改失败");
bool result = QFile::rename(sourceItem->text(), srcFile.dir().filePath(destItem->text()));
// qDebug() << "src: " << sourceItem->text() << ", dst " << destItem->text();
if (result)
{
resultItem->setText("修改成功");
}
else
{
resultItem->setText("修改失败");
}
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,6 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>90</x>
<y>490</y>
<width>91</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>重命名校验</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
Expand Down

0 comments on commit 38b95ed

Please sign in to comment.