D16156: Keeping the given code document filename consistent.

Tomaz Canabrava noreply at phabricator.kde.org
Fri Oct 12 16:14:20 BST 2018


tcanabrava requested changes to this revision.
tcanabrava added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> project.cpp:226
>  {
> -    // compute first unused document path
> -    QStringList usedPaths;
> -    foreach (KTextEditor::Document *document, d->m_codeDocuments) {
> -        usedPaths.append(document->url().toLocalFile());
> +    auto path = d->m_workingDirectory.path() + QChar('/') + filePath + QString(".js");
> +

QLatin1Char('/'),
 QStringLiteral(".js")

Those creates the data in copile time instead of runtime

> project.cpp:243-253
> +    auto doc = KTextEditor::Editor::instance()->createDocument(nullptr);
> +    if (!doc->openUrl(url)) {
> +        qCritical() << "Error when opening code file, aborting.";
> +        return nullptr;
> +    }
> +
> +    if (!addCodeDocument(doc)) {

the code for createCode and openCode document are the same, share the internal code.

> project.h:94
> +     */
> +    KTextEditor::Document* createCodeDocument(QString filePath);
> +

const QString& filePath, this way you don't create a copy of the variable just to pass it around.

> mainwindow.cpp:370
>      Project *project = new Project(m_graphEditor);
> -    project->addCodeDocument(KTextEditor::Editor::instance()->createDocument(nullptr));
> +    project->createCodeDocument(QString("codeFile"));
>      project->addGraphDocument(m_graphEditor->createDocument());

QStringLiteral , but perhaps it's better to  i18n("untitled") ?

> mainwindow.cpp:493
> +
> +    QString fullPath = m_currentProject->workingDir() + QString("/") + basePrefix + QString(".js");
> +    QFile file(fullPath);

QLatin1Char('/'), QStringLiteral(".js")

> mainwindow.cpp:494
> +    QString fullPath = m_currentProject->workingDir() + QString("/") + basePrefix + QString(".js");
> +    QFile file(fullPath);
> +    if (file.exists()) {

QFileInfo (cheaper than a QFile)

REPOSITORY
  R73 Rocs

REVISION DETAIL
  https://phabricator.kde.org/D16156

To: fernandorodrigues, tcanabrava
Cc: kde-edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20181012/481a0a5d/attachment-0001.html>


More information about the kde-edu mailing list