38 Q_INIT_RESOURCE(accordionwidgeticons);
44 this->setLayout(
new QVBoxLayout());
47 dynamic_cast<QVBoxLayout*
>(this->layout())->addStretch();
48 this->layout()->setSpacing(1);
49 this->layout()->setContentsMargins(QMargins());
51 this->
spacer =
dynamic_cast<QSpacerItem*
>(this->layout()->itemAt(0));
96 "Can not swap content pane at index " + QString::number(index)
97 +
". Index out of range.")) {
102 this->
errorString =
"Can not swap content pane as new pane is already "
103 "managed by accordion widget";
108 dynamic_cast<QVBoxLayout*
>(this->layout())->removeWidget(this->
contentPanes.at(index));
115 dynamic_cast<QVBoxLayout*
>(this->layout())->insertWidget(index, this->
contentPanes.at(index));
143 "Can not move from " + QString::number(currentIndex)
144 +
". Index out of range.")
146 "Can not move to " + QString::number(newIndex)
147 +
". Index out of range.")) {
151 QVBoxLayout* layout =
dynamic_cast<QVBoxLayout*
>(this->layout());
156 layout->removeWidget(movePane);
157 layout->insertWidget(newIndex, movePane);
170 }
catch (
const std::out_of_range& ex) {
171 qDebug() << Q_FUNC_INFO <<
"Can not return Content Pane: " << ex.what();
172 this->
errorString =
"Can not return Content Pane: " + QString(ex.what());
196 std::for_each(this->
contentPanes.begin(), this->contentPanes.end(),
198 if (pane->getActive()) {
199 indexVector.push_back(this->findContentPaneIndex(
"", nullptr, pane));
232 this->
errorString =
"Can not add content pane as it already exists";
236 if (cpane ==
nullptr) {
237 if (cframe !=
nullptr) {
238 cpane =
new ContentPane(std::move(header), cframe);
243 dynamic_cast<QVBoxLayout*
>(this->layout())->insertWidget(this->layout()->count() - 1, cpane);
259 "Can not insert Content Pane at index " + QString::number(index)
260 +
". Index out of range")) {
268 if (cpane ==
nullptr) {
269 if (contentFrame !=
nullptr) {
270 cpane =
new ContentPane(std::move(header), contentFrame);
276 dynamic_cast<QVBoxLayout*
>(this->layout())->insertWidget(index, cpane);
294 "Can not remove content pane at index " + QString::number(index)
295 +
". Index out of range")) {
302 this->
errorString =
"Can not remove content pane as it is not part "
303 "of the accordion widget";
308 dynamic_cast<QVBoxLayout*
>(this->layout())->removeWidget(this->
contentPanes.at(index));
330 std::find_if(this->
contentPanes.begin(), this->contentPanes.end(),
336 index =
static_cast<int>(result - this->
contentPanes.begin());
339 if (cframe !=
nullptr) {
340 auto result = std::find_if(
342 [cframe](
ContentPane* cpane) { return cpane->getContentFrame() == cframe; });
344 index =
static_cast<int>(result - this->
contentPanes.begin());
347 if (cpane !=
nullptr) {
348 auto result = std::find(this->
contentPanes.begin(), this->contentPanes.end(), cpane);
350 index =
static_cast<int>(result - this->
contentPanes.begin());
365 if (sizeIndexAllowed) {
367 qDebug() << Q_FUNC_INFO << errMessage;
373 qDebug() << Q_FUNC_INFO << errMessage;
392 std::vector<int> activePanes;
395 if (activePanes.size() == 1)
407 std::for_each(this->
contentPanes.begin(), this->contentPanes.end(),
409 if (pane->getActive())
410 pane->closeContentPane();
431 style()->drawPrimitive(QStyle::PE_Widget, &o, &p,
this);
Defines ContentPane class.
void clicked()
Clicked signal is emitted when the header is clicked.
void closeContentPane()
Close the content pane.
void openContentPane()
Open the content pane.
bool getActive()
Check if this Content pane is active.
QString const & name(EShape k)