Skip to content

Commit 2d4cb03

Browse files
committed
Updated README and Bugfixes.
The README has an updated ToDo section Fixed critical bugs when searching for more than one element in ContentPane vector. We are now using std::for_each. API documentation setCollapsible / getCollapsible. Signed-off-by: Christian Rapp <0x2a@posteo.org>
1 parent a4d91cb commit 2d4cb03

File tree

3 files changed

+35
-39
lines changed

3 files changed

+35
-39
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ mkdir build
4343
cd build
4444
# run cmake to create make files. use -DQACCORDION_EXTERNAL=ON if you make use of
4545
# git submodules
46-
cmake -DCMAKE_BUILD_TYPE=Release ../
46+
cmake -DCMAKE_BUILD_TYPE=RELEASE ../
4747
# now compile the source code and create the shared library. you can speed up
4848
# compilation with the j option.
4949
make
5050
# install the shared library
5151
sudo make install
52-
5352
```
54-
5553
There are ready to use packages for the following Linux distributions:
5654

5755
* [Archlinux (AUR)](https://aur.archlinux.org/packages/qaccordion/)
@@ -96,7 +94,7 @@ doxygen qAccordionDoxyfile
9694

9795
### Demo Application
9896

99-
In the `test` folder you can find a demo application that you can build with library.
97+
In the `test` folder you can find a demo application that you can build with the library.
10098
You must use the CMake option `BUILD_TESTER` so it gets compiled.
10199

102100
```shell
@@ -113,6 +111,8 @@ If you find a Bug or have a feature request head over to github and open a new [
113111

114112
## ToDo ##
115113
* Drag and Drop support. The API already supports moving Content Panes but only programmatically.
114+
* User defined Icons and Icon position.
115+
* Changable Animation Type
116116
* Maybe much, maybe nothing. So far it covers all my use cases ;)
117117

118118
## FAQ ##
@@ -137,4 +137,4 @@ GNU General Public License for more details.
137137
138138
You should have received a copy of the GNU General Public License
139139
along with this program. If not, see <http://www.gnu.org/licenses/>.
140-
```
140+
`````

include/qAccordion/qaccordion.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,20 @@ class QAccordion : public QWidget
303303
bool getMultiActive();
304304

305305
/**
306-
* @brief setCollapsible
306+
* @brief If collapsible is true you can close all ContentPanes
307307
* @param status
308+
*
309+
* @details
310+
* With the collapsible option you can control if one content pane has to be
311+
* open and can't be closed.
308312
*/
309313
void setCollapsible(bool status);
314+
/**
315+
* @brief Get collapsible status
316+
* @return bool
317+
* @sa
318+
* setCollapsible()
319+
*/
310320
bool getCollapsible();
311321

312322
/**

src/qaccordion.cpp

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,13 @@ void QAccordion::getActiveContentPaneIndex(std::vector<int> &indexVector)
182182
{
183183
// first of all make sure it is empty
184184
indexVector.clear();
185-
std::vector<ContentPane *>::const_iterator it = this->contentPanes.begin();
186-
while (it != this->contentPanes.end()) {
187-
it = std::find_if(this->contentPanes.begin(), this->contentPanes.end(),
188-
[this, &indexVector](ContentPane *cpane) {
189-
return cpane->getOpen();
190-
});
191-
if (it != this->contentPanes.end()) {
192-
indexVector.push_back(
193-
this->findContentPaneIndex("", nullptr, (*it)));
194-
}
195-
}
185+
std::for_each(this->contentPanes.begin(), this->contentPanes.end(),
186+
[&indexVector, this](ContentPane *pane) {
187+
if (pane->getOpen()) {
188+
indexVector.push_back(
189+
this->findContentPaneIndex("", nullptr, pane));
190+
}
191+
});
196192
}
197193

198194
int QAccordion::getNumberOfContentPanes() { return this->contentPanes.size(); }
@@ -237,18 +233,13 @@ int QAccordion::internalAddContentPane(QString header, QFrame *cframe,
237233
// panes that are already open.
238234
// TODO: Is it really necessary to search for more than one open cpane?
239235
if (!cpane->getOpen()) {
240-
// check if multiple open is allowed
236+
// check if multiActive is allowed
241237
if (!this->getMultiActive()) {
242-
std::vector<ContentPane *>::const_iterator it =
243-
this->contentPanes.begin();
244-
while (it != this->contentPanes.end()) {
245-
it = std::find_if(
246-
this->contentPanes.begin(), this->contentPanes.end(),
247-
[](ContentPane *cpane) { return cpane->getOpen(); });
248-
if (it != this->contentPanes.end()) {
249-
(*it)->closeContentPane();
250-
}
251-
}
238+
std::for_each(this->contentPanes.begin(),
239+
this->contentPanes.end(), [](ContentPane *pane) {
240+
if (pane->getOpen())
241+
pane->closeContentPane();
242+
});
252243
}
253244
cpane->openContentPane();
254245
}
@@ -297,18 +288,13 @@ bool QAccordion::internalInsertContentPane(uint index, QString header,
297288
// panes that are already open.
298289
// TODO: Is it really necessary to search for more than one open cpane?
299290
if (!cpane->getOpen()) {
300-
// check if multiple open is allowed
291+
// check if multiActive is allowed
301292
if (!this->getMultiActive()) {
302-
std::vector<ContentPane *>::const_iterator it =
303-
this->contentPanes.begin();
304-
while (it != this->contentPanes.end()) {
305-
it = std::find_if(
306-
this->contentPanes.begin(), this->contentPanes.end(),
307-
[](ContentPane *cpane) { return cpane->getOpen(); });
308-
if (it != this->contentPanes.end()) {
309-
(*it)->closeContentPane();
310-
}
311-
}
293+
std::for_each(this->contentPanes.begin(),
294+
this->contentPanes.end(), [](ContentPane *pane) {
295+
if (pane->getOpen())
296+
pane->closeContentPane();
297+
});
312298
}
313299
cpane->openContentPane();
314300
}

0 commit comments

Comments
 (0)