GUI: Implemented "Recheck all files" button (#3614), renamed "Recheck files" button to "Recheck modified files" (#3624)

This commit is contained in:
PKEuS 2015-10-14 19:07:20 +02:00
parent dcb746a49a
commit 6dcb918b78
8 changed files with 55 additions and 17 deletions

View File

@ -11,6 +11,7 @@
<file>images/preferences-system.png</file>
<file>images/process-stop.png</file>
<file>images/text-x-generic.png</file>
<file>images/view-recheck.png</file>
<file>images/view-refresh.png</file>
<file>images/showerrors.png</file>
<file>images/showstylewarnings.png</file>

BIN
gui/images/view-recheck.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 894 B

View File

@ -148,7 +148,8 @@
</widget>
<addaction name="mActionCheckFiles"/>
<addaction name="mActionCheckDirectory"/>
<addaction name="mActionRecheck"/>
<addaction name="mActionRecheckModified"/>
<addaction name="mActionRecheckAll"/>
<addaction name="mActionStop"/>
<addaction name="separator"/>
<addaction name="menuC_standard"/>
@ -188,7 +189,8 @@
<addaction name="mActionOpenProjectFile"/>
<addaction name="mActionShowScratchpad"/>
<addaction name="mActionSave"/>
<addaction name="mActionRecheck"/>
<addaction name="mActionRecheckModified"/>
<addaction name="mActionRecheckAll"/>
<addaction name="mActionStop"/>
<addaction name="mActionClearResults"/>
<addaction name="mActionSettings"/>
@ -273,18 +275,27 @@
<string>Ctrl+D</string>
</property>
</action>
<action name="mActionRecheck">
<action name="mActionRecheckModified">
<property name="icon">
<iconset resource="gui.qrc">
<normaloff>:/images/view-refresh.png</normaloff>:/images/view-refresh.png</iconset>
</property>
<property name="text">
<string>&amp;Recheck files</string>
<string>&amp;Recheck modified files</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="mActionRecheckAll">
<property name="icon">
<iconset resource="gui.qrc">
<normaloff>:/images/view-recheck.png</normaloff>:/images/view-recheck.png</iconset>
</property>
<property name="text">
<string>&amp;Recheck all files</string>
</property>
</action>
<action name="mActionStop">
<property name="icon">
<iconset resource="gui.qrc">

View File

@ -103,7 +103,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics()));
connect(mUI.mActionLibraryEditor, SIGNAL(triggered()), this, SLOT(ShowLibraryEditor()));
connect(mUI.mActionRecheck, SIGNAL(triggered()), this, SLOT(ReCheck()));
connect(mUI.mActionRecheckModified, SIGNAL(triggered()), this, SLOT(ReCheckModified()));
connect(mUI.mActionRecheckAll, SIGNAL(triggered()), this, SLOT(ReCheckAll()));
connect(mUI.mActionStop, SIGNAL(triggered()), this, SLOT(StopChecking()));
connect(mUI.mActionSave, SIGNAL(triggered()), this, SLOT(Save()));
@ -144,7 +145,8 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
mUI.mActionPrintPreview->setEnabled(false);
mUI.mActionClearResults->setEnabled(false);
mUI.mActionSave->setEnabled(false);
mUI.mActionRecheck->setEnabled(false);
mUI.mActionRecheckModified->setEnabled(false);
mUI.mActionRecheckAll->setEnabled(false);
EnableProjectOpenActions(true);
EnableProjectActions(false);
@ -776,14 +778,24 @@ void MainWindow::ProgramSettings()
}
}
void MainWindow::ReCheck()
void MainWindow::ReCheckModified()
{
const QStringList files = mThread->GetReCheckFiles();
ReCheck(false);
}
void MainWindow::ReCheckAll()
{
ReCheck(true);
}
void MainWindow::ReCheck(bool all)
{
const QStringList files = mThread->GetReCheckFiles(all);
if (files.empty())
return;
// Clear details, statistics and progress
mUI.mResults->Clear(false);
mUI.mResults->Clear(all);
// Clear results for changed files
for (int i = 0; i < files.size(); ++i)
@ -795,7 +807,7 @@ void MainWindow::ReCheck()
if (mProject)
qDebug() << "Rechecking project file" << mProject->GetProjectFile()->GetFilename();
mThread->Check(GetCppcheckSettings(), true);
mThread->Check(GetCppcheckSettings(), !all);
}
void MainWindow::ClearResults()
@ -859,8 +871,10 @@ void MainWindow::EnableCheckButtons(bool enable)
mUI.mActionStop->setEnabled(!enable);
mUI.mActionCheckFiles->setEnabled(enable);
if (!enable || mThread->HasPreviousFiles())
mUI.mActionRecheck->setEnabled(enable);
if (!enable || mThread->HasPreviousFiles()) {
mUI.mActionRecheckModified->setEnabled(enable);
mUI.mActionRecheckAll->setEnabled(enable);
}
mUI.mActionCheckDirectory->setEnabled(enable);
}

View File

@ -79,10 +79,16 @@ public slots:
void CheckFiles();
/**
* @brief Slot to recheck files
* @brief Slot to recheck all files
*
*/
void ReCheck();
void ReCheckAll();
/**
* @brief Slot to recheck modified files
*
*/
void ReCheckModified();
/**
* @brief Slot to clear all search results
@ -307,6 +313,12 @@ protected slots:
private:
/**
* @brief Rechecks files
*
*/
void ReCheck(bool all);
/**
* @brief Check the project.
* @param project Pointer to the project to check.

View File

@ -55,7 +55,7 @@ void ThreadHandler::Check(const Settings &settings, bool recheck)
{
if (recheck && mRunningThreadCount == 0) {
// only recheck changed files
mResults.SetFiles(GetReCheckFiles());
mResults.SetFiles(GetReCheckFiles(false));
}
if (mResults.GetFileCount() == 0 || mRunningThreadCount > 0 || settings._jobs == 0) {
@ -188,7 +188,7 @@ int ThreadHandler::GetPreviousScanDuration() const
return mScanDuration;
}
QStringList ThreadHandler::GetReCheckFiles() const
QStringList ThreadHandler::GetReCheckFiles(bool all) const
{
if (mLastCheckTime.isNull())
return mLastFiles;

View File

@ -123,7 +123,7 @@ public:
* @brief Get files that should be rechecked because they have been
* changed.
*/
QStringList GetReCheckFiles() const;
QStringList GetReCheckFiles(bool all) const;
signals:
/**