From 0c13708f4e22770fbbd631dc0f730df5ee675c79 Mon Sep 17 00:00:00 2001 From: Kochi Date: Mon, 13 Jan 2020 13:04:21 +0900 Subject: [PATCH] =?UTF-8?q?#135=20=E3=83=87=E3=82=A3=E3=83=AC=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=AA=E4=BD=9C=E6=88=90=E5=AF=BE=E5=BF=9C=20&=20#9?= =?UTF-8?q?=20=E9=95=B7=E3=81=95=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=AE=E7=82=BA=E5=BC=95=E6=95=B0=E3=82=92=E3=83=95?= =?UTF-8?q?=E3=83=AB=E3=83=91=E3=82=B9=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fileSystemManager.py | 9 +++++++-- tabObjects.py | 28 ++++++++++++++++------------ views/main.py | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/fileSystemManager.py b/fileSystemManager.py index c652485..34876d6 100644 --- a/fileSystemManager.py +++ b/fileSystemManager.py @@ -6,6 +6,7 @@ import win32api import re +import os from enum import Enum def GetFileSystemObject(letter): @@ -24,8 +25,12 @@ def GetFileSystemObject(letter): #end keyError return cls() -def ValidationObjectName(s): - """ファイルやディレクトリの名前sに何らかの問題があればその内容を返す""" +def ValidationObjectName(path): + """ + ファイルやディレクトリの名前pathに何らかの問題があればその内容を返す + sはフルパス + """ + s=os.path.split(path)[1] #使用できない文字の確認 ngString=[] diff --git a/tabObjects.py b/tabObjects.py index c99037b..782440d 100644 --- a/tabObjects.py +++ b/tabObjects.py @@ -324,17 +324,17 @@ def OnLabelEditEnd(self,evt): if evt.IsEditCancelled(): #ユーザによる編集キャンセル return e=self.hListCtrl.GetEditControl() - print(fileSystemManager.ValidationObjectName(e.GetLineText(0))) - if fileSystemManager.ValidationObjectName(e.GetLineText(0)): - dialog(_("エラー"),fileSystemManager.ValidationObjectName(e.GetLineText(0))) - evt.Veto() - return f=self.listObject.GetElement(self.hListCtrl.GetFocusedItem()) if isinstance(f,browsableObjects.File): - inst={"operation": "rename", "files": [f.fullpath], "to": [f.directory+"\\"+e.GetLineText(0)]} + newName=f.directory+"\\"+e.GetLineText(0) else: - inst={"operation": "rename", "files": [f.fullpath], "to": [e.GetLineText(0)]} + newName=e.GetLineText(0) #end ファイルかドライブか + if fileSystemManager.ValidationObjectName(newName): + dialog(_("エラー"),fileSystemManager.ValidationObjectName(e.GetLineText(0))) + evt.Veto() + return + inst={"operation": "rename", "files": [f.fullpath], "to": [newName]} op=fileOperator.FileOperator(inst) ret=op.Execute() if op.CheckSucceeded()==0: @@ -403,20 +403,24 @@ def SortCycleAd(self): self.hListCtrl.DeleteAllItems() self.UpdateListContent(self.listObject.GetItems()) - def UpdateFilelist(self,silence=False): + def UpdateFilelist(self,silence=False,cursorTargetName=""): """同じフォルダで、ファイルとフォルダ情報を最新に更新する。""" if silence==True: globalVars.app.say(_("更新")) - item=self.listObject.GetElement(self.GetFocusedItem()) + if cursorTargetName=="": + item=self.listObject.GetElement(self.GetFocusedItem()) result=self.listObject.Update() - cursor=self.listObject.Search(item.basename) if result != errorCodes.OK: return errorCodes.FILE_NOT_FOUND #アクセス負荷など + if cursorTargetName=="": + cursor=self.listObject.Search(item.basename,0) + else: + cursor=self.listObject.Search(cursorTargetName,0) self.Update(self.listObject,cursor) def MakeDirectory(self,newdir): dir=self.listObject.rootDirectory - if fileSystemManager.ValidationObjectName(newdir): + if fileSystemManager.ValidationObjectName(dir+"\\"+newdir): dialog(_("エラー"),fileSystemManager.ValidationObjectName(newdir)) return dest=os.path.join(dir,newdir) @@ -427,7 +431,7 @@ def MakeDirectory(self,newdir): dialog(_("エラー"),_("フォルダを作成できません。")) return #end error - self.UpdateFilelist(silence=True) + self.UpdateFilelist(silence=True,cursorTargetName=newdir) def MakeShortcut(self,option): prm="" diff --git a/views/main.py b/views/main.py index 1a1fbd6..2250c59 100644 --- a/views/main.py +++ b/views/main.py @@ -303,7 +303,7 @@ def OnMenuSelect(self,event): d.Initialize() ret=d.Show() if ret==wx.ID_CANCEL: return - self.parent.activeTab.MakeDirectory(self.parent.activeTab.listObject.rootDirectory+"\\"+d.GetValue()) + self.parent.activeTab.MakeDirectory(d.GetValue()) d.Destroy() return if selected==menuItemsStore.getRef("FILE_FILEOPTEST"):