| 1829 | } |
| 1830 | |
| 1831 | QString QGLViewer::cameraPathKeysString() const |
| 1832 | { |
| 1833 | if (pathIndex_.isEmpty()) |
| 1834 | return QString(); |
| 1835 | |
| 1836 | QVector<Qt::Key> keys; |
| 1837 | keys.reserve(pathIndex_.count()); |
| 1838 | for (QMap<Qt::Key, unsigned int>::ConstIterator i = pathIndex_.begin(), endi=pathIndex_.end(); i != endi; ++i) |
| 1839 | keys.push_back(i.key()); |
| 1840 | qSort(keys); |
| 1841 | |
| 1842 | QVector<Qt::Key>::const_iterator it = keys.begin(), end = keys.end(); |
| 1843 | QString res = keyString(*it); |
| 1844 | |
| 1845 | const int maxDisplayedKeys = 6; |
| 1846 | int nbDisplayedKeys = 0; |
| 1847 | Qt::Key previousKey = (*it); |
| 1848 | int state = 0; |
| 1849 | ++it; |
| 1850 | while ((it != end) && (nbDisplayedKeys < maxDisplayedKeys-1)) |
| 1851 | { |
| 1852 | switch (state) |
| 1853 | { |
| 1854 | case 0 : |
| 1855 | if ((*it) == previousKey + 1) |
| 1856 | state++; |
| 1857 | else |
| 1858 | { |
| 1859 | res += ", " + keyString(*it); |
| 1860 | nbDisplayedKeys++; |
| 1861 | } |
| 1862 | break; |
| 1863 | case 1 : |
| 1864 | if ((*it) == previousKey + 1) |
| 1865 | state++; |
| 1866 | else |
| 1867 | { |
| 1868 | res += ", " + keyString(previousKey); |
| 1869 | res += ", " + keyString(*it); |
| 1870 | nbDisplayedKeys += 2; |
| 1871 | state = 0; |
| 1872 | } |
| 1873 | break; |
| 1874 | default : |
| 1875 | if ((*it) != previousKey + 1) |
| 1876 | { |
| 1877 | res += ".." + keyString(previousKey); |
| 1878 | res += ", " + keyString(*it); |
| 1879 | nbDisplayedKeys += 2; |
| 1880 | state = 0; |
| 1881 | } |
| 1882 | break; |
| 1883 | } |
| 1884 | previousKey = *it; |
| 1885 | ++it; |
| 1886 | } |
| 1887 | |
| 1888 | if (state == 1) |