Changeset View
Changeset View
Standalone View
Standalone View
git/fileviewgitplugin.cpp
Show First 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 313 | if (state == UnversionedVersion || state == LocallyModifiedUnstagedVersion || | |||
---|---|---|---|---|---|
315 | ++addableCount; | 315 | ++addableCount; | ||
316 | } | 316 | } | ||
317 | if (state == LocallyModifiedVersion || state == LocallyModifiedUnstagedVersion || | 317 | if (state == LocallyModifiedVersion || state == LocallyModifiedUnstagedVersion || | ||
318 | state == ConflictingVersion) { | 318 | state == ConflictingVersion) { | ||
319 | ++revertCount; | 319 | ++revertCount; | ||
320 | } | 320 | } | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | m_logAction->setEnabled(versionedCount == items.count()); | ||||
323 | m_addAction->setEnabled(addableCount == items.count()); | 324 | m_addAction->setEnabled(addableCount == items.count()); | ||
324 | m_revertAction->setEnabled(revertCount == items.count()); | 325 | m_revertAction->setEnabled(revertCount == items.count()); | ||
325 | m_removeAction->setEnabled(versionedCount == items.count()); | 326 | m_removeAction->setEnabled(versionedCount == items.count()); | ||
326 | } | 327 | } | ||
327 | else{ | 328 | else{ | ||
329 | m_logAction->setEnabled(false); | ||||
328 | m_addAction->setEnabled(false); | 330 | m_addAction->setEnabled(false); | ||
329 | m_revertAction->setEnabled(false); | 331 | m_revertAction->setEnabled(false); | ||
330 | m_removeAction->setEnabled(false); | 332 | m_removeAction->setEnabled(false); | ||
331 | } | 333 | } | ||
332 | 334 | | |||
333 | QList<QAction*> actions; | 335 | QList<QAction*> actions; | ||
336 | actions.append(m_logAction); | ||||
334 | actions.append(m_addAction); | 337 | actions.append(m_addAction); | ||
335 | actions.append(m_removeAction); | 338 | actions.append(m_removeAction); | ||
336 | actions.append(m_revertAction); | 339 | actions.append(m_revertAction); | ||
337 | return actions; | 340 | return actions; | ||
338 | } | 341 | } | ||
339 | 342 | | |||
340 | QList<QAction*> FileViewGitPlugin::contextMenuDirectoryActions(const QString& directory) const | 343 | QList<QAction*> FileViewGitPlugin::contextMenuDirectoryActions(const QString& directory) const | ||
341 | { | 344 | { | ||
342 | QList<QAction*> actions; | 345 | QList<QAction*> actions; | ||
343 | if (!m_pendingOperation){ | 346 | if (!m_pendingOperation) { | ||
347 | m_contextItems.clear(); | ||||
344 | m_contextDir = directory; | 348 | m_contextDir = directory; | ||
345 | } | 349 | } | ||
346 | m_checkoutAction->setEnabled(!m_pendingOperation); | 350 | m_checkoutAction->setEnabled(!m_pendingOperation); | ||
347 | actions.append(m_checkoutAction); | 351 | actions.append(m_checkoutAction); | ||
348 | 352 | | |||
349 | bool canCommit = false; | 353 | bool canCommit = false; | ||
350 | bool showChanges = false; | 354 | bool showChanges = false; | ||
351 | bool shouldMerge = false; | 355 | bool shouldMerge = false; | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 433 | { | |||
430 | if (link.scheme() != QLatin1String("rev")) { | 434 | if (link.scheme() != QLatin1String("rev")) { | ||
431 | return; | 435 | return; | ||
432 | } | 436 | } | ||
433 | KRun::runCommand(QStringLiteral("git difftool --dir-diff %1^ %1").arg(link.path()), nullptr, m_contextDir); | 437 | KRun::runCommand(QStringLiteral("git difftool --dir-diff %1^ %1").arg(link.path()), nullptr, m_contextDir); | ||
434 | } | 438 | } | ||
435 | 439 | | |||
436 | void FileViewGitPlugin::log() | 440 | void FileViewGitPlugin::log() | ||
437 | { | 441 | { | ||
442 | QStringList items; | ||||
443 | if (m_contextItems.isEmpty()) { | ||||
444 | items << QLatin1String("."); | ||||
elvisangelaccio: `QLatin1String` for concatenations. | |||||
445 | } else { | ||||
446 | for (auto &item : qAsConst(m_contextItems)) { | ||||
447 | items << item.url().fileName(); | ||||
448 | } | ||||
449 | } | ||||
450 | | ||||
438 | QProcess process; | 451 | QProcess process; | ||
439 | process.setWorkingDirectory(m_contextDir); | 452 | process.setWorkingDirectory(m_contextDir); | ||
440 | process.start( | 453 | process.start( | ||
441 | QLatin1String("git"), | 454 | QLatin1String("git"), | ||
442 | QStringList { | 455 | QStringList { | ||
443 | QStringLiteral("log"), | 456 | QStringLiteral("log"), | ||
444 | QStringLiteral("--relative=."), | | |||
445 | QStringLiteral("--date=format:%d-%m-%Y"), | 457 | QStringLiteral("--date=format:%d-%m-%Y"), | ||
446 | QStringLiteral("-n 100"), | 458 | QStringLiteral("-n 100"), | ||
447 | QStringLiteral("--pretty=format:<tr> <td><a href=\"rev:%h\">%h</a></td> <td>%ad</td> <td>%s</td> <td>%an</td> </tr>") | 459 | QStringLiteral("--pretty=format:<tr> <td><a href=\"rev:%h\">%h</a></td> <td>%ad</td> <td>%s</td> <td>%an</td> </tr>") | ||
448 | } | 460 | } + items | ||
449 | ); | 461 | ); | ||
450 | 462 | | |||
451 | if (!process.waitForFinished() || process.exitCode() != 0) { | 463 | if (!process.waitForFinished() || process.exitCode() != 0) { | ||
452 | emit errorMessage(xi18nd("@info:status", "<application>Git</application> Log failed.")); | 464 | emit errorMessage(xi18nd("@info:status", "<application>Git</application> Log failed.")); | ||
453 | return; | 465 | return; | ||
454 | } | 466 | } | ||
455 | 467 | | |||
456 | const QString gitOutput = process.readAllStandardOutput(); | 468 | const QString gitOutput = process.readAllStandardOutput(); | ||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
QLatin1String for concatenations.