-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quantor Results are now transferred to the UI.
- Loading branch information
Fredo Erxleben
committed
Mar 6, 2015
1 parent
c9f41a5
commit eecc5e7
Showing
18 changed files
with
321 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "MapModel.h" | ||
|
||
using namespace q2d::util; | ||
|
||
MapModel::MapModel(QObject *parent) : | ||
QAbstractTableModel(parent) | ||
{ | ||
m_map = nullptr; | ||
} | ||
|
||
int MapModel::rowCount(const QModelIndex& parent) const | ||
{ | ||
Q_UNUSED(parent); | ||
if (m_map) | ||
return m_map->count(); | ||
return 0; | ||
} | ||
|
||
int MapModel::columnCount(const QModelIndex & parent) const | ||
{ | ||
Q_UNUSED(parent); | ||
return 2; | ||
} | ||
|
||
QVariant MapModel::data(const QModelIndex& index, int role) const | ||
{ | ||
if (m_map == nullptr) | ||
return QVariant(); | ||
if (index.row() < 0 || | ||
index.row() >= m_map->count() || | ||
role != Qt::DisplayRole) { | ||
return QVariant(); | ||
} | ||
if (index.column() == 0) | ||
return m_map->keys().at(index.row()); | ||
if (index.column() == 1) | ||
return m_map->values().at(index.row()); | ||
return QVariant(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef MAPMODEL_H | ||
#define MAPMODEL_H | ||
|
||
#include <QAbstractTableModel> | ||
#include <QMap> | ||
|
||
/** | ||
* @brief The MapModel class | ||
* @author mhcuervo | ||
* | ||
* COPYRIGHT NOTICE: this class was originally written by mhcuervo as posted on | ||
* http://stackoverflow.com/questions/23484511/how-to-display-a-simple-qmap-in-a-qtableview-in-qt | ||
* Changes were made due to refactoring and adaption to the concrete use case. | ||
*/ | ||
namespace q2d { | ||
namespace util { | ||
|
||
class MapModel : public QAbstractTableModel | ||
{ | ||
Q_OBJECT | ||
private: | ||
const QMap<QString, bool>* m_map; | ||
public: | ||
|
||
enum MapRoles { | ||
KeyRole = Qt::UserRole + 1, | ||
ValueRole | ||
}; | ||
|
||
explicit MapModel(QObject *parent = 0); | ||
int rowCount(const QModelIndex& parent = QModelIndex()) const; | ||
int columnCount(const QModelIndex& parent = QModelIndex()) const; | ||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | ||
inline void setMap(const QMap<QString, bool>* map) { m_map = map; } | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif // MAPMODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "QuantorResultDialog.h" | ||
#include "ui_QuantorResultDialog.h" | ||
|
||
#include "../MapModel.h" | ||
|
||
#include <QAbstractTableModel> | ||
|
||
QuantorResultDialog::QuantorResultDialog(QWidget *parent, QString resultText, const QMap<QString, bool>* resultMapping) : | ||
QDialog(parent), | ||
m_ui(new Ui::QuantorResultDialog) | ||
{ | ||
m_ui->setupUi(this); | ||
m_ui->lbl_resultText->setText(resultText); | ||
q2d::util::MapModel* model = new q2d::util::MapModel(this); | ||
model->setMap(resultMapping); | ||
m_ui->table_Assignments->setModel(model); | ||
} | ||
|
||
QuantorResultDialog::~QuantorResultDialog() | ||
{ | ||
m_ui->table_Assignments->model()->deleteLater(); | ||
delete m_ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef QUANTORRESULTDIALOG_H | ||
#define QUANTORRESULTDIALOG_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class QuantorResultDialog; | ||
} | ||
|
||
class QuantorResultDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
private: | ||
Ui::QuantorResultDialog *m_ui; | ||
public: | ||
explicit QuantorResultDialog(QWidget *parent, QString resultText, const QMap<QString, bool>* resultMapping); | ||
~QuantorResultDialog(); | ||
}; | ||
|
||
#endif // QUANTORRESULTDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>QuantorResultDialog</class> | ||
<widget class="QDialog" name="QuantorResultDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLabel" name="lbl_result"> | ||
<property name="text"> | ||
<string>Result:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="lbl_resultText"> | ||
<property name="text"> | ||
<string>(NONE)</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="QTableView" name="table_Assignments"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.