2014-01-29 19:14:04 +00:00
|
|
|
/*
|
2015-02-20 14:56:22 +00:00
|
|
|
Copyright 2006-2015 The QElectroTech Team
|
2014-01-29 19:14:04 +00:00
|
|
|
This file is part of QElectroTech.
|
2014-03-12 09:32:56 +00:00
|
|
|
|
2014-01-29 19:14:04 +00:00
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2014-03-12 09:32:56 +00:00
|
|
|
|
2014-01-29 19:14:04 +00:00
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2014-03-12 09:32:56 +00:00
|
|
|
|
2014-01-29 19:14:04 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2014-03-12 09:32:56 +00:00
|
|
|
#ifndef ELEMENTSELECTORWIDGET_H
|
|
|
|
#define ELEMENTSELECTORWIDGET_H
|
2013-12-28 13:28:27 +00:00
|
|
|
|
|
|
|
#include <QWidget>
|
2014-07-21 20:44:32 +00:00
|
|
|
class Element;
|
|
|
|
class QSignalMapper;
|
2014-12-03 10:45:16 +00:00
|
|
|
class QButtonGroup;
|
2013-12-28 13:28:27 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
2014-03-12 09:32:56 +00:00
|
|
|
class ElementSelectorWidget;
|
2013-12-28 13:28:27 +00:00
|
|
|
}
|
|
|
|
|
2014-02-26 23:57:22 +00:00
|
|
|
/**
|
2014-03-12 09:32:56 +00:00
|
|
|
* @brief The ElementSelectorWidget class
|
|
|
|
* This class provide a widget with a list of element.
|
|
|
|
* User can select an element in the list and higligth it.
|
|
|
|
* For know what element is selected, call selectedElement.
|
2014-02-26 23:57:22 +00:00
|
|
|
*/
|
2014-03-12 09:32:56 +00:00
|
|
|
class ElementSelectorWidget : public QWidget
|
2013-12-28 13:28:27 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-03-12 09:32:56 +00:00
|
|
|
///Methods
|
2013-12-28 13:28:27 +00:00
|
|
|
public:
|
2014-03-12 09:32:56 +00:00
|
|
|
explicit ElementSelectorWidget(QList <Element *> elmt_list, QWidget *parent = 0);
|
|
|
|
~ElementSelectorWidget();
|
|
|
|
Element * selectedElement () const{return selected_element;}
|
|
|
|
void showElement(Element *elmt);
|
2014-03-15 20:49:05 +00:00
|
|
|
void clear();
|
|
|
|
void setList(QList <Element *> elmt_list);
|
|
|
|
|
2014-12-04 10:54:38 +00:00
|
|
|
QStringList filter () const;
|
|
|
|
|
2014-03-15 20:49:05 +00:00
|
|
|
public slots:
|
2014-12-04 10:54:38 +00:00
|
|
|
void filtered(const QString &str);
|
2014-03-12 09:32:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void buildInterface();
|
2013-12-29 18:09:25 +00:00
|
|
|
|
|
|
|
private slots:
|
2015-05-07 22:15:00 +00:00
|
|
|
void setSelectedElement (const int i) {selected_element = elements_list.at(i);}
|
|
|
|
void showElementFromList (const int i);
|
|
|
|
void showedElementWasDeleted ();
|
2013-12-28 13:28:27 +00:00
|
|
|
|
2014-01-14 23:09:07 +00:00
|
|
|
|
2014-03-12 09:32:56 +00:00
|
|
|
///Attributes
|
|
|
|
private:
|
|
|
|
Ui::ElementSelectorWidget *ui;
|
2014-12-03 10:45:16 +00:00
|
|
|
QList <Element *> elements_list;
|
|
|
|
QSignalMapper *sm_, *sm_show_;
|
|
|
|
Element *selected_element, *showed_element;
|
|
|
|
QList <QWidget *> content_list;
|
2014-12-04 10:54:38 +00:00
|
|
|
QStringList in_filter, //In filter is used inside this class to filter the content of this widget
|
|
|
|
out_filter; //Out filter is used to return (with the method filter) a list of
|
|
|
|
//available string to filter the content of this widget
|
2014-12-03 10:45:16 +00:00
|
|
|
QButtonGroup *m_button_group;
|
2013-12-28 13:28:27 +00:00
|
|
|
};
|
|
|
|
|
2014-03-12 09:32:56 +00:00
|
|
|
#endif // ELEMENTSELECTORWIDGET_H
|