| 131 | } |
| 132 | |
| 133 | void ProjectModelPerformanceTest::addItemDelayed() |
| 134 | { |
| 135 | QElapsedTimer timer; |
| 136 | timer.start(); |
| 137 | ProjectBaseItem* parent = nullptr; |
| 138 | Path path; |
| 139 | if( !currentParent.isEmpty() ) { |
| 140 | parent = currentParent.top(); |
| 141 | path = Path(parent->path(), QStringLiteral("f%1").arg(parent->rowCount())); |
| 142 | } else { |
| 143 | path = Path(QUrl::fromLocalFile(QStringLiteral("/f%1").arg(model->rowCount()))); |
| 144 | } |
| 145 | ProjectBaseItem* item = nullptr; |
| 146 | if( currentParent.size() < BIG_DEPTH ) { |
| 147 | item = new ProjectFolderItem(nullptr, path, parent); |
| 148 | } else { |
| 149 | item = new ProjectFileItem( nullptr, path, parent ); |
| 150 | } |
| 151 | if( currentParent.isEmpty() ) { |
| 152 | model->appendRow( item ); |
| 153 | } |
| 154 | |
| 155 | // Abort/Continue conditions are: |
| 156 | // Go one level deeper (by pushing item on stack) as long as we haven't reached the max depth or the max width |
| 157 | // else if we've reached the max width then pop, i.e go one level up |
| 158 | // else the next run will add a sibling to the just-generated item |
| 159 | if( currentParent.size() < BIG_DEPTH && ( currentParent.isEmpty() || currentParent.top()->rowCount() < BIG_WIDTH ) ) { |
| 160 | currentParent.push( item ); |
| 161 | } else if( !currentParent.isEmpty() && currentParent.top()->rowCount() >= BIG_WIDTH ) { |
| 162 | currentParent.pop(); |
| 163 | } |
| 164 | if( ( currentParent.isEmpty() && ( model->rowCount() - originalWidth ) < BIG_WIDTH ) || !currentParent.isEmpty() ) { |
| 165 | QTimer::singleShot( 0, this, &ProjectModelPerformanceTest::addItemDelayed ); |
| 166 | } |
| 167 | qDebug() << "addBigTreeDelayed" << timer.elapsed(); |
| 168 | } |
| 169 | |
| 170 | void ProjectModelPerformanceTest::addSmallTree() |
| 171 | { |