/* * Cppcheck - A tool for static C/C++ code analysis * Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include "common.h" #include "project.h" #include "projectfile.h" #include "statsdialog.h" StatsDialog::StatsDialog(QWidget *parent) : QDialog(parent) { mUI.setupUi(this); connect(mUI.mCopyToClipboard, SIGNAL(pressed()), this, SLOT(copyToClipboard())); } void StatsDialog::setProject(const Project& project) { ProjectFile *projectFile = project.GetProjectFile(); if (projectFile) { mUI.mProject->setText(projectFile->GetRootPath()); mUI.mPaths->setText(projectFile->GetCheckPaths().join(";")); mUI.mIncludePaths->setText(projectFile->GetIncludeDirs().join(";")); mUI.mDefines->setText(projectFile->GetDefines().join(";")); } else { mUI.mProject->setText(""); mUI.mPaths->setText(""); mUI.mIncludePaths->setText(""); mUI.mDefines->setText(""); } } void StatsDialog::setPathSelected(const QString& path) { mUI.mPath->setText(path); } void StatsDialog::setNumberOfFilesScanned(int num) { mUI.mNumberOfFilesScanned->setText(QString::number(num)); } void StatsDialog::setScanDuration(double seconds) { mUI.mScanDuration->setText(tr("%1 secs").arg(seconds)); } void StatsDialog::copyToClipboard() { QClipboard *clipboard = QApplication::clipboard(); if (clipboard) { // Plain text summary QString textSummary = tr( "Project Settings\n" "\tProject:\t%1\n" "\tPaths:\t%2\n" "\tInclude paths:\t%3\n" "\tDefines:\t%4\n" "Previous Scan\n" "\tPath selected:\t%5\n" "\tNumber of files scanned:\t%6\n" "\tScan duration:\t%7\n" ) .arg(mUI.mProject->text()) .arg(mUI.mPaths->text()) .arg(mUI.mIncludePaths->text()) .arg(mUI.mDefines->text()) .arg(mUI.mPath->text()) .arg(mUI.mNumberOfFilesScanned->text()) .arg(mUI.mScanDuration->text()); // HTML summary QString htmlSummary = tr( "

Project Settings

\n" "\n" " \n" " \n" " \n" " \n" "
Project:%1
Paths:%2
Include paths:%3
Defines:%4
\n" "

Previous Scan

\n" "\n" " \n" " \n" " \n" "
Path selected:%5
Number of files scanned:%6
Scan duration:%7
\n" ) .arg(mUI.mProject->text()) .arg(mUI.mPaths->text()) .arg(mUI.mIncludePaths->text()) .arg(mUI.mDefines->text()) .arg(mUI.mPath->text()) .arg(mUI.mNumberOfFilesScanned->text()) .arg(mUI.mScanDuration->text()); QMimeData *mimeData = new QMimeData(); mimeData->setText(textSummary); mimeData->setHtml(htmlSummary); clipboard->setMimeData(mimeData); } }