ObjectExplorerModel.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package MemoryX::gui-plugins::SceneEditor
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26#include <QBrush>
27#include <QMimeData>
28#include <QModelIndexList>
29#include <QPointer>
30#include <QSize>
31#include <QSortFilterProxyModel>
32#include <QStandardItemModel>
33#include <QStringList>
34
36
37namespace gui
38{
39 /**
40 * This class provides a model for storing classes from memoryxcontroller::PriorKnowledgeController and allows to filter them.
41 *
42 * @see memoryxcontroller::PriorKnowledgeController
43 */
44 class ObjectExplorerModel : public QSortFilterProxyModel
45 {
46 Q_OBJECT
47
48 private:
49 class ObjectExplorerModelPrivate : public QStandardItemModel
50 {
51 public:
52 explicit ObjectExplorerModelPrivate(const controller::ControllerPtr& control,
53 int rows,
54 int columns,
55 QObject* parent = 0);
56
57 QStringList mimeTypes() const override;
58
59 QMimeData* mimeData(const QModelIndexList& indexes) const override;
60
61 void onReload();
62
63 std::pair<std::string, std::string> getItemInformation(const QModelIndex& index);
64
65 QPixmap getItemPixmap(const QModelIndex& index) const;
66
67 private:
69 QSize sizeHint;
70
71 QIcon getPreviewImageOfObject(const controller::ControllerPtr& controller,
72 const memoryx::ObjectClassPtr& object);
73 };
74
75 public:
76 /**
77 * Creates a new instance of this class.
78 *
79 * @param control The main controller of the whole plugin.
80 *
81 * @see controller::Controller
82 */
83 explicit ObjectExplorerModel(const controller::ControllerPtr& control, QObject* parent = 0);
84
85 /**
86 * Reloads the model.
87 * Should be called after the plugin is connected.
88 */
89 void onConnect();
90
91 /**
92 * Sets the string to filter all classes. Only the classes, which contain this string are shown after this.
93 * The string is caseinsensitive.
94 *
95 * @param searchPattern The string to filter with.
96 */
97 void setFilterFixedString(QString searchPattern);
98
99 /**
100 * Returns a tupel containing information about the class at the given index.
101 * The tupel contains the class name at first and class collection at second position.
102 *
103 * @param index The index in this model of the class.
104 *
105 * @return The tupel containing the informations.
106 */
107 std::pair<std::string, std::string> getItemInformation(const QModelIndex& index);
108
109 /**
110 * Returns the Icon of the class at index.
111 *
112 * @param index The index in this model of the class.
113 *
114 * @return The pixmap containing the image.
115 */
116 QPixmap getItemPixmap(const QModelIndex& index) const;
117
118 signals:
119 void reload();
120
121 private slots:
122 void onReload();
123
124 private:
126 QPointer<gui::ObjectExplorerModel::ObjectExplorerModelPrivate> sModel;
127
128 bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
129 bool showThis(const QModelIndex& index) const;
130 };
131} // namespace gui
uint8_t index
ObjectExplorerModel(const controller::ControllerPtr &control, QObject *parent=0)
Creates a new instance of this class.
void onConnect()
Reloads the model.
std::pair< std::string, std::string > getItemInformation(const QModelIndex &index)
Returns a tupel containing information about the class at the given index.
QPixmap getItemPixmap(const QModelIndex &index) const
Returns the Icon of the class at index.
void setFilterFixedString(QString searchPattern)
Sets the string to filter all classes.
This file is part of ArmarX.
std::weak_ptr< Controller > ControllerWeakPtr
std::shared_ptr< Controller > ControllerPtr
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35