Sat, 28 Jul 2018 19:14:11 +0200
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Project/IdlCompilerDefineNameDialog.py Sat Jul 28 19:14:11 2018 +0200 @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +""" +Module implementing IdlCompilerDefineNameDialog. +""" + +from PyQt5.QtCore import pyqtSlot +from PyQt5.QtWidgets import QDialog + +from .Ui_IdlCompilerDefineNameDialog import Ui_IdlCompilerDefineNameDialog + + +class IdlCompilerDefineNameDialog(QDialog, Ui_IdlCompilerDefineNameDialog): + """ + Class documentation goes here. + """ + def __init__(self, parent=None): + """ + Constructor + + @param parent reference to the parent widget + @type QWidget + """ + super(IdlCompilerDefineNameDialog, self).__init__(parent) + self.setupUi(self) + + @pyqtSlot(str) + def on_nameEdit_textChanged(self, p0): + """ + Slot documentation goes here. + + @param p0 DESCRIPTION + @type str + """ + # TODO: not implemented yet + raise NotImplementedError
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Project/IdlCompilerDefineNameDialog.ui Sat Jul 28 19:14:11 2018 +0200 @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>IdlCompilerDefineNameDialog</class> + <widget class="QDialog" name="IdlCompilerDefineNameDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>108</height> + </rect> + </property> + <property name="windowTitle"> + <string>Define Name</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="nameEdit"> + <property name="toolTip"> + <string>Enter the variable name</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Value:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="valueEdit"> + <property name="toolTip"> + <string>Enter an optional value</string> + </property> + </widget> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>nameEdit</tabstop> + <tabstop>valueEdit</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>IdlCompilerDefineNameDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>IdlCompilerDefineNameDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Project/IdlCompilerOptionsDialog.py Sat Jul 28 19:14:11 2018 +0200 @@ -0,0 +1,370 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter some IDL compiler options. +""" + +from PyQt5.QtCore import pyqtSlot, Qt +from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QInputDialog + +from .Ui_IdlCompilerOptionsDialog import Ui_IdlCompilerOptionsDialog + +import UI.PixmapCache + +from E5Gui import E5PathPickerDialog +from E5Gui.E5PathPicker import E5PathPickerModes + + +class IdlCompilerOptionsDialog(QDialog, Ui_IdlCompilerOptionsDialog): + """ + Class implementing a dialog to enter some IDL compiler options. + """ + def __init__(self, includeDirectories, definedNames, undefinedNames, + project=None, parent=None): + """ + Constructor + + @param includeDirectories list of include directories + @type list of str + @param definedNames list of defined variables with name and value + separated by '=' + @type list of str + @param undefinedNames list of undefined names + @type list of str + @param projectDirectory directory name of the project + @type str + @param parent reference to the parent widget + @type QWidget + """ + super(IdlCompilerOptionsDialog, self).__init__(parent) + self.setupUi(self) + + self.__project = project + + self.idAddButton.setIcon(UI.PixmapCache.getIcon("plus.png")) + self.idDeleteButton.setIcon(UI.PixmapCache.getIcon("minus.png")) + self.idEditButton.setIcon(UI.PixmapCache.getIcon("edit.png")) + + self.dnAddButton.setIcon(UI.PixmapCache.getIcon("plus.png")) + self.dnDeleteButton.setIcon(UI.PixmapCache.getIcon("minus.png")) + self.dnEditButton.setIcon(UI.PixmapCache.getIcon("edit.png")) + + self.unAddButton.setIcon(UI.PixmapCache.getIcon("plus.png")) + self.unDeleteButton.setIcon(UI.PixmapCache.getIcon("minus.png")) + self.unEditButton.setIcon(UI.PixmapCache.getIcon("edit.png")) + + self.__populateIncludeDirectoriesList(includeDirectories) + self.__populateDefineNamesList(definedNames) + self.unList.addItems(undefinedNames) + + self.__updateIncludeDirectoryButtons() + self.__updateDefineNameButtons() + self.__updateUndefineNameButtons() + + ####################################################################### + ## Methods implementing the 'Include Directory' option + ####################################################################### + + def __updateIncludeDirectoryButtons(self): + """ + Private method to set the state of the 'Include Directory' buttons. + """ + enable = len(self.idList.selectedItems()) + self.idDeleteButton.setEnabled(enable) + self.idEditButton.setEnabled(enable) + + def __populateIncludeDirectoriesList(self, includeDirectories): + """ + Private method to populate the 'Include Directories' list. + + @param includeDirectories list of include directories + @type list of str + """ + for directory in includeDirectories: + if self.__project: + path = self.__project.getRelativeUniversalPath(directory) + if not path: + # it is the project directory + path = "." + self.idList.addItem(path) + else: + self.idList.addItem(directory) + + def __generateIncludeDirectoriesList(self): + """ + Private method to prepare the list of 'Include Directories'. + + @return list of 'Include Directories' + @rtype list of str + """ + return [ + self.idList.item(row).text() + for row in range(self.idList.count()) + ] + + def __includeDirectoriesContain(self, directory): + """ + Private method to test, if the currently defined 'Include Directories' + contain a given one. + + @param directory directory name to be tested + @type str + @return flag indicating that the given directory is already included + @rtype bool + """ + for row in range(self.idList.count()): + if self.idList.item(row).text() == directory: + return True + + return False + + @pyqtSlot() + def on_idList_itemSelectionChanged(self): + """ + Private slot handling the selection of an 'Include Directory' entry. + """ + self.__updateIncludeDirectoryButtons() + + @pyqtSlot() + def on_idAddButton_clicked(self): + """ + Private slot to add an 'Include Directory'. + """ + if self.__project: + defaultDirectory = self.__project.getProjectPath() + else: + defaultDirectory = "" + path, ok = E5PathPickerDialog.getPath( + self, + self.tr("Include Directory"), + self.tr("Select Include Directory"), + E5PathPickerModes.DirectoryShowFilesMode, + defaultDirectory=defaultDirectory + ) + if ok and path: + if self.__project: + path = self.__project.getRelativeUniversalPath(path) + if not path: + path = "." + if not self.__includeDirectoriesContain(path): + self.idList.addItem(path) + + @pyqtSlot() + def on_idDeleteButton_clicked(self): + """ + Private slot to delete the selected 'Include Directory' entry. + """ + itm = self.idList.selectedItems()[0] + row = self.idList.row(itm) + self.idList.takeItem(row) + del itm + + @pyqtSlot() + def on_idEditButton_clicked(self): + """ + Private slot to edit the selected 'Include Directory' entry. + """ + itm = self.idList.selectedItems()[0] + if self.__project: + path = self.__project.getAbsoluteUniversalPath(itm.text()) + defaultDirectory = self.__project.getProjectPath() + else: + path = itm.text() + defaultDirectory = "" + path, ok = E5PathPickerDialog.getPath( + self, + self.tr("Include Directory"), + self.tr("Select Include Directory"), + E5PathPickerModes.DirectoryShowFilesMode, + path=path, + defaultDirectory=defaultDirectory + ) + if ok and path: + if self.__project: + path = self.__project.getRelativeUniversalPath(path) + if not path: + path = "." + if self.__includeDirectoriesContain(path) and itm.text() != path: + # the entry exists already, delete the edited one + row = self.idList.row(itm) + self.idList.takeItem(row) + del itm + else: + itm.setText(path) + + ####################################################################### + ## Methods implementing the 'Define Name' option + ####################################################################### + + def __updateDefineNameButtons(self): + """ + Private method to set the state of the 'Define Name' buttons. + """ + enable = len(self.dnList.selectedItems()) + self.dnDeleteButton.setEnabled(enable) + self.dnEditButton.setEnabled(enable) + + def __populateDefineNamesList(self, definedNames): + """ + Private method to populate the list of defined names. + + @param definedNames list of defined variables with name and value + separated by '=' + @type list of str + """ + for definedName in definedNames: + if definedName: + nameValueList = definedName.split("=") + name = nameValueList[0].strip() + if len(nameValueList) > 1: + value = nameValueList[1].strip() + else: + value = "" + QTreeWidgetItem(self.dnList, [name, value]) + + self.dnList.sortItems(0, Qt.AscendingOrder) + + @pyqtSlot() + def on_dnList_itemSelectionChanged(self): + """ + Private slot handling the selection of a 'Define Name' entry. + """ + self.__updateDefineNameButtons() + + @pyqtSlot() + def on_dnAddButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_dnDeleteButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + @pyqtSlot() + def on_dnEditButton_clicked(self): + """ + Slot documentation goes here. + """ + # TODO: not implemented yet + raise NotImplementedError + + ####################################################################### + ## Methods implementing the 'Undefine Name' option + ####################################################################### + + def __updateUndefineNameButtons(self): + """ + Private method to set the state of the 'Undefine Name' buttons. + """ + enable = len(self.unList.selectedItems()) + self.unDeleteButton.setEnabled(enable) + self.unEditButton.setEnabled(enable) + + def __generateUndefinedNamesList(self): + """ + Private method to prepare the list of 'Undefined Names'. + + @return list of 'Undefined Names' + @rtype list of str + """ + return [ + self.unList.item(row).text() + for row in range(self.unList.count()) + ] + + def __undefinedNamesContain(self, name): + """ + Private method to test, if the currently defined 'Undefined Names' + contain a given one. + + @param name variable name to be tested + @type str + @return flag indicating that the given name is already included + @rtype bool + """ + for row in range(self.unList.count()): + if self.unList.item(row).text() == name: + return True + + return False + + @pyqtSlot() + def on_unList_itemSelectionChanged(self): + """ + Private slot handling the selection of a 'Undefine Name' entry. + """ + self.__updateUndefineNameButtons() + + @pyqtSlot() + def on_unAddButton_clicked(self): + """ + Private slot to add a 'Undefine Name' entry. + """ + name, ok = QInputDialog.getText( + self, + self.tr("Undefine Name"), + self.tr("Enter a variable name to be undefined:") + ) + name = name.strip() + if ok and name and not self.__undefinedNamesContain(name): + self.unList.addItem(name) + + @pyqtSlot() + def on_unDeleteButton_clicked(self): + """ + Private slot to delete the selected 'Undefine Name' entry. + """ + itm = self.unList.selectedItems()[0] + row = self.unList.row(itm) + self.unList.takeItem(row) + del itm + + @pyqtSlot() + def on_unEditButton_clicked(self): + """ + Private slot to edit the selected 'Undefine Name' entry. + """ + itm = self.unList.selectedItems()[0] + name, ok = QInputDialog.getText( + self, + self.tr("Undefine Name"), + self.tr("Enter a variable name to be undefined:"), + text=itm.text() + ) + name = name.strip() + if ok and name: + if self.__undefinedNamesContain(name) and itm.text() != name: + # the entry exists already, delete the edited one + row = self.unList.row(itm) + self.unList.takeItem(row) + del itm + else: + itm.setText(name) + + ####################################################################### + ## Methods implementing the result preparation + ####################################################################### + + def getData(self): + """ + Public method to return the data entered by the user. + + @return tuple containing the list of include directories, list of + defined names and list of undefined names + @rtype tuple of (list of str, list of str, list of str) + """ + return ( + self.__generateIncludeDirectoriesList(), + [], + self.__generateUndefinedNamesList(), + )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Project/IdlCompilerOptionsDialog.ui Sat Jul 28 19:14:11 2018 +0200 @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>IdlCompilerOptionsDialog</class> + <widget class="QDialog" name="IdlCompilerOptionsDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>IDL Compiler Options</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QGroupBox" name="includeDirectoriesGroup"> + <property name="title"> + <string>Include Directories (absolute or project relative)</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QListWidget" name="idList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QToolButton" name="idAddButton"> + <property name="toolTip"> + <string>Add an include directory</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="idDeleteButton"> + <property name="toolTip"> + <string>Delete an include directory</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="idEditButton"> + <property name="toolTip"> + <string>Edit an include directory</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Define Names</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QTreeWidget" name="dnList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="itemsExpandable"> + <bool>false</bool> + </property> + <property name="sortingEnabled"> + <bool>false</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <attribute name="headerDefaultSectionSize"> + <number>150</number> + </attribute> + <attribute name="headerShowSortIndicator" stdset="0"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string>Name</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string> </string> + </property> + </column> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QToolButton" name="dnAddButton"> + <property name="toolTip"> + <string>Add a name entry</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="dnDeleteButton"> + <property name="toolTip"> + <string>Delete a name entry</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="dnEditButton"> + <property name="toolTip"> + <string>Edit a name entry</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Undefine Names</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QListWidget" name="unList"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QToolButton" name="unAddButton"> + <property name="toolTip"> + <string>Add a name entry</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="unDeleteButton"> + <property name="toolTip"> + <string>Delete a name entry</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="unEditButton"> + <property name="toolTip"> + <string>Edit a name entry</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <tabstops> + <tabstop>idList</tabstop> + <tabstop>idAddButton</tabstop> + <tabstop>idDeleteButton</tabstop> + <tabstop>idEditButton</tabstop> + <tabstop>dnList</tabstop> + <tabstop>dnAddButton</tabstop> + <tabstop>dnDeleteButton</tabstop> + <tabstop>dnEditButton</tabstop> + <tabstop>unList</tabstop> + <tabstop>unAddButton</tabstop> + <tabstop>unDeleteButton</tabstop> + <tabstop>unEditButton</tabstop> + </tabstops> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>IdlCompilerOptionsDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>IdlCompilerOptionsDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>
--- a/Project/ProjectInterfacesBrowser.py Sat Jul 28 18:28:55 2018 +0200 +++ b/Project/ProjectInterfacesBrowser.py Sat Jul 28 19:14:11 2018 +0200 @@ -560,13 +560,14 @@ args.append("-bpython") args.append("-I.") for directory in params["IncludeDirs"]: - args.append("-I{0}".format(directory)) + args.append("-I{0}".format( + self.project.getAbsoluteUniversalPath(directory))) for name in params["DefinedNames"]: args.append("-D{0}".format(name)) for name in params["UndefinedNames"]: args.append("-U{0}".format(name)) - fn = os.path.join(self.project.ppath, fn) + fn = self.project.getAbsoluteUniversalPath(fn) self.idlFile = fn args.append("-C{0}".format(os.path.dirname(fn))) args.append(fn) @@ -669,12 +670,6 @@ i += 1 progress.setValue(numIDLs) - - def __configureCorba(self): - """ - Private method to open the configuration dialog. - """ - e5App().getObject("UserInterface").showPreferences("corbaPage") def __configureIdlCompiler(self): """ @@ -684,14 +679,17 @@ params = self.project.pdata["IDLPARAMS"] # TODO: remove this test code once done - print("__configureIdlCompiler") - return + params = { + "IncludeDirs": ["sub3", "sub2"], + "DefinedNames": ["n2", "n1=1", "n3 = h e l p"], + "UndefinedNames": ["v5", "v2", "aa"], + } # TODO: implement IDL compiler options dialog from .IdlCompilerOptionsDialog import IdlCompilerOptionsDialog dlg = IdlCompilerOptionsDialog( params["IncludeDirs"][:], params["DefinedNames"][:], - params["UndefinedNames"][:]) + params["UndefinedNames"][:], self.project, self) if dlg.exec_() == QDialog.Accepted: include, defined, undefined = dlg.getData() if include != params["IncludeDirs"]: @@ -703,3 +701,9 @@ if undefined != params["UndefinedNames"]: params["UndefinedNames"] = undefined[:] self.project.setDirty(True) + + def __configureCorba(self): + """ + Private method to open the configuration dialog. + """ + e5App().getObject("UserInterface").showPreferences("corbaPage")
--- a/eric6.e4p Sat Jul 28 18:28:55 2018 +0200 +++ b/eric6.e4p Sat Jul 28 19:14:11 2018 +0200 @@ -917,6 +917,8 @@ <Source>Project/CreateDialogCodeDialog.py</Source> <Source>Project/DebuggerPropertiesDialog.py</Source> <Source>Project/FiletypeAssociationDialog.py</Source> + <Source>Project/IdlCompilerDefineNameDialog.py</Source> + <Source>Project/IdlCompilerOptionsDialog.py</Source> <Source>Project/LexerAssociationDialog.py</Source> <Source>Project/MakePropertiesDialog.py</Source> <Source>Project/NewDialogClassDialog.py</Source> @@ -2067,6 +2069,8 @@ <Form>Project/CreateDialogCodeDialog.ui</Form> <Form>Project/DebuggerPropertiesDialog.ui</Form> <Form>Project/FiletypeAssociationDialog.ui</Form> + <Form>Project/IdlCompilerDefineNameDialog.ui</Form> + <Form>Project/IdlCompilerOptionsDialog.ui</Form> <Form>Project/LexerAssociationDialog.ui</Form> <Form>Project/MakePropertiesDialog.ui</Form> <Form>Project/NewDialogClassDialog.ui</Form>