Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/danmar/cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
vBm committed Dec 15, 2010
2 parents 0b8f2ef + 500c0a1 commit f15539d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gui/logview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <QTextStream>
#include "common.h"
#include "logview.h"

Expand All @@ -29,6 +33,7 @@ LogView::LogView(QSettings *programSettings, QWidget *parent)

connect(mUI.mCloseButton, SIGNAL(clicked()), this, SLOT(CloseButtonClicked()));
connect(mUI.mClearButton, SIGNAL(clicked()), this, SLOT(ClearButtonClicked()));
connect(mUI.mSaveButton, SIGNAL(clicked()), this, SLOT(SaveButtonClicked()));

resize(mSettings->value(SETTINGS_LOG_VIEW_WIDTH, 400).toInt(),
mSettings->value(SETTINGS_LOG_VIEW_HEIGHT, 300).toInt());
Expand All @@ -54,3 +59,22 @@ void LogView::ClearButtonClicked()
{
mUI.mLogEdit->clear();
}

void LogView::SaveButtonClicked()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log"),
"", tr("Text files (*.txt *.log);;All files (*.*)"));
if (!fileName.isEmpty())
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QMessageBox::warning(this, tr("Cppcheck"),
tr("Could not open file for writing: \"%1\"").arg(fileName));
return;
}

QTextStream out(&file);
out << mUI.mLogEdit->toPlainText();
}
}
6 changes: 6 additions & 0 deletions gui/logview.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ protected slots:
*/
void ClearButtonClicked();

/**
* @brief Called when save button is clicked.
*
*/
void SaveButtonClicked();

private:
Ui::LogView mUI;

Expand Down
7 changes: 7 additions & 0 deletions gui/logview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="mSaveButton">
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mClearButton">
<property name="text">
Expand Down

0 comments on commit f15539d

Please sign in to comment.