src/widgets/headeredit.cpp

changeset 1306
be85306198a2
parent 1302
e14d7826373a
child 1326
69a90bd2dba2
equal deleted inserted replaced
1305:31627acdd4b5 1306:be85306198a2
72 ui.winding, 72 ui.winding,
73 qOverload<int>(&QComboBox::currentIndexChanged), 73 qOverload<int>(&QComboBox::currentIndexChanged),
74 [&](int index) 74 [&](int index)
75 { 75 {
76 if (this->hasValidHeader()) 76 if (this->hasValidHeader())
77 { 77 this->m_model->setWinding(static_cast<Winding>(index));
78 this->m_header->winding = static_cast<Winding>(index);
79 emit windingChanged(this->m_header->winding);
80 }
81 } 78 }
82 ); 79 );
83 connect( 80 connect(
84 ui.license, 81 ui.license,
85 qOverload<int>(&QComboBox::currentIndexChanged), 82 qOverload<int>(&QComboBox::currentIndexChanged),
183 { 180 {
184 delete this->headerHistoryModel; 181 delete this->headerHistoryModel;
185 delete &this->ui; 182 delete &this->ui;
186 } 183 }
187 184
188 void HeaderEdit::setHeader(LDHeader* header) 185 void HeaderEdit::setDocument(LDDocument* document)
189 { 186 {
187 LDHeader* header = &document->header;
188 this->m_model = document;
190 this->m_header = header; 189 this->m_header = header;
191 this->ui.description->setText(header->description); 190 this->ui.description->setText(header->description);
192 this->ui.author->setText(header->author); 191 this->ui.author->setText(header->author);
193 this->ui.category->setCurrentIndex(::categories.indexOf(header->category)); 192 this->ui.category->setCurrentIndex(::categories.indexOf(header->category));
194 this->ui.license->setCurrentIndex(static_cast<int>(header->license)); 193 this->ui.license->setCurrentIndex(static_cast<int>(header->license));
195 this->ui.alias->setChecked(header->qualfiers & LDHeader::Alias); 194 this->ui.alias->setChecked(header->qualfiers & LDHeader::Alias);
196 this->ui.physicalColor->setChecked(header->qualfiers & LDHeader::Physical_Color); 195 this->ui.physicalColor->setChecked(header->qualfiers & LDHeader::Physical_Color);
197 this->ui.flexibleSection->setChecked(header->qualfiers & LDHeader::Flexible_Section); 196 this->ui.flexibleSection->setChecked(header->qualfiers & LDHeader::Flexible_Section);
198 this->ui.cmdline->setText(header->cmdline); 197 this->ui.cmdline->setText(header->cmdline);
199 this->ui.winding->setCurrentIndex(header->winding); 198 this->ui.winding->setCurrentIndex(document->winding());
200 this->ui.keywords->document()->setPlainText(header->keywords); 199 this->ui.keywords->document()->setPlainText(header->keywords);
201 this->ui.help->document()->setPlainText(header->help); 200 this->ui.help->document()->setPlainText(header->help);
202 this->headerHistoryModel->setHeader(header); 201 this->headerHistoryModel->setHeader(header);
203 this->setEnabled(this->hasValidHeader()); 202 this->setEnabled(this->hasValidHeader());
204 } 203 }
205 204
206 LDHeader* HeaderEdit::header() const
207 {
208 return this->m_header;
209 }
210
211 bool HeaderEdit::hasValidHeader() const 205 bool HeaderEdit::hasValidHeader() const
212 { 206 {
213 return this->m_header != nullptr and this->m_header->type != LDHeader::NoHeader; 207 return this->m_header != nullptr and this->m_header->type != LDHeader::NoHeader;
214 } 208 }

mercurial