aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiff <spiff@xbmc.org>2011-01-08 13:34:35 +0100
committerspiff <spiff@xbmc.org>2011-01-10 20:00:33 +0100
commit41712a0298b4612481b423c17519dd59a03f0f5b (patch)
treee48d49b3a16139d2f6d48ebbc3a9eb9d64c73dbf
parent4476b2df112bfa69abe6e142346c574016371b58 (diff)
added: support for multi-file selections in the file browser. part of ticket #10894 (some cosmetic changes by me) - thanks to fellbeast
-rw-r--r--system/keymaps/keyboard.xml5
-rw-r--r--xbmc/GUIDialogFileBrowser.cpp54
-rw-r--r--xbmc/GUIDialogFileBrowser.h4
3 files changed, 63 insertions, 0 deletions
diff --git a/system/keymaps/keyboard.xml b/system/keymaps/keyboard.xml
index aef10c1692..29a9fa3d96 100644
--- a/system/keymaps/keyboard.xml
+++ b/system/keymaps/keyboard.xml
@@ -567,4 +567,9 @@
<backspace>Close</backspace>
</keyboard>
</NumericInput>
+ <FileBrowser>
+ <keyboard>
+ <space>Highlight</space>
+ </keyboard>
+ </FileBrowser>
</keymap>
diff --git a/xbmc/GUIDialogFileBrowser.cpp b/xbmc/GUIDialogFileBrowser.cpp
index ab1bb02cba..a4ca82feff 100644
--- a/xbmc/GUIDialogFileBrowser.cpp
+++ b/xbmc/GUIDialogFileBrowser.cpp
@@ -69,6 +69,7 @@ CGUIDialogFileBrowser::CGUIDialogFileBrowser()
m_singleList = false;
m_thumbLoader.SetObserver(this);
m_flipEnabled = false;
+ m_multipleSelection = false;
}
CGUIDialogFileBrowser::~CGUIDialogFileBrowser()
@@ -177,6 +178,16 @@ bool CGUIDialogFileBrowser::OnMessage(CGUIMessage& message)
OnClick(iItem);
return true;
}
+ else if (iAction == ACTION_HIGHLIGHT_ITEM && m_multipleSelection)
+ {
+ CFileItemPtr pItem = (*m_vecItems)[iItem];
+ if (!pItem->m_bIsShareOrDrive && !pItem->m_bIsFolder)
+ {
+ pItem->Select(!pItem->IsSelected());
+ CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), message.GetSenderId(), iItem + 1);
+ OnMessage(msg);
+ }
+ }
}
else if (message.GetSenderId() == CONTROL_OK)
{
@@ -205,6 +216,15 @@ bool CGUIDialogFileBrowser::OnMessage(CGUIMessage& message)
}
else
{
+ if (m_multipleSelection)
+ {
+ for (int iItem = 0; iItem < m_vecItems->Size(); ++iItem)
+ {
+ CFileItemPtr pItem = (*m_vecItems)[iItem];
+ if (pItem->IsSelected())
+ m_markedPath.push_back(pItem->m_strPath);
+ }
+ }
m_bConfirmed = true;
Close();
}
@@ -625,6 +645,11 @@ bool CGUIDialogFileBrowser::ShowAndGetImage(const VECSOURCES &shares, const CStd
return ShowAndGetFile(shares, ".png|.jpg|.bmp|.gif|.tbn", heading, path, true); // true for use thumbs
}
+bool CGUIDialogFileBrowser::ShowAndGetImageList(const VECSOURCES &shares, const CStdString &heading, CStdStringArray &path)
+{
+ return ShowAndGetFileList(shares, ".png|.jpg|.bmp|.gif|.tbn", heading, path, true); // true for use thumbs
+}
+
bool CGUIDialogFileBrowser::ShowAndGetDirectory(const VECSOURCES &shares, const CStdString &heading, CStdString &path, bool bWriteOnly)
{
// an extension mask of "/" ensures that no files are shown
@@ -744,6 +769,35 @@ bool CGUIDialogFileBrowser::ShowAndGetFile(const CStdString &directory, const CS
return confirmed;
}
+bool CGUIDialogFileBrowser::ShowAndGetFileList(const VECSOURCES &shares, const CStdString &mask, const CStdString &heading, CStdStringArray &path, bool useThumbs /* = false */, bool useFileDirectories /* = false */)
+{
+ CGUIDialogFileBrowser *browser = new CGUIDialogFileBrowser();
+ if (!browser)
+ return false;
+ g_windowManager.AddUniqueInstance(browser);
+
+ browser->m_useFileDirectories = useFileDirectories;
+ browser->m_multipleSelection = true;
+ browser->m_browsingForImages = useThumbs;
+ browser->SetHeading(heading);
+ browser->SetSources(shares);
+ browser->m_browsingForFolders = 0;
+ browser->m_rootDir.SetMask(mask);
+ browser->m_addNetworkShareEnabled = false;
+ browser->DoModal();
+ bool confirmed(browser->IsConfirmed());
+ if (confirmed)
+ {
+ if (browser->m_markedPath.size())
+ path = browser->m_markedPath;
+ else
+ path.push_back(browser->m_selectedPath);
+ }
+ g_windowManager.Remove(browser->GetID());
+ delete browser;
+ return confirmed;
+}
+
void CGUIDialogFileBrowser::SetHeading(const CStdString &heading)
{
Initialize();
diff --git a/xbmc/GUIDialogFileBrowser.h b/xbmc/GUIDialogFileBrowser.h
index f03f1e4a4c..ca085b07e1 100644
--- a/xbmc/GUIDialogFileBrowser.h
+++ b/xbmc/GUIDialogFileBrowser.h
@@ -47,8 +47,10 @@ public:
static bool ShowAndGetFile(const VECSOURCES &shares, const CStdString &mask, const CStdString &heading, CStdString &path, bool useThumbs = false, bool useFileDirectories = false);
static bool ShowAndGetFile(const CStdString &directory, const CStdString &mask, const CStdString &heading, CStdString &path, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false);
static bool ShowAndGetSource(CStdString &path, bool allowNetworkShares, VECSOURCES* additionalShare = NULL, const CStdString& strType="");
+ static bool ShowAndGetFileList(const VECSOURCES &shares, const CStdString &mask, const CStdString &heading, CStdStringArray &path, bool useThumbs = false, bool useFileDirectories = false);
static bool ShowAndGetImage(const VECSOURCES &shares, const CStdString &heading, CStdString &path);
static bool ShowAndGetImage(const CFileItemList &items, const VECSOURCES &shares, const CStdString &heading, CStdString &path, bool* flip=NULL, int label=21371);
+ static bool ShowAndGetImageList(const VECSOURCES &shares, const CStdString &heading, CStdStringArray &path);
void SetSources(const VECSOURCES &shares);
@@ -87,6 +89,8 @@ protected:
bool m_browsingForImages;
bool m_useFileDirectories;
bool m_singleList; // if true, we have no shares or anything
+ bool m_multipleSelection;
+ CStdStringArray m_markedPath;
CPictureThumbLoader m_thumbLoader;
CGUIViewControl m_viewControl;