qtAvailableOperations.h 1.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
//=========================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
//
//  This software is distributed WITHOUT ANY WARRANTY; without even
//  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//  PURPOSE.  See the above copyright notice for more information.
//=========================================================================
#ifndef smtk_extension_qtAvailableOperations_h
#define smtk_extension_qtAvailableOperations_h

#include "smtk/extension/qt/Exports.h"

#include "smtk/operation/Operation.h"

#include <QListWidget>
#include <QVBoxLayout>

namespace smtk
{
namespace extension
{

/**\brief Present a list of available operations to users.
  *
  * Depending on whether the operation's defaults allow it,
  * an operation may be run immediately (with default parameters)
  * or sent to an editor (where the user may change parameters
  * and run or cancel editing).
  */
class SMTKQTEXT_EXPORT qtAvailableOperations : public QWidget
{
  Q_OBJECT
public:
  qtAvailableOperations(QWidget* parent = nullptr);
  virtual ~qtAvailableOperations();

  smtk::view::AvailableOperationsPtr operationSource() const { return m_operationSource; }
  void setOperationSource(smtk::view::AvailableOperationsPtr avail);

  QListWidget* listWidget() const { return m_operationList; }

signals:
  void tryOperation(const smtk::operation::Operation::Index& op);
  void editOperation(const smtk::operation::Operation::Index& op);
  void hoverOperation(const smtk::operation::Operation::Index& op);

protected:
  QListWidget* m_operationList;
  QVBoxLayout* m_layout;
  smtk::view::AvailableOperationsPtr m_operationSource;
  int m_operationSourceObserverId;

  void updateList();
};
}
}

#endif // smtk_extension_qtAvailableOperations_h