1 #include <QColorDialog>
5 #include "qui/motif_editor/MotifDetail.hpp"
10 static const QRegExp iupacAlphabet("[ACTGUWRKYSMBHDVN]*", Qt::CaseInsensitive);
11 static const QRegExpValidator iupacValidator(iupacAlphabet, 0);
13 MotifDetail::MotifDetail(QWidget *parent)
15 motif_color(1.0, 1.0, 1.0)
20 MotifDetail::MotifDetail(const MotifDetail &md)
21 : QWidget((QWidget *)md.parent()),
22 motif_color(md.motif_color),
23 motifText(md.motifText.displayText())
27 MotifDetail::MotifDetail(std::string& m, Color& c, QWidget *parent)
35 void MotifDetail::setupWidget()
37 QHBoxLayout *layout = new QHBoxLayout;
39 colorButton.setFlat(true);
41 colorButton.setPalette(QPalette(qcolor()));
42 colorButton.setAutoFillBackground(true);
43 connect(&colorButton, SIGNAL(clicked()), this, SLOT(promptColor()));
44 layout->addWidget(&colorButton);
45 motifText.setValidator(&iupacValidator);
46 layout->addWidget(&motifText);
51 void MotifDetail::setMotif(const string &m)
53 motifText.setText(m.c_str());
56 string MotifDetail::motif() const
58 return motifText.text().toStdString();
61 void MotifDetail::setColor(const Color &c)
64 colorButton.setPalette(QPalette(qcolor()));
67 Color MotifDetail::color() const
72 QColor MotifDetail::qcolor() const
75 qc.setRedF(motif_color.r());
76 qc.setGreenF(motif_color.g());
77 qc.setBlueF(motif_color.b());
81 void MotifDetail::promptColor()
83 QColor new_qcolor = QColorDialog::getColor(qcolor(), this);
84 Color new_color(new_qcolor.redF(), new_qcolor.greenF(), new_qcolor.blueF());