Commit bc3fde7f authored by dt's avatar dt
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents a12dbe95 e8dafc28
...@@ -315,6 +315,12 @@ ...@@ -315,6 +315,12 @@
\snippet examples/addressbook-sdk/part2/addressbook.h members1 \snippet examples/addressbook-sdk/part2/addressbook.h members1
The Qt types used for our private members, e.g., QPushButton, QLineEdit,
QTextEdit, etc., need to be included with the \c include directive, as
shown below:
\snippet examples/addressbook-sdk/part2/addressbook.h include
\note The names, e.g., \c addButton etc., correspond to the name of the \note The names, e.g., \c addButton etc., correspond to the name of the
actual object. You can modify them by double-clicking on their names within actual object. You can modify them by double-clicking on their names within
\QD's \gui{Object Inspector}. \QD's \gui{Object Inspector}.
...@@ -727,6 +733,7 @@ ...@@ -727,6 +733,7 @@
dialog that can prompt the user for a contact's name. Qt provides QDialog, dialog that can prompt the user for a contact's name. Qt provides QDialog,
which we subclass in this chapter, to implement a FindDialog class. which we subclass in this chapter, to implement a FindDialog class.
\section1 Designing \c FindDialog \section1 Designing \c FindDialog
#image #image
...@@ -743,6 +750,7 @@ ...@@ -743,6 +750,7 @@
in a horizontal layout. Then set a top level layout - either horizontal or in a horizontal layout. Then set a top level layout - either horizontal or
vertical. vertical.
\section1 Implementing \c FindDialog \section1 Implementing \c FindDialog
Let's look at \c{FindDialog}'s header file. Here, we need to provide Let's look at \c{FindDialog}'s header file. Here, we need to provide
...@@ -751,8 +759,38 @@ ...@@ -751,8 +759,38 @@
\snippet examples/addressbook-sdk/part5/finddialog.h private members \snippet examples/addressbook-sdk/part5/finddialog.h private members
We define a public function, \c getFindText(), to be used by classes that
instantiate \c FindDialog. This function allows the these classes to obtain
the search string entered by the user. A public slot, \c findClicked(), is
also defined to handle the search string when the user clicks the \gui Find
button.
\snippet examples/addressbook-sdk/part5/finddialog.h getFindText
\dots
\snippet examples/addressbook-sdk/part5/finddialog.h findClicked
Now, lets look at our constructor in the \c{finddialog.cpp} file. Here, we
set up the private variables, \c lineEdit, \c findButton, and \c findText.
\snippet examples/addressbook-sdk/part5/finddialog.cpp constructor
We connect our signals to their respective slots. Notice that
\c{findButton}'s \l{QPushButton:}{clicked()} signal is connected to
\c findClicked() and \l{QDialog::}{accept()}. The \l{QDialog::}{accept()}
slot provided by QDialog hides the dialog and sets the result code to
\l{QDialog::}{Accepted}. We use this function to help \c{AddressBook}'s
\c findContact() function know when the \c FindDialog object has been
closed. We will explain this logic in further detail when discussing the
\c findContact() function.
\image addressbook-tutorial-part5-signals-and-slots.png
In \c findClicked(), we validate to ensure that the user did not click the
\gui Find button without entering a contact's name. Then, we set
\c findText to the search string, extracted from \c lineEdit. After that,
we clear the contents of \c lineEdit and hide the dialog.
\snippet examples/addressbook-sdk/part5/finddialog.cpp findClicked
*/ */
......
//! [class definition]
#ifndef ADDRESSBOOK_H #ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H #define ADDRESSBOOK_H
//! [include]
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QPushButton> #include <QtGui/QPushButton>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QTextEdit> #include <QtGui/QTextEdit>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
//! [include]
namespace Ui namespace Ui
{ {
...@@ -48,4 +48,3 @@ private: ...@@ -48,4 +48,3 @@ private:
}; };
#endif // ADDRESSBOOK_H #endif // ADDRESSBOOK_H
//! [class definition]
#include "finddialog.h" #include "finddialog.h"
#include "ui_finddialog.h" #include "ui_finddialog.h"
//! [constructor]
FindDialog::FindDialog(QWidget *parent) : FindDialog::FindDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::FindDialog) m_ui(new Ui::FindDialog)
...@@ -18,12 +19,14 @@ FindDialog::FindDialog(QWidget *parent) : ...@@ -18,12 +19,14 @@ FindDialog::FindDialog(QWidget *parent) :
setWindowTItle(tr("Find a Contact")); setWindowTItle(tr("Find a Contact"));
} }
//! [constructor]
FindDialog::~FindDialog() FindDialog::~FindDialog()
{ {
delete m_ui; delete m_ui;
} }
//! [findClicked]
void FindDialog::findClicked() void FindDialog::findClicked()
{ {
QString text = lineEdit->text(); QString text = lineEdit->text();
...@@ -38,6 +41,7 @@ void FindDialog::findClicked() ...@@ -38,6 +41,7 @@ void FindDialog::findClicked()
hide(); hide();
} }
} }
//! [findClicked]
QString FindDialog::getFindText() QString FindDialog::getFindText()
{ {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define FINDDIALOG_H #define FINDDIALOG_H
#include <QtGui/QDialog> #include <QtGui/QDialog>
#include <QLineEdit> #include <QtGui/QLineEdit>
#include <QPushButton> #include <QtGui/QPushButton>
namespace Ui { namespace Ui {
class FindDialog; class FindDialog;
...@@ -14,10 +14,14 @@ class FindDialog : public QDialog { ...@@ -14,10 +14,14 @@ class FindDialog : public QDialog {
public: public:
FindDialog(QWidget *parent = 0); FindDialog(QWidget *parent = 0);
~FindDialog(); ~FindDialog();
//! [getFindText]
QString getFindText(); QString getFindText();
//! [getFindText]
//! [findClicked]
public slots: public slots:
void findClicked(); void findClicked();
//! [findClicked]
//! [private members] //! [private members]
private: private:
......
...@@ -279,8 +279,12 @@ void BreakHandler::removeAt(int index) ...@@ -279,8 +279,12 @@ void BreakHandler::removeAt(int index)
void BreakHandler::clear() void BreakHandler::clear()
{ {
for (int index = size(); --index >= 0; ) qDeleteAll(m_bp);
removeAt(index); m_bp.clear();
m_enabled.clear();
m_disabled.clear();
m_removed.clear();
m_inserted.clear();
} }
int BreakHandler::findBreakpoint(const BreakpointData &needle) int BreakHandler::findBreakpoint(const BreakpointData &needle)
...@@ -326,19 +330,19 @@ void BreakHandler::saveBreakpoints() ...@@ -326,19 +330,19 @@ void BreakHandler::saveBreakpoints()
const BreakpointData *data = at(index); const BreakpointData *data = at(index);
QMap<QString, QVariant> map; QMap<QString, QVariant> map;
if (!data->fileName.isEmpty()) if (!data->fileName.isEmpty())
map["filename"] = data->fileName; map.insert(QLatin1String("filename"), data->fileName);
if (!data->lineNumber.isEmpty()) if (!data->lineNumber.isEmpty())
map["linenumber"] = data->lineNumber; map.insert(QLatin1String("linenumber"), data->lineNumber);
if (!data->funcName.isEmpty()) if (!data->funcName.isEmpty())
map["funcname"] = data->funcName; map.insert(QLatin1String("funcname"), data->funcName);
if (!data->condition.isEmpty()) if (!data->condition.isEmpty())
map["condition"] = data->condition; map.insert(QLatin1String("condition"), data->condition);
if (!data->ignoreCount.isEmpty()) if (!data->ignoreCount.isEmpty())
map["ignorecount"] = data->ignoreCount; map.insert(QLatin1String("ignorecount"), data->ignoreCount);
if (!data->enabled) if (!data->enabled)
map["disabled"] = "1"; map.insert(QLatin1String("disabled"), QLatin1String("1"));
if (data->useFullPath) if (data->useFullPath)
map["usefullpath"] = "1"; map.insert(QLatin1String("usefullpath"), QLatin1String("1"));
list.append(map); list.append(map);
} }
setSessionValueRequested("Breakpoints", list); setSessionValueRequested("Breakpoints", list);
...@@ -349,18 +353,31 @@ void BreakHandler::loadBreakpoints() ...@@ -349,18 +353,31 @@ void BreakHandler::loadBreakpoints()
QVariant value; QVariant value;
sessionValueRequested("Breakpoints", &value); sessionValueRequested("Breakpoints", &value);
QList<QVariant> list = value.toList(); QList<QVariant> list = value.toList();
clear(); clear();
foreach (const QVariant &var, list) { foreach (const QVariant &var, list) {
const QMap<QString, QVariant> map = var.toMap(); const QMap<QString, QVariant> map = var.toMap();
BreakpointData *data = new BreakpointData(this); BreakpointData *data = new BreakpointData(this);
data->fileName = map["filename"].toString(); QVariant v = map.value(QLatin1String("filename"));
data->lineNumber = map["linenumber"].toString(); if (v.isValid())
data->condition = map["condition"].toString(); data->fileName = v.toString();
data->ignoreCount = map["ignorecount"].toString(); v = map.value(QLatin1String("linenumber"));
data->funcName = map["funcname"].toString(); if (v.isValid())
data->enabled = !map["disabled"].toInt(); data->lineNumber = v.toString();
data->useFullPath = bool(map["usefullpath"].toInt()); v = map.value(QLatin1String("condition"));
if (v.isValid())
data->condition = v.toString();
v = map.value(QLatin1String("ignorecount"));
if (v.isValid())
data->ignoreCount = v.toInt();
v = map.value(QLatin1String("funcname"));
if (v.isValid())
data->funcName = v.toString();
v = map.value(QLatin1String("disabled"));
if (v.isValid())
data->enabled = !v.toInt();
v = map.value(QLatin1String("usefullpath"));
if (v.isValid())
data->useFullPath = bool(v.toInt());
data->markerFileName = data->fileName; data->markerFileName = data->fileName;
data->markerLineNumber = data->lineNumber.toInt(); data->markerLineNumber = data->lineNumber.toInt();
append(data); append(data);
......
...@@ -407,12 +407,19 @@ static bool setBreakPointEnabledById(CIDebugControl *ctl, unsigned long id, bool ...@@ -407,12 +407,19 @@ static bool setBreakPointEnabledById(CIDebugControl *ctl, unsigned long id, bool
return true; return true;
} }
static inline QString msgCannotSetBreakAtFunction(const QString &func, const QString &why)
{
return QString::fromLatin1("Cannot set a breakpoint at '%1': %2").arg(func, why);
}
// Synchronize (halted) engine breakpoints with those of the BreakHandler. // Synchronize (halted) engine breakpoints with those of the BreakHandler.
bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl, bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl,
CIDebugSymbols *syms, CIDebugSymbols *syms,
BreakHandler *handler, BreakHandler *handler,
QString *errorMessage) QString *errorMessage, QStringList *warnings)
{ {
errorMessage->clear();
warnings->clear();
// Do an initial check whether we are in a state that allows // Do an initial check whether we are in a state that allows
// for modifying breakPoints // for modifying breakPoints
ULONG engineCount; ULONG engineCount;
...@@ -420,25 +427,29 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl, ...@@ -420,25 +427,29 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl,
*errorMessage = QString::fromLatin1("Cannot modify breakpoints: %1").arg(*errorMessage); *errorMessage = QString::fromLatin1("Cannot modify breakpoints: %1").arg(*errorMessage);
return false; return false;
} }
QString warning;
// Insert new ones // Insert new ones
bool updateMarkers = false; bool updateMarkers = false;
foreach (BreakpointData *nbd, handler->insertedBreakpoints()) { foreach (BreakpointData *nbd, handler->insertedBreakpoints()) {
warning.clear();
// Function breakpoints: Are the module names specified? // Function breakpoints: Are the module names specified?
bool breakPointOk = false; bool breakPointOk = false;
if (nbd->funcName.isEmpty()) { if (nbd->funcName.isEmpty()) {
breakPointOk = true; breakPointOk = true;
} else { } else {
switch (resolveSymbol(syms, &nbd->funcName, errorMessage)) { switch (resolveSymbol(syms, &nbd->funcName, &warning)) {
case ResolveSymbolOk: case ResolveSymbolOk:
breakPointOk = true; breakPointOk = true;
break; break;
case ResolveSymbolAmbiguous: case ResolveSymbolAmbiguous:
qWarning("Warning: %s\n", qPrintable(*errorMessage)); warnings->push_back(msgCannotSetBreakAtFunction(nbd->funcName, warning));
warning.clear();
breakPointOk = true; breakPointOk = true;
break; break;
case ResolveSymbolNotFound: case ResolveSymbolNotFound:
case ResolveSymbolError: case ResolveSymbolError:
qWarning("Warning: %s\n", qPrintable(*errorMessage)); warnings->push_back(msgCannotSetBreakAtFunction(nbd->funcName, warning));
warning.clear();
break; break;
}; };
} // function breakpoint } // function breakpoint
...@@ -447,7 +458,7 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl, ...@@ -447,7 +458,7 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl,
quint64 address; quint64 address;
unsigned long id; unsigned long id;
CDBBreakPoint ncdbbp(*nbd); CDBBreakPoint ncdbbp(*nbd);
breakPointOk = ncdbbp.add(debugControl, &address, &id, errorMessage); breakPointOk = ncdbbp.add(debugControl, &address, &id, &warning);
if (breakPointOk) { if (breakPointOk) {
if (debugBP) if (debugBP)
qDebug() << "Added " << id << " at " << address << ncdbbp; qDebug() << "Added " << id << " at " << address << ncdbbp;
...@@ -464,22 +475,21 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl, ...@@ -464,22 +475,21 @@ bool CDBBreakPoint::synchronizeBreakPoints(CIDebugControl* debugControl,
nbd->bpFuncName = nbd->funcName; nbd->bpFuncName = nbd->funcName;
} }
} // had symbol } // had symbol
if (!breakPointOk) if (!breakPointOk && !warning.isEmpty())
qWarning("%s\n", qPrintable(*errorMessage)); warnings->push_back(warning); }
}
// Delete // Delete
foreach (BreakpointData *rbd, handler->takeRemovedBreakpoints()) { foreach (BreakpointData *rbd, handler->takeRemovedBreakpoints()) {
if (!removeBreakPointById(debugControl, rbd->bpNumber.toUInt(), errorMessage)) if (!removeBreakPointById(debugControl, rbd->bpNumber.toUInt(), &warning))
qWarning("%s\n", qPrintable(*errorMessage)); warnings->push_back(warning);
delete rbd; delete rbd;
} }
// Enable/Disable // Enable/Disable
foreach (BreakpointData *ebd, handler->takeEnabledBreakpoints()) foreach (BreakpointData *ebd, handler->takeEnabledBreakpoints())
if (!setBreakPointEnabledById(debugControl, ebd->bpNumber.toUInt(), true, errorMessage)) if (!setBreakPointEnabledById(debugControl, ebd->bpNumber.toUInt(), true, &warning))
qWarning("%s\n", qPrintable(*errorMessage)); warnings->push_back(warning);
foreach (BreakpointData *dbd, handler->takeDisabledBreakpoints()) foreach (BreakpointData *dbd, handler->takeDisabledBreakpoints())
if (!setBreakPointEnabledById(debugControl, dbd->bpNumber.toUInt(), false, errorMessage)) if (!setBreakPointEnabledById(debugControl, dbd->bpNumber.toUInt(), false, &warning))
qWarning("%s\n", qPrintable(*errorMessage)); warnings->push_back(warning);
if (updateMarkers) if (updateMarkers)
handler->updateMarkers(); handler->updateMarkers();
......
...@@ -73,7 +73,8 @@ struct CDBBreakPoint ...@@ -73,7 +73,8 @@ struct CDBBreakPoint
static bool getBreakPoints(CIDebugControl* debugControl, QList<CDBBreakPoint> *bps, QString *errorMessage); static bool getBreakPoints(CIDebugControl* debugControl, QList<CDBBreakPoint> *bps, QString *errorMessage);
// Synchronize (halted) engine with BreakHandler. // Synchronize (halted) engine with BreakHandler.
static bool synchronizeBreakPoints(CIDebugControl* ctl, CIDebugSymbols *syms, static bool synchronizeBreakPoints(CIDebugControl* ctl, CIDebugSymbols *syms,
BreakHandler *bh, QString *errorMessage); BreakHandler *bh,
QString *errorMessage, QStringList *warnings);
// Return a 'canonical' file (using '/' and capitalized drive letter) // Return a 'canonical' file (using '/' and capitalized drive letter)
static QString canonicalSourceFile(const QString &f); static QString canonicalSourceFile(const QString &f);
......
...@@ -1182,6 +1182,8 @@ void CdbDebugEngine::selectThread(int index) ...@@ -1182,6 +1182,8 @@ void CdbDebugEngine::selectThread(int index)
void CdbDebugEngine::attemptBreakpointSynchronization() void CdbDebugEngine::attemptBreakpointSynchronization()
{ {
if (!m_d->m_hDebuggeeProcess) // Sometimes called from the breakpoint Window
return;
QString errorMessage; QString errorMessage;
if (!m_d->attemptBreakpointSynchronization(&errorMessage)) if (!m_d->attemptBreakpointSynchronization(&errorMessage))
warning(msgFunctionFailed(Q_FUNC_INFO, errorMessage)); warning(msgFunctionFailed(Q_FUNC_INFO, errorMessage));
...@@ -1215,10 +1217,15 @@ bool CdbDebugEnginePrivate::attemptBreakpointSynchronization(QString *errorMessa ...@@ -1215,10 +1217,15 @@ bool CdbDebugEnginePrivate::attemptBreakpointSynchronization(QString *errorMessa
return true; return true;
} }
return CDBBreakPoint::synchronizeBreakPoints(m_cif.debugControl, QStringList warnings;
const bool ok = CDBBreakPoint::synchronizeBreakPoints(m_cif.debugControl,
m_cif.debugSymbols, m_cif.debugSymbols,
m_debuggerManagerAccess->breakHandler(), m_debuggerManagerAccess->breakHandler(),
errorMessage); errorMessage, &warnings);
if (const int warningsCount = warnings.size())
for (int w = 0; w < warningsCount; w++)
m_engine->warning(warnings.at(w));
return ok;
} }
void CdbDebugEngine::reloadDisassembler() void CdbDebugEngine::reloadDisassembler()
......
...@@ -138,6 +138,7 @@ static ResolveSymbolResult resolveSymbol(CIDebugSymbols *syms, QString *symbol, ...@@ -138,6 +138,7 @@ static ResolveSymbolResult resolveSymbol(CIDebugSymbols *syms, QString *symbol,
QStringList *matches, QStringList *matches,
QString *errorMessage) QString *errorMessage)
{ {
errorMessage->clear();
// Is it an incomplete symbol? // Is it an incomplete symbol?
if (symbol->contains(QLatin1Char('!'))) if (symbol->contains(QLatin1Char('!')))
return ResolveSymbolOk; return ResolveSymbolOk;
......
...@@ -168,19 +168,16 @@ static QStringList readLines(const QString &absoluteFileName) ...@@ -168,19 +168,16 @@ static QStringList readLines(const QString &absoluteFileName)
return lines; return lines;
} }
bool GenericProject::addFiles(const QStringList &filePaths) bool GenericProject::setFiles(const QStringList &filePaths)
{ {
// Make sure we can open the file for writing // Make sure we can open the file for writing
QFile file(filesFileName()); QFile file(filesFileName());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false; return false;
QStringList newFileList = m_files;
newFileList.append(filePaths);
QTextStream stream(&file); QTextStream stream(&file);
QDir baseDir(QFileInfo(m_fileName).dir()); QDir baseDir(QFileInfo(m_fileName).dir());
foreach (const QString &filePath, newFileList) foreach (const QString &filePath, filePaths)
stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n'); stream << baseDir.relativeFilePath(filePath) << QLatin1Char('\n');
file.close(); file.close();
...@@ -188,6 +185,27 @@ bool GenericProject::addFiles(const QStringList &filePaths) ...@@ -188,6 +185,27 @@ bool GenericProject::addFiles(const QStringList &filePaths)
return true; return true;
} }
bool GenericProject::addFiles(const QStringList &filePaths)
{
QStringList newFileList = m_files;
newFileList.append(filePaths);
return setFiles(newFileList);
}
bool GenericProject::removeFiles(const QStringList &filePaths)
{
QStringList newFileList;
QSet<QString> filesToRemove = filePaths.toSet();
foreach (const QString &file, m_files) {
if (!filesToRemove.contains(file))
newFileList.append(file);
}
return setFiles(newFileList);
}
void GenericProject::parseProject(RefreshOptions options) void GenericProject::parseProject(RefreshOptions options)
{ {
if (options & Files) if (options & Files)
......
...@@ -94,7 +94,9 @@ public: ...@@ -94,7 +94,9 @@ public:
QString buildParser(const QString &buildConfiguration) const; QString buildParser(const QString &buildConfiguration) const;
ProjectExplorer::ToolChain *toolChain() const; ProjectExplorer::ToolChain *toolChain() const;
bool setFiles(const QStringList &filePaths);
bool addFiles(const QStringList &filePaths); bool addFiles(const QStringList &filePaths);
bool removeFiles(const QStringList &filePaths);
enum RefreshOptions { enum RefreshOptions {
Files = 0x01, Files = 0x01,
......