[Libreoffice-commits] .: Branch 'feature/template-dialog' - sfx2/inc sfx2/source
Rafael Dominguez
rdominguez at kemper.freedesktop.org
Mon Jun 25 19:03:36 PDT 2012
sfx2/inc/sfx2/templatefolderview.hxx | 3 +++
sfx2/inc/sfx2/thumbnailview.hxx | 3 +++
sfx2/source/control/templatefolderview.cxx | 6 ++++++
sfx2/source/control/thumbnailview.cxx | 9 +++++++++
sfx2/source/doc/templatedlg.cxx | 15 +++++++++++++++
5 files changed, 36 insertions(+)
New commits:
commit fbd484275ac7d53ceef49737800f7c528d10ebca
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Mon Jun 25 21:33:26 2012 -0430
Implement ThumbnailView sorting functionality.
- Add a class to sort items by their name.
Change-Id: I6f5fdc88e6d24ec826dab11e093d8cc826112cb8
diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index 5ae7385..00d88da 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -43,6 +43,9 @@ public:
void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
+ void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*,
+ const ThumbnailViewItem*) > &func);
+
void setTemplateStateHdl (const Link &aLink) { maTemplateStateHdl = aLink; }
bool removeTemplate (const sal_uInt16 nItemId);
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 887b504..f12a1fb 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -240,6 +240,9 @@ public:
void filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func);
+ void sortItems (const boost::function<bool (const ThumbnailViewItem*,
+ const ThumbnailViewItem*) > &func);
+
void setItemStateHdl (const Link &aLink) { maItemStateHdl = aLink; }
protected:
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index caef6bd..cb8b69c 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -342,6 +342,12 @@ void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
}
}
+void TemplateFolderView::sortOverlayItems(const boost::function<bool (const ThumbnailViewItem*,
+ const ThumbnailViewItem*) > &func)
+{
+ mpItemView->sortItems(func);
+}
+
bool TemplateFolderView::removeTemplate (const sal_uInt16 nItemId)
{
sal_uInt16 nRegionId = mpItemView->getRegionId();
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index cf4b225..0ede266 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1392,6 +1392,15 @@ void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailView
Invalidate();
}
+void ThumbnailView::sortItems (const boost::function<bool (const ThumbnailViewItem*, const ThumbnailViewItem*) > &func)
+{
+ std::sort(mItemList.begin(),mItemList.end(),func);
+
+ CalculateItemPositions();
+
+ Invalidate();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index ee4f3a2..dcf3fc0 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -43,6 +43,17 @@ using namespace ::com::sun::star::frame;
void lcl_createTemplate(uno::Reference<XComponentLoader> xDesktop, const FILTER_APPLICATION eApp);
+// Sort by name in ascending order
+class SortView_Name
+{
+public:
+
+ bool operator() (const ThumbnailViewItem *pItem1, const ThumbnailViewItem *pItem2)
+ {
+ return (pItem1->maText.compareTo(pItem2->maText) < 0);
+ }
+};
+
SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
: ModalDialog(parent, SfxResId(DLG_TEMPLATE_MANAGER)),
aButtonAll(this,SfxResId(BTN_SELECT_ALL)),
@@ -341,6 +352,10 @@ IMPL_LINK(SfxTemplateManagerDlg, MenuSelectHdl, Menu*, pMenu)
lcl_createTemplate(mxDesktop,FILTER_APP_DRAW);
break;
case MNI_ACTION_SORT_NAME:
+ if (maView->isOverlayVisible())
+ maView->sortOverlayItems(SortView_Name());
+ else
+ maView->sortItems(SortView_Name());
break;
default:
break;
More information about the Libreoffice-commits
mailing list