GUI: Rename methods in ApplicationList
This commit is contained in:
parent
8d704f7709
commit
24ce4292f2
|
@ -36,10 +36,10 @@ ApplicationList::ApplicationList(QObject *parent) :
|
|||
|
||||
ApplicationList::~ApplicationList()
|
||||
{
|
||||
Clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
bool ApplicationList::LoadSettings()
|
||||
bool ApplicationList::loadSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
QStringList names = settings.value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList();
|
||||
|
@ -64,18 +64,18 @@ bool ApplicationList::LoadSettings()
|
|||
app.setName("gedit");
|
||||
app.setPath("/usr/bin/gedit");
|
||||
app.setParameters("+(line) (file)");
|
||||
AddApplication(app);
|
||||
addApplication(app);
|
||||
defapp = 0;
|
||||
}
|
||||
CheckAndAddApplication("/usr/bin/geany","geany","+(line) (file)");
|
||||
CheckAndAddApplication("/usr/bin/qtcreator","Qt Creator","-client (file):(line)");
|
||||
checkAndAddApplication("/usr/bin/geany","geany","+(line) (file)");
|
||||
checkAndAddApplication("/usr/bin/qtcreator","Qt Creator","-client (file):(line)");
|
||||
// use as default for kde environments
|
||||
if (QFileInfo("/usr/bin/kate").isExecutable()) {
|
||||
Application app;
|
||||
app.setName("kate");
|
||||
app.setPath("/usr/bin/kate");
|
||||
app.setParameters("-l(line) (file)");
|
||||
AddApplication(app);
|
||||
addApplication(app);
|
||||
defapp = 0;
|
||||
}
|
||||
#else
|
||||
|
@ -86,7 +86,7 @@ bool ApplicationList::LoadSettings()
|
|||
} else if (names.size() == paths.size()) {
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
const Application app(names[i], paths[i], params[i]);
|
||||
AddApplication(app);
|
||||
addApplication(app);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,15 +100,15 @@ bool ApplicationList::LoadSettings()
|
|||
return succeeded;
|
||||
}
|
||||
|
||||
void ApplicationList::SaveSettings() const
|
||||
void ApplicationList::saveSettings() const
|
||||
{
|
||||
QSettings settings;
|
||||
QStringList names;
|
||||
QStringList paths;
|
||||
QStringList params;
|
||||
|
||||
for (int i = 0; i < GetApplicationCount(); i++) {
|
||||
const Application& app = GetApplication(i);
|
||||
for (int i = 0; i < getApplicationCount(); i++) {
|
||||
const Application& app = getApplication(i);
|
||||
names << app.getName();
|
||||
paths << app.getPath();
|
||||
params << app.getParameters();
|
||||
|
@ -120,12 +120,12 @@ void ApplicationList::SaveSettings() const
|
|||
settings.setValue(SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex);
|
||||
}
|
||||
|
||||
int ApplicationList::GetApplicationCount() const
|
||||
int ApplicationList::getApplicationCount() const
|
||||
{
|
||||
return mApplications.size();
|
||||
}
|
||||
|
||||
Application& ApplicationList::GetApplication(const int index)
|
||||
Application& ApplicationList::getApplication(const int index)
|
||||
{
|
||||
if (index >= 0 && index < mApplications.size()) {
|
||||
return mApplications[index];
|
||||
|
@ -135,7 +135,7 @@ Application& ApplicationList::GetApplication(const int index)
|
|||
return dummy;
|
||||
}
|
||||
|
||||
const Application& ApplicationList::GetApplication(const int index) const
|
||||
const Application& ApplicationList::getApplication(const int index) const
|
||||
{
|
||||
if (index >= 0 && index < mApplications.size()) {
|
||||
return mApplications[index];
|
||||
|
@ -145,7 +145,7 @@ const Application& ApplicationList::GetApplication(const int index) const
|
|||
return dummy;
|
||||
}
|
||||
|
||||
void ApplicationList::AddApplication(const Application &app)
|
||||
void ApplicationList::addApplication(const Application &app)
|
||||
{
|
||||
if (app.getName().isEmpty() || app.getPath().isEmpty()) {
|
||||
return;
|
||||
|
@ -153,52 +153,52 @@ void ApplicationList::AddApplication(const Application &app)
|
|||
mApplications << app;
|
||||
}
|
||||
|
||||
void ApplicationList::RemoveApplication(const int index)
|
||||
void ApplicationList::removeApplication(const int index)
|
||||
{
|
||||
mApplications.removeAt(index);
|
||||
}
|
||||
|
||||
void ApplicationList::SetDefault(const int index)
|
||||
void ApplicationList::setDefault(const int index)
|
||||
{
|
||||
if (index < mApplications.size() && index >= 0) {
|
||||
mDefaultApplicationIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationList::Copy(const ApplicationList *list)
|
||||
void ApplicationList::copy(const ApplicationList *list)
|
||||
{
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
for (int i = 0; i < list->GetApplicationCount(); i++) {
|
||||
const Application& app = list->GetApplication(i);
|
||||
AddApplication(app);
|
||||
clear();
|
||||
for (int i = 0; i < list->getApplicationCount(); i++) {
|
||||
const Application& app = list->getApplication(i);
|
||||
addApplication(app);
|
||||
}
|
||||
mDefaultApplicationIndex = list->GetDefaultApplication();
|
||||
mDefaultApplicationIndex = list->getDefaultApplication();
|
||||
}
|
||||
|
||||
void ApplicationList::Clear()
|
||||
void ApplicationList::clear()
|
||||
{
|
||||
mApplications.clear();
|
||||
mDefaultApplicationIndex = -1;
|
||||
}
|
||||
|
||||
bool ApplicationList::CheckAndAddApplication(QString appPath, QString name, QString parameters)
|
||||
bool ApplicationList::checkAndAddApplication(QString appPath, QString name, QString parameters)
|
||||
{
|
||||
if (QFileInfo(appPath).exists() && QFileInfo(appPath).isExecutable()) {
|
||||
Application app;
|
||||
app.setName(name);
|
||||
app.setPath("\"" + appPath + "\"");
|
||||
app.setParameters(parameters);
|
||||
AddApplication(app);
|
||||
addApplication(app);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ApplicationList::FindDefaultWindowsEditor()
|
||||
bool ApplicationList::findDefaultWindowsEditor()
|
||||
{
|
||||
bool foundOne = false;
|
||||
#ifdef WIN64 // As long as we do support 32-bit XP, we cannot be sure that the environment variable "ProgramFiles(x86)" exists
|
||||
|
@ -209,24 +209,24 @@ bool ApplicationList::FindDefaultWindowsEditor()
|
|||
const QString appPathx64(getenv("ProgramW6432"));
|
||||
const QString windowsPath(getenv("windir"));
|
||||
|
||||
if (CheckAndAddApplication(appPathx86 + "\\Notepad++\\notepad++.exe", "Notepad++", "-n(line) (file)"))
|
||||
if (checkAndAddApplication(appPathx86 + "\\Notepad++\\notepad++.exe", "Notepad++", "-n(line) (file)"))
|
||||
foundOne = true;
|
||||
else if (CheckAndAddApplication(appPathx64 + "\\Notepad++\\notepad++.exe", "Notepad++", "-n(line) (file)"))
|
||||
else if (checkAndAddApplication(appPathx64 + "\\Notepad++\\notepad++.exe", "Notepad++", "-n(line) (file)"))
|
||||
foundOne = true;
|
||||
|
||||
if (CheckAndAddApplication(appPathx86 + "\\Notepad2\\Notepad2.exe", "Notepad2", "/g (line) (file)"))
|
||||
if (checkAndAddApplication(appPathx86 + "\\Notepad2\\Notepad2.exe", "Notepad2", "/g (line) (file)"))
|
||||
foundOne = true;
|
||||
else if (CheckAndAddApplication(appPathx64 + "\\Notepad2\\Notepad2.exe", "Notepad2", "/g (line) (file)"))
|
||||
else if (checkAndAddApplication(appPathx64 + "\\Notepad2\\Notepad2.exe", "Notepad2", "/g (line) (file)"))
|
||||
foundOne = true;
|
||||
|
||||
if (CheckAndAddApplication(windowsPath + "\\system32\\notepad.exe", "Notepad", "(file)"))
|
||||
if (checkAndAddApplication(windowsPath + "\\system32\\notepad.exe", "Notepad", "(file)"))
|
||||
foundOne = true;
|
||||
|
||||
QString regPath = "HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\command";
|
||||
QSettings registry(regPath, QSettings::NativeFormat);
|
||||
QString qtCreatorRegistry = registry.value("Default", QString()).toString();
|
||||
QString qtCreatorPath = qtCreatorRegistry.left(qtCreatorRegistry.indexOf(".exe") + 4);
|
||||
if (!qtCreatorRegistry.isEmpty() && CheckAndAddApplication(qtCreatorPath, "Qt Creator", "-client (file):(line)")) {
|
||||
if (!qtCreatorRegistry.isEmpty() && checkAndAddApplication(qtCreatorPath, "Qt Creator", "-client (file):(line)")) {
|
||||
foundOne = true;
|
||||
}
|
||||
return foundOne;
|
||||
|
|
|
@ -43,18 +43,18 @@ public:
|
|||
* application list. Most probably because of older version settings need
|
||||
* to be upgraded.
|
||||
*/
|
||||
bool LoadSettings();
|
||||
bool loadSettings();
|
||||
|
||||
/**
|
||||
* @brief Save all applications
|
||||
*/
|
||||
void SaveSettings() const;
|
||||
void saveSettings() const;
|
||||
|
||||
/**
|
||||
* @brief Get the amount of applications in the list
|
||||
* @return The count of applications
|
||||
*/
|
||||
int GetApplicationCount() const;
|
||||
int getApplicationCount() const;
|
||||
|
||||
/**
|
||||
* @brief Get specific application's name
|
||||
|
@ -62,14 +62,14 @@ public:
|
|||
* @param index Index of the application whose name to get
|
||||
* @return Name of the application
|
||||
*/
|
||||
const Application& GetApplication(const int index) const;
|
||||
Application& GetApplication(const int index);
|
||||
const Application& getApplication(const int index) const;
|
||||
Application& getApplication(const int index);
|
||||
|
||||
/**
|
||||
* @brief Return the default application.
|
||||
* @return Index of the default application.
|
||||
*/
|
||||
int GetDefaultApplication() const {
|
||||
int getDefaultApplication() const {
|
||||
return mDefaultApplicationIndex;
|
||||
}
|
||||
|
||||
|
@ -78,27 +78,27 @@ public:
|
|||
*
|
||||
* @param app Application to add.
|
||||
*/
|
||||
void AddApplication(const Application &app);
|
||||
void addApplication(const Application &app);
|
||||
|
||||
/**
|
||||
* @brief Remove an application from the list
|
||||
*
|
||||
* @param index Index of the application to remove.
|
||||
*/
|
||||
void RemoveApplication(const int index);
|
||||
void removeApplication(const int index);
|
||||
|
||||
/**
|
||||
* @brief Set application as default application.
|
||||
* @param index Index of the application to make the default one
|
||||
*/
|
||||
void SetDefault(const int index);
|
||||
void setDefault(const int index);
|
||||
|
||||
/**
|
||||
* @brief Remove all applications from this list and copy all applications from
|
||||
* list given as a parameter.
|
||||
* @param list Copying source
|
||||
*/
|
||||
void Copy(const ApplicationList *list);
|
||||
void copy(const ApplicationList *list);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -106,17 +106,17 @@ protected:
|
|||
* @brief Clear the list
|
||||
*
|
||||
*/
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* @brief Find editor used by default in Windows.
|
||||
* Check if Notepad++ is installed and use it. If not, use Notepad.
|
||||
*/
|
||||
bool FindDefaultWindowsEditor();
|
||||
bool findDefaultWindowsEditor();
|
||||
|
||||
private:
|
||||
|
||||
bool CheckAndAddApplication(QString appPath, QString name, QString parameters);
|
||||
bool checkAndAddApplication(QString appPath, QString name, QString parameters);
|
||||
|
||||
/**
|
||||
* @brief List of applications
|
||||
|
|
|
@ -298,7 +298,7 @@ void MainWindow::LoadSettings()
|
|||
else
|
||||
mUI.mActionAutoDetectLanguage->setChecked(true);
|
||||
|
||||
bool succeeded = mApplications->LoadSettings();
|
||||
bool succeeded = mApplications->loadSettings();
|
||||
if (!succeeded) {
|
||||
const QString msg = tr("There was a problem with loading the editor application settings.\n\n"
|
||||
"This is probably because the settings were changed between the Cppcheck versions. "
|
||||
|
@ -349,7 +349,7 @@ void MainWindow::SaveSettings() const
|
|||
else
|
||||
mSettings->setValue(SETTINGS_ENFORCED_LANGUAGE, Settings::None);
|
||||
|
||||
mApplications->SaveSettings();
|
||||
mApplications->saveSettings();
|
||||
|
||||
mSettings->setValue(SETTINGS_LANGUAGE, mTranslation->GetCurrentLanguage());
|
||||
mUI.mResults->SaveSettings(mSettings);
|
||||
|
|
|
@ -530,12 +530,12 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
//member variables
|
||||
QSignalMapper *signalMapper = new QSignalMapper(this);
|
||||
|
||||
if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) {
|
||||
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
|
||||
//Create an action for the application
|
||||
int defaultApplicationIndex = mApplications->GetDefaultApplication();
|
||||
int defaultApplicationIndex = mApplications->getDefaultApplication();
|
||||
if (defaultApplicationIndex < 0)
|
||||
defaultApplicationIndex = 0;
|
||||
const Application& app = mApplications->GetApplication(defaultApplicationIndex);
|
||||
const Application& app = mApplications->getApplication(defaultApplicationIndex);
|
||||
QAction *start = new QAction(app.getName(), &menu);
|
||||
if (multipleSelection)
|
||||
start->setDisabled(true);
|
||||
|
@ -558,7 +558,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
|
||||
// Add menuitems to copy full path/filename to clipboard
|
||||
if (mContextItem) {
|
||||
if (mApplications->GetApplicationCount() > 0) {
|
||||
if (mApplications->getApplicationCount() > 0) {
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
|
@ -609,7 +609,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
index = indexAt(e->pos());
|
||||
if (index.isValid()) {
|
||||
mContextItem = mModel.itemFromIndex(index);
|
||||
if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) {
|
||||
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
|
||||
//Disconnect all signals
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
|
||||
|
@ -628,7 +628,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
|||
void ResultsTree::StartApplication(QStandardItem *target, int application)
|
||||
{
|
||||
//If there are no applications specified, tell the user about it
|
||||
if (mApplications->GetApplicationCount() == 0) {
|
||||
if (mApplications->getApplicationCount() == 0) {
|
||||
QMessageBox msg(QMessageBox::Critical,
|
||||
tr("Cppcheck"),
|
||||
tr("No editor application configured.\n\n"
|
||||
|
@ -640,7 +640,7 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
}
|
||||
|
||||
if (application == -1)
|
||||
application = mApplications->GetDefaultApplication();
|
||||
application = mApplications->getDefaultApplication();
|
||||
|
||||
if (application == -1) {
|
||||
QMessageBox msg(QMessageBox::Critical,
|
||||
|
@ -654,7 +654,7 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
|
||||
}
|
||||
|
||||
if (target && application >= 0 && application < mApplications->GetApplicationCount() && target->parent()) {
|
||||
if (target && application >= 0 && application < mApplications->getApplicationCount() && target->parent()) {
|
||||
// Make sure we are working with the first column
|
||||
if (target->column() != 0)
|
||||
target = target->parent()->child(target->row(), 0);
|
||||
|
@ -694,7 +694,7 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
|
|||
file.append("\"");
|
||||
}
|
||||
|
||||
const Application& app = mApplications->GetApplication(application);
|
||||
const Application& app = mApplications->getApplication(application);
|
||||
QString params = app.getParameters();
|
||||
params.replace("(file)", file, Qt::CaseInsensitive);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
|
|||
{
|
||||
mUI.setupUi(this);
|
||||
QSettings settings;
|
||||
mTempApplications->Copy(list);
|
||||
mTempApplications->copy(list);
|
||||
|
||||
mUI.mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString());
|
||||
mUI.mForce->setCheckState(BoolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool()));
|
||||
|
@ -205,7 +205,7 @@ void SettingsDialog::AddApplication()
|
|||
ApplicationDialog dialog(tr("Add a new application"), app, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
mTempApplications->AddApplication(app);
|
||||
mTempApplications->addApplication(app);
|
||||
mUI.mListWidget->addItem(app.getName());
|
||||
}
|
||||
}
|
||||
|
@ -215,14 +215,14 @@ void SettingsDialog::RemoveApplication()
|
|||
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
|
||||
foreach (QListWidgetItem *item, selected) {
|
||||
const int removeIndex = mUI.mListWidget->row(item);
|
||||
const int currentDefault = mTempApplications->GetDefaultApplication();
|
||||
mTempApplications->RemoveApplication(removeIndex);
|
||||
const int currentDefault = mTempApplications->getDefaultApplication();
|
||||
mTempApplications->removeApplication(removeIndex);
|
||||
if (removeIndex == currentDefault)
|
||||
// If default app is removed set default to unknown
|
||||
mTempApplications->SetDefault(-1);
|
||||
mTempApplications->setDefault(-1);
|
||||
else if (removeIndex < currentDefault)
|
||||
// Move default app one up if earlier app was removed
|
||||
mTempApplications->SetDefault(currentDefault - 1);
|
||||
mTempApplications->setDefault(currentDefault - 1);
|
||||
}
|
||||
mUI.mListWidget->clear();
|
||||
PopulateApplicationList();
|
||||
|
@ -234,12 +234,12 @@ void SettingsDialog::EditApplication()
|
|||
QListWidgetItem *item = 0;
|
||||
foreach (item, selected) {
|
||||
int row = mUI.mListWidget->row(item);
|
||||
Application& app = mTempApplications->GetApplication(row);
|
||||
Application& app = mTempApplications->getApplication(row);
|
||||
ApplicationDialog dialog(tr("Modify an application"), app, this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString name = app.getName();
|
||||
if (mTempApplications->GetDefaultApplication() == row)
|
||||
if (mTempApplications->getDefaultApplication() == row)
|
||||
name += tr(" [Default]");
|
||||
item->setText(name);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void SettingsDialog::DefaultApplication()
|
|||
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
|
||||
if (!selected.isEmpty()) {
|
||||
int index = mUI.mListWidget->row(selected[0]);
|
||||
mTempApplications->SetDefault(index);
|
||||
mTempApplications->setDefault(index);
|
||||
mUI.mListWidget->clear();
|
||||
PopulateApplicationList();
|
||||
}
|
||||
|
@ -259,9 +259,9 @@ void SettingsDialog::DefaultApplication()
|
|||
|
||||
void SettingsDialog::PopulateApplicationList()
|
||||
{
|
||||
const int defapp = mTempApplications->GetDefaultApplication();
|
||||
for (int i = 0; i < mTempApplications->GetApplicationCount(); i++) {
|
||||
const Application& app = mTempApplications->GetApplication(i);
|
||||
const int defapp = mTempApplications->getDefaultApplication();
|
||||
for (int i = 0; i < mTempApplications->getApplicationCount(); i++) {
|
||||
const Application& app = mTempApplications->getApplication(i);
|
||||
QString name = app.getName();
|
||||
if (i == defapp) {
|
||||
name += " ";
|
||||
|
@ -275,7 +275,7 @@ void SettingsDialog::PopulateApplicationList()
|
|||
if (defapp == -1)
|
||||
mUI.mListWidget->setCurrentRow(0);
|
||||
else {
|
||||
if (mTempApplications->GetApplicationCount() > defapp)
|
||||
if (mTempApplications->getApplicationCount() > defapp)
|
||||
mUI.mListWidget->setCurrentRow(defapp);
|
||||
else
|
||||
mUI.mListWidget->setCurrentRow(0);
|
||||
|
@ -284,7 +284,7 @@ void SettingsDialog::PopulateApplicationList()
|
|||
|
||||
void SettingsDialog::Ok()
|
||||
{
|
||||
mApplications->Copy(mTempApplications);
|
||||
mApplications->copy(mTempApplications);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue