BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
widgetboxcategorylistview.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_WIDGETBOXCATEGORYLISTVIEW_H
43 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_WIDGETBOXCATEGORYLISTVIEW_H
44 
45 #include <QtDesigner/QDesignerWidgetBoxInterface>
46 
47 #include <QListView>
48 #include <QtCore/QList>
49 
50 QT_BEGIN_NAMESPACE
51 
52 class QDesignerFormEditorInterface;
53 class QDesignerDnDItemInterface;
54 
55 class QSortFilterProxyModel;
56 class QRegExp;
57 
59 
60 namespace qdesigner_internal {
61 
62 class WidgetBoxCategoryModel;
63 
64 // List view of a category, switchable between icon and list mode.
65 // Provides a filtered view.
66 class WidgetBoxCategoryListView : public QListView {
67  Q_OBJECT
68 public:
69  // Whether to access the filtered or unfiltered view
71 
72  // explicit WidgetBoxCategoryListView(QDesignerFormEditorInterface *core, QWidget *parent =
73  // 0);
74  explicit WidgetBoxCategoryListView(SampleDesignerInterface* core, QWidget* parent = 0);
75  void setViewMode(ViewMode vm);
76 
77  void dropWidgets(const QList<QDesignerDnDItemInterface*>& item_list);
78 
79  using QListView::contentsSize;
80 
81  // These methods operate on the filtered/unfiltered model according to accessmode
82  int count(EAccessMode am) const;
83  QDesignerWidgetBoxInterface::Widget widgetAt(EAccessMode am, const QModelIndex& index) const;
84  QDesignerWidgetBoxInterface::Widget widgetAt(EAccessMode am, int row) const;
85  void removeRow(EAccessMode am, int row);
86  void setCurrentItem(EAccessMode am, int row);
87 
88  // These methods operate on the unfiltered model and are used for serialization
89  void addWidget(const QDesignerWidgetBoxInterface::Widget& widget, const QIcon& icon,
90  bool editable);
91  bool containsWidget(const QString& name);
92  QDesignerWidgetBoxInterface::Category category() const;
93  bool removeCustomWidgets();
94 
95  // Helper: Ensure a <ui> tag in the case of empty XML
96  static QString widgetDomXml(const QDesignerWidgetBoxInterface::Widget& widget);
97 
98 signals:
100  void pressed(const QString& name, const QString& xml, const QPoint& globalPos);
101  void itemRemoved();
103 
104 public slots:
105  void filter(const QRegExp& re);
106 
107 private slots:
108  void slotPressed(const QModelIndex& index);
109  void removeCurrentItem();
110  void editCurrentItem();
111 
112 private:
113  int mapRowToSource(int filterRow) const;
114  QSortFilterProxyModel* m_proxyModel;
116 };
117 
118 } // namespace qdesigner_internal
119 
120 QT_END_NAMESPACE
121 
122 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_WIDGETBOXCATEGORYLISTVIEW_H
sample designer interface
WidgetBoxCategoryListView(SampleDesignerInterface *core, QWidget *parent=0)
QDesignerWidgetBoxInterface::Category category() const
QDesignerWidgetBoxInterface::Widget widgetAt(EAccessMode am, const QModelIndex &index) const
static QString widgetDomXml(const QDesignerWidgetBoxInterface::Widget &widget)
void dropWidgets(const QList< QDesignerDnDItemInterface * > &item_list)
void addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable)
void pressed(const QString &name, const QString &xml, const QPoint &globalPos)
QString const & name(EShape k)
Definition: particles.cpp:21