diff --git a/doc/addressbook-sdk.qdoc b/doc/addressbook-sdk.qdoc index 1a85abeec90..24ac82abc7d 100644 --- a/doc/addressbook-sdk.qdoc +++ b/doc/addressbook-sdk.qdoc @@ -714,8 +714,8 @@ of buttons. When the user clicks on the \gui Find button, it is useful to display a - 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. + dialog prompting the user for a contact's name. Qt provides QDialog, which + we subclass in this chapter, to implement a FindDialog class. \section1 Designing The FindDialog @@ -737,24 +737,17 @@ \section1 Implementing The FindDialog Class - Let's look at \c{FindDialog}'s header file. Here, we need to provide - private members for the class so that we can access the widgets freely - throughout the class. + Let's look at \c{FindDialog}'s header file. We define a public function, + \c findText(), 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 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 + \snippet examples/addressbook-sdk/part5/finddialog.h findText \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. + Now, lets look at our constructor in the \c{finddialog.cpp} file. \snippet examples/addressbook-sdk/part5/finddialog.cpp constructor diff --git a/doc/examples/addressbook-sdk/part5/addressbook.cpp b/doc/examples/addressbook-sdk/part5/addressbook.cpp index 22b0340bc1c..eca1c0d24aa 100644 --- a/doc/examples/addressbook-sdk/part5/addressbook.cpp +++ b/doc/examples/addressbook-sdk/part5/addressbook.cpp @@ -6,64 +6,31 @@ AddressBook::AddressBook(QWidget *parent) { ui->setupUi(this); - nameLine = new QLineEdit; - nameLine = ui->nameLine; - nameLine->setReadOnly(true); + ui->nameLine->setReadOnly(true); + ui->addressText->setReadOnly(true); + ui->submitButton->hide(); + ui->cancelButton->hide(); + ui->nextButton->setEnabled(false); + ui->previousButton->setEnabled(false); + ui->editButton->setEnabled(false); + ui->removeButton->setEnabled(false); - addressText = new QTextEdit; - addressText = ui->addressText; - addressText->setReadOnly(true); - - addButton = new QPushButton; - addButton = ui->addButton; - - submitButton = new QPushButton; - submitButton = ui->submitButton; - submitButton->hide(); - - cancelButton = new QPushButton; - cancelButton = ui->cancelButton; - cancelButton->hide(); - - nextButton = new QPushButton; - nextButton = ui->nextButton; - nextButton->setEnabled(false); - - previousButton = new QPushButton; - previousButton = ui->previousButton; - previousButton->setEnabled(false); - - editButton = new QPushButton; - editButton = ui->editButton; - editButton->setEnabled(false); - - removeButton = new QPushButton; - removeButton = ui->removeButton; - removeButton->setEnabled(false); - -//! [private members] - findButton = new QPushButton; - findButton = ui->findButton; - - dialog = new FindDialog; -//! [private members] - - connect(addButton, SIGNAL(clicked()), this, + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addContact())); - connect(submitButton, SIGNAL(clicked()), this, + connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); - connect(cancelButton, SIGNAL(clicked()), this, + connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); - connect(nextButton, SIGNAL(clicked()), this, + connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(next())); - connect(previousButton, SIGNAL(clicked()), this, + connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(previous())); - connect(editButton, SIGNAL(clicked()), this, + connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editContact())); - connect(removeButton, SIGNAL(clicked()), this, + connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); //! [signal slot] - connect(findButton, SIGNAL(clicked()), this, + connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findContact())); //! [signal slot] @@ -77,23 +44,25 @@ AddressBook::~AddressBook() void AddressBook::addContact() { - oldName = nameLine->text(); - oldAddress = addressText->toPlainText(); + oldName = ui->nameLine->text(); + oldAddress = ui->addressText->toPlainText(); - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); updateInterface(AddingMode); } void AddressBook::submitContact() { - QString name = nameLine->text(); - QString address = addressText->toPlainText(); + QString name = ui->nameLine->text(); + QString address = ui->addressText->toPlainText(); if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + updateInterface(NavigationMode); + return; } if (currentMode == AddingMode) { @@ -130,15 +99,15 @@ void AddressBook::submitContact() void AddressBook::cancel() { - nameLine->setText(oldName); - nameLine->setReadOnly(true); + ui->nameLine->setText(oldName); + ui->nameLine->setReadOnly(true); updateInterface(NavigationMode); } void AddressBook::next() { - QString name = nameLine->text(); + QString name = ui->nameLine->text(); QMap::iterator i = contacts.find(name); if (i != contacts.end()) @@ -146,18 +115,18 @@ void AddressBook::next() if (i == contacts.end()) i = contacts.begin(); - nameLine->setText(i.key()); - addressText->setText(i.value()); + ui->nameLine->setText(i.key()); + ui->addressText->setText(i.value()); } void AddressBook::previous() { - QString name = nameLine->text(); + QString name = ui->nameLine->text(); QMap::iterator i = contacts.find(name); if (i == contacts.end()) { - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); return; } @@ -165,22 +134,22 @@ void AddressBook::previous() i = contacts.end(); i--; - nameLine->setText(i.key()); - addressText->setText(i.value()); + ui->nameLine->setText(i.key()); + ui->addressText->setText(i.value()); } void AddressBook::editContact() { - oldName = nameLine->text(); - oldAddress = addressText->toPlainText(); + oldName = ui->nameLine->text(); + oldAddress = ui->addressText->toPlainText(); updateInterface(EditingMode); } void AddressBook::removeContact() { - QString name = nameLine->text(); - QString address = addressText->toPlainText(); + QString name = ui->nameLine->text(); + QString address = ui->addressText->toPlainText(); if (contacts.contains(name)) { int button = QMessageBox::question(this, @@ -209,43 +178,43 @@ void AddressBook::updateInterface(Mode mode) case AddingMode: case EditingMode: - nameLine->setReadOnly(false); - nameLine->setFocus(Qt::OtherFocusReason); - addressText->setReadOnly(false); + ui->nameLine->setReadOnly(false); + ui->nameLine->setFocus(Qt::OtherFocusReason); + ui->addressText->setReadOnly(false); - addButton->setEnabled(false); - editButton->setEnabled(false); - removeButton->setEnabled(false); + ui->addButton->setEnabled(false); + ui->editButton->setEnabled(false); + ui->removeButton->setEnabled(false); - nextButton->setEnabled(false); - previousButton->setEnabled(false); + ui->nextButton->setEnabled(false); + ui->previousButton->setEnabled(false); - submitButton->show(); - cancelButton->show(); + ui->submitButton->show(); + ui->cancelButton->show(); break; case NavigationMode: if (contacts.isEmpty()) { - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); } - nameLine->setReadOnly(true); - addressText->setReadOnly(true); - addButton->setEnabled(true); + ui->nameLine->setReadOnly(true); + ui->addressText->setReadOnly(true); + ui->addButton->setEnabled(true); int number = contacts.size(); - editButton->setEnabled(number >= 1); - removeButton->setEnabled(number >= 1); + ui->editButton->setEnabled(number >= 1); + ui->removeButton->setEnabled(number >= 1); //! [enable] - findButton->setEnabled(number > 2); + ui->findButton->setEnabled(number > 2); //! [enable] - nextButton->setEnabled(number > 1); - previousButton->setEnabled(number >1); + ui->nextButton->setEnabled(number > 1); + ui->previousButton->setEnabled(number >1); - submitButton->hide(); - cancelButton->hide(); + ui->submitButton->hide(); + ui->cancelButton->hide(); break; } } @@ -253,14 +222,14 @@ void AddressBook::updateInterface(Mode mode) //! [findContact] void AddressBook::findContact() { - dialog->show(); + FindDialog dialog; - if (dialog->exec() == QDialog::Accepted) { - QString contactName = dialog->getFindText(); + if (dialog.exec() == QDialog::Accepted) { + QString contactName = dialog.findText(); if (contacts.contains(contactName)) { - nameLine->setText(contactName); - addressText->setText(contacts.value(contactName)); + ui->nameLine->setText(contactName); + ui->addressText->setText(contacts.value(contactName)); } else { QMessageBox::information(this, tr("Contact Not Found"), tr("Sorry, \"%1\" is not in your address book.").arg(contactName)); diff --git a/doc/examples/addressbook-sdk/part5/addressbook.h b/doc/examples/addressbook-sdk/part5/addressbook.h index aa70b70f1f9..c0cbf32599a 100644 --- a/doc/examples/addressbook-sdk/part5/addressbook.h +++ b/doc/examples/addressbook-sdk/part5/addressbook.h @@ -2,10 +2,8 @@ #define ADDRESSBOOK_H #include -#include -#include -#include #include +#include //! [include] #include "finddialog.h" //! [include] @@ -38,28 +36,12 @@ public slots: private: Ui::AddressBook *ui; - void updateInterface(Mode mode); - QPushButton *addButton; - QPushButton *submitButton; - QPushButton *cancelButton; - QPushButton *editButton; - QPushButton *removeButton; - QPushButton *nextButton; - QPushButton *previousButton; -//! [private members] - QPushButton *findButton; -//! [private members] - QLineEdit *nameLine; - QTextEdit *addressText; QMap contacts; QString oldName; QString oldAddress; Mode currentMode; -//! [dialog] - FindDialog *dialog; -//! [dialog] }; #endif // ADDRESSBOOK_H diff --git a/doc/examples/addressbook-sdk/part5/finddialog.cpp b/doc/examples/addressbook-sdk/part5/finddialog.cpp index 27914974a19..579a3f36046 100644 --- a/doc/examples/addressbook-sdk/part5/finddialog.cpp +++ b/doc/examples/addressbook-sdk/part5/finddialog.cpp @@ -8,15 +8,8 @@ FindDialog::FindDialog(QWidget *parent) : m_ui(new Ui::FindDialog) { m_ui->setupUi(this); - lineEdit = new QLineEdit; - lineEdit = m_ui->lineEdit; - findButton = new QPushButton; - findButton = m_ui->findButton; - - findText = ""; - - connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked())); + connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked())); setWindowTitle(tr("Find a Contact")); } @@ -30,23 +23,21 @@ FindDialog::~FindDialog() //! [findClicked] void FindDialog::findClicked() { - QString text = lineEdit->text(); + QString text = m_ui->lineEdit->text(); if (text.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name.")); - return; + reject(); } else { - findText = text; - lineEdit->clear(); - hide(); + accept(); } } //! [findClicked] -//! [getFindText] -QString FindDialog::getFindText() +//! [findText] +QString FindDialog::findText() { - return findText; + return m_ui->lineEdit->text(); } -//! [getFindText] +//! [findText] diff --git a/doc/examples/addressbook-sdk/part5/finddialog.h b/doc/examples/addressbook-sdk/part5/finddialog.h index aef5aee9fa3..9912dec8dfc 100644 --- a/doc/examples/addressbook-sdk/part5/finddialog.h +++ b/doc/examples/addressbook-sdk/part5/finddialog.h @@ -14,9 +14,9 @@ class FindDialog : public QDialog { public: FindDialog(QWidget *parent = 0); ~FindDialog(); -//! [getFindText] - QString getFindText(); -//! [getFindText] +//! [findText] + QString findText(); +//! [findText] //! [findClicked] public slots: @@ -26,9 +26,6 @@ public slots: //! [private members] private: Ui::FindDialog *m_ui; - QPushButton *findButton; - QLineEdit *lineEdit; - QString findText; //! [private members] }; diff --git a/doc/examples/addressbook-sdk/part6/addressbook.cpp b/doc/examples/addressbook-sdk/part6/addressbook.cpp index 5748fe377ab..6d8a15bc24d 100644 --- a/doc/examples/addressbook-sdk/part6/addressbook.cpp +++ b/doc/examples/addressbook-sdk/part6/addressbook.cpp @@ -6,69 +6,30 @@ AddressBook::AddressBook(QWidget *parent) { ui->setupUi(this); - nameLine = new QLineEdit; - nameLine = ui->nameLine; - nameLine->setReadOnly(true); + ui->nameLine->setReadOnly(true); + ui->addressText->setReadOnly(true); + ui->submitButton->hide(); + ui->cancelButton->hide(); + ui->nextButton->setEnabled(false); + ui->previousButton->setEnabled(false); + ui->editButton->setEnabled(false); + ui->removeButton->setEnabled(false); - addressText = new QTextEdit; - addressText = ui->addressText; - addressText->setReadOnly(true); - - addButton = new QPushButton; - addButton = ui->addButton; - - submitButton = new QPushButton; - submitButton = ui->submitButton; - submitButton->hide(); - - cancelButton = new QPushButton; - cancelButton = ui->cancelButton; - cancelButton->hide(); - - nextButton = new QPushButton; - nextButton = ui->nextButton; - nextButton->setEnabled(false); - - previousButton = new QPushButton; - previousButton = ui->previousButton; - previousButton->setEnabled(false); - - editButton = new QPushButton; - editButton = ui->editButton; - editButton->setEnabled(false); - - removeButton = new QPushButton; - removeButton = ui->removeButton; - removeButton->setEnabled(false); - - findButton = new QPushButton; - findButton = ui->findButton; - - dialog = new FindDialog; - -//! [private members] - loadButton = new QPushButton; - loadButton = ui->loadButton; - - saveButton = new QPushButton; - saveButton = ui->saveButton; -//! [private members] - - connect(addButton, SIGNAL(clicked()), this, + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addContact())); - connect(submitButton, SIGNAL(clicked()), this, + connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); - connect(cancelButton, SIGNAL(clicked()), this, + connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); - connect(nextButton, SIGNAL(clicked()), this, + connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(next())); - connect(previousButton, SIGNAL(clicked()), this, + connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(previous())); - connect(editButton, SIGNAL(clicked()), this, + connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editContact())); - connect(removeButton, SIGNAL(clicked()), this, + connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); - connect(findButton, SIGNAL(clicked()), this, + connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findContact())); setWindowTitle(tr("Simple Address Book")); @@ -81,23 +42,25 @@ AddressBook::~AddressBook() void AddressBook::addContact() { - oldName = nameLine->text(); - oldAddress = addressText->toPlainText(); + oldName = ui->nameLine->text(); + oldAddress = ui->addressText->toPlainText(); - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); updateInterface(AddingMode); } void AddressBook::submitContact() { - QString name = nameLine->text(); - QString address = addressText->toPlainText(); + QString name = ui->nameLine->text(); + QString address = ui->addressText->toPlainText(); if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); + updateInterface(NavigationMode); + return; } if (currentMode == AddingMode) { @@ -134,15 +97,15 @@ void AddressBook::submitContact() void AddressBook::cancel() { - nameLine->setText(oldName); - nameLine->setReadOnly(true); + ui->nameLine->setText(oldName); + ui->nameLine->setReadOnly(true); updateInterface(NavigationMode); } void AddressBook::next() { - QString name = nameLine->text(); + QString name = ui->nameLine->text(); QMap::iterator i = contacts.find(name); if (i != contacts.end()) @@ -150,18 +113,18 @@ void AddressBook::next() if (i == contacts.end()) i = contacts.begin(); - nameLine->setText(i.key()); - addressText->setText(i.value()); + ui->nameLine->setText(i.key()); + ui->addressText->setText(i.value()); } void AddressBook::previous() { - QString name = nameLine->text(); + QString name = ui->nameLine->text(); QMap::iterator i = contacts.find(name); if (i == contacts.end()) { - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); return; } @@ -169,22 +132,22 @@ void AddressBook::previous() i = contacts.end(); i--; - nameLine->setText(i.key()); - addressText->setText(i.value()); + ui->nameLine->setText(i.key()); + ui->addressText->setText(i.value()); } void AddressBook::editContact() { - oldName = nameLine->text(); - oldAddress = addressText->toPlainText(); + oldName = ui->nameLine->text(); + oldAddress = ui->addressText->toPlainText(); updateInterface(EditingMode); } void AddressBook::removeContact() { - QString name = nameLine->text(); - QString address = addressText->toPlainText(); + QString name = ui->nameLine->text(); + QString address = ui->addressText->toPlainText(); if (contacts.contains(name)) { int button = QMessageBox::question(this, @@ -213,55 +176,55 @@ void AddressBook::updateInterface(Mode mode) case AddingMode: case EditingMode: - nameLine->setReadOnly(false); - nameLine->setFocus(Qt::OtherFocusReason); - addressText->setReadOnly(false); + ui->nameLine->setReadOnly(false); + ui->nameLine->setFocus(Qt::OtherFocusReason); + ui->addressText->setReadOnly(false); - addButton->setEnabled(false); - editButton->setEnabled(false); - removeButton->setEnabled(false); + ui->addButton->setEnabled(false); + ui->editButton->setEnabled(false); + ui->removeButton->setEnabled(false); - nextButton->setEnabled(false); - previousButton->setEnabled(false); + ui->nextButton->setEnabled(false); + ui->previousButton->setEnabled(false); - submitButton->show(); - cancelButton->show(); + ui->submitButton->show(); + ui->cancelButton->show(); break; case NavigationMode: if (contacts.isEmpty()) { - nameLine->clear(); - addressText->clear(); + ui->nameLine->clear(); + ui->addressText->clear(); } - nameLine->setReadOnly(true); - addressText->setReadOnly(true); - addButton->setEnabled(true); + ui->nameLine->setReadOnly(true); + ui->addressText->setReadOnly(true); + ui->addButton->setEnabled(true); int number = contacts.size(); - editButton->setEnabled(number >= 1); - removeButton->setEnabled(number >= 1); - findButton->setEnabled(number > 2); - nextButton->setEnabled(number > 1); - previousButton->setEnabled(number >1); + ui->editButton->setEnabled(number >= 1); + ui->removeButton->setEnabled(number >= 1); + ui->findButton->setEnabled(number > 2); + ui->nextButton->setEnabled(number > 1); + ui->previousButton->setEnabled(number >1); - submitButton->hide(); - cancelButton->hide(); + ui->submitButton->hide(); + ui->cancelButton->hide(); break; } } void AddressBook::findContact() { - dialog->show(); + FindDialog dialog; - if (dialog->exec() == QDialog::Accepted) { - QString contactName = dialog->getFindText(); + if (dialog.exec() == QDialog::Accepted) { + QString contactName = dialog.findText(); if (contacts.contains(contactName)) { - nameLine->setText(contactName); - addressText->setText(contacts.value(contactName)); + ui->nameLine->setText(contactName); + ui->addressText->setText(contacts.value(contactName)); } else { QMessageBox::information(this, tr("Contact Not Found"), tr("Sorry, \"%1\" is not in your address book.").arg(contactName)); @@ -333,8 +296,8 @@ void AddressBook::loadFromFile() tr("The file you are attempting to open contains no contacts.")); } else { QMap::iterator i = contacts.begin(); - nameLine->setText(i.key()); - addressText->setText(i.value()); + ui->nameLine->setText(i.key()); + ui->addressText->setText(i.value()); } } diff --git a/doc/examples/addressbook-sdk/part6/addressbook.h b/doc/examples/addressbook-sdk/part6/addressbook.h index 3ed6231a5d6..2dd06cb9aea 100644 --- a/doc/examples/addressbook-sdk/part6/addressbook.h +++ b/doc/examples/addressbook-sdk/part6/addressbook.h @@ -2,10 +2,8 @@ #define ADDRESSBOOK_H #include -#include -#include -#include #include +#include #include "finddialog.h" namespace Ui @@ -38,22 +36,7 @@ public slots: private: Ui::AddressBook *ui; - void updateInterface(Mode mode); - QPushButton *addButton; - QPushButton *submitButton; - QPushButton *cancelButton; - QPushButton *editButton; - QPushButton *removeButton; - QPushButton *nextButton; - QPushButton *previousButton; - QPushButton *findButton; -//! [private members] - QPushButton *loadButton; - QPushButton *saveButton; -//! [private members] - QLineEdit *nameLine; - QTextEdit *addressText; QMap contacts; QString oldName; diff --git a/doc/examples/addressbook-sdk/part6/finddialog.cpp b/doc/examples/addressbook-sdk/part6/finddialog.cpp index 478ab9e9cd8..0ddbb29a150 100644 --- a/doc/examples/addressbook-sdk/part6/finddialog.cpp +++ b/doc/examples/addressbook-sdk/part6/finddialog.cpp @@ -7,15 +7,8 @@ FindDialog::FindDialog(QWidget *parent) : m_ui(new Ui::FindDialog) { m_ui->setupUi(this); - lineEdit = new QLineEdit; - lineEdit = m_ui->lineEdit; - findButton = new QPushButton; - findButton = m_ui->findButton; - - findText = ""; - - connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked())); + connect(m_ui->findButton, SIGNAL(clicked()), this, SLOT(findClicked())); setWindowTitle(tr("Find a Contact")); } @@ -27,20 +20,18 @@ FindDialog::~FindDialog() void FindDialog::findClicked() { - QString text = lineEdit->text(); + QString text = m_ui->lineEdit->text(); if (text.isEmpty()) { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name.")); - return; + reject(); } else { - findText = text; - lineEdit->clear(); - hide(); + accept(); } } -QString FindDialog::getFindText() +QString FindDialog::findText() { - return findText; + return m_ui->lineEdit->text(); } diff --git a/doc/examples/addressbook-sdk/part6/finddialog.h b/doc/examples/addressbook-sdk/part6/finddialog.h index 95bdaea5061..1166102537c 100644 --- a/doc/examples/addressbook-sdk/part6/finddialog.h +++ b/doc/examples/addressbook-sdk/part6/finddialog.h @@ -14,16 +14,13 @@ class FindDialog : public QDialog { public: FindDialog(QWidget *parent = 0); ~FindDialog(); - QString getFindText(); + QString findText(); public slots: void findClicked(); private: Ui::FindDialog *m_ui; - QPushButton *findButton; - QLineEdit *lineEdit; - QString findText; }; #endif // FINDDIALOG_H diff --git a/share/qtcreator/schemes/MS_Visual_C++.kms b/share/qtcreator/schemes/MS_Visual_C++.kms index fb549aa23fa..87c6bbe39eb 100644 --- a/share/qtcreator/schemes/MS_Visual_C++.kms +++ b/share/qtcreator/schemes/MS_Visual_C++.kms @@ -264,7 +264,7 @@ - + diff --git a/share/qtcreator/schemes/Xcode.kms b/share/qtcreator/schemes/Xcode.kms index 644fb98f77d..4ab3a8a5507 100644 --- a/share/qtcreator/schemes/Xcode.kms +++ b/share/qtcreator/schemes/Xcode.kms @@ -150,7 +150,7 @@ - + diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 59e3222badd..fe68964b631 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -138,6 +138,11 @@ void PathChooser::addButton(const QString &text, QObject *receiver, const char * m_d->m_hLayout->addWidget(button); } +QAbstractButton *PathChooser::buttonAtIndex(int index) const +{ + return findChildren().at(index); +} + QString PathChooser::path() const { return m_d->m_lineEdit->text(); diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index 7222dc3aedb..984b7db8371 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -33,6 +33,7 @@ #include "utils_global.h" #include +#include namespace Core { namespace Utils { @@ -91,6 +92,7 @@ public: static QString homePath(); void addButton(const QString &text, QObject *receiver, const char *slotFunc); + QAbstractButton *buttonAtIndex(int index) const; private: // Returns overridden title or the one from diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index adccb2f9d05..69da9ef1329 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -39,10 +39,22 @@ #include <QtGui/QWheelEvent> #include <QtGui/QApplication> #include <QtGui/QClipboard> -#include <QtCore/QDebug> +#include <QtCore/QByteArrayMatcher> using namespace BINEditor; +// QByteArray::toLower() is broken, it stops at the first \0 +static void lower(QByteArray &ba) +{ + char *data = ba.data(); + char *end = data + ba.size(); + while (data != end) { + if (*data >= 0x41 && *data <= 0x5A) + *data += 0x20; + ++data; + } +} + static QByteArray calculateHexPattern(const QByteArray &pattern) { QByteArray result; @@ -65,13 +77,17 @@ BinEditor::BinEditor(QWidget *parent) : QAbstractScrollArea(parent) { m_ieditor = 0; + m_inLazyMode = false; + m_blockSize = 4096; init(); m_unmodifiedState = 0; + m_readOnly = false; m_hexCursor = true; m_cursorPosition = 0; m_anchorPosition = 0; m_lowNibble = false; m_cursorVisible = false; + m_caseSensitiveSearch = false; setFocusPolicy(Qt::WheelFocus); m_addressString = QString(9, QLatin1Char(':')); } @@ -89,7 +105,7 @@ void BinEditor::init() m_lineHeight = fm.lineSpacing(); m_charWidth = fm.width(QChar(QLatin1Char('M'))); m_columnWidth = 2 * m_charWidth + fm.width(QChar(QLatin1Char(' '))); - m_numLines = m_data.size() / 16 + 1; + m_numLines = m_size / 16 + 1; m_numVisibleLines = viewport()->height() / m_lineHeight; m_textWidth = 16 * m_charWidth + m_charWidth; int m_numberWidth = fm.width(QChar(QLatin1Char('9'))); @@ -114,6 +130,84 @@ void BinEditor::init() } +void BinEditor::addLazyData(int block, const QByteArray &data) +{ + Q_ASSERT(m_inLazyMode); + Q_ASSERT(data.size() == m_blockSize); + m_lazyData.insert(block, data); + m_lazyRequests.remove(block); + viewport()->update(); +} + +bool BinEditor::requestDataAt(int pos, bool synchronous) const +{ + if (!m_inLazyMode) + return true; + + int block = pos / m_blockSize; + QMap<int, QByteArray>::const_iterator it = m_lazyData.find(block); + if (it == m_lazyData.end()) { + if (!m_lazyRequests.contains(block)) { + m_lazyRequests.insert(block); + emit const_cast<BinEditor*>(this)->lazyDataRequested(block, synchronous); + if (!m_lazyRequests.contains(block)) + return true; // synchronous data source + } + return false; + } + + return true; +} + +char BinEditor::dataAt(int pos) const +{ + if (!m_inLazyMode) + return m_data.at(pos); + + int block = pos / m_blockSize; + return m_lazyData.value(block, m_emptyBlock).at(pos - (block*m_blockSize)); + +} + +void BinEditor::changeDataAt(int pos, char c) +{ + if (!m_inLazyMode) { + m_data[pos] = c; + return; + } + int block = pos / m_blockSize; + if (m_lazyData.contains(block)) + m_lazyData[block][pos - (block*m_blockSize)] = c; +} + +QByteArray BinEditor::dataMid(int from, int length) const +{ + if (!m_inLazyMode) + return m_data.mid(from, length); + + int end = from + length; + int block = from / m_blockSize; + + QByteArray data; + do { + data += m_lazyData.value(block++, m_emptyBlock); + } while (block * m_blockSize < end); + + return data.mid(from - ((from / m_blockSize) * m_blockSize), length); +} + +QByteArray BinEditor::blockData(int block) const +{ + if (!m_inLazyMode) { + QByteArray data = m_data.mid(block * m_blockSize, m_blockSize); + if (data.size() < m_blockSize) + data.resize(m_blockSize); + return data; + } + return m_lazyData.value(block, m_emptyBlock); +} + + void BinEditor::setFontSettings(const TextEditor::FontSettings &fs) { setFont(fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_TEXT)).font()); @@ -188,15 +282,33 @@ bool BinEditor::isModified() const return (m_undoStack.size() != m_unmodifiedState); } +void BinEditor::setReadOnly(bool readOnly) +{ + m_readOnly = readOnly; +} + +bool BinEditor::isReadOnly() const +{ + return m_readOnly; +} + void BinEditor::setData(const QByteArray &data) { + m_inLazyMode = false; + m_lazyData.clear(); + m_lazyRequests.clear(); m_data = data; + m_size = data.size(); + m_unmodifiedState = 0; m_undoStack.clear(); m_redoStack.clear(); - init(); - emit cursorPositionChanged(m_cursorPosition); + init(); + m_cursorPosition = 0; + verticalScrollBar()->setValue(0); + + emit cursorPositionChanged(m_cursorPosition); viewport()->update(); } @@ -205,6 +317,44 @@ QByteArray BinEditor::data() const return m_data; } +bool BinEditor::applyModifications(QByteArray &data) const +{ + if (!m_inLazyMode) { + data = m_data; + return true; + } + if (data.size() != m_size) + return false; + for (QMap<int,QByteArray>::const_iterator it = m_lazyData.begin(); it != m_lazyData.end(); ++it) { + ::memcpy(data.data() + it.key() * m_blockSize, it->constData(), m_blockSize); + } + return true; +} + +void BinEditor::setLazyData(int cursorPosition, int size, int blockSize) +{ + m_inLazyMode = true; + m_blockSize = blockSize; + Q_ASSERT((blockSize/16) * 16 == blockSize); + m_emptyBlock = QByteArray(blockSize, '\0'); + m_data.clear(); + m_lazyData.clear(); + m_lazyRequests.clear(); + m_size = size; + + m_unmodifiedState = 0; + m_undoStack.clear(); + m_redoStack.clear(); + + init(); + + m_cursorPosition = cursorPosition; + verticalScrollBar()->setValue(m_cursorPosition / 16); + + emit cursorPositionChanged(m_cursorPosition); + viewport()->update(); +} + void BinEditor::resizeEvent(QResizeEvent *) { init(); @@ -269,9 +419,9 @@ int BinEditor::posAt(const QPoint &pos) const x -= 16 * m_columnWidth + m_charWidth; for (column = 0; column < 15; ++column) { int pos = (topLine + line) * 16 + column; - if (pos < 0 || pos >= m_data.size()) + if (pos < 0 || pos >= m_size) break; - QChar qc(QLatin1Char(m_data.at(pos))); + QChar qc(QLatin1Char(dataAt(pos))); if (!qc.isPrint()) qc = 0xB7; x -= fontMetrics().width(qc); @@ -280,7 +430,7 @@ int BinEditor::posAt(const QPoint &pos) const } } - return (qMin(m_data.size(), qMin(m_numLines, topLine + line) * 16) + column); + return (qMin(m_size, qMin(m_numLines, topLine + line) * 16) + column); } bool BinEditor::inTextArea(const QPoint &pos) const @@ -306,35 +456,118 @@ void BinEditor::updateLines(int fromPosition, int toPosition) viewport()->update(0, y, viewport()->width(), h); } -int BinEditor::find(const QByteArray &pattern, int from, QTextDocument::FindFlags findFlags) +int BinEditor::dataIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const { - if (pattern.isEmpty()) - return false; + if (!m_inLazyMode && caseSensitive) { + return m_data.indexOf(pattern, from); + } + + int trailing = pattern.size(); + if (trailing > m_blockSize) + return -1; + + QByteArray buffer; + buffer.resize(m_blockSize + trailing); + char *b = buffer.data(); + QByteArrayMatcher matcher(pattern); + + int block = from / m_blockSize; + + while (from < m_size) { + if (!requestDataAt(block * m_blockSize, true)) + return -1; + QByteArray data = blockData(block); + ::memcpy(b, b + m_blockSize, trailing); + ::memcpy(b + trailing, data.constData(), m_blockSize); + + if (!caseSensitive) + ::lower(buffer); + + int pos = matcher.indexIn(buffer, from - (block * m_blockSize) + trailing); + if (pos >= 0) + return pos + block * m_blockSize - trailing; + ++block; + from = block * m_blockSize - trailing; + } + return -1; +} + +int BinEditor::dataLastIndexOf(const QByteArray &pattern, int from, bool caseSensitive) const +{ + if (!m_inLazyMode && caseSensitive) + return m_data.lastIndexOf(pattern, from); + + int trailing = pattern.size(); + if (trailing > m_blockSize) + return -1; + + QByteArray buffer; + buffer.resize(m_blockSize + trailing); + char *b = buffer.data(); + + int block = from / m_blockSize; + + while (from > 0) { + if (!requestDataAt(block * m_blockSize, true)) + return -1; + QByteArray data = blockData(block); + ::memcpy(b + m_blockSize, b, trailing); + ::memcpy(b, data.constData(), m_blockSize); + + if (!caseSensitive) + ::lower(buffer); + + int pos = buffer.lastIndexOf(pattern, from - (block * m_blockSize)); + if (pos >= 0) + return pos + block * m_blockSize; + --block; + from = block * m_blockSize + (m_blockSize-1) + trailing; + } + return -1; +} + + +int BinEditor::find(const QByteArray &pattern_arg, int from, QTextDocument::FindFlags findFlags) +{ + if (pattern_arg.isEmpty()) + return 0; + + QByteArray pattern = pattern_arg; + + bool caseSensitiveSearch = (findFlags & QTextDocument::FindCaseSensitively); + + if (!caseSensitiveSearch) + ::lower(pattern); + bool backwards = (findFlags & QTextDocument::FindBackward); - int found = backwards ? m_data.lastIndexOf(pattern, from) - : m_data.indexOf(pattern, from); + int found = backwards ? dataLastIndexOf(pattern, from, caseSensitiveSearch) + : dataIndexOf(pattern, from, caseSensitiveSearch); + int foundHex = -1; - QByteArray hexPattern = calculateHexPattern(pattern); + QByteArray hexPattern = calculateHexPattern(pattern_arg); if (!hexPattern.isEmpty()) { - foundHex = backwards ? m_data.lastIndexOf(hexPattern, from) - : m_data.indexOf(hexPattern, from); + foundHex = backwards ? dataLastIndexOf(hexPattern, from) + : dataIndexOf(hexPattern, from); } int pos = (found >= 0 && (foundHex < 0 || found < foundHex)) ? found : foundHex; + + if (pos >= m_size) + pos = -1; + if (pos >= 0) { setCursorPosition(pos); setCursorPosition(pos + (found == pos ? pattern.size() : hexPattern.size()), KeepAnchor); } - return pos; } -int BinEditor::findPattern(const QByteArray &data, int from, int offset, int *match) +int BinEditor::findPattern(const QByteArray &data, const QByteArray &dataHex, int from, int offset, int *match) { if (m_searchPattern.isEmpty()) return -1; int normal = m_searchPattern.isEmpty()? -1 : data.indexOf(m_searchPattern, from - offset); - int hex = m_searchPatternHex.isEmpty()? -1 : data.indexOf(m_searchPatternHex, from - offset); + int hex = m_searchPatternHex.isEmpty()? -1 : dataHex.indexOf(m_searchPatternHex, from - offset); if (normal >= 0 && (hex < 0 || normal < hex)) { if (match) @@ -398,17 +631,22 @@ void BinEditor::paintEvent(QPaintEvent *e) int matchLength = 0; - QByteArray patternData; + QByteArray patternData, patternDataHex; int patternOffset = qMax(0, topLine*16 - m_searchPattern.size()); - if (!m_searchPattern.isEmpty()) - patternData = m_data.mid(patternOffset, m_numVisibleLines * 16); + if (!m_searchPattern.isEmpty()) { + patternData = dataMid(patternOffset, m_numVisibleLines * 16 + (topLine*16 - patternOffset)); + patternDataHex = patternData; + if (!m_caseSensitiveSearch) + ::lower(patternData); + } - int foundPatternAt = findPattern(patternData, patternOffset, patternOffset, &matchLength); + + int foundPatternAt = findPattern(patternData, patternDataHex, patternOffset, patternOffset, &matchLength); int selStart = qMin(m_cursorPosition, m_anchorPosition); int selEnd = qMax(m_cursorPosition, m_anchorPosition); - QString itemString(QLatin1String("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")); + QString itemString(16*3, QLatin1Char(' ')); QChar *itemStringData = itemString.data(); const char *hex = "0123456789abcdef"; @@ -426,16 +664,27 @@ void BinEditor::paintEvent(QPaintEvent *e) painter.drawText(-xoffset, i * m_lineHeight + m_ascent, addressString(((uint) line) * 16)); - QString printable; + int cursor = -1; - for (int c = 0; c < 16; ++c) { - int pos = line * 16 + c; - if (pos >= m_data.size()) - break; - QChar qc(QLatin1Char(m_data.at(pos))); - if (qc.unicode() >= 127 || !qc.isPrint()) - qc = 0xB7; - printable += qc; + if (line * 16 <= m_cursorPosition && m_cursorPosition < line * 16 + 16) + cursor = m_cursorPosition - line * 16; + + bool hasData = requestDataAt(line * 16); + + QString printable; + + if (hasData) { + for (int c = 0; c < 16; ++c) { + int pos = line * 16 + c; + if (pos >= m_size) + break; + QChar qc(QLatin1Char(dataAt(pos))); + if (qc.unicode() >= 127 || !qc.isPrint()) + qc = 0xB7; + printable += qc; + } + } else { + printable = QString(16, QLatin1Char(' ')); } QRect selectionRect; @@ -443,47 +692,45 @@ void BinEditor::paintEvent(QPaintEvent *e) bool isFullySelected = (selStart < selEnd && selStart <= line*16 && (line+1)*16 <= selEnd); - for (int c = 0; c < 16; ++c) { - int pos = line * 16 + c; - if (pos >= m_data.size()) { - while (c < 16) { - itemStringData[c*3] = itemStringData[c*3+1] = ' '; - ++c; + if (hasData) { + for (int c = 0; c < 16; ++c) { + int pos = line * 16 + c; + if (pos >= m_size) { + while (c < 16) { + itemStringData[c*3] = itemStringData[c*3+1] = ' '; + ++c; + } + break; + } + + if (foundPatternAt >= 0 && pos >= foundPatternAt + matchLength) + foundPatternAt = findPattern(patternData, patternDataHex, foundPatternAt + matchLength, patternOffset, &matchLength); + + + uchar value = (uchar)dataAt(pos); + itemStringData[c*3] = hex[value >> 4]; + itemStringData[c*3+1] = hex[value & 0xf]; + + int item_x = -xoffset + m_margin + c * m_columnWidth + m_labelWidth; + + if (foundPatternAt >= 0 && pos >= foundPatternAt && pos < foundPatternAt + matchLength) { + painter.fillRect(item_x, y-m_ascent, m_columnWidth, m_lineHeight, QColor(0xffef0b)); + int printable_item_x = -xoffset + m_margin + m_labelWidth + 16 * m_columnWidth + m_charWidth + + painter.fontMetrics().width( printable.left(c)); + painter.fillRect(printable_item_x, y-m_ascent, + painter.fontMetrics().width(printable.at(c)), + m_lineHeight, QColor(0xffef0b)); + } + + if (selStart < selEnd && !isFullySelected && pos >= selStart && pos < selEnd) { + selectionRect |= QRect(item_x, y-m_ascent, m_columnWidth, m_lineHeight); + int printable_item_x = -xoffset + m_margin + m_labelWidth + 16 * m_columnWidth + m_charWidth + + painter.fontMetrics().width( printable.left(c)); + printableSelectionRect |= QRect(printable_item_x, y-m_ascent, + painter.fontMetrics().width(printable.at(c)), + m_lineHeight); } - break; } - - if (foundPatternAt >= 0 && pos >= foundPatternAt + matchLength) - foundPatternAt = findPattern(patternData, foundPatternAt + matchLength, patternOffset, &matchLength); - - - uchar value = (uchar)m_data.at(pos); - itemStringData[c*3] = hex[value >> 4]; - itemStringData[c*3+1] = hex[value & 0xf]; - - int item_x = -xoffset + m_margin + c * m_columnWidth + m_labelWidth; - - if (foundPatternAt >= 0 && pos >= foundPatternAt && pos < foundPatternAt + matchLength) { - painter.fillRect(item_x, y-m_ascent, m_columnWidth, m_lineHeight, QColor(0xffef0b)); - int printable_item_x = -xoffset + m_margin + m_labelWidth + 16 * m_columnWidth + m_charWidth - + painter.fontMetrics().width( printable.left(c)); - painter.fillRect(printable_item_x, y-m_ascent, - painter.fontMetrics().width(printable.at(c)), - m_lineHeight, QColor(0xffef0b)); - } - - if (selStart < selEnd && !isFullySelected && pos >= selStart && pos < selEnd) { - selectionRect |= QRect(item_x, y-m_ascent, m_columnWidth, m_lineHeight); - int printable_item_x = -xoffset + m_margin + m_labelWidth + 16 * m_columnWidth + m_charWidth - + painter.fontMetrics().width( printable.left(c)); - printableSelectionRect |= QRect(printable_item_x, y-m_ascent, - painter.fontMetrics().width(printable.at(c)), - m_lineHeight); - } - - if (pos == m_cursorPosition) - cursor = c; - } int x = -xoffset + m_margin + m_labelWidth; @@ -575,7 +822,7 @@ int BinEditor::cursorPosition() const void BinEditor::setCursorPosition(int pos, MoveMode moveMode) { - pos = qMin(m_data.size()-1, qMax(0, pos)); + pos = qMin(m_size-1, qMax(0, pos)); if (pos == m_cursorPosition && (m_anchorPosition == m_cursorPosition || moveMode == KeepAnchor) && !m_lowNibble) @@ -654,7 +901,7 @@ void BinEditor::mouseReleaseEvent(QMouseEvent *) void BinEditor::selectAll() { setCursorPosition(0); - setCursorPosition(m_data.size()-1, KeepAnchor); + setCursorPosition(m_size-1, KeepAnchor); } void BinEditor::clear() @@ -728,10 +975,13 @@ void BinEditor::keyPressEvent(QKeyEvent *e) break; case Qt::Key_End: setCursorPosition((e->modifiers() & Qt::ControlModifier) ? - (m_data.size()-1) : (m_cursorPosition/16 * 16 + 15), moveMode); + (m_size-1) : (m_cursorPosition/16 * 16 + 15), moveMode); break; - default: { + default: + if (m_readOnly) + break; + { QString text = e->text(); for (int i = 0; i < text.length(); ++i) { QChar c = text.at(i); @@ -745,11 +995,11 @@ void BinEditor::keyPressEvent(QKeyEvent *e) if (nibble < 0) continue; if (m_lowNibble) { - changeData(m_cursorPosition, nibble + (m_data[m_cursorPosition] & 0xf0)); + changeData(m_cursorPosition, nibble + (dataAt(m_cursorPosition) & 0xf0)); m_lowNibble = false; setCursorPosition(m_cursorPosition + 1); } else { - changeData(m_cursorPosition, (nibble << 4) + (m_data[m_cursorPosition] & 0x0f), true); + changeData(m_cursorPosition, (nibble << 4) + (dataAt(m_cursorPosition) & 0x0f), true); m_lowNibble = true; updateLines(); } @@ -787,14 +1037,17 @@ void BinEditor::copy() int selStart = qMin(m_cursorPosition, m_anchorPosition); int selEnd = qMax(m_cursorPosition, m_anchorPosition); if (selStart < selEnd) - QApplication::clipboard()->setText(QString::fromLatin1(m_data.mid(selStart, selEnd - selStart))); + QApplication::clipboard()->setText(QString::fromLatin1(dataMid(selStart, selEnd - selStart))); } -void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags /*findFlags*/) +void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags findFlags) { if (m_searchPattern == pattern) return; m_searchPattern = pattern; + m_caseSensitiveSearch = (findFlags & QTextDocument::FindCaseSensitively); + if (!m_caseSensitiveSearch) + ::lower(m_searchPattern); m_searchPatternHex = calculateHexPattern(pattern); viewport()->update(); } @@ -802,12 +1055,14 @@ void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument: void BinEditor::changeData(int position, uchar character, bool highNibble) { + if (!requestDataAt(position)) + return; m_redoStack.clear(); if (m_unmodifiedState > m_undoStack.size()) m_unmodifiedState = -1; BinEditorEditCommand cmd; cmd.position = position; - cmd.character = (uchar) m_data[position]; + cmd.character = (uchar) dataAt(position); cmd.highNibble = highNibble; if (!highNibble && !m_undoStack.isEmpty() && m_undoStack.top().position == position && m_undoStack.top().highNibble) { @@ -816,7 +1071,7 @@ void BinEditor::changeData(int position, uchar character, bool highNibble) m_undoStack.pop(); } - m_data[position] = (char) character; + changeDataAt(position, (char) character); bool emitModificationChanged = (m_undoStack.size() == m_unmodifiedState); m_undoStack.push(cmd); if (emitModificationChanged) { @@ -835,8 +1090,8 @@ void BinEditor::undo() bool emitModificationChanged = (m_undoStack.size() == m_unmodifiedState); BinEditorEditCommand cmd = m_undoStack.pop(); emitModificationChanged |= (m_undoStack.size() == m_unmodifiedState); - uchar c = m_data[cmd.position]; - m_data[cmd.position] = (char)cmd.character; + uchar c = dataAt(cmd.position); + changeDataAt(cmd.position, (char)cmd.character); cmd.character = c; m_redoStack.push(cmd); setCursorPosition(cmd.position); @@ -853,8 +1108,8 @@ void BinEditor::redo() if (m_redoStack.isEmpty()) return; BinEditorEditCommand cmd = m_redoStack.pop(); - uchar c = m_data[cmd.position]; - m_data[cmd.position] = (char)cmd.character; + uchar c = dataAt(cmd.position); + changeDataAt(cmd.position, (char)cmd.character); cmd.character = c; bool emitModificationChanged = (m_undoStack.size() == m_unmodifiedState); m_undoStack.push(cmd); diff --git a/src/plugins/bineditor/bineditor.h b/src/plugins/bineditor/bineditor.h index 64955804137..3349ad3e04c 100644 --- a/src/plugins/bineditor/bineditor.h +++ b/src/plugins/bineditor/bineditor.h @@ -33,6 +33,7 @@ #include <QtGui/qabstractscrollarea.h> #include <QtCore/qbasictimer.h> #include <QtCore/qstack.h> +#include <QtCore/qset.h> #include <QtGui/qtextdocument.h> #include <QtGui/qtextformat.h> @@ -50,6 +51,7 @@ class BinEditor : public QAbstractScrollArea { Q_OBJECT Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false) + Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false) public: BinEditor(QWidget *parent = 0); @@ -58,6 +60,14 @@ public: void setData(const QByteArray &data); QByteArray data() const; + inline int dataSize() const { return m_size; } + + inline bool inLazyMode() const { return m_inLazyMode; } + void setLazyData(int cursorPosition, int size, int blockSize = 4096); + inline int lazyDataBlockSize() const { return m_blockSize; } + void addLazyData(int block, const QByteArray &data); + bool applyModifications(QByteArray &data) const; + void zoomIn(int range = 1); void zoomOut(int range = 1); @@ -72,6 +82,9 @@ public: void setModified(bool); bool isModified() const; + void setReadOnly(bool); + bool isReadOnly() const; + int find(const QByteArray &pattern, int from = 0, QTextDocument::FindFlags findFlags = 0); void selectAll(); @@ -107,6 +120,8 @@ Q_SIGNALS: void copyAvailable(bool); void cursorPositionChanged(int position); + void lazyDataRequested(int block, bool syncronous); + protected: void scrollContentsBy(int dx, int dy); void paintEvent(QPaintEvent *e); @@ -122,8 +137,26 @@ protected: void timerEvent(QTimerEvent *); private: + bool m_inLazyMode; QByteArray m_data; + QMap <int, QByteArray> m_lazyData; + int m_blockSize; + mutable QSet<int> m_lazyRequests; + QByteArray m_emptyBlock; + QByteArray m_lowerBlock; + int m_size; + + int dataIndexOf(const QByteArray &pattern, int from, bool caseSensitive = true) const; + int dataLastIndexOf(const QByteArray &pattern, int from, bool caseSensitive = true) const; + + bool requestDataAt(int pos, bool synchronous = false) const; + char dataAt(int pos) const; + void changeDataAt(int pos, char c); + QByteArray dataMid(int from, int length) const; + QByteArray blockData(int block) const; + int m_unmodifiedState; + int m_readOnly; int m_margin; int m_descent; int m_ascent; @@ -145,6 +178,7 @@ private: QByteArray m_searchPattern; QByteArray m_searchPatternHex; + bool m_caseSensitiveSearch; QBasicTimer m_cursorBlinkTimer; @@ -158,7 +192,7 @@ private: void changeData(int position, uchar character, bool highNibble = false); - int findPattern(const QByteArray &data, int from, int offset, int *match); + int findPattern(const QByteArray &data, const QByteArray &dataHex, int from, int offset, int *match); void drawItems(QPainter *painter, int x, int y, const QString &itemString); struct BinEditorEditCommand { diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 4f854b71381..0daa6e32b67 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -33,6 +33,7 @@ #include <QtCore/QFile> #include <QtCore/QFileInfo> +#include <QtCore/QDebug> #include <QtGui/QMenu> #include <QtGui/QAction> #include <QtGui/QMainWindow> @@ -84,7 +85,7 @@ public: int found = m_editor->find(pattern, pos, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags)); if (found < 0) found = m_editor->find(pattern, - (findFlags & Find::IFindSupport::FindBackward)?m_editor->data().size()-1:0, + (findFlags & Find::IFindSupport::FindBackward)?m_editor->dataSize()-1:0, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags)); return found; } @@ -136,6 +137,7 @@ public: m_mimeType(QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE)) { m_editor = parent; + connect(m_editor, SIGNAL(lazyDataRequested(int, bool)), this, SLOT(provideData(int))); } ~BinEditorFile() {} @@ -143,8 +145,21 @@ public: bool save(const QString &fileName = QString()) { QFile file(fileName); + + QByteArray data; + if (m_editor->inLazyMode()) { + QFile read(m_fileName); + if (!read.open(QIODevice::ReadOnly)) + return false; + data = read.readAll(); + read.close(); + if (!m_editor->applyModifications(data)) + return false; + } else { + data = m_editor->data(); + } if (file.open(QIODevice::WriteOnly)) { - file.write(m_editor->data()); + file.write(data); file.close(); m_editor->setModified(false); m_editor->editorInterface()->setDisplayName(QFileInfo(fileName).fileName()); @@ -159,14 +174,32 @@ public: QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { m_fileName = fileName; - m_editor->setData(file.readAll()); - m_editor->editorInterface()->setDisplayName(QFileInfo(fileName).fileName()); + if (file.isSequential()) { + m_editor->setData(file.readAll()); + } else { + m_editor->setLazyData(0, file.size()); + m_editor->editorInterface()->setDisplayName(QFileInfo(fileName).fileName()); + } file.close(); return true; } return false; } +private slots: + void provideData(int block) { + QFile file(m_fileName); + if (file.open(QIODevice::ReadOnly)) { + int blockSize = m_editor->lazyDataBlockSize(); + file.seek(block * blockSize); + QByteArray data = file.read(blockSize); + if (data.size() != blockSize) + data.resize(blockSize); + m_editor->addLazyData(block, data); + file.close(); + } + } +public: void setFilename(const QString &filename) { m_fileName = filename; diff --git a/src/plugins/coreplugin/core.qrc b/src/plugins/coreplugin/core.qrc index 202ee41db42..42f59f6c1e1 100644 --- a/src/plugins/coreplugin/core.qrc +++ b/src/plugins/coreplugin/core.qrc @@ -44,24 +44,5 @@ <file>images/unlocked.png</file> <file>images/extension.png</file> <file>images/darkclosebutton.png</file> - <file>images/welcomemode/btn_26.png</file> - <file>images/welcomemode/btn_26_hover.png</file> - <file>images/welcomemode/btn_27.png</file> - <file>images/welcomemode/btn_27_hover.png</file> - <file>images/welcomemode/feedback_arrow.png</file> - <file>images/welcomemode/feedback_arrow_hover.png</file> - <file>images/welcomemode/feedback-bar-background.png</file> - <file>images/welcomemode/list_bullet_arrow.png</file> - <file>images/welcomemode/mode_project.png</file> - <file>images/welcomemode/nokia_logo.png</file> - <file>images/welcomemode/product_logo.png</file> - <file>images/welcomemode/qt_logo.png</file> - <file>images/welcomemode/rc_combined.png</file> - <file>images/welcomemode/background_center_frame.png</file> - <file>images/welcomemode/center_frame_header.png</file> - <file>images/welcomemode/btn_26_pressed.png</file> - <file>images/welcomemode/combobox_arrow.png</file> - <file>images/welcomemode/arrow-left.png</file> - <file>images/welcomemode/arrow-right.png</file> </qresource> </RCC> diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index a7a619b7689..7fb7d71c240 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -28,7 +28,6 @@ **************************************************************************/ #include "coreplugin.h" -#include "welcomemode.h" #include "editmode.h" #include "editormanager.h" #include "mainwindow.h" @@ -42,16 +41,12 @@ using namespace Core::Internal; CorePlugin::CorePlugin() : - m_mainWindow(new MainWindow), m_welcomeMode(0), m_editMode(0) + m_mainWindow(new MainWindow), m_editMode(0) { } CorePlugin::~CorePlugin() { - if (m_welcomeMode) { - removeObject(m_welcomeMode); - delete m_welcomeMode; - } if (m_editMode) { removeObject(m_editMode); delete m_editMode; @@ -68,9 +63,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) Q_UNUSED(arguments) const bool success = m_mainWindow->init(errorMessage); if (success) { - m_welcomeMode = new WelcomeMode; - addObject(m_welcomeMode); - EditorManager *editorManager = m_mainWindow->editorManager(); m_editMode = new EditMode(editorManager); addObject(m_editMode); @@ -80,7 +72,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) void CorePlugin::extensionsInitialized() { - m_mainWindow->modeManager()->activateMode(m_welcomeMode->uniqueModeName()); m_mainWindow->extensionsInitialized(); } diff --git a/src/plugins/coreplugin/coreplugin.h b/src/plugins/coreplugin/coreplugin.h index 4580dd6fd0e..04e5be49b47 100644 --- a/src/plugins/coreplugin/coreplugin.h +++ b/src/plugins/coreplugin/coreplugin.h @@ -32,10 +32,13 @@ #include <extensionsystem/iplugin.h> +namespace Core { + class IMode; +} + namespace Core { namespace Internal { -class WelcomeMode; class EditMode; class MainWindow; @@ -56,7 +59,7 @@ public slots: private: MainWindow *m_mainWindow; - WelcomeMode *m_welcomeMode; + Core::IMode *m_welcomeMode; EditMode *m_editMode; }; diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index fbe1d6cc642..8bdc845c48f 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -20,8 +20,6 @@ DEPENDPATH += dialogs \ editormanager \ scriptmanager SOURCES += mainwindow.cpp \ - welcomemode.cpp \ - rssfetcher.cpp \ editmode.cpp \ tabpositionindicator.cpp \ fancyactionbar.cpp \ @@ -81,9 +79,6 @@ SOURCES += mainwindow.cpp \ dialogs/iwizard.cpp \ settingsdatabase.cpp HEADERS += mainwindow.h \ - welcomemode.h \ - welcomemode_p.h \ - rssfetcher.h \ editmode.h \ tabpositionindicator.h \ fancyactionbar.h \ @@ -166,8 +161,7 @@ FORMS += dialogs/newdialog.ui \ dialogs/saveitemsdialog.ui \ dialogs/openwithdialog.ui \ editormanager/openeditorsview.ui \ - generalsettings.ui \ - welcomemode.ui + generalsettings.ui RESOURCES += core.qrc \ fancyactionbar.qrc diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp index e99bc204699..03c1663c8b8 100644 --- a/src/plugins/coreplugin/editmode.cpp +++ b/src/plugins/coreplugin/editmode.cpp @@ -56,7 +56,6 @@ EditMode::EditMode(EditorManager *editorManager) : QWidget *rightSplitWidget = new QWidget; rightSplitWidget->setLayout(m_rightSplitWidgetLayout); m_rightSplitWidgetLayout->insertWidget(0, new Core::EditorManagerPlaceHolder(this)); - m_rightSplitWidgetLayout->addWidget(new Core::FindToolBarPlaceHolder(this)); MiniSplitter *rightPaneSplitter = new MiniSplitter; rightPaneSplitter->insertWidget(0, rightSplitWidget); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index c5a211c6ef5..55d98f395e4 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -35,6 +35,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/actionmanager/actionmanager.h> +#include <coreplugin/findplaceholder.h> #include <utils/qtcassert.h> #include <utils/styledbar.h> @@ -176,6 +177,8 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) : tl->addWidget(m_container); + tl->addWidget(new FindToolBarPlaceHolder(this)); + { m_statusHLine->setFrameStyle(QFrame::HLine); diff --git a/src/plugins/coreplugin/findplaceholder.cpp b/src/plugins/coreplugin/findplaceholder.cpp index 3036c94167c..0bd5895baa6 100644 --- a/src/plugins/coreplugin/findplaceholder.cpp +++ b/src/plugins/coreplugin/findplaceholder.cpp @@ -30,6 +30,8 @@ #include "findplaceholder.h" #include "modemanager.h" +#include <extensionsystem/pluginmanager.h> + #include <QtGui/QVBoxLayout> @@ -37,29 +39,48 @@ using namespace Core; FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0; -FindToolBarPlaceHolder::FindToolBarPlaceHolder(Core::IMode *mode, QWidget *parent) - : QWidget(parent), m_mode(mode) +FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) + : QWidget(parent), m_owner(owner), m_subWidget(0) { setLayout(new QVBoxLayout); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); layout()->setMargin(0); - connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode *)), - this, SLOT(currentModeChanged(Core::IMode *))); + ExtensionSystem::PluginManager::instance()->addObject(this); } FindToolBarPlaceHolder::~FindToolBarPlaceHolder() { -} - -void FindToolBarPlaceHolder::currentModeChanged(Core::IMode *mode) -{ + ExtensionSystem::PluginManager::instance()->removeObject(this); + if (m_subWidget) { + m_subWidget->setVisible(false); + m_subWidget->setParent(0); + } if (m_current == this) m_current = 0; - if (m_mode == mode) - m_current = this; +} + +QWidget *FindToolBarPlaceHolder::owner() const +{ + return m_owner; +} + +void FindToolBarPlaceHolder::setWidget(QWidget *widget) +{ + if (m_subWidget) { + m_subWidget->setVisible(false); + m_subWidget->setParent(0); + } + m_subWidget = widget; + if (m_subWidget) + layout()->addWidget(m_subWidget); } FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent() { return m_current; } + +void FindToolBarPlaceHolder::setCurrent(FindToolBarPlaceHolder *placeHolder) +{ + m_current = placeHolder; +} diff --git a/src/plugins/coreplugin/findplaceholder.h b/src/plugins/coreplugin/findplaceholder.h index 1c46d3d33a9..c6f815476d7 100644 --- a/src/plugins/coreplugin/findplaceholder.h +++ b/src/plugins/coreplugin/findplaceholder.h @@ -31,6 +31,8 @@ #define FINDPLACEHOLDER_H #include "core_global.h" + +#include <QtCore/QPointer> #include <QtGui/QWidget> namespace Core { @@ -41,14 +43,17 @@ class CORE_EXPORT FindToolBarPlaceHolder : public QWidget { Q_OBJECT public: - FindToolBarPlaceHolder(Core::IMode *mode, QWidget *parent = 0); + FindToolBarPlaceHolder(QWidget *owner, QWidget *parent = 0); ~FindToolBarPlaceHolder(); + QWidget *owner() const; + void setWidget(QWidget *widget); static FindToolBarPlaceHolder *getCurrent(); -private slots: - void currentModeChanged(Core::IMode *); + static void setCurrent(FindToolBarPlaceHolder *placeHolder); + private: - Core::IMode *m_mode; + QWidget *m_owner; + QPointer<QWidget> m_subWidget; static FindToolBarPlaceHolder *m_current; }; diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h index b5baf944d7e..b4a22775a9d 100644 --- a/src/plugins/coreplugin/iversioncontrol.h +++ b/src/plugins/coreplugin/iversioncontrol.h @@ -48,46 +48,66 @@ public: virtual QString name() const = 0; - // Enable the VCS, that is, make its menu actions visible. virtual bool isEnabled() const = 0; + + /*! + * Enable the VCS, that is, make its menu actions visible. + */ virtual void setEnabled(bool enabled) = 0; - // Returns whether files in this directory should be managed with this - // version control. + /*! + * Returns whether files in this directory should be managed with this + * version control. + */ virtual bool managesDirectory(const QString &filename) const = 0; - // This function should return the topmost directory, for which this - // IVersionControl should be used. The VCSManager assumes that all files - // in the returned directory are managed by the same IVersionControl - // Note that this is used as an optimization, so that the VCSManager - // doesn't need to call managesDirectory(..) for each directory - // This function is called after finding out that the directory is managed - // by a specific version control. + /*! + * This function should return the topmost directory, for which this + * IVersionControl should be used. The VCSManager assumes that all files in + * the returned directory are managed by the same IVersionControl. + * + * Note that this is used as an optimization, so that the VCSManager + * doesn't need to call managesDirectory(..) for each directory. + * + * This function is called after finding out that the directory is managed + * by a specific version control. + */ virtual QString findTopLevelForDirectory(const QString &directory) const = 0; - // Called to query whether a VCS supports the respective operations. + /*! + * Called to query whether a VCS supports the respective operations. + */ virtual bool supportsOperation(Operation operation) const = 0; - // Called prior to save, if the file is read only. Should be implemented - // if the scc requires a operation before editing the file, e.g. 'p4 edit' - // Note: The EditorManager calls this for the editors. + /*! + * Called prior to save, if the file is read only. Should be implemented if + * the scc requires a operation before editing the file, e.g. 'p4 edit' + * + * \note The EditorManager calls this for the editors. + */ virtual bool vcsOpen(const QString &fileName) = 0; - // Called after a file has been added to a project If the version control - // needs to know which files it needs to track you should reimplement this - // function, e.g. 'p4 add', 'cvs add', 'svn add'. - // Note: This function should be called from IProject subclasses after - // files are added to the project + /*! + * Called after a file has been added to a project If the version control + * needs to know which files it needs to track you should reimplement this + * function, e.g. 'p4 add', 'cvs add', 'svn add'. + * + * \note This function should be called from IProject subclasses after + * files are added to the project. + */ virtual bool vcsAdd(const QString &filename) = 0; - // Called after a file has been removed from the project (if the user - // wants), e.g. 'p4 delete', 'svn delete'. - // You probably want to call VcsManager::showDeleteDialog, which asks the - // user to confirm the deletion + /*! + * Called after a file has been removed from the project (if the user + * wants), e.g. 'p4 delete', 'svn delete'. + * + * You probably want to call VcsManager::showDeleteDialog, which asks the + * user to confirm the deletion. + */ virtual bool vcsDelete(const QString &filename) = 0; // TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g - // virtual bool sccManaged(const QStryng &filename) = 0; + // virtual bool sccManaged(const QString &filename) = 0; }; } // namespace Core diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index be678e721c5..2d11cefe95d 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -303,7 +303,6 @@ bool MainWindow::init(QString *errorMessage) oph->setCloseable(false); outputModeWidget->layout()->addWidget(oph); oph->setVisible(true); // since the output pane placeholder is invisible at startup by default (which makes sense in most cases) - outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode)); outputModeWidget->setFocusProxy(oph); connect(m_modeManager, SIGNAL(currentModeChanged(Core::IMode*)), @@ -558,14 +557,14 @@ void MainWindow::registerDefaultActions() connect(m_focusToEditor, SIGNAL(activated()), this, SLOT(setFocusToEditor())); // New File Action - m_newAction = new QAction(QIcon(Constants::ICON_NEWFILE), tr("&New File/Project..."), this); + m_newAction = new QAction(QIcon(Constants::ICON_NEWFILE), tr("&New File or Project..."), this); cmd = am->registerAction(m_newAction, Constants::NEW, m_globalContext); cmd->setDefaultKeySequence(QKeySequence::New); mfile->addAction(cmd, Constants::G_FILE_NEW); connect(m_newAction, SIGNAL(triggered()), this, SLOT(newFile())); // Open Action - m_openAction = new QAction(QIcon(Constants::ICON_OPENFILE), tr("&Open File/Project..."), this); + m_openAction = new QAction(QIcon(Constants::ICON_OPENFILE), tr("&Open File or Project..."), this); cmd = am->registerAction(m_openAction, Constants::OPEN, m_globalContext); cmd->setDefaultKeySequence(QKeySequence::Open); mfile->addAction(cmd, Constants::G_FILE_OPEN); diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp index 7033ffd6857..228c653919d 100644 --- a/src/plugins/coreplugin/outputpane.cpp +++ b/src/plugins/coreplugin/outputpane.cpp @@ -37,6 +37,7 @@ #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/findplaceholder.h> #include <extensionsystem/pluginmanager.h> @@ -205,6 +206,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) : toolLayout->addWidget(m_closeButton); mainlayout->addWidget(m_toolBar); mainlayout->addWidget(m_outputWidgetPane, 10); + mainlayout->addWidget(new Core::FindToolBarPlaceHolder(this)); setLayout(mainlayout); m_buttonsWidget = new QWidget; diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index ff9975e013f..e7216e13ee3 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -1384,7 +1384,8 @@ void CPPEditor::mouseMoveEvent(QMouseEvent *e) void CPPEditor::mouseReleaseEvent(QMouseEvent *e) { - if (e->modifiers() & Qt::ControlModifier && !(e->modifiers() & Qt::ShiftModifier) + if (m_mouseNavigationEnabled && e->modifiers() & Qt::ControlModifier + && !(e->modifiers() & Qt::ShiftModifier) && e->button() == Qt::LeftButton) { const QTextCursor cursor = cursorForPosition(e->pos()); diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp index 5c8a6ec2b2c..51d1ecdf9ce 100644 --- a/src/plugins/cppeditor/cpphoverhandler.cpp +++ b/src/plugins/cppeditor/cpphoverhandler.cpp @@ -284,9 +284,13 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in TypeOfExpression typeOfExpression; typeOfExpression.setSnapshot(documents); + // We only want to show F1 if the tooltip matches the help id + bool showF1 = true; + foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) { if (m.line() == lineNumber) { m_toolTip = m.text(); + showF1 = false; break; } } @@ -295,12 +299,13 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in foreach (const Document::Include &incl, doc->includes()) { if (incl.line() == lineNumber) { m_toolTip = QDir::toNativeSeparators(incl.fileName()); + m_helpId = QFileInfo(incl.fileName()).fileName(); break; } } } - if (m_toolTip.isEmpty()) { + if (m_helpId.isEmpty()) { // Move to the end of a qualified name bool stop = false; while (!stop) { @@ -314,7 +319,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in } } - // Fetch the expression's code. + // Fetch the expression's code ExpressionUnderCursor expressionUnderCursor; const QString expression = expressionUnderCursor(tc); @@ -334,25 +339,27 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in m_helpId = buildHelpId(resolvedSymbol, resolvedName); - Symbol *symbol = result.second; - if (resolvedSymbol) - symbol = resolvedSymbol; + if (m_toolTip.isEmpty()) { + Symbol *symbol = result.second; + if (resolvedSymbol) + symbol = resolvedSymbol; - Overview overview; - overview.setShowArgumentNames(true); - overview.setShowReturnTypes(true); - overview.setShowFullyQualifiedNamed(true); + Overview overview; + overview.setShowArgumentNames(true); + overview.setShowReturnTypes(true); + overview.setShowFullyQualifiedNamed(true); - if (lookupSymbol && (lookupSymbol->isDeclaration() || lookupSymbol->isArgument())) { - m_toolTip = overview.prettyType(firstType, buildHelpId(lookupSymbol, lookupSymbol->name())); + if (lookupSymbol && (lookupSymbol->isDeclaration() || lookupSymbol->isArgument())) { + m_toolTip = overview.prettyType(firstType, buildHelpId(lookupSymbol, lookupSymbol->name())); - } else if (firstType->isClassType() || firstType->isEnumType() || - firstType->isForwardClassDeclarationType()) { - m_toolTip = m_helpId; + } else if (firstType->isClassType() || firstType->isEnumType() || + firstType->isForwardClassDeclarationType()) { + m_toolTip = m_helpId; - } else { - m_toolTip = overview.prettyType(firstType, m_helpId); + } else { + m_toolTip = overview.prettyType(firstType, m_helpId); + } } } } @@ -378,9 +385,11 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in m_toolTip = Qt::escape(m_toolTip); if (!m_helpId.isEmpty() && !m_helpEngine->linksForIdentifier(m_helpId).isEmpty()) { - m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>" - "<td><img src=\":/cppeditor/images/f1.svg\"></td></tr></table>")) - .arg(m_toolTip); + if (showF1) { + m_toolTip = QString(QLatin1String("<table><tr><td valign=middle><nobr>%1</td>" + "<td><img src=\":/cppeditor/images/f1.svg\"></td></tr></table>")) + .arg(m_toolTip); + } editor->setContextHelpId(m_helpId); } else if (!m_toolTip.isEmpty()) { m_toolTip = QString(QLatin1String("<nobr>%1")).arg(m_toolTip); diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index b1ee04b131e..b5cc600ffa1 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -49,6 +49,7 @@ #include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditorplugin.h> #include <texteditor/texteditorsettings.h> +#include <texteditor/texteditorconstants.h> #include <cpptools/cpptoolsconstants.h> #include <QtCore/QFileInfo> @@ -216,6 +217,15 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); + m_actionHandler->initializeActions(); + + cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION); + am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd); + + cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); + am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd); + + readSettings(); return true; } diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp index 4be55bd840b..9c6e915a3b6 100644 --- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp @@ -32,6 +32,8 @@ #include <coreplugin/editormanager/editormanager.h> #include <cplusplus/CppDocument.h> +#include <QtCore/QStringMatcher> + using namespace CppTools::Internal; using namespace CPlusPlus; diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp index 9f026c6b397..fe45a913398 100644 --- a/src/plugins/cpptools/cppquickopenfilter.cpp +++ b/src/plugins/cpptools/cppquickopenfilter.cpp @@ -35,6 +35,8 @@ #include <texteditor/itexteditor.h> #include <texteditor/basetexteditor.h> +#include <QtCore/QStringMatcher> + using namespace CppTools::Internal; CppQuickOpenFilter::CppQuickOpenFilter(CppModelManager *manager, Core::EditorManager *editorManager) diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp index 837747e85d1..a0cdcf531bb 100644 --- a/src/plugins/debugger/debuggeroutputwindow.cpp +++ b/src/plugins/debugger/debuggeroutputwindow.cpp @@ -48,6 +48,7 @@ #ifndef GDBDEBUGGERLEAN #include <aggregation/aggregate.h> +#include <coreplugin/findplaceholder.h> #include <find/basetextfind.h> using namespace Find; @@ -309,9 +310,13 @@ DebuggerOutputWindow::DebuggerOutputWindow(QWidget *parent) m_splitter->addWidget(m_inputText); m_splitter->addWidget(m_combinedText); - QGridLayout *layout = new QGridLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); + layout->setSpacing(0); layout->addWidget(m_splitter); +#ifndef GDBDEBUGGERLEAN + layout->addWidget(new Core::FindToolBarPlaceHolder(this)); +#endif setLayout(layout); #ifndef GDBDEBUGGERLEAN diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 33c204355b1..6319f1f648e 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -798,11 +798,11 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess QBoxLayout *editorHolderLayout = new QVBoxLayout; editorHolderLayout->setMargin(0); editorHolderLayout->setSpacing(0); - editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_debugMode)); - editorHolderLayout->addWidget(new FindToolBarPlaceHolder(m_debugMode)); QWidget *editorAndFindWidget = new QWidget; editorAndFindWidget->setLayout(editorHolderLayout); + editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_debugMode)); + editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget)); MiniSplitter *rightPaneSplitter = new MiniSplitter; rightPaneSplitter->addWidget(editorAndFindWidget); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c6611fb4841..08d502f986b 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1310,7 +1310,23 @@ void GdbEngine::handleExecRun(const GdbResultRecord &response, const QVariant &) { if (response.resultClass == GdbResultRunning) { qq->notifyInferiorRunning(); - } else if (response.resultClass == GdbResultError) { + } else { + QTC_ASSERT(response.resultClass == GdbResultError, /**/); + const QByteArray &msg = response.data.findChild("msg").data(); + QMessageBox::critical(q->mainWindow(), tr("Error"), + tr("Starting executable failed:\n") + QString::fromLocal8Bit(msg)); + QTC_ASSERT(q->status() == DebuggerInferiorRunning, /**/); + //interruptInferior(); + qq->notifyInferiorExited(); + } +} + +void GdbEngine::handleExecContinue(const GdbResultRecord &response, const QVariant &) +{ + if (response.resultClass == GdbResultRunning) { + qq->notifyInferiorRunning(); + } else { + QTC_ASSERT(response.resultClass == GdbResultError, /**/); const QByteArray &msg = response.data.findChild("msg").data(); if (msg == "Cannot find bounds of current function") { qq->notifyInferiorStopped(); @@ -1623,7 +1639,7 @@ bool GdbEngine::startDebugger(const QSharedPointer<DebuggerStartParameters> &sp) postCommand(_("tbreak main")); m_waitingForFirstBreakpointToBeHit = true; qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-run")); + postCommand(_("-exec-run"), CB(handleExecRun)); #endif qq->breakHandler()->setAllPending(); } @@ -1636,7 +1652,7 @@ void GdbEngine::continueInferior() q->resetLocation(); setTokenBarrier(); qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-continue"), CB(handleExecRun)); + postCommand(_("-exec-continue"), CB(handleExecContinue)); } void GdbEngine::handleStart(const GdbResultRecord &response, const QVariant &) @@ -1655,7 +1671,7 @@ void GdbEngine::handleStart(const GdbResultRecord &response, const QVariant &) postCommand(_("tbreak *") + needle.cap(1)); m_waitingForFirstBreakpointToBeHit = true; qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-run")); + postCommand(_("-exec-run"), CB(handleExecRun)); } else { debugMessage(_("PARSING START ADDRESS FAILED: ") + msg); } @@ -1717,7 +1733,7 @@ void GdbEngine::handleSetTargetAsync(const GdbResultRecord &record, const QVaria void GdbEngine::handleTargetRemote(const GdbResultRecord &record, const QVariant &) { if (record.resultClass == GdbResultDone) { - //postCommand(_("-exec-continue"), CB(handleExecRun)); + //postCommand(_("-exec-continue"), CB(handleExecContinue)); handleAqcuiredInferior(); m_autoContinue = true; } else if (record.resultClass == GdbResultError) { @@ -1740,9 +1756,9 @@ void GdbEngine::stepExec() setTokenBarrier(); qq->notifyInferiorRunningRequested(); if (qq->isReverseDebugging()) - postCommand(_("reverse-step"), CB(handleExecRun)); + postCommand(_("reverse-step"), CB(handleExecContinue)); else - postCommand(_("-exec-step"), CB(handleExecRun)); + postCommand(_("-exec-step"), CB(handleExecContinue)); } void GdbEngine::stepIExec() @@ -1750,16 +1766,16 @@ void GdbEngine::stepIExec() setTokenBarrier(); qq->notifyInferiorRunningRequested(); if (qq->isReverseDebugging()) - postCommand(_("reverse-stepi"), CB(handleExecRun)); + postCommand(_("reverse-stepi"), CB(handleExecContinue)); else - postCommand(_("-exec-step-instruction"), CB(handleExecRun)); + postCommand(_("-exec-step-instruction"), CB(handleExecContinue)); } void GdbEngine::stepOutExec() { setTokenBarrier(); qq->notifyInferiorRunningRequested(); - postCommand(_("-exec-finish"), CB(handleExecRun)); + postCommand(_("-exec-finish"), CB(handleExecContinue)); } void GdbEngine::nextExec() @@ -1767,9 +1783,9 @@ void GdbEngine::nextExec() setTokenBarrier(); qq->notifyInferiorRunningRequested(); if (qq->isReverseDebugging()) - postCommand(_("reverse-next"), CB(handleExecRun)); + postCommand(_("reverse-next"), CB(handleExecContinue)); else - postCommand(_("-exec-next"), CB(handleExecRun)); + postCommand(_("-exec-next"), CB(handleExecContinue)); } void GdbEngine::nextIExec() @@ -1777,9 +1793,9 @@ void GdbEngine::nextIExec() setTokenBarrier(); qq->notifyInferiorRunningRequested(); if (qq->isReverseDebugging()) - postCommand(_("reverse-nexti"), CB(handleExecRun)); + postCommand(_("reverse-nexti"), CB(handleExecContinue)); else - postCommand(_("exec-next-instruction"), CB(handleExecRun)); + postCommand(_("exec-next-instruction"), CB(handleExecContinue)); } void GdbEngine::runToLineExec(const QString &fileName, int lineNumber) diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 41137705879..c8ff6a6698d 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -210,6 +210,7 @@ private: void handleAsyncOutput(const GdbMi &data); void handleResultRecord(const GdbResultRecord &response); void handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &); + void handleExecContinue(const GdbResultRecord &response, const QVariant &); void handleExecRun(const GdbResultRecord &response, const QVariant &); void handleExecJumpToLine(const GdbResultRecord &response, const QVariant &); void handleExecRunToFunction(const GdbResultRecord &response, const QVariant &); diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/find/currentdocumentfind.cpp index 1fc029a1d96..f2eb129452d 100644 --- a/src/plugins/find/currentdocumentfind.cpp +++ b/src/plugins/find/currentdocumentfind.cpp @@ -45,7 +45,7 @@ CurrentDocumentFind::CurrentDocumentFind() : m_currentFind(0) { connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), - this, SLOT(updateCurrentFindFilter(QWidget*,QWidget*))); + this, SLOT(updateCandidateFindFilter(QWidget*,QWidget*))); } void CurrentDocumentFind::removeConnections() @@ -71,6 +71,11 @@ bool CurrentDocumentFind::isEnabled() const return m_currentFind && (!m_currentWidget || m_currentWidget->isVisible()); } +bool CurrentDocumentFind::candidateIsEnabled() const +{ + return (m_candidateFind != 0); +} + bool CurrentDocumentFind::supportsReplace() const { QTC_ASSERT(m_currentFind, return false); @@ -139,7 +144,7 @@ void CurrentDocumentFind::clearFindScope() m_currentFind->clearFindScope(); } -void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now) +void CurrentDocumentFind::updateCandidateFindFilter(QWidget *old, QWidget *now) { Q_UNUSED(old) QWidget *candidate = now; @@ -149,13 +154,20 @@ void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now) if (!impl) candidate = candidate->parentWidget(); } - if (!impl || impl == m_currentFind) + m_candidateWidget = candidate; + m_candidateFind = impl; + emit candidateChanged(); +} + +void CurrentDocumentFind::acceptCandidate() +{ + if (!m_candidateFind || m_candidateFind == m_currentFind) return; removeFindSupportConnections(); if (m_currentFind) m_currentFind->highlightAll(QString(), 0); - m_currentWidget = candidate; - m_currentFind = impl; + m_currentWidget = m_candidateWidget; + m_currentFind = m_candidateFind; if (m_currentFind) { connect(m_currentFind, SIGNAL(changed()), this, SIGNAL(changed())); connect(m_currentFind, SIGNAL(destroyed(QObject*)), SLOT(findSupportDestroyed())); diff --git a/src/plugins/find/currentdocumentfind.h b/src/plugins/find/currentdocumentfind.h index eb8bdf38e0c..82f6da9b0c8 100644 --- a/src/plugins/find/currentdocumentfind.h +++ b/src/plugins/find/currentdocumentfind.h @@ -53,6 +53,7 @@ public: QString completedFindString() const; bool isEnabled() const; + bool candidateIsEnabled() const; void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags); bool findIncremental(const QString &txt, IFindSupport::FindFlags findFlags); bool findStep(const QString &txt, IFindSupport::FindFlags findFlags); @@ -62,6 +63,7 @@ public: IFindSupport::FindFlags findFlags); void defineFindScope(); void clearFindScope(); + void acceptCandidate(); void removeConnections(); bool setFocusToCurrentFindSupport(); @@ -70,9 +72,10 @@ public: signals: void changed(); + void candidateChanged(); private slots: - void updateCurrentFindFilter(QWidget *old, QWidget *now); + void updateCandidateFindFilter(QWidget *old, QWidget *now); void findSupportDestroyed(); private: @@ -80,6 +83,8 @@ private: QPointer<IFindSupport> m_currentFind; QPointer<QWidget> m_currentWidget; + QPointer<IFindSupport> m_candidateFind; + QPointer<QWidget> m_candidateWidget; }; } // namespace Internal diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp index 72bd60e0f35..d3574569d73 100644 --- a/src/plugins/find/findplugin.cpp +++ b/src/plugins/find/findplugin.cpp @@ -107,6 +107,7 @@ void FindPlugin::extensionsInitialized() void FindPlugin::shutdown() { + m_findToolBar->setVisible(false); m_findToolBar->setParent(0); m_currentDocumentFind->removeConnections(); writeSettings(); diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 2e8df6b263c..4c855ae2a76 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -32,7 +32,6 @@ #include "textfindconstants.h" #include <coreplugin/coreconstants.h> -#include <coreplugin/findplaceholder.h> #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> @@ -213,8 +212,9 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen connect(m_regularExpressionAction, SIGNAL(triggered(bool)), this, SLOT(setRegularExpressions(bool))); lineEditMenu->addAction(m_regularExpressionAction); - connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions())); - updateActions(); + connect(m_currentDocumentFind, SIGNAL(candidateChanged()), this, SLOT(adaptToCandidate())); + connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateToolBar())); + updateToolBar(); } FindToolBar::~FindToolBar() @@ -264,11 +264,23 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event) return Core::Utils::StyledBar::eventFilter(obj, event); } -void FindToolBar::updateActions() +void FindToolBar::adaptToCandidate() +{ + updateFindAction(); + if (findToolBarPlaceHolder() == Core::FindToolBarPlaceHolder::getCurrent()) { + m_currentDocumentFind->acceptCandidate(); + } +} + +void FindToolBar::updateFindAction() +{ + m_findInDocumentAction->setEnabled(m_currentDocumentFind->candidateIsEnabled()); +} + +void FindToolBar::updateToolBar() { bool enabled = m_currentDocumentFind->isEnabled(); bool replaceEnabled = enabled && m_currentDocumentFind->supportsReplace(); - m_findInDocumentAction->setEnabled(enabled); m_findNextAction->setEnabled(enabled); m_findPreviousAction->setEnabled(enabled); @@ -507,19 +519,37 @@ void FindToolBar::hideAndResetFocus() hide(); } +Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const +{ + QList<Core::FindToolBarPlaceHolder*> placeholders = ExtensionSystem::PluginManager::instance() + ->getObjects<Core::FindToolBarPlaceHolder>(); + QWidget *candidate = QApplication::focusWidget(); + while (candidate) { + foreach (Core::FindToolBarPlaceHolder *ph, placeholders) { + if (ph->owner() == candidate) + return ph; + } + candidate = candidate->parentWidget(); + } + return 0; +} + void FindToolBar::openFind() { - if (!m_currentDocumentFind->isEnabled()) + if (!m_currentDocumentFind->candidateIsEnabled()) return; - Core::FindToolBarPlaceHolder *holder = Core::FindToolBarPlaceHolder::getCurrent(); - QLayout *findContainerLayout = holder ? holder->layout() : 0; - - if (findContainerLayout) { - findContainerLayout->addWidget(this); - holder->setVisible(true); - setVisible(true); - setFocus(); - } + Core::FindToolBarPlaceHolder *holder = findToolBarPlaceHolder(); + if (!holder) + return; + Core::FindToolBarPlaceHolder *previousHolder = Core::FindToolBarPlaceHolder::getCurrent(); + if (previousHolder) + previousHolder->setWidget(0); + Core::FindToolBarPlaceHolder::setCurrent(holder); + m_currentDocumentFind->acceptCandidate(); + holder->setWidget(this); + holder->setVisible(true); + setVisible(true); + setFocus(); QString text = m_currentDocumentFind->currentFindString(); if (!text.isEmpty()) setFindText(text); @@ -528,7 +558,6 @@ void FindToolBar::openFind() selectFindText(); } - bool FindToolBar::focusNextPrevChild(bool next) { // close tab order change diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h index 8985b3419c3..8922cc49250 100644 --- a/src/plugins/find/findtoolbar.h +++ b/src/plugins/find/findtoolbar.h @@ -34,6 +34,7 @@ #include "ifindfilter.h" #include "currentdocumentfind.h" +#include <coreplugin/findplaceholder.h> #include <utils/styledbar.h> #include <QtGui/QStringListModel> @@ -74,13 +75,16 @@ private slots: void hideAndResetFocus(); void openFind(); - void updateActions(); + void updateFindAction(); + void updateToolBar(); void findFlagsChanged(); void setCaseSensitive(bool sensitive); void setWholeWord(bool wholeOnly); void setRegularExpressions(bool regexp); + void adaptToCandidate(); + protected: bool focusNextPrevChild(bool next); @@ -90,6 +94,7 @@ private: void setFindFlag(IFindSupport::FindFlag flag, bool enabled); bool hasFindFlag(IFindSupport::FindFlag flag); IFindSupport::FindFlags effectiveFindFlags(); + Core::FindToolBarPlaceHolder *findToolBarPlaceHolder() const; bool eventFilter(QObject *obj, QEvent *event); void setFindText(const QString &text); diff --git a/src/plugins/find/findwidget.ui b/src/plugins/find/findwidget.ui index 8fb5973c130..08abeb8efc7 100644 --- a/src/plugins/find/findwidget.ui +++ b/src/plugins/find/findwidget.ui @@ -24,7 +24,7 @@ <number>0</number> </property> <property name="bottomMargin"> - <number>1</number> + <number>2</number> </property> <property name="horizontalSpacing"> <number>5</number> @@ -78,7 +78,7 @@ <property name="sizeHint" stdset="0"> <size> <width>40</width> - <height>20</height> + <height>0</height> </size> </property> </spacer> diff --git a/src/plugins/help/Help.pluginspec b/src/plugins/help/Help.pluginspec index 29f1b469610..d7ccc070fdc 100644 --- a/src/plugins/help/Help.pluginspec +++ b/src/plugins/help/Help.pluginspec @@ -22,5 +22,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> <dependency name="Core" version="1.2.80"/> <dependency name="Find" version="1.2.80"/> <dependency name="QuickOpen" version="1.2.80"/> + <dependency name="Welcome" version="1.2.80"/> </dependencyList> </plugin> diff --git a/src/plugins/help/help.pro b/src/plugins/help/help.pro index b733a1fa70d..1f5ec5585ea 100644 --- a/src/plugins/help/help.pro +++ b/src/plugins/help/help.pro @@ -4,6 +4,7 @@ include(../../qtcreatorplugin.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/find/find.pri) include(../../plugins/quickopen/quickopen.pri) +include(../../plugins/welcome/welcome.pri) QT += network CONFIG += help DEFINES += QT_CLUCENE_SUPPORT \ diff --git a/src/plugins/help/helpmode.cpp b/src/plugins/help/helpmode.cpp index d7a806cc620..f6fcfc3c56b 100644 --- a/src/plugins/help/helpmode.cpp +++ b/src/plugins/help/helpmode.cpp @@ -46,7 +46,7 @@ HelpMode::HelpMode(QWidget *widget, QWidget *centralWidget, QObject *parent) setPriority(Constants::P_MODE_HELP); setWidget(widget); m_centralWidget->layout()->setSpacing(0); - m_centralWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(this)); + m_centralWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_centralWidget)); } diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index c48c7fe02c2..f6e8db8fb33 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -43,17 +43,19 @@ #include "searchwidget.h" #include <extensionsystem/pluginmanager.h> -#include <coreplugin/icore.h> -#include <coreplugin/coreconstants.h> -#include <coreplugin/modemanager.h> -#include <coreplugin/uniqueidmanager.h> + #include <coreplugin/actionmanager/actionmanager.h> +#include <coreplugin/coreconstants.h> +#include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/findplaceholder.h> +#include <coreplugin/icore.h> #include <coreplugin/minisplitter.h> #include <coreplugin/modemanager.h> #include <coreplugin/rightpane.h> #include <coreplugin/sidebar.h> -#include <coreplugin/welcomemode.h> -#include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/uniqueidmanager.h> + +#include <welcome/welcomemode.h> #include <texteditor/texteditorconstants.h> @@ -463,16 +465,21 @@ void HelpPlugin::createRightPaneSideBar() w->setLayout(hboxLayout); connect(closeButton, SIGNAL(clicked()), this, SLOT(slotHideRightPane())); + m_rightPaneSideBar = new QWidget; QVBoxLayout *rightPaneLayout = new QVBoxLayout; rightPaneLayout->setMargin(0); rightPaneLayout->setSpacing(0); - rightPaneLayout->addWidget(w); + m_rightPaneSideBar->setLayout(rightPaneLayout); + m_rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); + addAutoReleasedObject(new Core::BaseRightPaneWidget(m_rightPaneSideBar)); + rightPaneLayout->addWidget(w); m_helpViewerForSideBar = new HelpViewer(m_helpEngine, 0); Aggregation::Aggregate *agg = new Aggregation::Aggregate(); agg->add(m_helpViewerForSideBar); agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar)); rightPaneLayout->addWidget(m_helpViewerForSideBar); + rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(m_rightPaneSideBar)); #if defined(QT_NO_WEBKIT) QFont font = m_helpViewerForSideBar->font(); font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("font"), @@ -494,11 +501,6 @@ void HelpPlugin::createRightPaneSideBar() connect(copyActionSideBar, SIGNAL(triggered()), this, SLOT(copyFromSideBar())); copyActionSideBar->setText(cmd->action()->text()); copyActionSideBar->setIcon(cmd->action()->icon()); - - m_rightPaneSideBar = new QWidget; - m_rightPaneSideBar->setLayout(rightPaneLayout); - m_rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); - addAutoReleasedObject(new Core::BaseRightPaneWidget(m_rightPaneSideBar)); } void HelpPlugin::copyFromSideBar() @@ -610,8 +612,8 @@ void HelpPlugin::extensionsInitialized() using namespace Core::Internal; using namespace Core::Constants; - WelcomeMode *welcomeMode = - qobject_cast<WelcomeMode*>(m_core->modeManager()->mode(MODE_WELCOME)); + Welcome::WelcomeMode *welcomeMode = + qobject_cast<Welcome::WelcomeMode*>(m_core->modeManager()->mode(MODE_WELCOME)); if (welcomeMode) { connect(welcomeMode, SIGNAL(openHelpPage(QString)), this, SLOT(openHelpPage(QString))); diff --git a/src/plugins/help/searchwidget.cpp b/src/plugins/help/searchwidget.cpp index 7d8a4feb9ae..3058cd877ab 100644 --- a/src/plugins/help/searchwidget.cpp +++ b/src/plugins/help/searchwidget.cpp @@ -52,6 +52,7 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) , searchEngine(engine) { QVBoxLayout *vLayout = new QVBoxLayout(this); + vLayout->setMargin(4); resultWidget = searchEngine->resultWidget(); QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget(); @@ -76,7 +77,6 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) SearchWidget::~SearchWidget() { - // nothing todo } void SearchWidget::zoomIn() diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 4ee15490856..6ef52c1591c 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -4,6 +4,7 @@ TEMPLATE = subdirs SUBDIRS = plugin_coreplugin \ + plugin_welcome \ plugin_find \ plugin_texteditor \ plugin_cppeditor \ @@ -30,13 +31,16 @@ SUBDIRS = plugin_coreplugin \ plugin_fakevim \ plugin_designer \ plugin_resourceeditor \ - plugin_genericprojectmanager \ + plugin_genericprojectmanager \ plugin_duieditor \ plugin_qmlprojectmanager \ debugger/dumper.pro plugin_coreplugin.subdir = coreplugin +plugin_welcome.subdir = welcome +plugin_welcome.depends = plugin_coreplugin + plugin_find.subdir = find plugin_find.depends += plugin_coreplugin @@ -90,6 +94,7 @@ plugin_projectexplorer.depends = plugin_quickopen plugin_projectexplorer.depends += plugin_find plugin_projectexplorer.depends += plugin_coreplugin plugin_projectexplorer.depends += plugin_texteditor +plugin_projectexplorer.depends += plugin_welcome plugin_qt4projectmanager.subdir = qt4projectmanager plugin_qt4projectmanager.depends = plugin_texteditor @@ -98,6 +103,7 @@ plugin_qt4projectmanager.depends += plugin_cpptools plugin_qt4projectmanager.depends += plugin_cppeditor plugin_qt4projectmanager.depends += plugin_help plugin_qt4projectmanager.depends += plugin_designer +plugin_qt4projectmanager.depends += plugin_welcome plugin_quickopen.subdir = quickopen plugin_quickopen.depends = plugin_coreplugin @@ -138,6 +144,7 @@ plugin_help.subdir = help plugin_help.depends = plugin_find plugin_help.depends += plugin_quickopen plugin_help.depends += plugin_coreplugin +plugin_help.depends += plugin_welcome plugin_resourceeditor.subdir = resourceeditor plugin_resourceeditor.depends = plugin_coreplugin diff --git a/src/plugins/projectexplorer/ProjectExplorer.pluginspec b/src/plugins/projectexplorer/ProjectExplorer.pluginspec index 8b5a7c317a7..6a66cfe1b88 100644 --- a/src/plugins/projectexplorer/ProjectExplorer.pluginspec +++ b/src/plugins/projectexplorer/ProjectExplorer.pluginspec @@ -23,5 +23,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> <dependency name="Find" version="1.2.80"/> <dependency name="QuickOpen" version="1.2.80"/> <dependency name="TextEditor" version="1.2.80"/> + <dependency name="Welcome" version="1.2.80"/> </dependencyList> </plugin> diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index b38baf82902..8a48225d515 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -139,6 +139,7 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) : m_project(project) { QVBoxLayout *vbox = new QVBoxLayout(this); + vbox->setContentsMargins(0, -1, 0, -1); QHBoxLayout *hbox = new QHBoxLayout(); hbox->addWidget(new QLabel(tr("Build Configuration:"), this)); m_buildConfigurationComboBox = new QComboBox(this); diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index 04f29eae7ea..cc82be902ff 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -126,6 +126,7 @@ void BuildStepsPage::updateBuildStepWidget(QTreeWidgetItem *newItem, QTreeWidget if (newItem) { int row = m_ui->buildSettingsList->indexOfTopLevelItem(newItem); m_ui->buildSettingsWidget->setCurrentIndex(row); + m_ui->groupBox->setTitle(newItem->text(0)); BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(m_ui->buildSettingsWidget->currentWidget()); Q_ASSERT(widget); widget->init(m_configuration); diff --git a/src/plugins/projectexplorer/buildstepspage.ui b/src/plugins/projectexplorer/buildstepspage.ui index 52a667f6b88..47b33c068cc 100644 --- a/src/plugins/projectexplorer/buildstepspage.ui +++ b/src/plugins/projectexplorer/buildstepspage.ui @@ -10,130 +10,140 @@ <height>300</height> </rect> </property> - <layout class="QGridLayout" name="gridLayout"> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="verticalSpacing"> + <number>-1</number> + </property> <item row="0" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QTreeWidget" name="buildSettingsList"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>150</width> - <height>16777215</height> - </size> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="uniformRowHeights"> - <bool>true</bool> - </property> - <property name="headerHidden"> - <bool>true</bool> - </property> - <column> - <property name="text"> - <string>1</string> - </property> - </column> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>-1</number> - </property> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="buildStepAddButton"> - <property name="text"> - <string>+</string> - </property> - <property name="popupMode"> - <enum>QToolButton::InstantPopup</enum> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buildStepRemoveToolButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>-</string> - </property> - <property name="popupMode"> - <enum>QToolButton::DelayedPopup</enum> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buildStepUpToolButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>^</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="buildStepDownToolButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>v</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> + <widget class="QTreeWidget" name="buildSettingsList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>150</width> + <height>16777215</height> + </size> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="headerHidden"> + <bool>true</bool> + </property> + <column> + <property name="text"> + <string>1</string> + </property> + </column> + </widget> </item> - <item row="0" column="1" rowspan="2"> - <widget class="QStackedWidget" name="buildSettingsWidget"> + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>10</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="currentIndex"> - <number>0</number> + <property name="title"> + <string>GroupBox</string> </property> - <widget class="QWidget" name="page_2"/> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QStackedWidget" name="buildSettingsWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>10</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="page_2"/> + </widget> + </item> + </layout> </widget> </item> <item row="1" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>-1</number> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>47</height> - </size> - </property> - </spacer> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="buildStepAddButton"> + <property name="text"> + <string>+</string> + </property> + <property name="popupMode"> + <enum>QToolButton::InstantPopup</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buildStepRemoveToolButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>-</string> + </property> + <property name="popupMode"> + <enum>QToolButton::DelayedPopup</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buildStepUpToolButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>^</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="buildStepDownToolButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>v</string> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 8b182e21671..5ff7d25e45a 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -68,6 +68,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE : m_ignoreChange(false), m_runConfiguration(rc) { QFormLayout *layout = new QFormLayout; + layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); layout->setMargin(0); m_userName = new QLineEdit(this); diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp index 5e6a313516e..3b5e51f8387 100644 --- a/src/plugins/projectexplorer/dependenciespanel.cpp +++ b/src/plugins/projectexplorer/dependenciespanel.cpp @@ -163,6 +163,7 @@ DependenciesWidget::DependenciesWidget(SessionManager *session, , m_model(new DependenciesModel(session, project, this)) { QHBoxLayout *layout = new QHBoxLayout(this); + layout->setContentsMargins(0, -1, 0, -1); QTreeView *treeView = new QTreeView(this); treeView->setModel(m_model); treeView->setHeaderHidden(true); diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.ui b/src/plugins/projectexplorer/editorsettingspropertiespage.ui index 3ac801e2242..1f97ce0f0b7 100644 --- a/src/plugins/projectexplorer/editorsettingspropertiespage.ui +++ b/src/plugins/projectexplorer/editorsettingspropertiespage.ui @@ -2,18 +2,29 @@ <ui version="4.0"> <class>ProjectExplorer::Internal::EditorSettingsPropertiesPage</class> <widget class="QWidget" name="ProjectExplorer::Internal::EditorSettingsPropertiesPage"> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>275</width> + <height>44</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> </property> - <item row="0" column="0"> + <property name="rightMargin"> + <number>0</number> + </property> + <item> <widget class="QLabel" name="encodingLabel"> <property name="text"> <string>Default File Encoding:</string> </property> </widget> </item> - <item row="0" column="1"> + <item> <widget class="QComboBox" name="encodingComboBox"/> </item> </layout> diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp index e0dc0b92f8d..6c5bd757523 100644 --- a/src/plugins/projectexplorer/environmenteditmodel.cpp +++ b/src/plugins/projectexplorer/environmenteditmodel.cpp @@ -434,6 +434,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent) m_summaryPage = new QWidget(); addWidget(m_summaryPage); QVBoxLayout *vbox = new QVBoxLayout(m_summaryPage); + vbox->setContentsMargins(0, -1, 0, -1); m_summaryText = new QLabel(this); m_summaryText->setText(""); diff --git a/src/plugins/projectexplorer/processstep.ui b/src/plugins/projectexplorer/processstep.ui index 6e52c4c8893..26fb34a3595 100644 --- a/src/plugins/projectexplorer/processstep.ui +++ b/src/plugins/projectexplorer/processstep.ui @@ -6,11 +6,17 @@ <rect> <x>0</x> <y>0</y> - <width>505</width> + <width>509</width> <height>271</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="margin"> + <number>0</number> + </property> <item> <widget class="QGroupBox" name="enabledGroupBox"> <property name="title"> @@ -86,6 +92,7 @@ <class>Core::Utils::PathChooser</class> <extends>QWidget</extends> <header location="global">utils/pathchooser.h</header> + <container>1</container> </customwidget> </customwidgets> <resources/> diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ea065c53943..f10b628aadd 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -74,11 +74,10 @@ #include <coreplugin/findplaceholder.h> #include <coreplugin/basefilewizard.h> #include <coreplugin/mainwindow.h> -#include <coreplugin/welcomemode.h> #include <coreplugin/vcsmanager.h> #include <coreplugin/iversioncontrol.h> #include <coreplugin/vcsmanager.h> -#include <coreplugin/welcomemode.h> +#include <welcome/welcomemode.h> #include <extensionsystem/pluginmanager.h> #include <utils/qtcassert.h> #include <utils/parameteraction.h> @@ -189,7 +188,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mode->setWidget(m_proWindow); mode->setContext(QList<int>() << pecontext); addAutoReleasedObject(mode); - m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(mode)); + m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_proWindow)); m_buildManager = new BuildManager(this); connect(m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)), @@ -647,7 +646,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er m_projectExplorerSettings.showCompilerOutput = s->value("ProjectExplorer/Settings/ShowCompilerOutput", false).toBool(); } - if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast<Core::Internal::WelcomeMode*> + if (Welcome::WelcomeMode *welcomeMode = qobject_cast<Welcome::WelcomeMode*> (Core::ICore::instance()->modeManager()->mode(Core::Constants::MODE_WELCOME))) { connect(welcomeMode, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); } @@ -837,7 +836,7 @@ void ProjectExplorerPlugin::showSessionManager() Core::IMode *welcomeMode = modeManager->mode(Core::Constants::MODE_WELCOME); if (modeManager->currentMode() == welcomeMode) { - updateWelcomePage(qobject_cast<Core::Internal::WelcomeMode*>(welcomeMode)); + updateWelcomePage(qobject_cast<Welcome::WelcomeMode*>(welcomeMode)); } } @@ -1020,9 +1019,9 @@ Project *ProjectExplorerPlugin::startupProject() const } // update welcome page -void ProjectExplorerPlugin::updateWelcomePage(Core::Internal::WelcomeMode *welcomeMode) +void ProjectExplorerPlugin::updateWelcomePage(Welcome::WelcomeMode *welcomeMode) { - Core::Internal::WelcomeMode::WelcomePageData welcomePageData; + Welcome::WelcomeMode::WelcomePageData welcomePageData; welcomePageData.sessionList = m_session->sessions(); welcomePageData.activeSession = m_session->activeSession(); welcomePageData.previousSession = m_session->lastSession(); @@ -1032,7 +1031,7 @@ void ProjectExplorerPlugin::updateWelcomePage(Core::Internal::WelcomeMode *welco void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode) { - if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast<Core::Internal::WelcomeMode*>(mode)) + if (Welcome::WelcomeMode *welcomeMode = qobject_cast<Welcome::WelcomeMode*>(mode)) updateWelcomePage(welcomeMode); } @@ -1081,7 +1080,7 @@ void ProjectExplorerPlugin::restoreSession() // update welcome page Core::ModeManager *modeManager = Core::ModeManager::instance(); connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)), this, SLOT(currentModeChanged(Core::IMode*))); - if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast<Core::Internal::WelcomeMode*>(modeManager->mode(Core::Constants::MODE_WELCOME))) { + if (Welcome::WelcomeMode *welcomeMode = qobject_cast<Welcome::WelcomeMode*>(modeManager->mode(Core::Constants::MODE_WELCOME))) { updateWelcomePage(welcomeMode); connect(welcomeMode, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString))); connect(welcomeMode, SIGNAL(requestProject(QString)), this, SLOT(loadProject(QString))); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 78c1d3c3ba8..0f781eac882 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -46,21 +46,20 @@ #include <QtGui/QTreeWidget> #include <QtGui/QTreeWidgetItem> - namespace Core { class IContext; class IMode; class IFileFactory; -namespace Internal { - class WelcomeMode; -} namespace Utils { class ParameterAction; } } -namespace ProjectExplorer { +namespace Welcome { + class WelcomeMode; +} +namespace ProjectExplorer { class BuildManager; class PersistentSettings; class RunConfiguration; @@ -210,7 +209,7 @@ private: void updateActions(); void addToRecentProjects(const QString &fileName, const QString &displayName); - void updateWelcomePage(Core::Internal::WelcomeMode *welcomeMode); + void updateWelcomePage(Welcome::WelcomeMode *welcomeMode); Internal::ProjectFileFactory *findProjectFileFactory(const QString &filename) const; static ProjectExplorerPlugin *m_instance; diff --git a/src/plugins/projectexplorer/projectexplorer_dependencies.pri b/src/plugins/projectexplorer/projectexplorer_dependencies.pri index 674c8bbb362..ecbb7a4b976 100644 --- a/src/plugins/projectexplorer/projectexplorer_dependencies.pri +++ b/src/plugins/projectexplorer/projectexplorer_dependencies.pri @@ -3,3 +3,4 @@ include(../../plugins/quickopen/quickopen.pri) include(../../plugins/find/find.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) +include(../../plugins/welcome/welcome.pri) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 4d5cf076a92..48811707c12 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -62,13 +62,22 @@ bool debug = false; PanelsWidget::PanelsWidget(QWidget *parent) : QScrollArea(parent) { - m_widget = new QWidget; - m_layout = new QVBoxLayout(m_widget); + QWidget *topwidget = new QWidget; + QHBoxLayout *topwidgetLayout = new QHBoxLayout; + topwidgetLayout->setMargin(0); + topwidgetLayout->setSpacing(0); + topwidget->setLayout(topwidgetLayout); + + QWidget *verticalWidget = new QWidget; + verticalWidget->setMaximumWidth(800); + m_layout = new QVBoxLayout; + verticalWidget->setLayout(m_layout); + topwidgetLayout->addWidget(verticalWidget); + topwidgetLayout->addStretch(10); setWidgetResizable(true); setFrameStyle(QFrame::NoFrame); - setWidget(m_widget); - + setWidget(topwidget); } PanelsWidget::~PanelsWidget() diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index bae2b8b78b6..3eaa30eebb0 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -69,7 +69,6 @@ private: QLabel *nameLabel; QWidget *panelWidget; }; - QWidget *m_widget; QVBoxLayout *m_layout; QList<Panel> m_panels; }; diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.ui b/src/plugins/projectexplorer/runsettingspropertiespage.ui index 2daaa3cfae3..f72388829ec 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.ui +++ b/src/plugins/projectexplorer/runsettingspropertiespage.ui @@ -11,54 +11,28 @@ </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> <item> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Active run configuration:</string> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="activeRunConfigurationCombo"> - <property name="maximumSize"> - <size> - <width>500</width> - <height>16777215</height> - </size> - </property> - <property name="sizeAdjustPolicy"> - <enum>QComboBox::AdjustToContents</enum> - </property> - <property name="minimumContentsLength"> - <number>15</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Edit run configuration:</string> - </property> - <property name="buddy"> - <cstring>runConfigurationCombo</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QComboBox" name="runConfigurationCombo"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Active run configuration:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="activeRunConfigurationCombo"> <property name="maximumSize"> <size> <width>500</width> @@ -73,22 +47,71 @@ </property> </widget> </item> - <item> - <widget class="QPushButton" name="addToolButton"> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> - <string>+</string> + <string>Edit run configuration:</string> + </property> + <property name="buddy"> + <cstring>runConfigurationCombo</cstring> </property> </widget> </item> - <item> - <widget class="QPushButton" name="removeToolButton"> - <property name="text"> - <string>-</string> - </property> - </widget> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QComboBox" name="runConfigurationCombo"> + <property name="maximumSize"> + <size> + <width>500</width> + <height>16777215</height> + </size> + </property> + <property name="sizeAdjustPolicy"> + <enum>QComboBox::AdjustToContents</enum> + </property> + <property name="minimumContentsLength"> + <number>15</number> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="addToolButton"> + <property name="text"> + <string>+</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="removeToolButton"> + <property name="text"> + <string>-</string> + </property> + </widget> + </item> + </layout> </item> </layout> </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> </layout> </item> <item> diff --git a/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec b/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec index c4b8d4455f4..3b515bd60e5 100644 --- a/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec +++ b/src/plugins/qt4projectmanager/Qt4ProjectManager.pluginspec @@ -25,5 +25,6 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> <dependency name="CppEditor" version="1.2.80"/> <dependency name="Help" version="1.2.80"/> <dependency name="Designer" version="1.2.80"/> + <dependency name="Welcome" version="1.2.80"/> </dependencyList> </plugin> diff --git a/src/plugins/qt4projectmanager/makestep.ui b/src/plugins/qt4projectmanager/makestep.ui index f2007e7e398..558fbeb6aad 100644 --- a/src/plugins/qt4projectmanager/makestep.ui +++ b/src/plugins/qt4projectmanager/makestep.ui @@ -7,10 +7,16 @@ <x>0</x> <y>0</y> <width>235</width> - <height>64</height> + <height>78</height> </rect> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> + <property name="margin"> + <number>0</number> + </property> <item row="0" column="0"> <widget class="QLabel" name="makeLabel"> <property name="text"> diff --git a/src/plugins/qt4projectmanager/qmakestep.ui b/src/plugins/qt4projectmanager/qmakestep.ui index abb882d7164..5d843c4fd0d 100644 --- a/src/plugins/qt4projectmanager/qmakestep.ui +++ b/src/plugins/qt4projectmanager/qmakestep.ui @@ -11,6 +11,12 @@ </rect> </property> <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> + <property name="margin"> + <number>0</number> + </property> <item row="0" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> @@ -20,6 +26,12 @@ </item> <item row="0" column="1"> <widget class="QComboBox" name="buildConfigurationComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <item> <property name="text"> <string>debug</string> diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp index 35174eb9471..e7a86cfd66a 100644 --- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp @@ -43,6 +43,7 @@ Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project) : BuildStepConfigWidget(), m_pro(project) { QVBoxLayout *vbox = new QVBoxLayout(this); + vbox->setMargin(0); m_clearSystemEnvironmentCheckBox = new QCheckBox(this); m_clearSystemEnvironmentCheckBox->setText("Clear system environment"); diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 7ae654abe5b..0a96f03e0d5 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -56,6 +56,20 @@ Qt4ProjectConfigWidget::Qt4ProjectConfigWidget(Qt4Project *project) { m_ui = new Ui::Qt4ProjectConfigWidget(); m_ui->setupUi(this); + + // fix the layout + QAbstractButton *browseButton = m_ui->shadowBuildDirEdit->buttonAtIndex(0); + browseButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_ui->gridLayout->addWidget(browseButton, 4, 2); + int minimumHeight = qMax(m_ui->qtVersionComboBox->sizeHint().height(), m_ui->manageQtVersionPushButtons->sizeHint().height()); + Qt::Alignment labelAlignment = Qt::Alignment(style()->styleHint(QStyle::SH_FormLayoutLabelAlignment)); + for (int i = 0; i < m_ui->gridLayout->rowCount(); ++i) { + m_ui->gridLayout->setRowMinimumHeight(i, minimumHeight); + QLayoutItem *item = m_ui->gridLayout->itemAtPosition(i, 0); + if (item) + item->setAlignment(labelAlignment); + } + m_ui->shadowBuildDirEdit->setPromptDialogTitle(tr("Shadow Build Directory")); m_ui->shadowBuildDirEdit->setExpectedKind(Core::Utils::PathChooser::Directory); m_ui->invalidQtWarningLabel->setVisible(false); diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.ui b/src/plugins/qt4projectmanager/qt4projectconfigwidget.ui index 5f238cb4195..44109137067 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.ui +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.ui @@ -10,11 +10,20 @@ <height>247</height> </rect> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout"> + <property name="horizontalSpacing"> + <number>8</number> + </property> + <property name="verticalSpacing"> + <number>4</number> </property> <item row="0" column="0"> <widget class="QLabel" name="nameLabel"> @@ -47,46 +56,52 @@ </widget> </item> <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>4</number> + </property> <item> <widget class="QComboBox" name="qtVersionComboBox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> </widget> </item> - <item> - <widget class="QPushButton" name="manageQtVersionPushButtons"> - <property name="text"> - <string>Manage Qt Versions</string> - </property> - </widget> - </item> <item> <widget class="QLabel" name="invalidQtWarningLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> <string>This Qt-Version is invalid.</string> </property> </widget> </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> </layout> </item> + <item row="1" column="2"> + <widget class="QPushButton" name="manageQtVersionPushButtons"> + <property name="text"> + <string>Manage</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Tool Chain:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="toolChainComboBox"/> + </item> <item row="3" column="0"> <widget class="QLabel" name="label"> <property name="text"> @@ -114,6 +129,16 @@ </property> </widget> </item> + <item row="4" column="1"> + <widget class="Core::Utils::PathChooser" name="shadowBuildDirEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> <item row="5" column="1"> <widget class="QLabel" name="importLabel"> <property name="text"> @@ -124,45 +149,9 @@ </property> </widget> </item> - <item row="4" column="1"> - <widget class="Core::Utils::PathChooser" name="shadowBuildDirEdit" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="toolChainComboBox"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Tool Chain:</string> - </property> - </widget> - </item> </layout> </item> - <item row="0" column="1"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Preferred</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0"> + <item> <spacer name="verticalSpacer"> <property name="orientation"> <enum>Qt::Vertical</enum> diff --git a/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri b/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri index 9a493156ad5..e1bd37df366 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri +++ b/src/plugins/qt4projectmanager/qt4projectmanager_dependencies.pri @@ -3,3 +3,4 @@ include(../../plugins/cpptools/cpptools.pri) include(../../plugins/cppeditor/cppeditor.pri) include(../../plugins/help/help.pri) include(../../plugins/designer/designer.pri) +include(../../plugins/welcome/welcome.pri) diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index e5832ce95f3..d5ab1116068 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -118,6 +118,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run m_isShown(false) { QFormLayout *toplayout = new QFormLayout(); + toplayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); toplayout->setMargin(0); QLabel *nameLabel = new QLabel(tr("Name:")); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index c16a99614c5..2d1f2342149 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -42,7 +42,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> #include <coreplugin/modemanager.h> -#include <coreplugin/welcomemode.h> +#include <welcome/welcomemode.h> #include <extensionsystem/pluginmanager.h> #include <help/helpplugin.h> #include <utils/qtcassert.h> @@ -121,7 +121,7 @@ QtVersionManager::QtVersionManager() writeVersionsIntoSettings(); - if (Core::Internal::WelcomeMode *welcomeMode = qobject_cast<Core::Internal::WelcomeMode*> + if (Welcome::WelcomeMode *welcomeMode = qobject_cast<Welcome::WelcomeMode*> (Core::ICore::instance()->modeManager()->mode(Core::Constants::MODE_WELCOME))) { connect(this, SIGNAL(updatedExamples(QString, QString)), welcomeMode, SIGNAL(updatedExamples(QString, QString))); diff --git a/src/plugins/quickopen/QuickOpen.pluginspec b/src/plugins/quickopen/QuickOpen.pluginspec index 17ac77d3db9..c28c03c6072 100644 --- a/src/plugins/quickopen/QuickOpen.pluginspec +++ b/src/plugins/quickopen/QuickOpen.pluginspec @@ -16,7 +16,7 @@ General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> - <description>Provides the QuickOpen widget and the hooks for QuickOpen filter implementations.</description> + <description>Provides the Locator widget and the hooks for QuickOpen filter implementations.</description> <url>http://www.qtsoftware.com</url> <dependencyList> <dependency name="Core" version="1.2.80"/> diff --git a/src/plugins/quickopen/basefilefilter.cpp b/src/plugins/quickopen/basefilefilter.cpp index c895af5a7c2..3ba6b8b06d4 100644 --- a/src/plugins/quickopen/basefilefilter.cpp +++ b/src/plugins/quickopen/basefilefilter.cpp @@ -32,6 +32,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <QtCore/QDir> +#include <QtCore/QStringMatcher> using namespace Core; using namespace QuickOpen; diff --git a/src/plugins/quickopen/quickopen.cp b/src/plugins/quickopen/quickopen.cp new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/plugins/quickopen/quickopenplugin.cpp b/src/plugins/quickopen/quickopenplugin.cpp index df5b300e649..51a8b5e2112 100644 --- a/src/plugins/quickopen/quickopenplugin.cpp +++ b/src/plugins/quickopen/quickopenplugin.cpp @@ -103,7 +103,7 @@ bool QuickOpenPlugin::initialize(const QStringList &, QString *) view->setDefaultPosition(Core::IView::First); addAutoReleasedObject(view); - const QString actionId = QLatin1String("QtCreator.QuickOpen"); + const QString actionId = QLatin1String("QtCreator.Locate"); QAction *action = new QAction(m_quickOpenToolWindow->windowIcon(), m_quickOpenToolWindow->windowTitle(), this); Core::Command *cmd = core->actionManager()->registerAction(action, actionId, QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+K")); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index b61236cdd95..fcc57f11380 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -838,6 +838,9 @@ void BaseTextEditor::cleanWhitespace() void BaseTextEditor::keyPressEvent(QKeyEvent *e) { + viewport()->setCursor(Qt::BlankCursor); + QToolTip::hideText(); + d->m_moveLineUndoHack = false; d->clearVisibleCollapsedBlock(); @@ -2728,6 +2731,8 @@ void BaseTextEditor::mouseMoveEvent(QMouseEvent *e) d->m_blockSelectionExtraX = 0; } } + if (viewport()->cursor().shape() == Qt::BlankCursor) + viewport()->setCursor(Qt::IBeamCursor); } void BaseTextEditor::mousePressEvent(QMouseEvent *e) @@ -3951,14 +3956,15 @@ void BaseTextEditor::rewrapParagraph() if (!currentWord.isEmpty()) { currentLength += currentWord.length() + 1; - if (currentLength > paragraphWidth - indentLevel) { + if (currentLength > paragraphWidth) { currentLength = currentWord.length() + 1 + indentLevel; + result.chop(1); // remove trailing space result.append(QChar::ParagraphSeparator); result.append(spacing); } result.append(currentWord); - result.append(QLatin1String(" ")); + result.append(QLatin1Char(' ')); currentWord.clear(); } @@ -3967,6 +3973,7 @@ void BaseTextEditor::rewrapParagraph() currentWord.append(ch); } + result.chop(1); result.append(QChar::ParagraphSeparator); cursor.insertText(result); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 5a8e457768a..67b551496c4 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -36,6 +36,7 @@ #include <coreplugin/icore.h> #include <utils/settingsutils.h> +#include <utils/qtcassert.h> #include <QtCore/QDebug> #include <QtCore/QSettings> @@ -357,7 +358,7 @@ QWidget *FontSettingsPage::createPage(QWidget *parent) connect(d_ptr->ui.sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString))); connect(d_ptr->ui.schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int))); connect(d_ptr->ui.copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme())); - connect(d_ptr->ui.deleteButton, SIGNAL(clicked()), this, SLOT(deleteColorScheme())); + connect(d_ptr->ui.deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme())); updatePointSizes(); refreshColorSchemeList(); @@ -466,23 +467,44 @@ void FontSettingsPage::copyColorScheme(const QString &name) } } -void FontSettingsPage::deleteColorScheme() +void FontSettingsPage::confirmDeleteColorScheme() { - int index = d_ptr->ui.schemeComboBox->currentIndex(); + const int index = d_ptr->ui.schemeComboBox->currentIndex(); if (index == -1) return; const ColorSchemeEntry &entry = d_ptr->m_schemeListModel->colorSchemeAt(index); + if (entry.readOnly) + return; - if (!entry.readOnly) { - int ret = QMessageBox::warning(d_ptr->ui.deleteButton->window(), - tr("Delete Color Scheme"), - tr("Are you sure you want to delete this color scheme permanently?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning, + tr("Delete Color Scheme"), + tr("Are you sure you want to delete this color scheme permanently?"), + QMessageBox::Discard | QMessageBox::Cancel, + d_ptr->ui.deleteButton->window()); - if (ret == QMessageBox::Yes && QFile::remove(entry.fileName)) - d_ptr->m_schemeListModel->removeColorScheme(index); - } + // Change the text and role of the discard button + QPushButton *deleteButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard)); + deleteButton->setText(tr("Delete")); + messageBox->addButton(deleteButton, QMessageBox::AcceptRole); + messageBox->setDefaultButton(deleteButton); + + connect(deleteButton, SIGNAL(clicked()), messageBox, SLOT(accept())); + connect(messageBox, SIGNAL(accepted()), this, SLOT(deleteColorScheme())); + messageBox->setAttribute(Qt::WA_DeleteOnClose); + messageBox->open(); +} + +void FontSettingsPage::deleteColorScheme() +{ + const int index = d_ptr->ui.schemeComboBox->currentIndex(); + QTC_ASSERT(index != -1, return) + + const ColorSchemeEntry &entry = d_ptr->m_schemeListModel->colorSchemeAt(index); + QTC_ASSERT(!entry.readOnly, return) + + if (QFile::remove(entry.fileName)) + d_ptr->m_schemeListModel->removeColorScheme(index); } void FontSettingsPage::maybeSaveColorScheme() diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index 33f7257be7c..f47a95b3116 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -114,6 +114,7 @@ private slots: void colorSchemeSelected(int index); void copyColorScheme(); void copyColorScheme(const QString &name); + void confirmDeleteColorScheme(); void deleteColorScheme(); private: diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index abf81e0b576..4c9a5207ad8 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -143,7 +143,9 @@ void TextEditorActionHandler::createActions() m_rewrapParagraphAction = new QAction(tr("&Rewrap Paragraph"), this); command = am->registerAction(m_rewrapParagraphAction, TextEditor::Constants::REWRAP_PARAGRAPH, m_contextId); - //command->setDefaultKeySequence(QKeySequence(tr("Alt+Q"))); (No default key sequence for now.) +#ifndef Q_WS_MAC + command->setDefaultKeySequence(QKeySequence(tr("Ctrl+E, R"))); +#endif advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_rewrapParagraphAction, SIGNAL(triggered(bool)), this, SLOT(rewrapParagraphAction())); diff --git a/src/plugins/welcome/Welcome.pluginspec b/src/plugins/welcome/Welcome.pluginspec new file mode 100644 index 00000000000..ab310c396e9 --- /dev/null +++ b/src/plugins/welcome/Welcome.pluginspec @@ -0,0 +1,24 @@ +<plugin name="Welcome" version="1.2.80" compatVersion="1.2.80"> + <vendor>Nokia Corporation</vendor> + <copyright>(C) 2008-2009 Nokia Corporation</copyright> + <license> +Commercial Usage + +Licensees holding valid Qt Commercial licenses may use this plugin in +accordance with the Qt Commercial License Agreement provided with the +Software or, alternatively, in accordance with the terms contained in +a written agreement between you and Nokia. + +GNU Lesser General Public License Usage + +Alternatively, this plugin may be used under the terms of the GNU Lesser +General Public License version 2.1 as published by the Free Software +Foundation. Please review the following information to +ensure the GNU Lesser General Public License version 2.1 requirements +will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> + <description>Default Welcome Screen Plugin</description> + <url>http://www.qtsoftware.com</url> + <dependencyList> + <dependency name="Core" version="1.2.80"/> + </dependencyList> +</plugin> diff --git a/src/plugins/coreplugin/images/welcomemode/arrow-left.png b/src/plugins/welcome/images/arrow-left.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/arrow-left.png rename to src/plugins/welcome/images/arrow-left.png diff --git a/src/plugins/coreplugin/images/welcomemode/arrow-right.png b/src/plugins/welcome/images/arrow-right.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/arrow-right.png rename to src/plugins/welcome/images/arrow-right.png diff --git a/src/plugins/coreplugin/images/welcomemode/background_center_frame.png b/src/plugins/welcome/images/background_center_frame.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/background_center_frame.png rename to src/plugins/welcome/images/background_center_frame.png diff --git a/src/plugins/coreplugin/images/welcomemode/btn_26.png b/src/plugins/welcome/images/btn_26.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/btn_26.png rename to src/plugins/welcome/images/btn_26.png diff --git a/src/plugins/coreplugin/images/welcomemode/btn_26_hover.png b/src/plugins/welcome/images/btn_26_hover.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/btn_26_hover.png rename to src/plugins/welcome/images/btn_26_hover.png diff --git a/src/plugins/coreplugin/images/welcomemode/btn_26_pressed.png b/src/plugins/welcome/images/btn_26_pressed.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/btn_26_pressed.png rename to src/plugins/welcome/images/btn_26_pressed.png diff --git a/src/plugins/coreplugin/images/welcomemode/btn_27.png b/src/plugins/welcome/images/btn_27.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/btn_27.png rename to src/plugins/welcome/images/btn_27.png diff --git a/src/plugins/coreplugin/images/welcomemode/btn_27_hover.png b/src/plugins/welcome/images/btn_27_hover.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/btn_27_hover.png rename to src/plugins/welcome/images/btn_27_hover.png diff --git a/src/plugins/coreplugin/images/welcomemode/center_frame_header.png b/src/plugins/welcome/images/center_frame_header.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/center_frame_header.png rename to src/plugins/welcome/images/center_frame_header.png diff --git a/src/plugins/coreplugin/images/welcomemode/combobox_arrow.png b/src/plugins/welcome/images/combobox_arrow.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/combobox_arrow.png rename to src/plugins/welcome/images/combobox_arrow.png diff --git a/src/plugins/coreplugin/images/welcomemode/feedback-bar-background.png b/src/plugins/welcome/images/feedback-bar-background.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/feedback-bar-background.png rename to src/plugins/welcome/images/feedback-bar-background.png diff --git a/src/plugins/coreplugin/images/welcomemode/feedback_arrow.png b/src/plugins/welcome/images/feedback_arrow.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/feedback_arrow.png rename to src/plugins/welcome/images/feedback_arrow.png diff --git a/src/plugins/coreplugin/images/welcomemode/feedback_arrow_hover.png b/src/plugins/welcome/images/feedback_arrow_hover.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/feedback_arrow_hover.png rename to src/plugins/welcome/images/feedback_arrow_hover.png diff --git a/src/plugins/coreplugin/images/welcomemode/list_bullet_arrow.png b/src/plugins/welcome/images/list_bullet_arrow.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/list_bullet_arrow.png rename to src/plugins/welcome/images/list_bullet_arrow.png diff --git a/src/plugins/coreplugin/images/welcomemode/mode_project.png b/src/plugins/welcome/images/mode_project.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/mode_project.png rename to src/plugins/welcome/images/mode_project.png diff --git a/src/plugins/coreplugin/images/welcomemode/nokia_logo.png b/src/plugins/welcome/images/nokia_logo.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/nokia_logo.png rename to src/plugins/welcome/images/nokia_logo.png diff --git a/src/plugins/coreplugin/images/welcomemode/product_logo.png b/src/plugins/welcome/images/product_logo.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/product_logo.png rename to src/plugins/welcome/images/product_logo.png diff --git a/src/plugins/coreplugin/images/welcomemode/qt_logo.png b/src/plugins/welcome/images/qt_logo.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/qt_logo.png rename to src/plugins/welcome/images/qt_logo.png diff --git a/src/plugins/coreplugin/images/welcomemode/rc_combined.png b/src/plugins/welcome/images/rc_combined.png similarity index 100% rename from src/plugins/coreplugin/images/welcomemode/rc_combined.png rename to src/plugins/welcome/images/rc_combined.png diff --git a/src/plugins/coreplugin/rssfetcher.cpp b/src/plugins/welcome/rssfetcher.cpp similarity index 99% rename from src/plugins/coreplugin/rssfetcher.cpp rename to src/plugins/welcome/rssfetcher.cpp index cceb5ceb7a4..f5fc756c9bb 100644 --- a/src/plugins/coreplugin/rssfetcher.cpp +++ b/src/plugins/welcome/rssfetcher.cpp @@ -43,7 +43,7 @@ #include <sys/utsname.h> #endif -using namespace Core::Internal; +using namespace Welcome; static const QString getOsString() { diff --git a/src/plugins/coreplugin/rssfetcher.h b/src/plugins/welcome/rssfetcher.h similarity index 96% rename from src/plugins/coreplugin/rssfetcher.h rename to src/plugins/welcome/rssfetcher.h index 4f161e1517a..9267fdb47ae 100644 --- a/src/plugins/coreplugin/rssfetcher.h +++ b/src/plugins/welcome/rssfetcher.h @@ -34,8 +34,7 @@ #include <QtCore/QXmlStreamReader> #include <QtNetwork/QHttp> -namespace Core { -namespace Internal { +namespace Welcome { class RSSFetcher : public QObject { @@ -69,8 +68,7 @@ private: int m_maxItems; }; -} // namespace Internal -} // namespace Core +} // namespace Welcome #endif // RSSFETCHER_H diff --git a/src/plugins/welcome/welcome.pri b/src/plugins/welcome/welcome.pri new file mode 100644 index 00000000000..5e0a99bca87 --- /dev/null +++ b/src/plugins/welcome/welcome.pri @@ -0,0 +1,2 @@ +include(coreplugin_dependencies.pri) +LIBS *= -l$$qtLibraryTarget(Welcome) diff --git a/src/plugins/welcome/welcome.pro b/src/plugins/welcome/welcome.pro new file mode 100644 index 00000000000..51e66a573f0 --- /dev/null +++ b/src/plugins/welcome/welcome.pro @@ -0,0 +1,22 @@ +TEMPLATE = lib +TARGET = Welcome +QT += network +include(../../qtcreatorplugin.pri) +include(../../plugins/coreplugin/coreplugin.pri) + +HEADERS += welcomeplugin.h \ + welcomemode.h \ + welcomemode_p.h \ + rssfetcher.h + +SOURCES += welcomeplugin.cpp \ + welcomemode.cpp \ + rssfetcher.cpp + +FORMS += welcomemode.ui + +RESOURCES += welcome.qrc + +DEFINES += WELCOME_LIBRARY + +OTHER_FILES += Welcome.pluginspec diff --git a/src/plugins/welcome/welcome.qrc b/src/plugins/welcome/welcome.qrc new file mode 100644 index 00000000000..f4786743275 --- /dev/null +++ b/src/plugins/welcome/welcome.qrc @@ -0,0 +1,23 @@ +<RCC> + <qresource prefix="/welcome" > + <file>images/btn_26.png</file> + <file>images/btn_26_hover.png</file> + <file>images/btn_27.png</file> + <file>images/btn_27_hover.png</file> + <file>images/feedback_arrow.png</file> + <file>images/feedback_arrow_hover.png</file> + <file>images/feedback-bar-background.png</file> + <file>images/list_bullet_arrow.png</file> + <file>images/mode_project.png</file> + <file>images/nokia_logo.png</file> + <file>images/product_logo.png</file> + <file>images/qt_logo.png</file> + <file>images/rc_combined.png</file> + <file>images/background_center_frame.png</file> + <file>images/center_frame_header.png</file> + <file>images/btn_26_pressed.png</file> + <file>images/combobox_arrow.png</file> + <file>images/arrow-left.png</file> + <file>images/arrow-right.png</file> + </qresource> +</RCC> diff --git a/src/plugins/welcome/welcome_global.h b/src/plugins/welcome/welcome_global.h new file mode 100644 index 00000000000..8629323fda3 --- /dev/null +++ b/src/plugins/welcome/welcome_global.h @@ -0,0 +1,12 @@ +#ifndef WELCOME_GLOBAL_H +#define WELCOME_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(WELCOME_LIBRARY) +# define WELCOME_EXPORT Q_DECL_EXPORT +#else +# define WELCOME_EXPORT Q_DECL_IMPORT +#endif + +#endif // CPPEDITOR_GLOBAL_H diff --git a/src/plugins/coreplugin/welcomemode.cpp b/src/plugins/welcome/welcomemode.cpp similarity index 96% rename from src/plugins/coreplugin/welcomemode.cpp rename to src/plugins/welcome/welcomemode.cpp index 27cbd4e9c3b..f712399dcc8 100644 --- a/src/plugins/coreplugin/welcomemode.cpp +++ b/src/plugins/welcome/welcomemode.cpp @@ -28,14 +28,16 @@ **************************************************************************/ #include "welcomemode.h" -#include "icore.h" -#include "iwizard.h" -#include "coreconstants.h" -#include "uniqueidmanager.h" -#include "modemanager.h" -#include "newdialog.h" #include "rssfetcher.h" +#include <coreplugin/icore.h> +#include <coreplugin/dialogs/iwizard.h> + +#include <coreplugin/coreconstants.h> +#include <coreplugin/uniqueidmanager.h> +#include <coreplugin/modemanager.h> +#include <coreplugin/dialogs/newdialog.h> + #include <utils/styledbar.h> #include <QtGui/QDesktopServices> @@ -53,8 +55,7 @@ #include "ui_welcomemode.h" -namespace Core { -namespace Internal { +namespace Welcome { struct WelcomeModePrivate { @@ -206,7 +207,7 @@ WelcomeMode::WelcomeMode() : connect(m_d->ui.nextTipBtn, SIGNAL(clicked()), this, SLOT(slotNextTip())); connect(m_d->ui.prevTipBtn, SIGNAL(clicked()), this, SLOT(slotPrevTip())); - QSettings *settings = ICore::instance()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); int id = settings->value("General/WelcomeTab", 0).toInt(); m_d->btnGrp->button(id)->setChecked(true); m_d->ui.stackedWidget->setCurrentIndex(id); @@ -214,7 +215,7 @@ WelcomeMode::WelcomeMode() : WelcomeMode::~WelcomeMode() { - QSettings *settings = ICore::instance()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->setValue("General/WelcomeTab", m_d->btnGrp->checkedId()); delete m_d->m_widget; delete m_d; @@ -232,7 +233,7 @@ QIcon WelcomeMode::icon() const int WelcomeMode::priority() const { - return Constants::P_MODE_WELCOME; + return Core::Constants::P_MODE_WELCOME; } QWidget* WelcomeMode::widget() @@ -242,13 +243,13 @@ QWidget* WelcomeMode::widget() const char* WelcomeMode::uniqueModeName() const { - return Constants::MODE_WELCOME; + return Core::Constants::MODE_WELCOME; } QList<int> WelcomeMode::context() const { static QList<int> contexts = QList<int>() - << UniqueIDManager::instance()->uniqueIdentifier(Constants::C_WELCOME_MODE); + << Core::UniqueIDManager::instance()->uniqueIdentifier(Core::Constants::C_WELCOME_MODE); return contexts; } @@ -292,7 +293,7 @@ void WelcomeMode::updateWelcomePage(const WelcomePageData &welcomePageData) void WelcomeMode::activateEditMode() { - Core::ModeManager *modeManager = ModeManager::instance(); + Core::ModeManager *modeManager = Core::ModeManager::instance(); if (modeManager->currentMode() == this) modeManager->activateMode(Core::Constants::MODE_EDIT); } @@ -516,7 +517,7 @@ void WelcomeModeButton::leaveEvent(QEvent *) WelcomeModeTreeWidget::WelcomeModeTreeWidget(QWidget *parent) : QTreeWidget(parent), - m_bullet(QLatin1String(":/core/images/welcomemode/list_bullet_arrow.png")) + m_bullet(QLatin1String(":/welcome/images/list_bullet_arrow.png")) { connect(this, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(slotItemClicked(QTreeWidgetItem *))); @@ -567,5 +568,4 @@ void WelcomeModeTreeWidget::slotItemClicked(QTreeWidgetItem *item) emit activated(item->data(0, Qt::UserRole).toString()); } -} // namespace Internal -} // namespace Core +} // namespace Welcome diff --git a/src/plugins/coreplugin/welcomemode.h b/src/plugins/welcome/welcomemode.h similarity index 95% rename from src/plugins/coreplugin/welcomemode.h rename to src/plugins/welcome/welcomemode.h index 46215998ee4..3825b9dbef3 100644 --- a/src/plugins/coreplugin/welcomemode.h +++ b/src/plugins/welcome/welcomemode.h @@ -30,6 +30,8 @@ #ifndef WELCOMEMODE_H #define WELCOMEMODE_H +#include "welcome_global.h" + #include <coreplugin/imode.h> #include <QtCore/QObject> @@ -40,12 +42,11 @@ class QWidget; class QUrl; QT_END_NAMESPACE -namespace Core { -namespace Internal { +namespace Welcome { struct WelcomeModePrivate; -class CORE_EXPORT WelcomeMode : public Core::IMode +class WELCOME_EXPORT WelcomeMode : public Core::IMode { Q_OBJECT @@ -102,7 +103,6 @@ private: WelcomeModePrivate *m_d; }; -} // namespace Internal -} // namespace Core +} // namespace Welcome #endif // WELCOMEMODE_H diff --git a/src/plugins/coreplugin/welcomemode.ui b/src/plugins/welcome/welcomemode.ui similarity index 96% rename from src/plugins/coreplugin/welcomemode.ui rename to src/plugins/welcome/welcomemode.ui index c1471f65d7a..8a70b233ea5 100644 --- a/src/plugins/coreplugin/welcomemode.ui +++ b/src/plugins/welcome/welcomemode.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>Core::Internal::WelcomePage</class> - <widget class="QWidget" name="Core::Internal::WelcomePage"> + <class>Welcome::WelcomePage</class> + <widget class="QWidget" name="Welcome::WelcomePage"> <property name="geometry"> <rect> <x>0</x> @@ -11,12 +11,12 @@ </rect> </property> <property name="styleSheet"> - <string notr="true">#Core--Internal--WelcomePage { + <string notr="true">#Welcome--WelcomePage { background-color: qlineargradient(spread:pad, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 rgba(247, 247, 247, 255), stop:1 rgba(215, 215, 215, 255)); } QToolButton, QPushButton, QComboBox { - border-image: url(:/core/images/welcomemode/btn_26.png) 4; + border-image: url(:/welcome/images/btn_26.png) 4; border-width: 4; padding: 0px 6px; font-size: 12px; @@ -31,7 +31,7 @@ QToolButton, QPushButton, QComboBox { } QComboBox::down-arrow { - image: url(:/core/images/welcomemode/combobox_arrow.png); + image: url(:/welcome/images/combobox_arrow.png); } QComboBox:drop-down @@ -44,7 +44,7 @@ QComboBox:drop-down } QToolButton:hover, QPushButton:hover, QComboBox:hover { - border-image: url(:/core/images/welcomemode/btn_26_hover.png) 4; + border-image: url(:/welcome/images/btn_26_hover.png) 4; } QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { @@ -52,7 +52,7 @@ QToolButton:disabled, QPushButton:disabled, QComboBox::disabled { } QToolButton:pressed, QPushButton:pressed{ - border-image: url(:/core/images/welcomemode/btn_26_pressed.png) 4; + border-image: url(:/welcome/images/btn_26_pressed.png) 4; } </string> </property> @@ -102,7 +102,7 @@ QToolButton:pressed, QPushButton:pressed{ </property> <property name="styleSheet"> <string notr="true">#mainFrame { - border-image: url(:/core/images/welcomemode/background_center_frame.png) 4; + border-image: url(:/welcome/images/background_center_frame.png) 4; border-width: 4; } </string> @@ -151,7 +151,7 @@ QToolButton:pressed, QPushButton:pressed{ </property> <property name="styleSheet"> <string>#headerFrame { - border-image: url(:/core/images/welcomemode/center_frame_header.png) 0; + border-image: url(:/welcome/images/center_frame_header.png) 0; border-width: 0; } </string> @@ -417,7 +417,7 @@ QToolButton:pressed { </widget> </item> <item row="1" column="0"> - <widget class="Core::Internal::WelcomeModeTreeWidget" name="tutorialTreeWidget"> + <widget class="Welcome::WelcomeModeTreeWidget" name="tutorialTreeWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -650,8 +650,8 @@ QToolButton:pressed { <string/> </property> <property name="icon"> - <iconset resource="core.qrc"> - <normaloff>:/core/images/welcomemode/arrow-left.png</normaloff>:/core/images/welcomemode/arrow-left.png</iconset> + <iconset resource="welcome.qrc"> + <normaloff>:/welcome/images/arrow-left.png</normaloff>:/welcome/images/arrow-left.png</iconset> </property> <property name="arrowType"> <enum>Qt::NoArrow</enum> @@ -672,8 +672,8 @@ QToolButton:pressed { <string/> </property> <property name="icon"> - <iconset resource="core.qrc"> - <normaloff>:/core/images/welcomemode/arrow-right.png</normaloff>:/core/images/welcomemode/arrow-right.png</iconset> + <iconset resource="welcome.qrc"> + <normaloff>:/welcome/images/arrow-right.png</normaloff>:/welcome/images/arrow-right.png</iconset> </property> <property name="arrowType"> <enum>Qt::NoArrow</enum> @@ -746,7 +746,7 @@ QToolButton:pressed { </widget> </item> <item row="1" column="0" colspan="3"> - <widget class="Core::Internal::WelcomeModeTreeWidget" name="sessTreeWidget"> + <widget class="Welcome::WelcomeModeTreeWidget" name="sessTreeWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -853,7 +853,7 @@ QToolButton:pressed { </widget> </item> <item row="1" column="0" colspan="3"> - <widget class="Core::Internal::WelcomeModeTreeWidget" name="projTreeWidget"> + <widget class="Welcome::WelcomeModeTreeWidget" name="projTreeWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -967,7 +967,7 @@ QToolButton:pressed { </widget> </item> <item> - <widget class="Core::Internal::WelcomeModeTreeWidget" name="newsTreeWidget"> + <widget class="Welcome::WelcomeModeTreeWidget" name="newsTreeWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -1051,7 +1051,7 @@ QToolButton:pressed { </widget> </item> <item> - <widget class="Core::Internal::WelcomeModeTreeWidget" name="sitesTreeWidget"> + <widget class="Welcome::WelcomeModeTreeWidget" name="sitesTreeWidget"> <property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -1166,8 +1166,8 @@ QToolButton:pressed { <string>Feedback</string> </property> <property name="icon"> - <iconset resource="core.qrc"> - <normaloff>:/core/images/welcomemode/feedback_arrow.png</normaloff>:/core/images/welcomemode/feedback_arrow.png</iconset> + <iconset resource="welcome.qrc"> + <normaloff>:/welcome/images/feedback_arrow.png</normaloff>:/welcome/images/feedback_arrow.png</iconset> </property> </widget> </item> @@ -1221,13 +1221,13 @@ QToolButton:pressed { </widget> <customwidgets> <customwidget> - <class>Core::Internal::WelcomeModeTreeWidget</class> + <class>Welcome::WelcomeModeTreeWidget</class> <extends>QTreeWidget</extends> <header>welcomemode_p.h</header> </customwidget> </customwidgets> <resources> - <include location="core.qrc"/> + <include location="welcome.qrc"/> </resources> <connections/> </ui> diff --git a/src/plugins/coreplugin/welcomemode_p.h b/src/plugins/welcome/welcomemode_p.h similarity index 98% rename from src/plugins/coreplugin/welcomemode_p.h rename to src/plugins/welcome/welcomemode_p.h index 75c75361d6d..efe80b36852 100644 --- a/src/plugins/coreplugin/welcomemode_p.h +++ b/src/plugins/welcome/welcomemode_p.h @@ -34,8 +34,7 @@ #include <QtGui/QLabel> #include <QtGui/QTreeWidget> -namespace Core { -namespace Internal { +namespace Welcome { class WelcomeModeButton : public QLabel { @@ -85,7 +84,6 @@ private: QIcon m_bullet; }; -} } #endif // WELCOMEMODE_P_H diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp new file mode 100644 index 00000000000..e9743a9428c --- /dev/null +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -0,0 +1,97 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** +**************************************************************************/ + +#include "welcomeplugin.h" + +#include "welcomemode.h" + +#include <coreplugin/actionmanager/actionmanager.h> +#include <coreplugin/basemode.h> +#include <coreplugin/coreconstants.h> +#include <coreplugin/icore.h> +#include <coreplugin/modemanager.h> +#include <coreplugin/uniqueidmanager.h> + +#include <QtCore/QDebug> +#include <QtCore/QtPlugin> +#include <QtGui/QAction> +#include <QtGui/QMenu> +#include <QtGui/QMessageBox> +#include <QtGui/QPushButton> + +using namespace Welcome; + + +WelcomePlugin::WelcomePlugin() + : m_welcomeMode(0) +{ +} + +WelcomePlugin::~WelcomePlugin() +{ + if (m_welcomeMode) { + removeObject(m_welcomeMode); + delete m_welcomeMode; + } +} + +/*! Initializes the plugin. Returns true on success. + Plugins want to register objects with the plugin manager here. + + \a error_message can be used to pass an error message to the plugin system, + if there was any. +*/ +bool WelcomePlugin::initialize(const QStringList &arguments, QString *error_message) +{ + Q_UNUSED(arguments) + Q_UNUSED(error_message) + + m_welcomeMode = new WelcomeMode; + addObject(m_welcomeMode); + + return true; +} + +/*! Notification that all extensions that this plugin depends on have been + initialized. The dependencies are defined in the plugins .qwp file. + + Normally this method is used for things that rely on other plugins to have + added objects to the plugin manager, that implement interfaces that we're + interested in. These objects can now be requested through the + PluginManagerInterface. + + The WelcomePlugin doesn't need things from other plugins, so it does + nothing here. +*/ +void WelcomePlugin::extensionsInitialized() +{ + Core::ModeManager::instance()->activateMode(m_welcomeMode->uniqueModeName()); +} + +Q_EXPORT_PLUGIN(WelcomePlugin) diff --git a/src/plugins/welcome/welcomeplugin.h b/src/plugins/welcome/welcomeplugin.h new file mode 100644 index 00000000000..970ec399500 --- /dev/null +++ b/src/plugins/welcome/welcomeplugin.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** +**************************************************************************/ + +#ifndef WELCOMEPLUGIN_H +#define WELCOMEPLUGIN_H + +#include <extensionsystem/iplugin.h> + +namespace Welcome { + +class WelcomeMode; + +class WelcomePlugin + : public ExtensionSystem::IPlugin +{ + Q_OBJECT + +public: + WelcomePlugin(); + ~WelcomePlugin(); + + bool initialize(const QStringList &arguments, QString *error_message); + + void extensionsInitialized(); + +private: + WelcomeMode *m_welcomeMode; +}; + +} // namespace Welcome + +#endif // WELCOMEPLUGIN_H diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 3c26f93a8a1..2f3e10f9ea0 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -139,7 +139,6 @@ public: ProBlock *currentBlock(); void updateItem(); - bool parseLine(const QString &line); void insertVariable(const ushort **pCur, const ushort *end); void insertOperator(const char op); void insertComment(const QString &comment); @@ -154,12 +153,8 @@ public: QString m_proitem; QString m_pendingComment; ushort *m_proitemPtr; - bool m_syntaxError; - bool m_contNextLine; - bool m_inQuote; - int m_parens; - enum StrState { NotStarted, Started, PutSpace }; + enum StrState { NeverStarted, NotStarted, Started, PutSpace }; /////////////// Evaluating pro file contents @@ -288,142 +283,125 @@ bool ProFileEvaluator::Private::read(ProFile *pro, QTextStream *ts) // Parser state m_block = 0; m_commentItem = 0; - m_inQuote = false; - m_parens = 0; - m_contNextLine = false; - m_syntaxError = false; m_lineNo = 1; m_blockstack.clear(); m_blockstack.push(pro); + int parens = 0; + bool inQuote = false; while (!ts->atEnd()) { QString line = ts->readLine(); - if (!parseLine(line)) { - q->errorMessage(format(".pro parse failure.")); - return false; - } - ++m_lineNo; - } - return true; -} - -bool ProFileEvaluator::Private::parseLine(const QString &line) -{ - if (m_blockstack.isEmpty()) - return false; - - const ushort *cur = (const ushort *)line.unicode(), - *end = cur + line.length(); - int parens = m_parens; - bool inQuote = m_inQuote; - bool escaped = false; - - m_proitem.reserve(line.length()); - m_proitemPtr = (ushort *)m_proitem.unicode(); - nextItem: - ushort *ptr = m_proitemPtr; - StrState sts = NotStarted; - while (cur < end) { - ushort c = *cur++; - if (c == '#') { // Yep - no escaping possible - m_proitemPtr = ptr; - insertComment(line.right(end - cur).simplified()); - goto done; - } - if (!escaped) { - if (c == '\\') { - escaped = true; - goto putch; - } else if (c == '"') { - inQuote = !inQuote; - goto putch; + const ushort *cur = (const ushort *)line.unicode(), + *end = cur + line.length(), + *cmtptr = 0; + m_proitem.reserve(line.length()); + m_proitemPtr = (ushort *)m_proitem.unicode(); + enum { NotEscaped, Escaped, PostEscaped } escaped = NotEscaped; + StrState sts = NeverStarted; + goto startItem; + nextItem: + escaped = NotEscaped; + nextItem1: + sts = NotStarted; + startItem: + ushort *ptr = m_proitemPtr; + while (cur < end) { + ushort c = *cur++; + if (c == '#') { // Yep - no escaping possible + cmtptr = cur; + break; } - } else { - escaped = false; - } - if (!inQuote) { - if (c == '(') { - ++parens; - } else if (c == ')') { - --parens; - } else if (!parens) { - if (m_block && (m_block->blockKind() & ProBlock::VariableKind)) { - if (c == ' ' || c == '\t') { - m_proitemPtr = ptr; - updateItem(); - goto nextItem; - } - } else { - if (c == ':') { - m_proitemPtr = ptr; - enterScope(false); - goto nextItem; - } - if (c == '{') { - m_proitemPtr = ptr; - enterScope(true); - goto nextItem; - } - if (c == '}') { - m_proitemPtr = ptr; - leaveScope(); - if (m_syntaxError) - goto done1; - goto nextItem; - } - if (c == '=') { - m_proitemPtr = ptr; - insertVariable(&cur, end); - goto nextItem; - } - if (c == '|' || c == '!') { - m_proitemPtr = ptr; - insertOperator(c); - goto nextItem; + if (escaped != Escaped) { + if (c == '\\') { + escaped = Escaped; + goto putch; + } else if (c == '"') { + inQuote = !inQuote; + goto putch1; + } + } + if (!inQuote) { + if (c == '(') { + ++parens; + } else if (c == ')') { + --parens; + } else if (!parens) { + if (m_block && (m_block->blockKind() & ProBlock::VariableKind)) { + if (c == ' ' || c == '\t') { + m_proitemPtr = ptr; + updateItem(); + if (escaped == Escaped) + escaped = PostEscaped; + goto nextItem1; + } + } else { + if (c == ':') { + m_proitemPtr = ptr; + enterScope(false); + goto nextItem; + } + if (c == '{') { + m_proitemPtr = ptr; + enterScope(true); + goto nextItem; + } + if (c == '}') { + m_proitemPtr = ptr; + leaveScope(); + goto nextItem; + } + if (c == '=') { + m_proitemPtr = ptr; + insertVariable(&cur, end); + goto nextItem; + } + if (c == '|' || c == '!') { + m_proitemPtr = ptr; + insertOperator(c); + goto nextItem; + } } } } - } - if (c == ' ' || c == '\t') { - if (sts == Started) - sts = PutSpace; - } else { - putch: - if (sts == PutSpace) - *ptr++ = ' '; - *ptr++ = c; - sts = Started; + if (c == ' ' || c == '\t') { + if (sts == Started) { + sts = PutSpace; + if (escaped == Escaped) + escaped = PostEscaped; + } + } else { + putch1: + escaped = NotEscaped; + putch: + if (sts == PutSpace) + *ptr++ = ' '; + *ptr++ = c; + sts = Started; + } } - } - m_proitemPtr = ptr; - done1: - m_contNextLine = escaped; - done: - m_inQuote = inQuote; - m_parens = parens; - if (m_syntaxError) - return false; - if (m_contNextLine) { - --m_proitemPtr; + if (escaped != NotEscaped) { + --ptr; + if (ptr != (ushort *)m_proitem.unicode() && *(ptr - 1) == ' ') + --ptr; + } + m_proitemPtr = ptr; updateItem(); - } else { - updateItem(); - finalizeBlock(); + if (cmtptr) + insertComment(line.right(end - cmtptr).simplified()); + if (sts != NeverStarted && escaped == NotEscaped) + finalizeBlock(); + ++m_lineNo; } return true; } void ProFileEvaluator::Private::finalizeBlock() { - if (m_blockstack.isEmpty()) { - m_syntaxError = true; - } else { - if (m_blockstack.top()->blockKind() & ProBlock::SingleLine) - leaveScope(); - m_block = 0; - m_commentItem = 0; - } + if (m_blockstack.top()->blockKind() & ProBlock::SingleLine) + leaveScope(); + m_block = 0; + m_commentItem = 0; } void ProFileEvaluator::Private::insertVariable(const ushort **pCur, const ushort *end) @@ -528,8 +506,6 @@ void ProFileEvaluator::Private::insertOperator(const char op) void ProFileEvaluator::Private::insertComment(const QString &comment) { - updateItem(); - QString strComment; if (!m_commentItem) strComment = m_pendingComment; @@ -574,7 +550,10 @@ void ProFileEvaluator::Private::enterScope(bool multiLine) void ProFileEvaluator::Private::leaveScope() { updateItem(); - m_blockstack.pop(); + if (m_blockstack.count() == 1) + q->errorMessage(format("Excess closing brace.")); + else + m_blockstack.pop(); finalizeBlock(); } @@ -2420,26 +2399,20 @@ bool ProFileEvaluator::Private::evaluateFile(const QString &fileName) bool ProFileEvaluator::Private::evaluateFeatureFile(const QString &fileName) { - QString fn; + QString fn = QLatin1Char('/') + fileName; + if (!fn.endsWith(QLatin1String(".prf"))) + fn += QLatin1String(".prf"); foreach (const QString &path, qmakeFeaturePaths()) { - QString fname = path + QLatin1Char('/') + fileName; + QString fname = path + fn; if (QFileInfo(fname).exists()) { - fn = fname; - break; - } - fname += QLatin1String(".prf"); - if (QFileInfo(fname).exists()) { - fn = fname; - break; + bool cumulative = m_cumulative; + m_cumulative = false; + bool ok = evaluateFile(fname); + m_cumulative = cumulative; + return ok; } } - if (fn.isEmpty()) - return false; - bool cumulative = m_cumulative; - m_cumulative = false; - bool ok = evaluateFile(fn); - m_cumulative = cumulative; - return ok; + return false; } QString ProFileEvaluator::Private::format(const char *fmt) const diff --git a/tests/auto/debugger/main.cpp b/tests/auto/debugger/main.cpp index 4260e21ee0d..dab2b6ea238 100644 --- a/tests/auto/debugger/main.cpp +++ b/tests/auto/debugger/main.cpp @@ -3,6 +3,7 @@ #include <QtCore/QObject> #include <QtCore/QProcess> #include <QtCore/QFileInfo> +#include <QtCore/QMetaMethod> #include <QtCore/QModelIndex> #if QT_VERSION >= 0x040500 #include <QtCore/QSharedPointer> @@ -155,6 +156,7 @@ private slots: void dumpQObjectMethodList(); void dumpQObjectPropertyList(); void dumpQObjectSignal(); + void dumpQObjectSignalList(); void dumpQPixmap(); #if QT_VERSION >= 0x040500 void dumpQSharedPointer(); @@ -187,6 +189,7 @@ private: void dumpQObjectMethodListHelper(QObject &obj); void dumpQObjectPropertyListHelper(QObject &obj); void dumpQObjectSignalHelper(QObject &o, int sigNum); + void dumpQObjectSignalListHelper(QObject &o); void dumpQPixmapHelper(QPixmap &p); #if QT_VERSION >= 0x040500 template <typename T> @@ -1082,22 +1085,26 @@ static const char *connectionType(uint type) return output; }; +class Cheater : public QObject +{ +public: + static QObjectPrivate *getPrivate(QObject &o) + { + return dynamic_cast<QObjectPrivate *>(static_cast<Cheater&>(o).d_ptr); + } +}; + +typedef QVector<QObjectPrivate::ConnectionList> ConnLists; + + + void tst_Debugger::dumpQObjectSignalHelper(QObject &o, int sigNum) { - class Cheater : public QObject - { - public: - static QObjectPrivate *getPrivate(QObject &o) - { - return dynamic_cast<QObjectPrivate *>(static_cast<Cheater&>(o).d_ptr); - } - }; QByteArray expected("addr='<synthetic>',numchild='1',type='"NS"QObjectSignal'"); #if QT_VERSION >= 0x040400 expected.append(",children=["); const QObjectPrivate *p = Cheater::getPrivate(o); Q_ASSERT(p != 0); - typedef QVector<QObjectPrivate::ConnectionList> ConnLists; const ConnLists *connLists = reinterpret_cast<const ConnLists *>(p->connectionLists); QObjectPrivate::ConnectionList connList = connLists != 0 && connLists->size() > sigNum ? @@ -1176,9 +1183,75 @@ void tst_Debugger::dumpQObjectSignal() dumpQObjectSignalHelper(m, signalIndex); } +void tst_Debugger::dumpQObjectSignalListHelper(QObject &o) +{ + const QMetaObject *mo = o.metaObject(); + QList<QMetaMethod> methods; + for (int i = 0; i < mo->methodCount(); ++i) { + const QMetaMethod &method = mo->method(i); + if (method.methodType() == QMetaMethod::Signal) + methods.append(method); + } + QString sizeStr = QString::number(methods.size()); + QByteArray addrString = ptrToBa(&o); + QByteArray expected = QByteArray("tiname='$I',addr='$A',type='QObjectSignalList',value='<"). + append(sizeStr).append(" items>',addr='").append(addrString).append("',numchild='"). + append(sizeStr).append("'"); +#if QT_VERSION >= 0x040400 + expected.append(",children=["); + const QObjectPrivate *p = Cheater::getPrivate(o); + Q_ASSERT(p != 0); + const ConnLists *connLists = reinterpret_cast<const ConnLists *>(p->connectionLists); + for (int i = 0; i < methods.size(); ++i) { + const char * const signature = methods.at(i).signature(); + int sigNum = mo->indexOfSignal(signature); + QObjectPrivate::ConnectionList connList = + connLists != 0 && connLists->size() > sigNum ? + connLists->at(sigNum) : QObjectPrivate::ConnectionList(); + expected.append("{name='").append(QString::number(sigNum)).append("',value='"). + append(signature).append("',numchild='").append(QString::number(connList.size())). + append("',addr='").append(addrString).append("',type='"NS"QObjectSignal'}"); + if (i < methods.size() - 1) + expected.append(","); + } + expected.append("]"); +#endif + testDumper(expected, &o, NS"QObjectSignalList", true); +} + +void tst_Debugger::dumpQObjectSignalList() +{ + // Case 1: Simple QObject. + QObject o; + o.setObjectName("Test"); + dumpQObjectSignalListHelper(o); + + // Case 2: QAbstractItemModel with no connections. + QStringListModel m(QStringList() << "Test1" << "Test2"); + dumpQObjectSignalListHelper(m); + + // Case 3: QAbstractItemModel with connections to itself and to another + // object, using different connection types. + qRegisterMetaType<QModelIndex>("QModelIndex"); + connect(&m, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int)), + &o, SLOT(deleteLater()), Qt::DirectConnection); + connect(&m, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), + &m, SLOT(revert()), Qt::QueuedConnection); + connect(&m, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int)), + &m, SLOT(submit()), Qt::QueuedConnection); + connect(&m, SIGNAL(columnsInserted(const QModelIndex &, int, int)), + &m, SLOT(submit()), Qt::BlockingQueuedConnection); + connect(&m, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), + &m, SLOT(deleteLater()), Qt::AutoConnection); + dumpQObjectSignalListHelper(m); +} + void tst_Debugger::dumpQPixmapHelper(QPixmap &p) { - + QByteArray expected = QByteArray("value='(").append(QString::number(p.width())). + append("x").append(QString::number(p.height())). + append("',type='"NS"QPixmap',numchild='0'"); + testDumper(expected, &p, NS"QPixmap", true); } void tst_Debugger::dumpQPixmap() diff --git a/tests/manual/trk/README b/tests/manual/trk/README new file mode 100644 index 00000000000..9428873eabf --- /dev/null +++ b/tests/manual/trk/README @@ -0,0 +1,2 @@ +Run ./run.sh in one terminal. +Run ./gdb-symbian in a second terminal. diff --git a/tests/manual/trk/adapter.cpp b/tests/manual/trk/adapter.cpp index a9e53d082be..bb63735acb6 100644 --- a/tests/manual/trk/adapter.cpp +++ b/tests/manual/trk/adapter.cpp @@ -112,6 +112,7 @@ private: void handleSetBreakpoint(const TrkResult &result); void handleClearBreakpoint(const TrkResult &result); void handleContinue(const TrkResult &result); + void handleSignalContinue(const TrkResult &result); void handleReadInfo(const TrkResult &result); void handleWaitForFinished(const TrkResult &result); void handleStep(const TrkResult &result); @@ -359,7 +360,21 @@ void Adapter::writeToGdb(const QByteArray &msg, const QByteArray &logNote) void Adapter::handleGdbResponse(const QByteArray &response) { // http://sourceware.org/gdb/current/onlinedocs/gdb_34.html - if (response == "g") { + + if (0) {} + + else if (response.startsWith("C")) { + // C sig[;addr] Continue with signal sig (hex signal number) + //Reply: See section D.3 Stop Reply Packets, for the reply specifications. + bool ok = false; + uint signalNumber = response.mid(1).toInt(&ok, 16); + QByteArray ba; + appendInt(&ba, m_session.pid); + appendInt(&ba, m_session.tid); + sendTrkMessage(0x18, CB(handleSignalContinue), ba, signalNumber); // Continue + } + + else if (response == "g") { // Read general registers. //writeToGdb("00000000", "read registers"); QByteArray ba; @@ -392,20 +407,68 @@ void Adapter::handleGdbResponse(const QByteArray &response) + QByteArray::number(m_session.currentThread)); } + else if (response == "k") { + // kill + QByteArray ba; + appendByte(&ba, 0); // Sub-command: Delete Process + appendInt(&ba, m_session.pid); + sendTrkMessage(0x41, CB(handleDeleteProcess), ba); // Delete Item + } + else if (response.startsWith("m")) { // m addr,length int pos = response.indexOf(','); bool ok = false; uint addr = response.mid(1, pos - 1).toInt(&ok, 16); uint len = response.mid(pos + 1).toInt(&ok, 16); - //qDebug() << "ADDR: " << QByteArray::number(addr, 16) << " " - // << QByteArray::number(len, 16); + //qDebug() << "GDB ADDR: " << hexNumber(addr) << " " << hexNumber(len); readMemory(addr, len); } - else if (response == "pf") { - // current instruction pointer? - writeToGdb("0000", "current IP"); + else if (response.startsWith("p")) { + // 0xf == current instruction pointer? + //writeToGdb("0000", "current IP"); + #if 0 + A1 = 0, first integer-like argument + A4 = 3, last integer-like argument + AP = 11, + IP = 12, + SP = 13, Contains address of top of stack + LR = 14, address to return to from a function call + PC = 15, Contains program counter + F0 = 16, first floating point register + F3 = 19, last floating point argument register + F7 = 23, last floating point register + FPS = 24, floating point status register + PS = 25, Contains processor status + WR0, WMMX data registers. + WR15 = WR0 + 15, + WC0, WMMX control registers. + WCSSF = WC0 + 2, + WCASF = WC0 + 3, + WC7 = WC0 + 7, + WCGR0, WMMX general purpose registers. + WCGR3 = WCGR0 + 3, + WCGR7 = WCGR0 + 7, + NUM_REGS, + + // Other useful registers. + FP = 11, Frame register in ARM code, if used. + THUMB_FP = 7, Frame register in Thumb code, if used. + NUM_ARG_REGS = 4, + LAST_ARG = A4, + NUM_FP_ARG_REGS = 4, + LAST_FP_ARG = F3 + #endif + bool ok = false; + uint registerNumber = response.mid(1).toInt(&ok, 16); + if (registerNumber < registerCount) { + QByteArray ba; + appendInt(&ba, m_snapshot.registers[registerNumber]); + writeToGdb(ba.toHex(), "read single known register"); + } else { + writeToGdb("0000", "read single unknown register"); + } } else if (response == "qAttached") { @@ -438,6 +501,12 @@ void Adapter::handleGdbResponse(const QByteArray &response) writeToGdb(QByteArray()); } + else if (response == "qSymbol::") { + // Notify the target that GDB is prepared to serve symbol lookup requests. + writeToGdb("OK", "no further symbols needed"); + //writeToGdb("qSymbol:" + QByteArray("_Z7E32Mainv").toHex(), "ask for more"); + } + else if (response == "QStartNoAckMode") { //$qSupported#37 //logMessage("Handling 'QStartNoAckMode'"); @@ -445,6 +514,16 @@ void Adapter::handleGdbResponse(const QByteArray &response) m_gdbAckMode = false; } + else if (response == "vCont?") { + // actions supported by the vCont packet + writeToGdb(""); + //writeToGdb("vCont;c"); + } + + //else if (response.startsWith("vCont")) { + // // vCont[;action[:thread-id]]...' + //} + else if (response.startsWith("?")) { // Indicate the reason the target halted. // The reply is the same as for step and continue. @@ -506,7 +585,7 @@ void Adapter::timerEvent(QTimerEvent *) tryTrkRead(); } -unsigned char Adapter::nextTrkWriteToken() +byte Adapter::nextTrkWriteToken() { ++m_trkWriteToken; if (m_trkWriteToken == 0) @@ -881,18 +960,7 @@ void Adapter::handleAndReportReadRegisters(const TrkResult &result) //logMessage(" RESULT: " + result.toString()); // [80 0B 00 00 00 00 00 C9 24 FF BC 00 00 00 00 00 // 60 00 00 00 00 00 00 78 67 79 70 00 00 00 00 00...] - QByteArray ba; -#if 0 - char buf[30]; - const char *data = result.data.data(); - for (int i = 0; i != registerCount; ++i) { - uint value = extractInt(data + 4 * i + 1); - qsnprintf(buf, sizeof(buf) - 1, "%08x", value); - ba.append(buf); - } -#else - ba = result.data.toHex(); -#endif + QByteArray ba = result.data.toHex(); writeToGdb(ba, "register contents"); } @@ -903,7 +971,7 @@ void Adapter::handleReadMemory(const TrkResult &result) uint blockaddr = result.cookie.toInt(); //qDebug() << "READING " << ba.size() << " BYTES: " // << quoteUnprintableLatin1(ba) - // << "ADDR: " << QByteArray::number(blockaddr, 16) + // << "ADDR: " << hexNumber(blockaddr) // << "COOKIE: " << result.cookie; m_snapshot.memory[blockaddr] = ba; } @@ -924,7 +992,7 @@ void Adapter::reportReadMemory(const TrkResult &result) ba = ba.mid(addr % memoryChunkSize, len); // qDebug() << "REPORTING MEMORY " << ba.size() - // << " ADDR: " << QByteArray::number(blockaddr, 16) << " LEN: " << len + // << " ADDR: " << hexNumber(blockaddr) << " LEN: " << len // << " BYTES: " << quoteUnprintableLatin1(ba); writeToGdb(ba.toHex(), "memory contents"); @@ -994,34 +1062,28 @@ void Adapter::handleClearBreakpoint(const TrkResult &result) logMessage("CLEAR BREAKPOINT "); } +void Adapter::handleSignalContinue(const TrkResult &result) +{ + int signalNumber = result.cookie.toInt(); + logMessage(" HANDLE SIGNAL CONTINUE: " + stringFromArray(result.data)); + qDebug() << "NUMBER" << signalNumber; + writeToGdb("O" + QByteArray("Console output").toHex()); + writeToGdb("W81"); // "Process exited with result 1 +} + void Adapter::handleContinue(const TrkResult &result) { logMessage(" HANDLE CONTINUE: " + stringFromArray(result.data)); - //if (result.result.token) - //logMessage(" ERROR: " + byte(result.result.token) - // sendTrkMessage(0x18, CB(handleContinue), - // formatInt(m_session.pid) + formatInt(m_session.tid)); - //} } void Adapter::handleDisconnect(const TrkResult &result) { logMessage(" HANDLE DISCONNECT: " + stringFromArray(result.data)); - //if (result.result.token) - //logMessage(" ERROR: " + byte(result.result.token) - // sendTrkMessage(0x18, CB(handleContinue), - // formatInt(m_session.pid) + formatInt(m_session.tid)); - //} } void Adapter::handleDeleteProcess(const TrkResult &result) { logMessage(" HANDLE DELETE PROCESS: " + stringFromArray(result.data)); - //if (result.result.token) - //logMessage(" ERROR: " + byte(result.token) - // sendTrkMessage(0x18, CB(handleContinue), - // formatInt(m_session.pid) + formatInt(m_session.tid)); - //} } void Adapter::handleStep(const TrkResult &result) diff --git a/tests/manual/trk/run.sh b/tests/manual/trk/run.sh index f3aeba72173..6d1eb142149 100755 --- a/tests/manual/trk/run.sh +++ b/tests/manual/trk/run.sh @@ -8,12 +8,12 @@ killall adapter trkserver > /dev/null 2>&1 trkservername="TRKSERVER-4"; gdbserverip=127.0.0.1 gdbserverport=2226 -replaysource=dump.txt +memorydump=TrkDump-78-6a-40-00.bin fuser -n tcp -k ${gdbserverport} rm /tmp/${trkservername} -./trkserver ${trkservername} ${replaysource} & +./trkserver ${trkservername} ${memorydump} & trkserverpid=$! sleep 1 @@ -22,19 +22,13 @@ sleep 1 adapterpid=$! echo " +# This is generated. Changes will be lost. set remote noack-packet on +set endian big target remote ${gdbserverip}:${gdbserverport} file filebrowseapp.sym -quit -" > gdb.txt - -./arm-gdb -x gdb.txt - -#sleep 4 - -kill -s USR1 ${adapterpid} -kill -s USR1 ${trkserverpid} - -echo +" > .gdbinit +#kill -s USR1 ${adapterpid} +#kill -s USR1 ${trkserverpid} #killall arm-gdb diff --git a/tests/manual/trk/trkserver.cpp b/tests/manual/trk/trkserver.cpp index ce3e6fb18fe..48ce6c3aff5 100644 --- a/tests/manual/trk/trkserver.cpp +++ b/tests/manual/trk/trkserver.cpp @@ -72,7 +72,7 @@ Inferior::Inferior() { pid = 0x000008F5; tid = 0x000008F6; - codeseg = 0x78674000; + codeseg = 0x786A4000; dataseg = 0x00400000; } @@ -85,7 +85,7 @@ public: ~TrkServer(); void setServerName(const QString &name) { m_serverName = name; } - void setReplaySource(const QString &source) { m_replaySource = source; } + void setMemoryDumpName(const QString &source) { m_memoryDumpName = source; } void startServer(); private slots: @@ -97,22 +97,25 @@ private slots: private: void logMessage(const QString &msg); + byte nextNotificationToken(); QString m_serverName; - QString m_replaySource; + QString m_memoryDumpName; QByteArray m_adapterReadBuffer; - QList<QByteArray> m_replayData; + QByteArray m_memoryData; QLocalServer m_server; int m_lastSent; QLocalSocket *m_adapterConnection; Inferior m_inferior; + byte m_notificationToken; }; TrkServer::TrkServer() { m_adapterConnection = 0; + m_notificationToken = 0; } TrkServer::~TrkServer() @@ -123,13 +126,13 @@ TrkServer::~TrkServer() void TrkServer::startServer() { - QFile file(m_replaySource); + QFile file(m_memoryDumpName); file.open(QIODevice::ReadOnly); - m_replayData = file.readAll().split('\n'); + m_memoryData = file.readAll(); file.close(); - logMessage(QString("Read %1 lines of data from %2") - .arg(m_replayData.size()).arg(m_replaySource)); + logMessage(QString("Read %1 bytes of data from %2") + .arg(m_memoryData.size()).arg(m_memoryDumpName)); m_lastSent = 0; if (!m_server.listen(m_serverName)) { @@ -149,26 +152,11 @@ void TrkServer::logMessage(const QString &msg) void TrkServer::handleConnection() { - //QByteArray block; - - //QByteArray msg = m_replayData[m_lastSent ++]; - - //QDataStream out(&block, QIODevice::WriteOnly); - //out.setVersion(QDataStream::Qt_4_0); - //out << (quint16)0; - //out << m_replayData; - //out.device()->seek(0); - //out << (quint16)(block.size() - sizeof(quint16)); - m_adapterConnection = m_server.nextPendingConnection(); connect(m_adapterConnection, SIGNAL(disconnected()), m_adapterConnection, SLOT(deleteLater())); connect(m_adapterConnection, SIGNAL(readyRead()), this, SLOT(readFromAdapter())); - - //m_adapterConnection->write(block); - //m_adapterConnection->flush(); - //m_adapterConnection->disconnectFromHost(); } void TrkServer::readFromAdapter() @@ -198,6 +186,7 @@ void TrkServer::handleAdapterMessage(const TrkResult &result) data.append(char(0x00)); // No error switch (result.code) { case 0x00: { // Ping + m_notificationToken = 0; writeToAdapter(0x80, 0x00, data); break; } @@ -211,25 +200,58 @@ void TrkServer::handleAdapterMessage(const TrkResult &result) Q_UNUSED(option); ushort len = extractShort(p + 1); uint addr = extractInt(p + 3); - qDebug() << "ADDR: " << QByteArray::number(addr, 16) << " " - << QByteArray::number(len, 16); + //qDebug() << "MESSAGE: " << result.data.toHex(); + qDebug() << "ADDR: " << hexNumber(addr) << " " << hexNumber(len); + if (addr < m_inferior.codeseg + || addr + len >= m_inferior.codeseg + m_memoryData.size()) { + qDebug() << "ADDRESS OUTSIDE CODESEG: " << hexNumber(addr) + << hexNumber(m_inferior.codeseg); + for (int i = 0; i != len / 4; ++i) + appendInt(&data, 0xDEADBEEF); + } for (int i = 0; i != len; ++i) - appendByte(&data, i); + appendByte(&data, m_memoryData[addr - m_inferior.codeseg + i]); writeToAdapter(0x80, result.token, data); break; } case 0x12: { // Read Registers - appendInt(&data, 0x00000000, BigEndian); - appendInt(&data, 0xC924FFBC, BigEndian); + appendByte(&data, 0x00); + appendByte(&data, 0x00); + appendByte(&data, 0x00); + appendInt(&data, 0xC92D7FBC, BigEndian); appendInt(&data, 0x00000000, BigEndian); appendInt(&data, 0x00600000, BigEndian); - appendInt(&data, 0x78677970, BigEndian); - for (int i = 5; i < registerCount - 1; ++i) - appendInt(&data, i + (i << 16), BigEndian); - appendInt(&data, 0x78676B00, BigEndian); + appendInt(&data, 0x00000000, BigEndian); + appendInt(&data, 0x786A7970, BigEndian); + appendInt(&data, 0x00000000, BigEndian); + appendInt(&data, 0x00000000, BigEndian); + appendInt(&data, 0x00000012, BigEndian); + appendInt(&data, 0x00000040, BigEndian); + appendInt(&data, 0xC82AF210, BigEndian); + appendInt(&data, 0x00000000, BigEndian); + appendInt(&data, 0xC8000548, BigEndian); + appendInt(&data, 0x00403ED0, BigEndian); + appendInt(&data, 0x786A6BD8, BigEndian); + appendInt(&data, 0x786A4CC8, BigEndian); + appendInt(&data, 0x68000010, BigEndian); writeToAdapter(0x80, result.token, data); break; } + case 0x18: { // Continue + writeToAdapter(0x80, result.token, data); // ACK Package + + if (0) { // Fake "Stop" + QByteArray note; + appendInt(¬e, 0); // FIXME: use proper address + appendInt(¬e, m_inferior.pid); + appendInt(¬e, m_inferior.tid); + appendByte(¬e, 0x00); + appendByte(¬e, 0x00); + writeToAdapter(0x90, nextNotificationToken(), note); + } + + break; + } case 0x40: { // Create Item appendInt(&data, m_inferior.pid, BigEndian); appendInt(&data, m_inferior.tid, BigEndian); @@ -238,6 +260,20 @@ void TrkServer::handleAdapterMessage(const TrkResult &result) writeToAdapter(0x80, result.token, data); break; } + case 0x41: { // Delete Item + writeToAdapter(0x80, result.token, data); + + // A Process? + // Command: 0xA1 Notify Deleted + //[A1 02 00 00 00 00 00 00 00 00 01 B5] + QByteArray note; // FIXME + appendByte(¬e, 0); + appendByte(¬e, 0); + appendInt(¬e, 0); + appendInt(¬e, m_inferior.pid); + writeToAdapter(0xA1, nextNotificationToken(), note); + break; + } default: data[0] = 0x10; // Command not supported writeToAdapter(0xff, result.token, data); @@ -246,6 +282,14 @@ void TrkServer::handleAdapterMessage(const TrkResult &result) } +byte TrkServer::nextNotificationToken() +{ + ++m_notificationToken; + if (m_notificationToken == 0) + ++m_notificationToken; + return m_notificationToken; +} + int main(int argc, char *argv[]) { if (argc < 3) { @@ -262,7 +306,7 @@ int main(int argc, char *argv[]) TrkServer server; server.setServerName(argv[1]); - server.setReplaySource(argv[2]); + server.setMemoryDumpName(argv[2]); server.startServer(); return app.exec(); diff --git a/tests/manual/trk/trkutils.cpp b/tests/manual/trk/trkutils.cpp index 8a3b67a9f39..3ab9d57d0f2 100644 --- a/tests/manual/trk/trkutils.cpp +++ b/tests/manual/trk/trkutils.cpp @@ -35,6 +35,11 @@ namespace trk { +QByteArray hexNumber(uint n) +{ + return QByteArray::number(n, 16); +} + QString TrkResult::toString() const { QString res = stringFromByte(code) + "[" + stringFromByte(token); @@ -236,15 +241,15 @@ void appendInt(QByteArray *ba, uint i, Endianness endian) int b1 = i % 256; i -= b1; i /= 256; int b0 = i % 256; i -= b0; i /= 256; if (endian == BigEndian) { - ba->append(b3); - ba->append(b2); - ba->append(b1); ba->append(b0); + ba->append(b1); + ba->append(b2); + ba->append(b3); } else { - ba->append(b0); - ba->append(b1); - ba->append(b2); ba->append(b3); + ba->append(b2); + ba->append(b1); + ba->append(b0); } } diff --git a/tests/manual/trk/trkutils.h b/tests/manual/trk/trkutils.h index 81e50c66147..2bb3965a7b0 100644 --- a/tests/manual/trk/trkutils.h +++ b/tests/manual/trk/trkutils.h @@ -72,7 +72,7 @@ enum CodeMode enum TargetConstants { - registerCount = 16, + registerCount = 17, memoryChunkSize = 256 }; @@ -147,6 +147,7 @@ struct TrkResult QByteArray frameMessage(byte command, byte token, const QByteArray &data); TrkResult extractResult(QByteArray *buffer); QByteArray errorMessage(byte code); +QByteArray hexNumber(uint n); } // namespace trk