Project/Project.py

changeset 4211
c6e175462586
parent 4079
a3319822d303
child 4303
57b5de82ce05
equal deleted inserted replaced
4207:a0c8a7f9839c 4211:c6e175462586
1853 for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]: 1853 for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS"]:
1854 for entry in self.pdata[key][:]: 1854 for entry in self.pdata[key][:]:
1855 if entry.startswith(start): 1855 if entry.startswith(start):
1856 filelist.append(os.path.join(self.ppath, entry)) 1856 filelist.append(os.path.join(self.ppath, entry))
1857 return filelist 1857 return filelist
1858
1859 def __reorganizeFiles(self):
1860 """
1861 Private method to reorganize files stored in the project.
1862 """
1863 reorganized = False
1864
1865 # init data store for the reorganization
1866 newPdata = {}
1867 for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS",
1868 "TRANSLATIONS"]:
1869 newPdata[key] = []
1870
1871 # iterate over all files checking for a reassignment
1872 for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES", "OTHERS",
1873 "TRANSLATIONS"]:
1874 for fn in self.pdata[key][:]:
1875 filetype = key
1876 bfn = os.path.basename(fn)
1877 for pattern in reversed(
1878 sorted(self.pdata["FILETYPES"].keys())):
1879 if fnmatch.fnmatch(bfn, pattern):
1880 filetype = self.pdata["FILETYPES"][pattern]
1881 break
1882
1883 if filetype != "__IGNORE__":
1884 newPdata[filetype].append(fn)
1885 if filetype != key:
1886 reorganized = True
1887
1888 if reorganized:
1889 # copy the reorganized files back to the project
1890 for key in ["SOURCES", "FORMS", "INTERFACES", "RESOURCES",
1891 "OTHERS", "TRANSLATIONS"]:
1892 self.pdata[key] = newPdata[key][:]
1893
1894 # repopulate the model
1895 self.__model.projectClosed()
1896 self.__model.projectOpened()
1858 1897
1859 def copyDirectory(self, olddn, newdn): 1898 def copyDirectory(self, olddn, newdn):
1860 """ 1899 """
1861 Public slot to copy a directory. 1900 Public slot to copy a directory.
1862 1901
2469 self.pluginGrp.setEnabled( 2508 self.pluginGrp.setEnabled(
2470 self.pdata["PROJECTTYPE"][0] in ["E4Plugin", "E6Plugin"]) 2509 self.pdata["PROJECTTYPE"][0] in ["E4Plugin", "E6Plugin"])
2471 2510
2472 self.__model.projectPropertiesChanged() 2511 self.__model.projectPropertiesChanged()
2473 self.projectPropertiesChanged.emit() 2512 self.projectPropertiesChanged.emit()
2513
2514 if self.pdata["PROJECTTYPE"][0] != projectType:
2515 self.__reorganizeFiles()
2474 2516
2475 def __showUserProperties(self): 2517 def __showUserProperties(self):
2476 """ 2518 """
2477 Private slot to display the user specific properties dialog. 2519 Private slot to display the user specific properties dialog.
2478 """ 2520 """
2524 from .FiletypeAssociationDialog import FiletypeAssociationDialog 2566 from .FiletypeAssociationDialog import FiletypeAssociationDialog
2525 dlg = FiletypeAssociationDialog(self) 2567 dlg = FiletypeAssociationDialog(self)
2526 if dlg.exec_() == QDialog.Accepted: 2568 if dlg.exec_() == QDialog.Accepted:
2527 dlg.transferData() 2569 dlg.transferData()
2528 self.setDirty(True) 2570 self.setDirty(True)
2571 self.__reorganizeFiles()
2529 2572
2530 def __showLexerAssociations(self): 2573 def __showLexerAssociations(self):
2531 """ 2574 """
2532 Private slot to display the lexer association dialog. 2575 Private slot to display the lexer association dialog.
2533 """ 2576 """

eric ide

mercurial