Skip to content

Commit

Permalink
Updated README and Bugfixes.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crapp committed Nov 6, 2015
1 parent a4d91cb commit 2d4cb03
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ mkdir build
cd build
# run cmake to create make files. use -DQACCORDION_EXTERNAL=ON if you make use of
# git submodules
cmake -DCMAKE_BUILD_TYPE=Release ../
cmake -DCMAKE_BUILD_TYPE=RELEASE ../
# now compile the source code and create the shared library. you can speed up
# compilation with the j option.
make
# install the shared library
sudo make install

```

There are ready to use packages for the following Linux distributions:

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

### Demo Application

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

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

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

## FAQ ##
Expand All @@ -137,4 +137,4 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
```
`````
12 changes: 11 additions & 1 deletion include/qAccordion/qaccordion.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,20 @@ class QAccordion : public QWidget
bool getMultiActive();

/**
* @brief setCollapsible
* @brief If collapsible is true you can close all ContentPanes
* @param status
*
* @details
* With the collapsible option you can control if one content pane has to be
* open and can't be closed.
*/
void setCollapsible(bool status);
/**
* @brief Get collapsible status
* @return bool
* @sa
* setCollapsible()
*/
bool getCollapsible();

/**
Expand Down
52 changes: 19 additions & 33 deletions src/qaccordion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,13 @@ void QAccordion::getActiveContentPaneIndex(std::vector<int> &indexVector)
{
// first of all make sure it is empty
indexVector.clear();
std::vector<ContentPane *>::const_iterator it = this->contentPanes.begin();
while (it != this->contentPanes.end()) {
it = std::find_if(this->contentPanes.begin(), this->contentPanes.end(),
[this, &indexVector](ContentPane *cpane) {
return cpane->getOpen();
});
if (it != this->contentPanes.end()) {
indexVector.push_back(
this->findContentPaneIndex("", nullptr, (*it)));
}
}
std::for_each(this->contentPanes.begin(), this->contentPanes.end(),
[&indexVector, this](ContentPane *pane) {
if (pane->getOpen()) {
indexVector.push_back(
this->findContentPaneIndex("", nullptr, pane));
}
});
}

int QAccordion::getNumberOfContentPanes() { return this->contentPanes.size(); }
Expand Down Expand Up @@ -237,18 +233,13 @@ int QAccordion::internalAddContentPane(QString header, QFrame *cframe,
// panes that are already open.
// TODO: Is it really necessary to search for more than one open cpane?
if (!cpane->getOpen()) {
// check if multiple open is allowed
// check if multiActive is allowed
if (!this->getMultiActive()) {
std::vector<ContentPane *>::const_iterator it =
this->contentPanes.begin();
while (it != this->contentPanes.end()) {
it = std::find_if(
this->contentPanes.begin(), this->contentPanes.end(),
[](ContentPane *cpane) { return cpane->getOpen(); });
if (it != this->contentPanes.end()) {
(*it)->closeContentPane();
}
}
std::for_each(this->contentPanes.begin(),
this->contentPanes.end(), [](ContentPane *pane) {
if (pane->getOpen())
pane->closeContentPane();
});
}
cpane->openContentPane();
}
Expand Down Expand Up @@ -297,18 +288,13 @@ bool QAccordion::internalInsertContentPane(uint index, QString header,
// panes that are already open.
// TODO: Is it really necessary to search for more than one open cpane?
if (!cpane->getOpen()) {
// check if multiple open is allowed
// check if multiActive is allowed
if (!this->getMultiActive()) {
std::vector<ContentPane *>::const_iterator it =
this->contentPanes.begin();
while (it != this->contentPanes.end()) {
it = std::find_if(
this->contentPanes.begin(), this->contentPanes.end(),
[](ContentPane *cpane) { return cpane->getOpen(); });
if (it != this->contentPanes.end()) {
(*it)->closeContentPane();
}
}
std::for_each(this->contentPanes.begin(),
this->contentPanes.end(), [](ContentPane *pane) {
if (pane->getOpen())
pane->closeContentPane();
});
}
cpane->openContentPane();
}
Expand Down

0 comments on commit 2d4cb03

Please sign in to comment.