Skip to content

Commit

Permalink
Now starts the default application by double clicking the error.
Browse files Browse the repository at this point in the history
  • Loading branch information
vesap committed May 23, 2009
1 parent 31a88bd commit 2b7bf67
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 21 deletions.
9 changes: 9 additions & 0 deletions gui/applicationlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,12 @@ void ApplicationList::RemoveApplication(const int index)
mApplications.removeAt(index);
}


void ApplicationList::MoveFirst(const int index)
{
if (index < mApplications.size() && index > 0)
{
mApplications.move(index, 0);
}
}

2 changes: 2 additions & 0 deletions gui/applicationlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ApplicationList : public QObject
void AddApplicationType(const QString &name, const QString &path);

void RemoveApplication(const int index);

void MoveFirst(const int index);
protected:


Expand Down
13 changes: 0 additions & 13 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,6 @@ Settings MainWindow::GetCppCheckSettings()
return result;
}


QStringList MainWindow::RemoveDuplicates(const QStringList &list)
{
QHash<QString, int> hash;
QString str;
foreach(str, list)
{
hash[str] = 0;
}

return QStringList(hash.uniqueKeys());
}

QStringList MainWindow::GetFilesRecursively(const QString &path)
{
QFileInfo info(path);
Expand Down
1 change: 0 additions & 1 deletion gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ protected slots:
void EnableCheckButtons(bool enable);
void DoCheckFiles(QFileDialog::FileMode mode);
QStringList GetFilesRecursively(const QString &path);
QStringList RemoveDuplicates(const QStringList &list);
Settings GetCppCheckSettings();
QStringList RemoveUnacceptedFiles(const QStringList &list);

Expand Down
25 changes: 19 additions & 6 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ ResultsTree::ResultsTree(QSettings &settings, ApplicationList &list) :
QStringList labels;
labels << tr("File") << tr("Severity") << tr("Line") << tr("Message");
mModel.setHorizontalHeaderLabels(labels);

setExpandsOnDoubleClick(false);
LoadSettings();
connect(this, SIGNAL(doubleClicked(const QModelIndex &)),
this, SLOT(QuickStartApplication(const QModelIndex &)));

}

ResultsTree::~ResultsTree()
Expand Down Expand Up @@ -365,12 +368,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
}
}


void ResultsTree::Context(int application)
void ResultsTree::StartApplication(QStandardItem *target, int application)
{
if (mContextItem)
if (target && application >= 0 && application < mApplications.GetApplicationCount())
{
QVariantMap data = mContextItem->data().toMap();
QVariantMap data = target->data().toMap();

QString program = mApplications.GetApplicationPath(application);

Expand Down Expand Up @@ -402,6 +404,17 @@ void ResultsTree::Context(int application)
program.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
program.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);

QProcess::execute(program);
QProcess::startDetached(program);
}
}


void ResultsTree::Context(int application)
{
StartApplication(mContextItem, application);
}

void ResultsTree::QuickStartApplication(const QModelIndex &index)
{
StartApplication(mModel.itemFromIndex(index), 0);
}
2 changes: 2 additions & 0 deletions gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ class ResultsTree : public QTreeView

void ShowResults(ShowTypes type, bool show);
protected slots:
void QuickStartApplication(const QModelIndex &index);
/**
* @brief Slot for context menu item to open an error with specified application
*
* @param application Index of the application to open the error
*/
void Context(int application);
protected:
void StartApplication(QStandardItem *target, int application);
void contextMenuEvent(QContextMenuEvent * e);

QStandardItem *AddBacktraceFiles(QStandardItem *parent,
Expand Down
19 changes: 18 additions & 1 deletion gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ SettingsDialog::SettingsDialog(QSettings &programSettings, ApplicationList &list
connect(modify, SIGNAL(clicked()),
this, SLOT(ModifyApplication()));

QPushButton *def = new QPushButton(tr("Make default application"));
appslayout->addWidget(def);
connect(def, SIGNAL(clicked()),
this, SLOT(DefaultApplication()));

connect(mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
this, SLOT(ModifyApplication()));


mListWidget->setSortingEnabled(false);
PopulateListWidget();


Expand Down Expand Up @@ -219,6 +224,18 @@ void SettingsDialog::ModifyApplication()
}
}

void SettingsDialog::DefaultApplication()
{
QList<QListWidgetItem *> selected = mListWidget->selectedItems();
if (selected.size() > 0)
{
int index = mListWidget->row(selected[0]);
mApplications.MoveFirst(index);
mListWidget->clear();
PopulateListWidget();
}
}

void SettingsDialog::PopulateListWidget()
{
for (int i = 0;i < mApplications.GetApplicationCount();i++)
Expand Down
1 change: 1 addition & 0 deletions gui/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected slots:
void AddApplication();
void DeleteApplication();
void ModifyApplication();
void DefaultApplication();
protected:
void PopulateListWidget();
/**
Expand Down

0 comments on commit 2b7bf67

Please sign in to comment.