/src/libtomahawk/widgets/checkdirtree.h

http://github.com/tomahawk-player/tomahawk · C Header · 91 lines · 53 code · 20 blank · 18 comment · 0 complexity · 596fcf4709fbafb0004ab2ec5da3d4af MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2011, Leo Franchi <lfranchi@kde.org>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef CHECKDIRTREE_H
  20. #define CHECKDIRTREE_H
  21. #include "DllMacro.h"
  22. #include <QFileSystemModel>
  23. #include <QTreeView>
  24. class DLLEXPORT CheckDirModel : public QFileSystemModel
  25. {
  26. Q_OBJECT
  27. public:
  28. CheckDirModel( QWidget* parent = 0 );
  29. virtual ~CheckDirModel();
  30. virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
  31. virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
  32. virtual bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );
  33. void setCheck( const QModelIndex& index, const QVariant& value );
  34. Qt::CheckState getCheck( const QModelIndex& index );
  35. signals:
  36. void dataChangedByUser( const QModelIndex & index );
  37. private slots:
  38. void getFileInfoResult();
  39. void volumeShowFinished();
  40. void processErrorOutput();
  41. private:
  42. QHash<QPersistentModelIndex, Qt::CheckState> m_checkTable;
  43. bool m_shownVolumes;
  44. QString m_setFilePath;
  45. QString m_getFileInfoPath;
  46. };
  47. class DLLEXPORT CheckDirTree : public QTreeView
  48. {
  49. Q_OBJECT
  50. public:
  51. CheckDirTree( QWidget* parent );
  52. void checkPath( const QString& path, Qt::CheckState state );
  53. void setExclusions( const QStringList& list );
  54. QStringList getExclusions();
  55. QStringList getCheckedPaths();
  56. signals:
  57. void changed();
  58. private slots:
  59. void onCollapse( const QModelIndex& idx );
  60. void onExpand( const QModelIndex& idx );
  61. void updateNode( const QModelIndex& idx );
  62. void modelReset();
  63. private:
  64. CheckDirModel m_dirModel;
  65. QSet<qint64> m_expandedSet;
  66. void fillDown( const QModelIndex& index );
  67. void updateParent( const QModelIndex& index );
  68. void getExclusionsForNode( const QModelIndex& index, QStringList& exclusions );
  69. void getChecksForNode( const QModelIndex& index, QStringList& checks );
  70. };
  71. #endif // CHECKDIRTREE_H