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