| @@ -67,7 +67,6 @@ namespace ProjectSettingsTreeClasses | |||||
| configTree.addListener (this); | configTree.addListener (this); | ||||
| } | } | ||||
| bool isRoot() const { return false; } | |||||
| bool isMissing() { return false; } | bool isMissing() { return false; } | ||||
| bool canBeSelected() const { return true; } | bool canBeSelected() const { return true; } | ||||
| bool mightContainSubItems() { return false; } | bool mightContainSubItems() { return false; } | ||||
| @@ -169,7 +168,6 @@ namespace ProjectSettingsTreeClasses | |||||
| jassert (exporter != nullptr); | jassert (exporter != nullptr); | ||||
| } | } | ||||
| bool isRoot() const { return false; } | |||||
| bool canBeSelected() const { return true; } | bool canBeSelected() const { return true; } | ||||
| bool mightContainSubItems() { return exporter->getNumConfigurations() > 0; } | bool mightContainSubItems() { return exporter->getNumConfigurations() > 0; } | ||||
| String getUniqueName() const { return project.getProjectUID() + "_exporter_" + String (exporterIndex); } | String getUniqueName() const { return project.getProjectUID() + "_exporter_" + String (exporterIndex); } | ||||
| @@ -292,7 +290,6 @@ namespace ProjectSettingsTreeClasses | |||||
| public: | public: | ||||
| ModulesItem (Project& project_) : project (project_) {} | ModulesItem (Project& project_) : project (project_) {} | ||||
| bool isRoot() const { return false; } | |||||
| bool canBeSelected() const { return true; } | bool canBeSelected() const { return true; } | ||||
| bool mightContainSubItems() { return false; } | bool mightContainSubItems() { return false; } | ||||
| String getUniqueName() const { return project.getProjectUID() + "_modules"; } | String getUniqueName() const { return project.getProjectUID() + "_modules"; } | ||||
| @@ -348,7 +345,6 @@ namespace ProjectSettingsTreeClasses | |||||
| exportersTree.addListener (this); | exportersTree.addListener (this); | ||||
| } | } | ||||
| bool isRoot() const { return true; } | |||||
| String getRenamingName() const { return getDisplayName(); } | String getRenamingName() const { return getDisplayName(); } | ||||
| String getDisplayName() const { return project.getTitle(); } | String getDisplayName() const { return project.getTitle(); } | ||||
| void setName (const String&) {} | void setName (const String&) {} | ||||
| @@ -362,12 +358,11 @@ namespace ProjectSettingsTreeClasses | |||||
| void addSubItems() | void addSubItems() | ||||
| { | { | ||||
| addSubItem (new ModulesItem (project)); | addSubItem (new ModulesItem (project)); | ||||
| JucerApplication::getApp()->addExtraConfigItems (project, *this); | |||||
| int i = 0; | int i = 0; | ||||
| for (Project::ExporterIterator exporter (project); exporter.next(); ++i) | for (Project::ExporterIterator exporter (project); exporter.next(); ++i) | ||||
| addSubItem (new ExporterItem (project, exporter.exporter.release(), i)); | addSubItem (new ExporterItem (project, exporter.exporter.release(), i)); | ||||
| JucerApplication::getApp()->addExtraConfigItems (project, *this); | |||||
| } | } | ||||
| void showPopupMenu() | void showPopupMenu() | ||||
| @@ -31,63 +31,6 @@ | |||||
| #include "../Project Saving/jucer_ProjectExporter.h" | #include "../Project Saving/jucer_ProjectExporter.h" | ||||
| //============================================================================== | |||||
| class TreePanelBase : public Component | |||||
| { | |||||
| public: | |||||
| TreePanelBase (const String& opennessStateKey_) | |||||
| : opennessStateKey (opennessStateKey_) | |||||
| { | |||||
| addAndMakeVisible (&tree); | |||||
| tree.setRootItemVisible (true); | |||||
| tree.setDefaultOpenness (true); | |||||
| tree.setColour (TreeView::backgroundColourId, Colours::transparentBlack); | |||||
| tree.setIndentSize (14); | |||||
| } | |||||
| ~TreePanelBase() | |||||
| { | |||||
| tree.setRootItem (nullptr); | |||||
| } | |||||
| void setRoot (JucerTreeViewBase* root) | |||||
| { | |||||
| rootItem = root; | |||||
| tree.setRootItem (root); | |||||
| tree.getRootItem()->setOpen (true); | |||||
| const ScopedPointer<XmlElement> treeOpenness (StoredSettings::getInstance()->getProps() | |||||
| .getXmlValue (opennessStateKey)); | |||||
| if (treeOpenness != nullptr) | |||||
| tree.restoreOpennessState (*treeOpenness, true); | |||||
| } | |||||
| void saveOpenness() | |||||
| { | |||||
| const ScopedPointer<XmlElement> opennessState (tree.getOpennessState (true)); | |||||
| if (opennessState != nullptr) | |||||
| StoredSettings::getInstance()->getProps().setValue (opennessStateKey, opennessState); | |||||
| } | |||||
| void deleteSelectedItems() | |||||
| { | |||||
| if (rootItem != nullptr) | |||||
| rootItem->deleteAllSelectedItems(); | |||||
| } | |||||
| void resized() | |||||
| { | |||||
| tree.setBounds (getLocalBounds()); | |||||
| } | |||||
| TreeView tree; | |||||
| ScopedPointer<JucerTreeViewBase> rootItem; | |||||
| private: | |||||
| String opennessStateKey; | |||||
| }; | |||||
| //============================================================================== | //============================================================================== | ||||
| class FileTreeTab : public TreePanelBase | class FileTreeTab : public TreePanelBase | ||||
| { | { | ||||
| @@ -100,5 +100,62 @@ private: | |||||
| void invokeShowDocument(); | void invokeShowDocument(); | ||||
| }; | }; | ||||
| //============================================================================== | |||||
| class TreePanelBase : public Component | |||||
| { | |||||
| public: | |||||
| TreePanelBase (const String& opennessStateKey_) | |||||
| : opennessStateKey (opennessStateKey_) | |||||
| { | |||||
| addAndMakeVisible (&tree); | |||||
| tree.setRootItemVisible (true); | |||||
| tree.setDefaultOpenness (true); | |||||
| tree.setColour (TreeView::backgroundColourId, Colours::transparentBlack); | |||||
| tree.setIndentSize (14); | |||||
| } | |||||
| ~TreePanelBase() | |||||
| { | |||||
| tree.setRootItem (nullptr); | |||||
| } | |||||
| void setRoot (JucerTreeViewBase* root) | |||||
| { | |||||
| rootItem = root; | |||||
| tree.setRootItem (root); | |||||
| tree.getRootItem()->setOpen (true); | |||||
| const ScopedPointer<XmlElement> treeOpenness (StoredSettings::getInstance()->getProps() | |||||
| .getXmlValue (opennessStateKey)); | |||||
| if (treeOpenness != nullptr) | |||||
| tree.restoreOpennessState (*treeOpenness, true); | |||||
| } | |||||
| void saveOpenness() | |||||
| { | |||||
| const ScopedPointer<XmlElement> opennessState (tree.getOpennessState (true)); | |||||
| if (opennessState != nullptr) | |||||
| StoredSettings::getInstance()->getProps().setValue (opennessStateKey, opennessState); | |||||
| } | |||||
| void deleteSelectedItems() | |||||
| { | |||||
| if (rootItem != nullptr) | |||||
| rootItem->deleteAllSelectedItems(); | |||||
| } | |||||
| void resized() | |||||
| { | |||||
| tree.setBounds (getLocalBounds()); | |||||
| } | |||||
| TreeView tree; | |||||
| ScopedPointer<JucerTreeViewBase> rootItem; | |||||
| private: | |||||
| String opennessStateKey; | |||||
| }; | |||||
| #endif // __JUCER_JUCERTREEVIEWBASE_JUCEHEADER__ | |||||
| #endif | |||||
| @@ -447,23 +447,39 @@ public: | |||||
| Returns -1 if the substring is not found. | Returns -1 if the substring is not found. | ||||
| */ | */ | ||||
| template <typename CharPointerType1, typename CharPointerType2> | template <typename CharPointerType1, typename CharPointerType2> | ||||
| static int indexOf (CharPointerType1 haystack, const CharPointerType2& needle) noexcept | |||||
| static int indexOf (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept | |||||
| { | { | ||||
| int index = 0; | int index = 0; | ||||
| const int needleLength = (int) needle.length(); | |||||
| const int substringLength = (int) substringToLookFor.length(); | |||||
| for (;;) | for (;;) | ||||
| { | { | ||||
| if (haystack.compareUpTo (needle, needleLength) == 0) | |||||
| if (textToSearch.compareUpTo (substringToLookFor, substringLength) == 0) | |||||
| return index; | return index; | ||||
| if (haystack.getAndAdvance() == 0) | |||||
| if (textToSearch.getAndAdvance() == 0) | |||||
| return -1; | return -1; | ||||
| ++index; | ++index; | ||||
| } | } | ||||
| } | } | ||||
| /** Returns a pointer to the first occurrence of a substring in a string. | |||||
| If the substring is not found, this will return a pointer to the string's | |||||
| null terminator. | |||||
| */ | |||||
| template <typename CharPointerType1, typename CharPointerType2> | |||||
| static CharPointerType1 find (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept | |||||
| { | |||||
| const int substringLength = (int) substringToLookFor.length(); | |||||
| while (textToSearch.compareUpTo (substringToLookFor, substringLength) != 0 | |||||
| && ! textToSearch.isEmpty()) | |||||
| ++textToSearch; | |||||
| return textToSearch; | |||||
| } | |||||
| /** Finds the character index of a given substring in another string, using | /** Finds the character index of a given substring in another string, using | ||||
| a case-independent match. | a case-independent match. | ||||
| Returns -1 if the substring is not found. | Returns -1 if the substring is not found. | ||||