| @@ -263,13 +263,37 @@ private: | |||||
| TreeViewContentComponent (const TreeViewContentComponent&); | TreeViewContentComponent (const TreeViewContentComponent&); | ||||
| const TreeViewContentComponent& operator= (const TreeViewContentComponent&); | const TreeViewContentComponent& operator= (const TreeViewContentComponent&); | ||||
| static void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers) | |||||
| void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers) | |||||
| { | { | ||||
| const bool shft = modifiers.isShiftDown(); | |||||
| const bool cmd = modifiers.isCommandDown(); | |||||
| TreeViewItem* firstSelected = 0; | |||||
| item->setSelected (shft || (! cmd) || (cmd && ! item->isSelected()), | |||||
| ! (shft || cmd)); | |||||
| if (modifiers.isShiftDown() && ((firstSelected = owner->getSelectedItem (0)) != 0)) | |||||
| { | |||||
| TreeViewItem* const lastSelected = owner->getSelectedItem (owner->getNumSelectedItems() - 1); | |||||
| jassert (lastSelected != 0); | |||||
| int rowStart = firstSelected->getRowNumberInTree(); | |||||
| int rowEnd = lastSelected->getRowNumberInTree(); | |||||
| if (rowStart > rowEnd) | |||||
| swapVariables (rowStart, rowEnd); | |||||
| int ourRow = item->getRowNumberInTree(); | |||||
| int otherEnd = ourRow < rowEnd ? (ourRow < rowStart ? (rowStart - 1) | |||||
| : rowStart) | |||||
| : (rowEnd + 1); | |||||
| if (ourRow > otherEnd) | |||||
| swapVariables (ourRow, otherEnd); | |||||
| for (int i = ourRow; i <= otherEnd; ++i) | |||||
| owner->getItemOnRow (i)->setSelected (true, false); | |||||
| } | |||||
| else | |||||
| { | |||||
| const bool cmd = modifiers.isCommandDown(); | |||||
| item->setSelected ((! cmd) || (! item->isSelected()), ! cmd); | |||||
| } | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -253,7 +253,12 @@ FileTreeComponent::~FileTreeComponent() | |||||
| //============================================================================== | //============================================================================== | ||||
| const File FileTreeComponent::getSelectedFile() const | const File FileTreeComponent::getSelectedFile() const | ||||
| { | { | ||||
| const FileListTreeItem* const item = dynamic_cast <const FileListTreeItem*> (getSelectedItem (0)); | |||||
| return getSelectedFile (0); | |||||
| } | |||||
| const File FileTreeComponent::getSelectedFile (const int index) const throw() | |||||
| { | |||||
| const FileListTreeItem* const item = dynamic_cast <const FileListTreeItem*> (getSelectedItem (index)); | |||||
| if (item != 0) | if (item != 0) | ||||
| return item->file; | return item->file; | ||||
| @@ -61,7 +61,17 @@ public: | |||||
| ~FileTreeComponent(); | ~FileTreeComponent(); | ||||
| //============================================================================== | //============================================================================== | ||||
| /** Returns the file that the user has currently selected. | |||||
| /** Returns the number of selected files in the tree. | |||||
| */ | |||||
| int getNumSelectedFiles() const throw() { return TreeView::getNumSelectedItems(); } | |||||
| /** Returns one of the files that the user has currently selected. | |||||
| Returns File::nonexistent if none is selected. | |||||
| */ | |||||
| const File getSelectedFile (int index) const throw(); | |||||
| /** Returns the first of the files that the user has currently selected. | |||||
| Returns File::nonexistent if none is selected. | Returns File::nonexistent if none is selected. | ||||
| */ | */ | ||||