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()),
24 motifName(md.motifName.displayText())
28 MotifDetail::MotifDetail(std::string& m, Color& c, std::string& name, QWidget *parent)
32 motifName(name.c_str())
37 void MotifDetail::setupWidget()
39 QHBoxLayout *layout = new QHBoxLayout;
41 enabledButton.setCheckState(Qt::Checked);
42 layout->addWidget(&enabledButton);
43 colorButton.setFlat(true);
44 colorButton.setPalette(QPalette(qcolor()));
45 colorButton.setAutoFillBackground(true);
46 connect(&colorButton, SIGNAL(clicked()), this, SLOT(promptColor()));
47 layout->addWidget(&colorButton);
48 motifText.setValidator(&iupacValidator);
49 layout->addWidget(&motifText);
50 layout->addWidget(&motifName);
55 void MotifDetail::setMotif(const string &m)
57 motifText.setText(m.c_str());
60 string MotifDetail::motif() const
62 return motifText.text().toStdString();
65 void MotifDetail::setName(const std::string& name)
67 motifName.setText(name.c_str());
70 std::string MotifDetail::name() const
72 return motifName.text().toStdString();
75 void MotifDetail::setColor(const Color &c)
78 colorButton.setPalette(QPalette(qcolor()));
81 Color MotifDetail::color() const
86 QColor MotifDetail::qcolor() const
89 qc.setRedF(motif_color.r());
90 qc.setGreenF(motif_color.g());
91 qc.setBlueF(motif_color.b());
95 void MotifDetail::promptColor()
97 QColor new_qcolor = QColorDialog::getColor(qcolor(), this);
98 Color new_color(new_qcolor.redF(), new_qcolor.greenF(), new_qcolor.blueF());
102 bool MotifDetail::enabled() const
104 return (enabledButton.checkState() == Qt::Checked);