Skip to content
Snippets Groups Projects
Commit def1b0e3 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

rename "WidgetBox" to more appropriate name (continued)

parent 4acf8699
No related branches found
No related tags found
1 merge request!245More simplifications for SampleDesigner Toolbox
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "GUI/Views/SampleDesigner/SampleToolBox.h" #include "GUI/Views/SampleDesigner/SampleToolBox.h"
#include "GUI/Views/widgetbox/DesignerMimeData.h" #include "GUI/Views/widgetbox/DesignerMimeData.h"
#include "GUI/Views/widgetbox/widgetboxtreewidget.h" #include "GUI/Views/widgetbox/SampleToolBoxTreeWidget.h"
#include <QApplication> #include <QApplication>
#include <QFocusEvent> #include <QFocusEvent>
#include <QIcon> #include <QIcon>
...@@ -57,7 +57,7 @@ protected: ...@@ -57,7 +57,7 @@ protected:
} // namespace } // namespace
SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new WidgetBoxTreeWidget) SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new SampleToolBoxTreeWidget)
{ {
setObjectName(QLatin1String("SampleToolBox")); setObjectName(QLatin1String("SampleToolBox"));
setWindowTitle("Items Toolbox"); setWindowTitle("Items Toolbox");
...@@ -67,7 +67,7 @@ SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new Widg ...@@ -67,7 +67,7 @@ SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new Widg
QLineEdit* filterEdit = new FilterEdit(toolBar); QLineEdit* filterEdit = new FilterEdit(toolBar);
filterEdit->setPlaceholderText("Filter"); filterEdit->setPlaceholderText("Filter");
filterEdit->setClearButtonEnabled(true); filterEdit->setClearButtonEnabled(true);
connect(filterEdit, &QLineEdit::textChanged, m_view, &WidgetBoxTreeWidget::filter); connect(filterEdit, &QLineEdit::textChanged, m_view, &SampleToolBoxTreeWidget::filter);
toolBar->addWidget(filterEdit); toolBar->addWidget(filterEdit);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
...@@ -77,7 +77,7 @@ SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new Widg ...@@ -77,7 +77,7 @@ SampleToolBox::SampleToolBox(QWidget* parent) : QWidget(parent), m_view(new Widg
layout->addWidget(m_view); layout->addWidget(m_view);
setLayout(layout); setLayout(layout);
connect(m_view, &WidgetBoxTreeWidget::pressed, this, &SampleToolBox::handleMousePress); connect(m_view, &SampleToolBoxTreeWidget::pressed, this, &SampleToolBox::handleMousePress);
fill(); fill();
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <QWidget> #include <QWidget>
class WidgetBoxTreeWidget; class SampleToolBoxTreeWidget;
//! ToolBox on the left side of SampleView //! ToolBox on the left side of SampleView
class SampleToolBox : public QWidget { class SampleToolBox : public QWidget {
...@@ -34,7 +34,7 @@ private slots: ...@@ -34,7 +34,7 @@ private slots:
const QPoint& globalMousePos); const QPoint& globalMousePos);
private: private:
WidgetBoxTreeWidget* m_view; SampleToolBoxTreeWidget* m_view;
}; };
#endif // BORNAGAIN_GUI_VIEWS_SAMPLEDESIGNER_SAMPLETOOLBOX_H #endif // BORNAGAIN_GUI_VIEWS_SAMPLEDESIGNER_SAMPLETOOLBOX_H
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// //
// BornAgain: simulate and fit reflection and scattering // BornAgain: simulate and fit reflection and scattering
// //
//! @file GUI/Views/widgetbox/widgetboxtreewidget.cpp //! @file GUI/Views/widgetbox/SampleToolBoxTreeWidget.cpp
//! @brief Implements class WidgetBoxTreeWidget //! @brief Implements class SampleToolBoxTreeWidget
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// //
// ************************************************************************************************ // ************************************************************************************************
#include "GUI/Views/widgetbox/widgetboxtreewidget.h" #include "GUI/Views/widgetbox/SampleToolBoxTreeWidget.h"
#include "Base/Utils/Assert.h" #include "Base/Utils/Assert.h"
#include "GUI/Views/widgetbox/SampleToolBoxGroupView.h" #include "GUI/Views/widgetbox/SampleToolBoxGroupView.h"
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
#include <QMenu> #include <QMenu>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
WidgetBoxTreeWidget::WidgetBoxTreeWidget(QWidget* parent) : QTreeWidget(parent), m_iconMode(false) SampleToolBoxTreeWidget::SampleToolBoxTreeWidget(QWidget* parent)
: QTreeWidget(parent), m_iconMode(false)
{ {
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
setIndentation(0); setIndentation(0);
...@@ -46,7 +47,7 @@ WidgetBoxTreeWidget::WidgetBoxTreeWidget(QWidget* parent) : QTreeWidget(parent), ...@@ -46,7 +47,7 @@ WidgetBoxTreeWidget::WidgetBoxTreeWidget(QWidget* parent) : QTreeWidget(parent),
SLOT(handleMousePress(QTreeWidgetItem*))); SLOT(handleMousePress(QTreeWidgetItem*)));
} }
SampleToolBoxGroupView* WidgetBoxTreeWidget::categoryViewAt(int idx) const SampleToolBoxGroupView* SampleToolBoxTreeWidget::categoryViewAt(int idx) const
{ {
SampleToolBoxGroupView* rc = nullptr; SampleToolBoxGroupView* rc = nullptr;
if (QTreeWidgetItem* cat_item = topLevelItem(idx)) if (QTreeWidgetItem* cat_item = topLevelItem(idx))
...@@ -56,7 +57,7 @@ SampleToolBoxGroupView* WidgetBoxTreeWidget::categoryViewAt(int idx) const ...@@ -56,7 +57,7 @@ SampleToolBoxGroupView* WidgetBoxTreeWidget::categoryViewAt(int idx) const
return rc; return rc;
} }
void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item) void SampleToolBoxTreeWidget::handleMousePress(QTreeWidgetItem* item)
{ {
if (item == nullptr) if (item == nullptr)
return; return;
...@@ -74,7 +75,8 @@ void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item) ...@@ -74,7 +75,8 @@ void WidgetBoxTreeWidget::handleMousePress(QTreeWidgetItem* item)
} }
} }
SampleToolBoxGroupView* WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem* parent, bool iconMode) SampleToolBoxGroupView* SampleToolBoxTreeWidget::addCategoryView(QTreeWidgetItem* parent,
bool iconMode)
{ {
QTreeWidgetItem* embed_item = new QTreeWidgetItem(parent); QTreeWidgetItem* embed_item = new QTreeWidgetItem(parent);
embed_item->setFlags(Qt::ItemIsEnabled); embed_item->setFlags(Qt::ItemIsEnabled);
...@@ -86,7 +88,7 @@ SampleToolBoxGroupView* WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem* pa ...@@ -86,7 +88,7 @@ SampleToolBoxGroupView* WidgetBoxTreeWidget::addCategoryView(QTreeWidgetItem* pa
return categoryView; return categoryView;
} }
void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item) void SampleToolBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item)
{ {
QTreeWidgetItem* embedItem = cat_item->child(0); QTreeWidgetItem* embedItem = cat_item->child(0);
if (embedItem == nullptr) if (embedItem == nullptr)
...@@ -101,19 +103,19 @@ void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item) ...@@ -101,19 +103,19 @@ void WidgetBoxTreeWidget::adjustSubListSize(QTreeWidgetItem* cat_item)
embedItem->setSizeHint(0, QSize(-1, height - 1)); embedItem->setSizeHint(0, QSize(-1, height - 1));
} }
void WidgetBoxTreeWidget::slotListMode() void SampleToolBoxTreeWidget::slotListMode()
{ {
m_iconMode = false; m_iconMode = false;
updateViewMode(); updateViewMode();
} }
void WidgetBoxTreeWidget::slotIconMode() void SampleToolBoxTreeWidget::slotIconMode()
{ {
m_iconMode = true; m_iconMode = true;
updateViewMode(); updateViewMode();
} }
void WidgetBoxTreeWidget::updateViewMode() void SampleToolBoxTreeWidget::updateViewMode()
{ {
if (const int numTopLevels = topLevelItemCount()) { if (const int numTopLevels = topLevelItemCount()) {
for (int i = numTopLevels - 1; i >= 0; --i) { for (int i = numTopLevels - 1; i >= 0; --i) {
...@@ -129,7 +131,7 @@ void WidgetBoxTreeWidget::updateViewMode() ...@@ -129,7 +131,7 @@ void WidgetBoxTreeWidget::updateViewMode()
updateGeometries(); updateGeometries();
} }
void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e) void SampleToolBoxTreeWidget::resizeEvent(QResizeEvent* e)
{ {
QTreeWidget::resizeEvent(e); QTreeWidget::resizeEvent(e);
if (const int numTopLevels = topLevelItemCount()) { if (const int numTopLevels = topLevelItemCount()) {
...@@ -138,7 +140,7 @@ void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e) ...@@ -138,7 +140,7 @@ void WidgetBoxTreeWidget::resizeEvent(QResizeEvent* e)
} }
} }
void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e) void SampleToolBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e)
{ {
QTreeWidgetItem* item = itemAt(e->pos()); QTreeWidgetItem* item = itemAt(e->pos());
...@@ -165,7 +167,7 @@ void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e) ...@@ -165,7 +167,7 @@ void WidgetBoxTreeWidget::contextMenuEvent(QContextMenuEvent* e)
menu.exec(mapToGlobal(e->pos())); menu.exec(mapToGlobal(e->pos()));
} }
void WidgetBoxTreeWidget::filter(const QString& f) void SampleToolBoxTreeWidget::filter(const QString& f)
{ {
const bool empty = f.isEmpty(); const bool empty = f.isEmpty();
QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString); QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString);
...@@ -192,7 +194,7 @@ void WidgetBoxTreeWidget::filter(const QString& f) ...@@ -192,7 +194,7 @@ void WidgetBoxTreeWidget::filter(const QString& f)
updateGeometries(); updateGeometries();
} }
void WidgetBoxTreeWidget::addGroup(const QString& title) void SampleToolBoxTreeWidget::addGroup(const QString& title)
{ {
QTreeWidgetItem* cat_item = new QTreeWidgetItem(); QTreeWidgetItem* cat_item = new QTreeWidgetItem();
cat_item->setText(0, title); cat_item->setText(0, title);
...@@ -207,8 +209,8 @@ void WidgetBoxTreeWidget::addGroup(const QString& title) ...@@ -207,8 +209,8 @@ void WidgetBoxTreeWidget::addGroup(const QString& title)
adjustSubListSize(cat_item); adjustSubListSize(cat_item);
} }
void WidgetBoxTreeWidget::addEntry(const QString& title, const QIcon& icon, void SampleToolBoxTreeWidget::addEntry(const QString& title, const QIcon& icon,
const QString& className, const QString& tooltip) const QString& className, const QString& tooltip)
{ {
const auto cat_idx = topLevelItemCount() - 1; const auto cat_idx = topLevelItemCount() - 1;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// //
// BornAgain: simulate and fit reflection and scattering // BornAgain: simulate and fit reflection and scattering
// //
//! @file GUI/Views/widgetbox/widgetboxtreewidget.h //! @file GUI/Views/widgetbox/SampleToolBoxTreeWidget.h
//! @brief Defines class WidgetBoxTreeWidget //! @brief Defines class SampleToolBoxTreeWidget
//! //!
//! @homepage http://www.bornagainproject.org //! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING) //! @license GNU General Public License v3 or higher (see COPYING)
...@@ -12,19 +12,20 @@ ...@@ -12,19 +12,20 @@
// //
// ************************************************************************************************ // ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEWS_WIDGETBOX_WIDGETBOXTREEWIDGET_H #ifndef BORNAGAIN_GUI_VIEWS_WIDGETBOX_SAMPLETOOLBOXTREEWIDGET_H
#define BORNAGAIN_GUI_VIEWS_WIDGETBOX_WIDGETBOXTREEWIDGET_H #define BORNAGAIN_GUI_VIEWS_WIDGETBOX_SAMPLETOOLBOXTREEWIDGET_H
#include <QTreeWidget> #include <QTreeWidget>
class SampleToolBoxGroupView; class SampleToolBoxGroupView;
//! A tree of categories //! A tree of groups inside the Sample Designer's Sample toolbox.
class WidgetBoxTreeWidget : public QTreeWidget { //! The toolbox is the selection are at the left side of the Sample Designer.
class SampleToolBoxTreeWidget : public QTreeWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit WidgetBoxTreeWidget(QWidget* parent = 0); explicit SampleToolBoxTreeWidget(QWidget* parent = 0);
//! Adds a group at the end of the list //! Adds a group at the end of the list
void addGroup(const QString& title); void addGroup(const QString& title);
...@@ -58,4 +59,4 @@ private: ...@@ -58,4 +59,4 @@ private:
bool m_iconMode; bool m_iconMode;
}; };
#endif // BORNAGAIN_GUI_VIEWS_WIDGETBOX_WIDGETBOXTREEWIDGET_H #endif // BORNAGAIN_GUI_VIEWS_WIDGETBOX_SAMPLETOOLBOXTREEWIDGET_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment