diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,13 @@ // test code #include +#include +#include #include "channelinfomodel.h" +#include "utils.h" + +#include "color_selector.hpp" +#include "color_dialog.hpp" MainWindow* pMainWindow; @@ -55,16 +61,42 @@ int main(int argc, char *argv[]) w.show(); // test code - ChannelInfoModel cim(10, &a); + ChannelInfoModel cim(2, &a); QTableView tv; + QSpinBox cb; + + QObject::connect(&cb, SELECT::OVERLOAD_OF(&QSpinBox::valueChanged), [&cim](int value) + { + cim.setNumOfChannels(value); + }); tv.setModel(&cim); tv.show(); + // cb.show(); - // cim.setNumOfChannels(3); - // cim.setNumOfChannels(10); - // cim.setNumOfChannels(7); + cim.setNumOfChannels(3); + cim.setNumOfChannels(7); + cim.setNumOfChannels(10); + + + color_widgets::ColorSelector cpicker; + cpicker.setColor(QColor("red")); + cpicker.show(); + + QObject::connect(tv.selectionModel(), &QItemSelectionModel::currentRowChanged, + [&cim, &cpicker](const QModelIndex ¤t, const QModelIndex &previous) + { + cpicker.setColor(cim.data(current, Qt::ForegroundRole).value()); + }); + + QObject::connect(&cpicker, &color_widgets::ColorSelector::colorChanged, + [&cim, &tv](QColor color) + { + auto index = tv.selectionModel()->currentIndex(); + index = index.sibling(index.row(), 0); + cim.setData(index, color, Qt::ForegroundRole); + }); return a.exec(); }