ctkDirectoryListView.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
  14. and was partially funded by NIH grant 3P41RR013218-12S1
  15. =========================================================================*/
  16. #ifndef __ctkDirectoryListView_h
  17. #define __ctkDirectoryListView_h
  18. // Qt includes
  19. #include <QWidget>
  20. // QtGUI includes
  21. #include "ctkWidgetsExport.h"
  22. class ctkDirectoryListViewPrivate;
  23. class CTK_WIDGETS_EXPORT ctkDirectoryListView : public QWidget
  24. {
  25. Q_OBJECT
  26. Q_PROPERTY(QStringList directoryList READ directoryList WRITE setDirectoryList NOTIFY directoryListChanged);
  27. public:
  28. /// Superclass typedef
  29. typedef QWidget Superclass;
  30. /// Constructor
  31. explicit ctkDirectoryListView(QWidget* parent = 0);
  32. /// Destructor
  33. virtual ~ctkDirectoryListView();
  34. /// Return True if the \a path has already been added
  35. bool hasDirectory(const QString& path)const;
  36. QStringList directoryList(bool absolutePath = false)const;
  37. QStringList selectedDirectoryList(bool absolutePath = false)const;
  38. public slots:
  39. /// If \a path exists, add it to the view and emit signal directoryListChanged().
  40. /// \sa directoryListChanged()
  41. void addDirectory(const QString& path);
  42. /// Remove all entries and set \a paths has current list.
  43. /// The signal directoryListChanged() is emitted if the current list of directories is
  44. /// different from the provided one.
  45. /// \sa addDirectory(), directoryListChanged()
  46. void setDirectoryList(const QStringList& paths);
  47. /// Remove \a path from the list.
  48. /// The signal directoryListChanged() is emitted if the path was in the list.
  49. /// \sa directoryListChanged()
  50. void removeDirectory(const QString& path);
  51. /// \sa selectAllDirectories()
  52. void removeSelectedDirectories();
  53. /// Select all directories.
  54. void selectAllDirectories();
  55. /// Clear the current directory selection.
  56. void clearDirectorySelection();
  57. signals:
  58. /// This signal is emitted when a directory is added to the view.
  59. void directoryListChanged();
  60. protected:
  61. QScopedPointer<ctkDirectoryListViewPrivate> d_ptr;
  62. private:
  63. Q_DECLARE_PRIVATE(ctkDirectoryListView);
  64. Q_DISABLE_COPY(ctkDirectoryListView);
  65. };
  66. #endif