| 116 | } |
| 117 | |
| 118 | void MavenAsynParse::createRows(const QString &path) |
| 119 | { |
| 120 | QString rootPath = path; |
| 121 | if (rootPath.endsWith(QDir::separator())) { |
| 122 | int separatorSize = QString(QDir::separator()).size(); |
| 123 | rootPath = rootPath.remove(rootPath.size() - separatorSize, separatorSize); |
| 124 | } |
| 125 | |
| 126 | // 缓存当前工程目录 |
| 127 | d->rootPath = rootPath; |
| 128 | QFileSystemWatcher::addPath(d->rootPath); |
| 129 | |
| 130 | {// 避免变量冲突 迭代文件夹 |
| 131 | QDir dir; |
| 132 | dir.setPath(rootPath); |
| 133 | dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); |
| 134 | dir.setSorting(QDir::Name); |
| 135 | QDirIterator dirItera(dir, QDirIterator::Subdirectories); |
| 136 | while (dirItera.hasNext()) { |
| 137 | QString childPath = dirItera.next().remove(0, rootPath.size()); |
| 138 | QFileSystemWatcher::addPath(dirItera.filePath()); |
| 139 | QStandardItem *item = findItem(childPath); |
| 140 | auto newItem = new QStandardItem(dirItera.fileName()); |
| 141 | newItem->setData(dirItera.filePath(), Project::FileIconRole); |
| 142 | newItem->setToolTip(dirItera.filePath()); |
| 143 | if (!item) { |
| 144 | d->rows.append(newItem); |
| 145 | } else { |
| 146 | item->appendRow(newItem); |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | {// 避免变量冲突 迭代文件 |
| 151 | QDir dir; |
| 152 | dir.setPath(rootPath); |
| 153 | dir.setFilter(QDir::NoDotAndDotDot | QDir::Files); |
| 154 | dir.setSorting(QDir::Name); |
| 155 | QDirIterator fileItera(dir, QDirIterator::Subdirectories); |
| 156 | while (fileItera.hasNext()) { |
| 157 | QString childPath = fileItera.next().remove(0, rootPath.size()); |
| 158 | QStandardItem *item = findItem(childPath); |
| 159 | auto newItem = new QStandardItem(fileItera.fileName()); |
| 160 | newItem->setData(fileItera.filePath(), Project::FileIconRole); |
| 161 | newItem->setToolTip(fileItera.filePath()); |
| 162 | if (!item) { |
| 163 | d->rows.append(newItem); |
| 164 | } else { |
| 165 | item->appendRow(newItem); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | QList<QStandardItem *> MavenAsynParse::rows(const QStandardItem *item) const |
| 172 | { |