Verified Commit e4d86a50 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

adapted to tlibs2 changes

parent 4ce73fd5
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
#include "tlibs2/libs/glplot.h" #include "tlibs2/libs/glplot.h"
#include "tlibs2/libs/math20.h" #include "tlibs2/libs/math20.h"
#include "tlibs2/libs/numerictablewidgetitem.h"
#include "../structfact/numerictablewidgetitem.h"
using t_real = double; using t_real = double;
......
/**
* numeric table widget item
* @author Tobias Weber <tweber@ill.fr>
* @date Dec-2018
* @license GPLv3, see 'LICENSE' file
* @desc The present version was forked on 28-Dec-2018 from my privately developed "misc" project (https://github.com/t-weber/misc).
*/
#ifndef __NUM_TABWIDGETITEM_H__
#define __NUM_TABWIDGETITEM_H__
#include <QtWidgets/QTableWidget>
#include <sstream>
#include <string>
template<class T = double>
class NumericTableWidgetItem : public QTableWidgetItem
{
public:
NumericTableWidgetItem(T&& val)
: QTableWidgetItem(std::to_string(std::forward<T>(val)).c_str())
{}
NumericTableWidgetItem(const T& val)
: QTableWidgetItem(std::to_string(val).c_str())
{}
NumericTableWidgetItem(const QString& val) : QTableWidgetItem(val)
{}
virtual bool operator<(const QTableWidgetItem& item) const override
{
T val1{}, val2{};
std::istringstream{text().toStdString()} >> val1;
std::istringstream{item.text().toStdString()} >> val2;
return val1 < val2;
}
virtual QTableWidgetItem* clone() const override
{
auto item = new NumericTableWidgetItem<T>(this->text());
item->setData(Qt::UserRole, this->data(Qt::UserRole));
return item;
};
};
#endif
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
#include "tlibs2/libs/glplot.h" #include "tlibs2/libs/glplot.h"
#include "tlibs2/libs/math20.h" #include "tlibs2/libs/math20.h"
#include "tlibs2/libs/qt/numerictablewidgetitem.h"
#include "numerictablewidgetitem.h"
using t_real = double; using t_real = double;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment