ctkDirectoryListView.h 3.4 KB

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