snu-quiqcl / iquip

Ion trap Quantum computing User Interface Project
GNU General Public License v3.0
7 stars 0 forks source link

Lolenc Compatible Iquip #312

Open alexist2623 opened 2 months ago

alexist2623 commented 2 months ago

Feature you want to implement

To control lolenc from iquip, functionality must be added to recognize and work with both C and C++ files.

How the feature is implemented

In explore.py, a code block was added to the _addFile method to recognize .cpp and .c files. The code ensures that these files are included in the list of files processed by the method, alongside .py files.

    @pyqtSlot(list, object)
    def _addFile(self, experimentList: List[str], widget: Union[QTreeWidget, QTreeWidgetItem]):
        """Adds the files into the children of the widget.

        A file or directory which starts with "_" will be ignored, e.g. __pycache__/.

        Args:
            experimentList: The list of files under the widget path.
            widget: See _FileFinderThread class.
        """
        for experimentFile in experimentList:
            if experimentFile.startswith("_"):
                continue
            if experimentFile.endswith("/"):
                experimentFileItem = QTreeWidgetItem(widget)
                experimentFileItem.setText(0, experimentFile[:-1])
                # Make an empty item for indicating that it is a directory.
                QTreeWidgetItem(experimentFileItem)
            elif (
                experimentFile.endswith(".cpp") or 
                experimentFile.endswith(".c") or 
                experimentFile.endswith(".py")
            ):
                experimentFileItem = QTreeWidgetItem(widget)
                experimentFileItem.setText(0, experimentFile)
kangz12345 commented 2 months ago

You could use if experimentFile.endswith((".cpp", ".c", ".py")) instead. See endswith().

alexist2623 commented 2 months ago

Oh it can be used with tuple! thank you!