diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Tests/QtAutogen | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Tests/QtAutogen')
53 files changed, 830 insertions, 859 deletions
diff --git a/Tests/QtAutogen/Adir/libA.cpp b/Tests/QtAutogen/Adir/libA.cpp index 3968c44..f79f24a 100644 --- a/Tests/QtAutogen/Adir/libA.cpp +++ b/Tests/QtAutogen/Adir/libA.cpp @@ -1,10 +1,9 @@ #include "libA.h" -LibA::LibA(QObject *parent) +LibA::LibA(QObject* parent) : QObject(parent) { - } int LibA::foo() diff --git a/Tests/QtAutogen/Adir/libA.h b/Tests/QtAutogen/Adir/libA.h index 03ad1e0..c4eb9f7 100644 --- a/Tests/QtAutogen/Adir/libA.h +++ b/Tests/QtAutogen/Adir/libA.h @@ -10,7 +10,7 @@ class LIBA_EXPORT LibA : public QObject { Q_OBJECT public: - explicit LibA(QObject *parent = 0); + explicit LibA(QObject* parent = 0); int foo(); }; diff --git a/Tests/QtAutogen/Bdir/libB.cpp b/Tests/QtAutogen/Bdir/libB.cpp index 72f2cfa..d3b6753 100644 --- a/Tests/QtAutogen/Bdir/libB.cpp +++ b/Tests/QtAutogen/Bdir/libB.cpp @@ -1,10 +1,9 @@ #include "libB.h" -LibB::LibB(QObject *parent) +LibB::LibB(QObject* parent) : QObject(parent) { - } int LibB::foo() diff --git a/Tests/QtAutogen/Bdir/libB.h b/Tests/QtAutogen/Bdir/libB.h index 746b67a..e4ab788 100644 --- a/Tests/QtAutogen/Bdir/libB.h +++ b/Tests/QtAutogen/Bdir/libB.h @@ -11,9 +11,10 @@ class LIBB_EXPORT LibB : public QObject { Q_OBJECT public: - explicit LibB(QObject *parent = 0); + explicit LibB(QObject* parent = 0); int foo(); + private: LibA a; }; diff --git a/Tests/QtAutogen/abc.cpp b/Tests/QtAutogen/abc.cpp index 4bbc769..b19c2a1 100644 --- a/Tests/QtAutogen/abc.cpp +++ b/Tests/QtAutogen/abc.cpp @@ -11,7 +11,6 @@ See the License for more information. ============================================================================*/ - #include "abc.h" #include "abc_p.h" @@ -20,18 +19,20 @@ class PrintAbc : public QObject { Q_OBJECT - public: - PrintAbc():QObject() {} - public slots: - void print() const { printf("abc\n"); } +public: + PrintAbc() + : QObject() + { + } +public slots: + void print() const { printf("abc\n"); } }; Abc::Abc() -:QObject() + : QObject() { } - void Abc::doAbc() { PrintAbc pa; diff --git a/Tests/QtAutogen/abc.h b/Tests/QtAutogen/abc.h index d1924b0..dc085b1 100644 --- a/Tests/QtAutogen/abc.h +++ b/Tests/QtAutogen/abc.h @@ -19,10 +19,10 @@ class Abc : public QObject { Q_OBJECT - public: - Abc(); - public slots: - void doAbc(); +public: + Abc(); +public slots: + void doAbc(); }; #endif diff --git a/Tests/QtAutogen/abc_p.h b/Tests/QtAutogen/abc_p.h index 952fff3..c9139b7 100644 --- a/Tests/QtAutogen/abc_p.h +++ b/Tests/QtAutogen/abc_p.h @@ -21,10 +21,10 @@ class AbcP : public QObject { Q_OBJECT - public: - AbcP() {} - public slots: - void doAbcP() { printf("I am private abc !\n"); } +public: + AbcP() {} +public slots: + void doAbcP() { printf("I am private abc !\n"); } }; #endif diff --git a/Tests/QtAutogen/bar.cpp b/Tests/QtAutogen/bar.cpp index 8be4815..2eefd08 100644 --- a/Tests/QtAutogen/bar.cpp +++ b/Tests/QtAutogen/bar.cpp @@ -16,7 +16,7 @@ #include <stdio.h> Bar::Bar() -:QObject() + : QObject() { } diff --git a/Tests/QtAutogen/blub.cpp b/Tests/QtAutogen/blub.cpp index bd53972..bbebf08 100644 --- a/Tests/QtAutogen/blub.cpp +++ b/Tests/QtAutogen/blub.cpp @@ -18,17 +18,19 @@ class BlubBlub : public QObject { Q_OBJECT - public: - BlubBlub():QObject() {} - public slots: - int getValue() const { return 13; } +public: + BlubBlub() + : QObject() + { + } +public slots: + int getValue() const { return 13; } }; Blub::Blub() { } - void Blub::blubber() { BlubBlub bb; diff --git a/Tests/QtAutogen/blub.h b/Tests/QtAutogen/blub.h index 1967bc1..7097b67 100644 --- a/Tests/QtAutogen/blub.h +++ b/Tests/QtAutogen/blub.h @@ -18,9 +18,9 @@ class Blub { - public: - Blub(); - void blubber(); +public: + Blub(); + void blubber(); }; #endif diff --git a/Tests/QtAutogen/calwidget.cpp b/Tests/QtAutogen/calwidget.cpp index 0e314cd..380e982 100644 --- a/Tests/QtAutogen/calwidget.cpp +++ b/Tests/QtAutogen/calwidget.cpp @@ -38,400 +38,399 @@ ** ****************************************************************************/ - #include <QCalendarWidget> - #include <QCheckBox> - #include <QComboBox> - #include <QDateEdit> - #include <QGridLayout> - #include <QGroupBox> - #include <QLabel> - #include <QTextCharFormat> - - #include "calwidget.h" - - #include "ui_calwidget.h" - #ifdef UI_CALWIDGET_H - #error Definition of UI_CALWIDGET_H should be disabled by file option. - #endif - - Window::Window() +#include <QCalendarWidget> +#include <QCheckBox> +#include <QComboBox> +#include <QDateEdit> +#include <QGridLayout> +#include <QGroupBox> +#include <QLabel> +#include <QTextCharFormat> + +#include "calwidget.h" + +#include "ui_calwidget.h" +#ifdef UI_CALWIDGET_H +#error Definition of UI_CALWIDGET_H should be disabled by file option. +#endif + +Window::Window() : ui(new Ui::Window) - { - createPreviewGroupBox(); - createGeneralOptionsGroupBox(); - createDatesGroupBox(); - createTextFormatsGroupBox(); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(previewGroupBox, 0, 0); - layout->addWidget(generalOptionsGroupBox, 0, 1); - layout->addWidget(datesGroupBox, 1, 0); - layout->addWidget(textFormatsGroupBox, 1, 1); - layout->setSizeConstraint(QLayout::SetFixedSize); - setLayout(layout); - - previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height()); - previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width()); - - setWindowTitle(tr("Calendar Widget")); - } - - void Window::localeChanged(int index) - { - calendar->setLocale(localeCombo->itemData(index).toLocale()); - } - - void Window::firstDayChanged(int index) - { - calendar->setFirstDayOfWeek(Qt::DayOfWeek( - firstDayCombo->itemData(index).toInt())); - } - - void Window::selectionModeChanged(int index) - { - calendar->setSelectionMode(QCalendarWidget::SelectionMode( - selectionModeCombo->itemData(index).toInt())); - } - - void Window::horizontalHeaderChanged(int index) - { - calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat( - horizontalHeaderCombo->itemData(index).toInt())); - } - - void Window::verticalHeaderChanged(int index) - { - calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat( - verticalHeaderCombo->itemData(index).toInt())); - } - - void Window::selectedDateChanged() - { - currentDateEdit->setDate(calendar->selectedDate()); - } - - void Window::minimumDateChanged(const QDate &date) - { - calendar->setMinimumDate(date); - maximumDateEdit->setDate(calendar->maximumDate()); - } - - void Window::maximumDateChanged(const QDate &date) - { - calendar->setMaximumDate(date); - minimumDateEdit->setDate(calendar->minimumDate()); - } - - void Window::weekdayFormatChanged() - { - QTextCharFormat format; - - format.setForeground(qvariant_cast<QColor>( - weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); - calendar->setWeekdayTextFormat(Qt::Monday, format); - calendar->setWeekdayTextFormat(Qt::Tuesday, format); - calendar->setWeekdayTextFormat(Qt::Wednesday, format); - calendar->setWeekdayTextFormat(Qt::Thursday, format); - calendar->setWeekdayTextFormat(Qt::Friday, format); - } - - void Window::weekendFormatChanged() - { - QTextCharFormat format; - - format.setForeground(qvariant_cast<QColor>( - weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); - calendar->setWeekdayTextFormat(Qt::Saturday, format); - calendar->setWeekdayTextFormat(Qt::Sunday, format); - } - - void Window::reformatHeaders() - { - QString text = headerTextFormatCombo->currentText(); - QTextCharFormat format; - - if (text == tr("Bold")) { - format.setFontWeight(QFont::Bold); - } else if (text == tr("Italic")) { - format.setFontItalic(true); - } else if (text == tr("Green")) { - format.setForeground(Qt::green); - } - calendar->setHeaderTextFormat(format); - } - - void Window::reformatCalendarPage() - { - if (firstFridayCheckBox->isChecked()) { - QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); - while (firstFriday.dayOfWeek() != Qt::Friday) - firstFriday = firstFriday.addDays(1); - QTextCharFormat firstFridayFormat; - firstFridayFormat.setForeground(Qt::blue); - calendar->setDateTextFormat(firstFriday, firstFridayFormat); - } - - //May First in Red takes precedence - if (mayFirstCheckBox->isChecked()) { - const QDate mayFirst(calendar->yearShown(), 5, 1); - QTextCharFormat mayFirstFormat; - mayFirstFormat.setForeground(Qt::red); - calendar->setDateTextFormat(mayFirst, mayFirstFormat); - } - } - - void Window::createPreviewGroupBox() - { - previewGroupBox = new QGroupBox(tr("Preview")); - - calendar = new QCalendarWidget; - calendar->setMinimumDate(QDate(1900, 1, 1)); - calendar->setMaximumDate(QDate(3000, 1, 1)); - calendar->setGridVisible(true); - - connect(calendar, SIGNAL(currentPageChanged(int,int)), - this, SLOT(reformatCalendarPage())); - - previewLayout = new QGridLayout; - previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); - previewGroupBox->setLayout(previewLayout); - } - - void Window::createGeneralOptionsGroupBox() - { - generalOptionsGroupBox = new QGroupBox(tr("General Options")); - - localeCombo = new QComboBox; - int curLocaleIndex = -1; - int index = 0; - for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { - QLocale::Language lang = static_cast<QLocale::Language>(_lang); - QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang); - for (int i = 0; i < countries.count(); ++i) { - QLocale::Country country = countries.at(i); - QString label = QLocale::languageToString(lang); - label += QLatin1Char('/'); - label += QLocale::countryToString(country); - QLocale locale(lang, country); - if (this->locale().language() == lang && this->locale().country() == country) - curLocaleIndex = index; - localeCombo->addItem(label, locale); - ++index; - } - } - if (curLocaleIndex != -1) - localeCombo->setCurrentIndex(curLocaleIndex); - localeLabel = new QLabel(tr("&Locale")); - localeLabel->setBuddy(localeCombo); - - firstDayCombo = new QComboBox; - firstDayCombo->addItem(tr("Sunday"), Qt::Sunday); - firstDayCombo->addItem(tr("Monday"), Qt::Monday); - firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday); - firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday); - firstDayCombo->addItem(tr("Thursday"), Qt::Thursday); - firstDayCombo->addItem(tr("Friday"), Qt::Friday); - firstDayCombo->addItem(tr("Saturday"), Qt::Saturday); - - firstDayLabel = new QLabel(tr("Wee&k starts on:")); - firstDayLabel->setBuddy(firstDayCombo); - - selectionModeCombo = new QComboBox; - selectionModeCombo->addItem(tr("Single selection"), - QCalendarWidget::SingleSelection); - selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection); - - selectionModeLabel = new QLabel(tr("&Selection mode:")); - selectionModeLabel->setBuddy(selectionModeCombo); - - gridCheckBox = new QCheckBox(tr("&Grid")); - gridCheckBox->setChecked(calendar->isGridVisible()); - - navigationCheckBox = new QCheckBox(tr("&Navigation bar")); - navigationCheckBox->setChecked(true); - - horizontalHeaderCombo = new QComboBox; - horizontalHeaderCombo->addItem(tr("Single letter day names"), - QCalendarWidget::SingleLetterDayNames); - horizontalHeaderCombo->addItem(tr("Short day names"), - QCalendarWidget::ShortDayNames); - horizontalHeaderCombo->addItem(tr("None"), - QCalendarWidget::NoHorizontalHeader); - horizontalHeaderCombo->setCurrentIndex(1); - - horizontalHeaderLabel = new QLabel(tr("&Horizontal header:")); - horizontalHeaderLabel->setBuddy(horizontalHeaderCombo); - - verticalHeaderCombo = new QComboBox; - verticalHeaderCombo->addItem(tr("ISO week numbers"), - QCalendarWidget::ISOWeekNumbers); - verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader); - - verticalHeaderLabel = new QLabel(tr("&Vertical header:")); - verticalHeaderLabel->setBuddy(verticalHeaderCombo); - - connect(localeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(localeChanged(int))); - connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(firstDayChanged(int))); - connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(selectionModeChanged(int))); - connect(gridCheckBox, SIGNAL(toggled(bool)), - calendar, SLOT(setGridVisible(bool))); - connect(navigationCheckBox, SIGNAL(toggled(bool)), - calendar, SLOT(setNavigationBarVisible(bool))); - connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(horizontalHeaderChanged(int))); - connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(verticalHeaderChanged(int))); - - QHBoxLayout *checkBoxLayout = new QHBoxLayout; - checkBoxLayout->addWidget(gridCheckBox); - checkBoxLayout->addStretch(); - checkBoxLayout->addWidget(navigationCheckBox); - - QGridLayout *outerLayout = new QGridLayout; - outerLayout->addWidget(localeLabel, 0, 0); - outerLayout->addWidget(localeCombo, 0, 1); - outerLayout->addWidget(firstDayLabel, 1, 0); - outerLayout->addWidget(firstDayCombo, 1, 1); - outerLayout->addWidget(selectionModeLabel, 2, 0); - outerLayout->addWidget(selectionModeCombo, 2, 1); - outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); - outerLayout->addWidget(horizontalHeaderLabel, 4, 0); - outerLayout->addWidget(horizontalHeaderCombo, 4, 1); - outerLayout->addWidget(verticalHeaderLabel, 5, 0); - outerLayout->addWidget(verticalHeaderCombo, 5, 1); - generalOptionsGroupBox->setLayout(outerLayout); - - firstDayChanged(firstDayCombo->currentIndex()); - selectionModeChanged(selectionModeCombo->currentIndex()); - horizontalHeaderChanged(horizontalHeaderCombo->currentIndex()); - verticalHeaderChanged(verticalHeaderCombo->currentIndex()); - } - - void Window::createDatesGroupBox() - { - datesGroupBox = new QGroupBox(tr("Dates")); - - minimumDateEdit = new QDateEdit; - minimumDateEdit->setDisplayFormat("MMM d yyyy"); - minimumDateEdit->setDateRange(calendar->minimumDate(), - calendar->maximumDate()); - minimumDateEdit->setDate(calendar->minimumDate()); - - minimumDateLabel = new QLabel(tr("&Minimum Date:")); - minimumDateLabel->setBuddy(minimumDateEdit); - - currentDateEdit = new QDateEdit; - currentDateEdit->setDisplayFormat("MMM d yyyy"); - currentDateEdit->setDate(calendar->selectedDate()); - currentDateEdit->setDateRange(calendar->minimumDate(), - calendar->maximumDate()); - - currentDateLabel = new QLabel(tr("&Current Date:")); - currentDateLabel->setBuddy(currentDateEdit); - - maximumDateEdit = new QDateEdit; - maximumDateEdit->setDisplayFormat("MMM d yyyy"); - maximumDateEdit->setDateRange(calendar->minimumDate(), - calendar->maximumDate()); - maximumDateEdit->setDate(calendar->maximumDate()); - - maximumDateLabel = new QLabel(tr("Ma&ximum Date:")); - maximumDateLabel->setBuddy(maximumDateEdit); - - connect(currentDateEdit, SIGNAL(dateChanged(QDate)), - calendar, SLOT(setSelectedDate(QDate))); - connect(calendar, SIGNAL(selectionChanged()), - this, SLOT(selectedDateChanged())); - connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), - this, SLOT(minimumDateChanged(QDate))); - connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), - this, SLOT(maximumDateChanged(QDate))); - - QGridLayout *dateBoxLayout = new QGridLayout; - dateBoxLayout->addWidget(currentDateLabel, 1, 0); - dateBoxLayout->addWidget(currentDateEdit, 1, 1); - dateBoxLayout->addWidget(minimumDateLabel, 0, 0); - dateBoxLayout->addWidget(minimumDateEdit, 0, 1); - dateBoxLayout->addWidget(maximumDateLabel, 2, 0); - dateBoxLayout->addWidget(maximumDateEdit, 2, 1); - dateBoxLayout->setRowStretch(3, 1); - - datesGroupBox->setLayout(dateBoxLayout); - } - - void Window::createTextFormatsGroupBox() - { - textFormatsGroupBox = new QGroupBox(tr("Text Formats")); - - weekdayColorCombo = createColorComboBox(); - weekdayColorCombo->setCurrentIndex( - weekdayColorCombo->findText(tr("Black"))); - - weekdayColorLabel = new QLabel(tr("&Weekday color:")); - weekdayColorLabel->setBuddy(weekdayColorCombo); - - weekendColorCombo = createColorComboBox(); - weekendColorCombo->setCurrentIndex( - weekendColorCombo->findText(tr("Red"))); - - weekendColorLabel = new QLabel(tr("Week&end color:")); - weekendColorLabel->setBuddy(weekendColorCombo); - - headerTextFormatCombo = new QComboBox; - headerTextFormatCombo->addItem(tr("Bold")); - headerTextFormatCombo->addItem(tr("Italic")); - headerTextFormatCombo->addItem(tr("Plain")); - - headerTextFormatLabel = new QLabel(tr("&Header text:")); - headerTextFormatLabel->setBuddy(headerTextFormatCombo); - - firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue")); - - mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); - - connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(weekdayFormatChanged())); - connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(weekendFormatChanged())); - connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), - this, SLOT(reformatHeaders())); - connect(firstFridayCheckBox, SIGNAL(toggled(bool)), - this, SLOT(reformatCalendarPage())); - connect(mayFirstCheckBox, SIGNAL(toggled(bool)), - this, SLOT(reformatCalendarPage())); - - QHBoxLayout *checkBoxLayout = new QHBoxLayout; - checkBoxLayout->addWidget(firstFridayCheckBox); - checkBoxLayout->addStretch(); - checkBoxLayout->addWidget(mayFirstCheckBox); - - QGridLayout *outerLayout = new QGridLayout; - outerLayout->addWidget(weekdayColorLabel, 0, 0); - outerLayout->addWidget(weekdayColorCombo, 0, 1); - outerLayout->addWidget(weekendColorLabel, 1, 0); - outerLayout->addWidget(weekendColorCombo, 1, 1); - outerLayout->addWidget(headerTextFormatLabel, 2, 0); - outerLayout->addWidget(headerTextFormatCombo, 2, 1); - outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); - textFormatsGroupBox->setLayout(outerLayout); - - weekdayFormatChanged(); - weekendFormatChanged(); - reformatHeaders(); - reformatCalendarPage(); - } - -QComboBox *Window::createColorComboBox() - { - QComboBox *comboBox = new QComboBox; - comboBox->addItem(tr("Red"), QColor(Qt::red)); - comboBox->addItem(tr("Blue"), QColor(Qt::blue)); - comboBox->addItem(tr("Black"), QColor(Qt::black)); - comboBox->addItem(tr("Magenta"), QColor(Qt::magenta)); - return comboBox; - } +{ + createPreviewGroupBox(); + createGeneralOptionsGroupBox(); + createDatesGroupBox(); + createTextFormatsGroupBox(); + + QGridLayout* layout = new QGridLayout; + layout->addWidget(previewGroupBox, 0, 0); + layout->addWidget(generalOptionsGroupBox, 0, 1); + layout->addWidget(datesGroupBox, 1, 0); + layout->addWidget(textFormatsGroupBox, 1, 1); + layout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(layout); + + previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height()); + previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width()); + + setWindowTitle(tr("Calendar Widget")); +} + +void Window::localeChanged(int index) +{ + calendar->setLocale(localeCombo->itemData(index).toLocale()); +} + +void Window::firstDayChanged(int index) +{ + calendar->setFirstDayOfWeek( + Qt::DayOfWeek(firstDayCombo->itemData(index).toInt())); +} + +void Window::selectionModeChanged(int index) +{ + calendar->setSelectionMode(QCalendarWidget::SelectionMode( + selectionModeCombo->itemData(index).toInt())); +} + +void Window::horizontalHeaderChanged(int index) +{ + calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat( + horizontalHeaderCombo->itemData(index).toInt())); +} + +void Window::verticalHeaderChanged(int index) +{ + calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat( + verticalHeaderCombo->itemData(index).toInt())); +} + +void Window::selectedDateChanged() +{ + currentDateEdit->setDate(calendar->selectedDate()); +} + +void Window::minimumDateChanged(const QDate& date) +{ + calendar->setMinimumDate(date); + maximumDateEdit->setDate(calendar->maximumDate()); +} + +void Window::maximumDateChanged(const QDate& date) +{ + calendar->setMaximumDate(date); + minimumDateEdit->setDate(calendar->minimumDate()); +} + +void Window::weekdayFormatChanged() +{ + QTextCharFormat format; + + format.setForeground(qvariant_cast<QColor>( + weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Monday, format); + calendar->setWeekdayTextFormat(Qt::Tuesday, format); + calendar->setWeekdayTextFormat(Qt::Wednesday, format); + calendar->setWeekdayTextFormat(Qt::Thursday, format); + calendar->setWeekdayTextFormat(Qt::Friday, format); +} + +void Window::weekendFormatChanged() +{ + QTextCharFormat format; + + format.setForeground(qvariant_cast<QColor>( + weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Saturday, format); + calendar->setWeekdayTextFormat(Qt::Sunday, format); +} + +void Window::reformatHeaders() +{ + QString text = headerTextFormatCombo->currentText(); + QTextCharFormat format; + + if (text == tr("Bold")) { + format.setFontWeight(QFont::Bold); + } else if (text == tr("Italic")) { + format.setFontItalic(true); + } else if (text == tr("Green")) { + format.setForeground(Qt::green); + } + calendar->setHeaderTextFormat(format); +} + +void Window::reformatCalendarPage() +{ + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; + firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } + + // May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } +} + +void Window::createPreviewGroupBox() +{ + previewGroupBox = new QGroupBox(tr("Preview")); + + calendar = new QCalendarWidget; + calendar->setMinimumDate(QDate(1900, 1, 1)); + calendar->setMaximumDate(QDate(3000, 1, 1)); + calendar->setGridVisible(true); + + connect(calendar, SIGNAL(currentPageChanged(int, int)), this, + SLOT(reformatCalendarPage())); + + previewLayout = new QGridLayout; + previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); + previewGroupBox->setLayout(previewLayout); +} + +void Window::createGeneralOptionsGroupBox() +{ + generalOptionsGroupBox = new QGroupBox(tr("General Options")); + + localeCombo = new QComboBox; + int curLocaleIndex = -1; + int index = 0; + for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { + QLocale::Language lang = static_cast<QLocale::Language>(_lang); + QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang); + for (int i = 0; i < countries.count(); ++i) { + QLocale::Country country = countries.at(i); + QString label = QLocale::languageToString(lang); + label += QLatin1Char('/'); + label += QLocale::countryToString(country); + QLocale locale(lang, country); + if (this->locale().language() == lang && + this->locale().country() == country) + curLocaleIndex = index; + localeCombo->addItem(label, locale); + ++index; + } + } + if (curLocaleIndex != -1) + localeCombo->setCurrentIndex(curLocaleIndex); + localeLabel = new QLabel(tr("&Locale")); + localeLabel->setBuddy(localeCombo); + + firstDayCombo = new QComboBox; + firstDayCombo->addItem(tr("Sunday"), Qt::Sunday); + firstDayCombo->addItem(tr("Monday"), Qt::Monday); + firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday); + firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday); + firstDayCombo->addItem(tr("Thursday"), Qt::Thursday); + firstDayCombo->addItem(tr("Friday"), Qt::Friday); + firstDayCombo->addItem(tr("Saturday"), Qt::Saturday); + + firstDayLabel = new QLabel(tr("Wee&k starts on:")); + firstDayLabel->setBuddy(firstDayCombo); + + selectionModeCombo = new QComboBox; + selectionModeCombo->addItem(tr("Single selection"), + QCalendarWidget::SingleSelection); + selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection); + + selectionModeLabel = new QLabel(tr("&Selection mode:")); + selectionModeLabel->setBuddy(selectionModeCombo); + + gridCheckBox = new QCheckBox(tr("&Grid")); + gridCheckBox->setChecked(calendar->isGridVisible()); + + navigationCheckBox = new QCheckBox(tr("&Navigation bar")); + navigationCheckBox->setChecked(true); + + horizontalHeaderCombo = new QComboBox; + horizontalHeaderCombo->addItem(tr("Single letter day names"), + QCalendarWidget::SingleLetterDayNames); + horizontalHeaderCombo->addItem(tr("Short day names"), + QCalendarWidget::ShortDayNames); + horizontalHeaderCombo->addItem(tr("None"), + QCalendarWidget::NoHorizontalHeader); + horizontalHeaderCombo->setCurrentIndex(1); + + horizontalHeaderLabel = new QLabel(tr("&Horizontal header:")); + horizontalHeaderLabel->setBuddy(horizontalHeaderCombo); + + verticalHeaderCombo = new QComboBox; + verticalHeaderCombo->addItem(tr("ISO week numbers"), + QCalendarWidget::ISOWeekNumbers); + verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader); + + verticalHeaderLabel = new QLabel(tr("&Vertical header:")); + verticalHeaderLabel->setBuddy(verticalHeaderCombo); + + connect(localeCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(localeChanged(int))); + connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(firstDayChanged(int))); + connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(selectionModeChanged(int))); + connect(gridCheckBox, SIGNAL(toggled(bool)), calendar, + SLOT(setGridVisible(bool))); + connect(navigationCheckBox, SIGNAL(toggled(bool)), calendar, + SLOT(setNavigationBarVisible(bool))); + connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(horizontalHeaderChanged(int))); + connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(verticalHeaderChanged(int))); + + QHBoxLayout* checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(gridCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(navigationCheckBox); + + QGridLayout* outerLayout = new QGridLayout; + outerLayout->addWidget(localeLabel, 0, 0); + outerLayout->addWidget(localeCombo, 0, 1); + outerLayout->addWidget(firstDayLabel, 1, 0); + outerLayout->addWidget(firstDayCombo, 1, 1); + outerLayout->addWidget(selectionModeLabel, 2, 0); + outerLayout->addWidget(selectionModeCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + outerLayout->addWidget(horizontalHeaderLabel, 4, 0); + outerLayout->addWidget(horizontalHeaderCombo, 4, 1); + outerLayout->addWidget(verticalHeaderLabel, 5, 0); + outerLayout->addWidget(verticalHeaderCombo, 5, 1); + generalOptionsGroupBox->setLayout(outerLayout); + + firstDayChanged(firstDayCombo->currentIndex()); + selectionModeChanged(selectionModeCombo->currentIndex()); + horizontalHeaderChanged(horizontalHeaderCombo->currentIndex()); + verticalHeaderChanged(verticalHeaderCombo->currentIndex()); +} + +void Window::createDatesGroupBox() +{ + datesGroupBox = new QGroupBox(tr("Dates")); + + minimumDateEdit = new QDateEdit; + minimumDateEdit->setDisplayFormat("MMM d yyyy"); + minimumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + minimumDateEdit->setDate(calendar->minimumDate()); + + minimumDateLabel = new QLabel(tr("&Minimum Date:")); + minimumDateLabel->setBuddy(minimumDateEdit); + + currentDateEdit = new QDateEdit; + currentDateEdit->setDisplayFormat("MMM d yyyy"); + currentDateEdit->setDate(calendar->selectedDate()); + currentDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + + currentDateLabel = new QLabel(tr("&Current Date:")); + currentDateLabel->setBuddy(currentDateEdit); + + maximumDateEdit = new QDateEdit; + maximumDateEdit->setDisplayFormat("MMM d yyyy"); + maximumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + maximumDateEdit->setDate(calendar->maximumDate()); + + maximumDateLabel = new QLabel(tr("Ma&ximum Date:")); + maximumDateLabel->setBuddy(maximumDateEdit); + + connect(currentDateEdit, SIGNAL(dateChanged(QDate)), calendar, + SLOT(setSelectedDate(QDate))); + connect(calendar, SIGNAL(selectionChanged()), this, + SLOT(selectedDateChanged())); + connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), this, + SLOT(minimumDateChanged(QDate))); + connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), this, + SLOT(maximumDateChanged(QDate))); + + QGridLayout* dateBoxLayout = new QGridLayout; + dateBoxLayout->addWidget(currentDateLabel, 1, 0); + dateBoxLayout->addWidget(currentDateEdit, 1, 1); + dateBoxLayout->addWidget(minimumDateLabel, 0, 0); + dateBoxLayout->addWidget(minimumDateEdit, 0, 1); + dateBoxLayout->addWidget(maximumDateLabel, 2, 0); + dateBoxLayout->addWidget(maximumDateEdit, 2, 1); + dateBoxLayout->setRowStretch(3, 1); + + datesGroupBox->setLayout(dateBoxLayout); +} + +void Window::createTextFormatsGroupBox() +{ + textFormatsGroupBox = new QGroupBox(tr("Text Formats")); + + weekdayColorCombo = createColorComboBox(); + weekdayColorCombo->setCurrentIndex(weekdayColorCombo->findText(tr("Black"))); + + weekdayColorLabel = new QLabel(tr("&Weekday color:")); + weekdayColorLabel->setBuddy(weekdayColorCombo); + + weekendColorCombo = createColorComboBox(); + weekendColorCombo->setCurrentIndex(weekendColorCombo->findText(tr("Red"))); + + weekendColorLabel = new QLabel(tr("Week&end color:")); + weekendColorLabel->setBuddy(weekendColorCombo); + + headerTextFormatCombo = new QComboBox; + headerTextFormatCombo->addItem(tr("Bold")); + headerTextFormatCombo->addItem(tr("Italic")); + headerTextFormatCombo->addItem(tr("Plain")); + + headerTextFormatLabel = new QLabel(tr("&Header text:")); + headerTextFormatLabel->setBuddy(headerTextFormatCombo); + + firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue")); + + mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); + + connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(weekdayFormatChanged())); + connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), this, + SLOT(weekendFormatChanged())); + connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), this, + SLOT(reformatHeaders())); + connect(firstFridayCheckBox, SIGNAL(toggled(bool)), this, + SLOT(reformatCalendarPage())); + connect(mayFirstCheckBox, SIGNAL(toggled(bool)), this, + SLOT(reformatCalendarPage())); + + QHBoxLayout* checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(firstFridayCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(mayFirstCheckBox); + + QGridLayout* outerLayout = new QGridLayout; + outerLayout->addWidget(weekdayColorLabel, 0, 0); + outerLayout->addWidget(weekdayColorCombo, 0, 1); + outerLayout->addWidget(weekendColorLabel, 1, 0); + outerLayout->addWidget(weekendColorCombo, 1, 1); + outerLayout->addWidget(headerTextFormatLabel, 2, 0); + outerLayout->addWidget(headerTextFormatCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + textFormatsGroupBox->setLayout(outerLayout); + + weekdayFormatChanged(); + weekendFormatChanged(); + reformatHeaders(); + reformatCalendarPage(); +} + +QComboBox* Window::createColorComboBox() +{ + QComboBox* comboBox = new QComboBox; + comboBox->addItem(tr("Red"), QColor(Qt::red)); + comboBox->addItem(tr("Blue"), QColor(Qt::blue)); + comboBox->addItem(tr("Black"), QColor(Qt::black)); + comboBox->addItem(tr("Magenta"), QColor(Qt::magenta)); + return comboBox; +} //#include "moc_calwidget.cpp" diff --git a/Tests/QtAutogen/calwidget.h b/Tests/QtAutogen/calwidget.h index d21a473..084d959 100644 --- a/Tests/QtAutogen/calwidget.h +++ b/Tests/QtAutogen/calwidget.h @@ -1,128 +1,127 @@ - /**************************************************************************** - ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - ** All rights reserved. - ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** You may use this file under the terms of the BSD license as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor - ** the names of its contributors may be used to endorse or promote - ** products derived from this software without specific prior written - ** permission. - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef WINDOW_H #define WINDOW_H #include <QWidget> - class QCalendarWidget; - class QCheckBox; - class QComboBox; - class QDate; - class QDateEdit; - class QGridLayout; - class QGroupBox; - class QLabel; +class QCalendarWidget; +class QCheckBox; +class QComboBox; +class QDate; +class QDateEdit; +class QGridLayout; +class QGroupBox; +class QLabel; - namespace Ui - { - class Window; - } +namespace Ui { +class Window; +} - class Window : public QWidget - { - Q_OBJECT +class Window : public QWidget +{ + Q_OBJECT - public: - Window(); +public: + Window(); - private slots: - void localeChanged(int index); - void firstDayChanged(int index); - void selectionModeChanged(int index); - void horizontalHeaderChanged(int index); - void verticalHeaderChanged(int index); - void selectedDateChanged(); - void minimumDateChanged(const QDate &date); - void maximumDateChanged(const QDate &date); - void weekdayFormatChanged(); - void weekendFormatChanged(); - void reformatHeaders(); - void reformatCalendarPage(); +private slots: + void localeChanged(int index); + void firstDayChanged(int index); + void selectionModeChanged(int index); + void horizontalHeaderChanged(int index); + void verticalHeaderChanged(int index); + void selectedDateChanged(); + void minimumDateChanged(const QDate& date); + void maximumDateChanged(const QDate& date); + void weekdayFormatChanged(); + void weekendFormatChanged(); + void reformatHeaders(); + void reformatCalendarPage(); - private: - void createPreviewGroupBox(); - void createGeneralOptionsGroupBox(); - void createDatesGroupBox(); - void createTextFormatsGroupBox(); - QComboBox *createColorComboBox(); +private: + void createPreviewGroupBox(); + void createGeneralOptionsGroupBox(); + void createDatesGroupBox(); + void createTextFormatsGroupBox(); + QComboBox* createColorComboBox(); - QGroupBox *previewGroupBox; - QGridLayout *previewLayout; - QCalendarWidget *calendar; + QGroupBox* previewGroupBox; + QGridLayout* previewLayout; + QCalendarWidget* calendar; - QGroupBox *generalOptionsGroupBox; - QLabel *localeLabel; - QLabel *firstDayLabel; - QLabel *selectionModeLabel; - QLabel *horizontalHeaderLabel; - QLabel *verticalHeaderLabel; - QComboBox *localeCombo; - QComboBox *firstDayCombo; - QComboBox *selectionModeCombo; - QCheckBox *gridCheckBox; - QCheckBox *navigationCheckBox; - QComboBox *horizontalHeaderCombo; - QComboBox *verticalHeaderCombo; + QGroupBox* generalOptionsGroupBox; + QLabel* localeLabel; + QLabel* firstDayLabel; + QLabel* selectionModeLabel; + QLabel* horizontalHeaderLabel; + QLabel* verticalHeaderLabel; + QComboBox* localeCombo; + QComboBox* firstDayCombo; + QComboBox* selectionModeCombo; + QCheckBox* gridCheckBox; + QCheckBox* navigationCheckBox; + QComboBox* horizontalHeaderCombo; + QComboBox* verticalHeaderCombo; - QGroupBox *datesGroupBox; - QLabel *currentDateLabel; - QLabel *minimumDateLabel; - QLabel *maximumDateLabel; - QDateEdit *currentDateEdit; - QDateEdit *minimumDateEdit; - QDateEdit *maximumDateEdit; + QGroupBox* datesGroupBox; + QLabel* currentDateLabel; + QLabel* minimumDateLabel; + QLabel* maximumDateLabel; + QDateEdit* currentDateEdit; + QDateEdit* minimumDateEdit; + QDateEdit* maximumDateEdit; - QGroupBox *textFormatsGroupBox; - QLabel *weekdayColorLabel; - QLabel *weekendColorLabel; - QLabel *headerTextFormatLabel; - QComboBox *weekdayColorCombo; - QComboBox *weekendColorCombo; - QComboBox *headerTextFormatCombo; + QGroupBox* textFormatsGroupBox; + QLabel* weekdayColorLabel; + QLabel* weekendColorLabel; + QLabel* headerTextFormatLabel; + QComboBox* weekdayColorCombo; + QComboBox* weekendColorCombo; + QComboBox* headerTextFormatCombo; - QCheckBox *firstFridayCheckBox; - QCheckBox *mayFirstCheckBox; + QCheckBox* firstFridayCheckBox; + QCheckBox* mayFirstCheckBox; - Ui::Window *ui; - }; + Ui::Window* ui; +}; - #endif +#endif diff --git a/Tests/QtAutogen/codeeditor.cpp b/Tests/QtAutogen/codeeditor.cpp index 01da062..0caf8a7 100644 --- a/Tests/QtAutogen/codeeditor.cpp +++ b/Tests/QtAutogen/codeeditor.cpp @@ -38,116 +38,109 @@ ** ****************************************************************************/ - #include <QtGui> - - #include "codeeditor.h" - - - CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) - { - lineNumberArea = new LineNumberArea(this); - - connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); - connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); - connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); - - updateLineNumberAreaWidth(0); - highlightCurrentLine(); - } - - - - int CodeEditor::lineNumberAreaWidth() - { - int digits = 1; - int max = qMax(1, blockCount()); - while (max >= 10) { - max /= 10; - ++digits; - } - - int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; - - return space; - } - - - - void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) - { - setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); - } - - - - void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) - { - if (dy) - lineNumberArea->scroll(0, dy); - else - lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); - - if (rect.contains(viewport()->rect())) - updateLineNumberAreaWidth(0); - } - - - - void CodeEditor::resizeEvent(QResizeEvent *e) - { - QPlainTextEdit::resizeEvent(e); - - QRect cr = contentsRect(); - lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); - } - - - - void CodeEditor::highlightCurrentLine() - { - QList<QTextEdit::ExtraSelection> extraSelections; - - if (!isReadOnly()) { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(Qt::yellow).lighter(160); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = textCursor(); - selection.cursor.clearSelection(); - extraSelections.append(selection); - } - - setExtraSelections(extraSelections); - } - - - - void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) - { - QPainter painter(lineNumberArea); - painter.fillRect(event->rect(), Qt::lightGray); - - - QTextBlock block = firstVisibleBlock(); - int blockNumber = block.blockNumber(); - int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); - int bottom = top + (int) blockBoundingRect(block).height(); - - while (block.isValid() && top <= event->rect().bottom()) { - if (block.isVisible() && bottom >= event->rect().top()) { - QString number = QString::number(blockNumber + 1); - painter.setPen(Qt::black); - painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), - Qt::AlignRight, number); - } - - block = block.next(); - top = bottom; - bottom = top + (int) blockBoundingRect(block).height(); - ++blockNumber; - } - } +#include <QtGui> + +#include "codeeditor.h" + +CodeEditor::CodeEditor(QWidget* parent) + : QPlainTextEdit(parent) +{ + lineNumberArea = new LineNumberArea(this); + + connect(this, SIGNAL(blockCountChanged(int)), this, + SLOT(updateLineNumberAreaWidth(int))); + connect(this, SIGNAL(updateRequest(QRect, int)), this, + SLOT(updateLineNumberArea(QRect, int))); + connect(this, SIGNAL(cursorPositionChanged()), this, + SLOT(highlightCurrentLine())); + + updateLineNumberAreaWidth(0); + highlightCurrentLine(); +} + +int CodeEditor::lineNumberAreaWidth() +{ + int digits = 1; + int max = qMax(1, blockCount()); + while (max >= 10) { + max /= 10; + ++digits; + } + + int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; + + return space; +} + +void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) +{ + setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); +} + +void CodeEditor::updateLineNumberArea(const QRect& rect, int dy) +{ + if (dy) + lineNumberArea->scroll(0, dy); + else + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), + rect.height()); + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); +} + +void CodeEditor::resizeEvent(QResizeEvent* e) +{ + QPlainTextEdit::resizeEvent(e); + + QRect cr = contentsRect(); + lineNumberArea->setGeometry( + QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); +} + +void CodeEditor::highlightCurrentLine() +{ + QList<QTextEdit::ExtraSelection> extraSelections; + + if (!isReadOnly()) { + QTextEdit::ExtraSelection selection; + + QColor lineColor = QColor(Qt::yellow).lighter(160); + + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + + setExtraSelections(extraSelections); +} + +void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event) +{ + QPainter painter(lineNumberArea); + painter.fillRect(event->rect(), Qt::lightGray); + + QTextBlock block = firstVisibleBlock(); + int blockNumber = block.blockNumber(); + int top = + (int)blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int)blockBoundingRect(block).height(); + + while (block.isValid() && top <= event->rect().bottom()) { + if (block.isVisible() && bottom >= event->rect().top()) { + QString number = QString::number(blockNumber + 1); + painter.setPen(Qt::black); + painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), + Qt::AlignRight, number); + } + + block = block.next(); + top = bottom; + bottom = top + (int)blockBoundingRect(block).height(); + ++blockNumber; + } +} #include "codeeditor.moc" diff --git a/Tests/QtAutogen/codeeditor.h b/Tests/QtAutogen/codeeditor.h index fd79a2a..b410bd4 100644 --- a/Tests/QtAutogen/codeeditor.h +++ b/Tests/QtAutogen/codeeditor.h @@ -1,99 +1,100 @@ - /**************************************************************************** - ** - ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - ** All rights reserved. - ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:BSD$ - ** You may use this file under the terms of the BSD license as follows: - ** - ** "Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions are - ** met: - ** * Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** * Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in - ** the documentation and/or other materials provided with the - ** distribution. - ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor - ** the names of its contributors may be used to endorse or promote - ** products derived from this software without specific prior written - ** permission. - ** - ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." - ** $QT_END_LICENSE$ - ** - ****************************************************************************/ - - #ifndef CODEEDITOR_H - #define CODEEDITOR_H - - #include <QObject> - #include <QPlainTextEdit> - - class QPaintEvent; - class QResizeEvent; - class QSize; - class QWidget; - - class LineNumberArea; - - - class CodeEditor : public QPlainTextEdit - { - Q_OBJECT - - public: - CodeEditor(QWidget *parent = 0); - - void lineNumberAreaPaintEvent(QPaintEvent *event); - int lineNumberAreaWidth(); - - protected: - void resizeEvent(QResizeEvent *event); - - private slots: - void updateLineNumberAreaWidth(int newBlockCount); - void highlightCurrentLine(); - void updateLineNumberArea(const QRect &, int); - - private: - QWidget *lineNumberArea; - }; - - - class LineNumberArea : public QWidget - { - public: - LineNumberArea(CodeEditor *editor) : QWidget(editor) { - codeEditor = editor; - } - - QSize sizeHint() const { - return QSize(codeEditor->lineNumberAreaWidth(), 0); - } - - protected: - void paintEvent(QPaintEvent *event) { - codeEditor->lineNumberAreaPaintEvent(event); - } - - private: - CodeEditor *codeEditor; - }; - - - #endif +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CODEEDITOR_H +#define CODEEDITOR_H + +#include <QObject> +#include <QPlainTextEdit> + +class QPaintEvent; +class QResizeEvent; +class QSize; +class QWidget; + +class LineNumberArea; + +class CodeEditor : public QPlainTextEdit +{ + Q_OBJECT + +public: + CodeEditor(QWidget* parent = 0); + + void lineNumberAreaPaintEvent(QPaintEvent* event); + int lineNumberAreaWidth(); + +protected: + void resizeEvent(QResizeEvent* event); + +private slots: + void updateLineNumberAreaWidth(int newBlockCount); + void highlightCurrentLine(); + void updateLineNumberArea(const QRect&, int); + +private: + QWidget* lineNumberArea; +}; + +class LineNumberArea : public QWidget +{ +public: + LineNumberArea(CodeEditor* editor) + : QWidget(editor) + { + codeEditor = editor; + } + + QSize sizeHint() const + { + return QSize(codeEditor->lineNumberAreaWidth(), 0); + } + +protected: + void paintEvent(QPaintEvent* event) + { + codeEditor->lineNumberAreaPaintEvent(event); + } + +private: + CodeEditor* codeEditor; +}; + +#endif diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/debug_class.cpp index 58e72e4..46b09e7 100644 --- a/Tests/QtAutogen/debug_class.cpp +++ b/Tests/QtAutogen/debug_class.cpp @@ -2,8 +2,9 @@ #include "debug_class.h" #include "ui_debug_class.h" -DebugClass::DebugClass(QWidget *parent) - : QWidget(parent), ui(new Ui::DebugClass) +DebugClass::DebugClass(QWidget* parent) + : QWidget(parent) + , ui(new Ui::DebugClass) { ui->setupUi(this); } diff --git a/Tests/QtAutogen/debug_class.h b/Tests/QtAutogen/debug_class.h index 71bc104..c02f0ed 100644 --- a/Tests/QtAutogen/debug_class.h +++ b/Tests/QtAutogen/debug_class.h @@ -1,8 +1,7 @@ #include <QWidget> -namespace Ui -{ +namespace Ui { class DebugClass; } @@ -10,11 +9,11 @@ class DebugClass : public QWidget { Q_OBJECT public: - explicit DebugClass(QWidget *parent = 0); + explicit DebugClass(QWidget* parent = 0); signals: void someSignal(); private: - Ui::DebugClass *ui; + Ui::DebugClass* ui; }; diff --git a/Tests/QtAutogen/defines_test/defines_test.cpp b/Tests/QtAutogen/defines_test/defines_test.cpp index 2836d35..cf4e9cb 100644 --- a/Tests/QtAutogen/defines_test/defines_test.cpp +++ b/Tests/QtAutogen/defines_test/defines_test.cpp @@ -23,7 +23,7 @@ Q_SIGNALS: }; #endif -int main(int argc, char **argv) +int main(int argc, char** argv) { #ifdef QT_CORE_LIB QMetaObject sosmo = SomeObject::staticMetaObject; diff --git a/Tests/QtAutogen/empty.h b/Tests/QtAutogen/empty.h index 4566142..6bdd2ac 100644 --- a/Tests/QtAutogen/empty.h +++ b/Tests/QtAutogen/empty.h @@ -5,5 +5,5 @@ class Empty : public QObject { Q_OBJECT public: - explicit Empty(QObject *parent = 0) {} + explicit Empty(QObject* parent = 0) {} }; diff --git a/Tests/QtAutogen/foo.cpp b/Tests/QtAutogen/foo.cpp index 699ba09..23ecc30 100644 --- a/Tests/QtAutogen/foo.cpp +++ b/Tests/QtAutogen/foo.cpp @@ -18,18 +18,20 @@ class FooFoo : public QObject { Q_OBJECT - public: - FooFoo():QObject() {} - public slots: - int getValue() const { return 12; } +public: + FooFoo() + : QObject() + { + } +public slots: + int getValue() const { return 12; } }; Foo::Foo() -:QObject() + : QObject() { } - void Foo::doFoo() { FooFoo ff; diff --git a/Tests/QtAutogen/foo.h b/Tests/QtAutogen/foo.h index f23ec07..98f6292 100644 --- a/Tests/QtAutogen/foo.h +++ b/Tests/QtAutogen/foo.h @@ -18,14 +18,14 @@ class Foo #ifdef FOO - : public QObject + : public QObject #endif { Q_OBJECT - public: - Foo(); - public slots: - void doFoo(); +public: + Foo(); +public slots: + void doFoo(); }; #endif diff --git a/Tests/QtAutogen/gadget.h b/Tests/QtAutogen/gadget.h index 7c688ee..3253e31 100644 --- a/Tests/QtAutogen/gadget.h +++ b/Tests/QtAutogen/gadget.h @@ -9,7 +9,8 @@ class Gadget Q_GADGET Q_ENUMS(Type) public: - enum Type { + enum Type + { Type0, Type1 }; diff --git a/Tests/QtAutogen/generated.cpp b/Tests/QtAutogen/generated.cpp index f53bf53..d514c61 100644 --- a/Tests/QtAutogen/generated.cpp +++ b/Tests/QtAutogen/generated.cpp @@ -1,10 +1,9 @@ #include "generated.h" -Generated::Generated(QObject *parent) +Generated::Generated(QObject* parent) : QObject(parent) { - } #include "moc_generated.cpp" diff --git a/Tests/QtAutogen/generated.h b/Tests/QtAutogen/generated.h index b6c2711..62e1607 100644 --- a/Tests/QtAutogen/generated.h +++ b/Tests/QtAutogen/generated.h @@ -12,7 +12,7 @@ class Generated : public QObject, MyInterface, MyOtherInterface Q_OBJECT Q_INTERFACES(MyInterface MyOtherInterface) public: - explicit Generated(QObject *parent = 0); + explicit Generated(QObject* parent = 0); }; #endif diff --git a/Tests/QtAutogen/libC.cpp b/Tests/QtAutogen/libC.cpp index 8d61cb1..a3acff1 100644 --- a/Tests/QtAutogen/libC.cpp +++ b/Tests/QtAutogen/libC.cpp @@ -1,10 +1,9 @@ #include "libC.h" -LibC::LibC(QObject *parent) +LibC::LibC(QObject* parent) : QObject(parent) { - } int LibC::foo() diff --git a/Tests/QtAutogen/libC.h b/Tests/QtAutogen/libC.h index 6682576..3bc2bad 100644 --- a/Tests/QtAutogen/libC.h +++ b/Tests/QtAutogen/libC.h @@ -11,10 +11,10 @@ class LIBC_EXPORT LibC : public QObject { Q_OBJECT public: - explicit LibC(QObject *parent = 0); - + explicit LibC(QObject* parent = 0); int foo(); + private: LibB b; }; diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp index 1636cd4..d557c70 100644 --- a/Tests/QtAutogen/main.cpp +++ b/Tests/QtAutogen/main.cpp @@ -56,8 +56,7 @@ #include <iostream> #endif - -int main(int argv, char **args) +int main(int argv, char** args) { QCoreApplication app(argv, args); diff --git a/Tests/QtAutogen/multiplewidgets.cpp b/Tests/QtAutogen/multiplewidgets.cpp index f143875..fda36ea 100644 --- a/Tests/QtAutogen/multiplewidgets.cpp +++ b/Tests/QtAutogen/multiplewidgets.cpp @@ -4,16 +4,16 @@ #include "ui_widget1.h" #include "ui_widget2.h" -Widget1::Widget1(QWidget *parent) - : QWidget(parent), - ui(new Ui::Widget1) +Widget1::Widget1(QWidget* parent) + : QWidget(parent) + , ui(new Ui::Widget1) { ui->setupUi(this); } -Widget2::Widget2(QWidget *parent) - : QWidget(parent), - ui(new Ui::Widget2) +Widget2::Widget2(QWidget* parent) + : QWidget(parent) + , ui(new Ui::Widget2) { ui->setupUi(this); } diff --git a/Tests/QtAutogen/multiplewidgets.h b/Tests/QtAutogen/multiplewidgets.h index 6ae6ad1..a4d0a50 100644 --- a/Tests/QtAutogen/multiplewidgets.h +++ b/Tests/QtAutogen/multiplewidgets.h @@ -12,9 +12,10 @@ class Widget1 : public QWidget { Q_OBJECT public: - Widget1(QWidget *parent = 0); + Widget1(QWidget* parent = 0); + private: - Ui::Widget1 *ui; + Ui::Widget1* ui; }; namespace Ui { @@ -25,9 +26,10 @@ class Widget2 : public QWidget { Q_OBJECT public: - Widget2(QWidget *parent = 0); + Widget2(QWidget* parent = 0); + private: - Ui::Widget2 *ui; + Ui::Widget2* ui; }; #endif diff --git a/Tests/QtAutogen/private_slot.cpp b/Tests/QtAutogen/private_slot.cpp index 1387a70..ab1682a 100644 --- a/Tests/QtAutogen/private_slot.cpp +++ b/Tests/QtAutogen/private_slot.cpp @@ -4,18 +4,13 @@ class PrivateSlotPrivate { public: - - void privateSlot() - { - - } + void privateSlot() {} }; -PrivateSlot::PrivateSlot(QObject *parent) - : QObject(parent), - d(new PrivateSlotPrivate) +PrivateSlot::PrivateSlot(QObject* parent) + : QObject(parent) + , d(new PrivateSlotPrivate) { - } #include "private_slot.moc" diff --git a/Tests/QtAutogen/private_slot.h b/Tests/QtAutogen/private_slot.h index 28e5448..8041eb2 100644 --- a/Tests/QtAutogen/private_slot.h +++ b/Tests/QtAutogen/private_slot.h @@ -10,10 +10,10 @@ class PrivateSlot : public QObject { Q_OBJECT public: - PrivateSlot(QObject *parent = 0); + PrivateSlot(QObject* parent = 0); private: - PrivateSlotPrivate * const d; + PrivateSlotPrivate* const d; Q_PRIVATE_SLOT(d, void privateSlot()) }; diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp index 75ae28f..4ecb6b4 100644 --- a/Tests/QtAutogen/resourcetester.cpp +++ b/Tests/QtAutogen/resourcetester.cpp @@ -6,21 +6,20 @@ #include <QFile> #include <QTimer> -ResourceTester::ResourceTester(QObject *parent) +ResourceTester::ResourceTester(QObject* parent) : QObject(parent) { - } void ResourceTester::doTest() { if (!QFile::exists(":/CMakeLists.txt")) - qApp->exit(EXIT_FAILURE); + qApp->exit(EXIT_FAILURE); if (!QFile::exists(":/main.cpp")) - qApp->exit(EXIT_FAILURE); + qApp->exit(EXIT_FAILURE); #ifdef TEST_DEBUG_CLASS if (!QFile::exists(":/debug_class.ui")) - qApp->exit(EXIT_FAILURE); + qApp->exit(EXIT_FAILURE); #endif QTimer::singleShot(0, qApp, SLOT(quit())); diff --git a/Tests/QtAutogen/resourcetester.h b/Tests/QtAutogen/resourcetester.h index b02cb4e..dbdb3ad 100644 --- a/Tests/QtAutogen/resourcetester.h +++ b/Tests/QtAutogen/resourcetester.h @@ -8,7 +8,7 @@ class ResourceTester : public QObject { Q_OBJECT public: - explicit ResourceTester(QObject *parent = 0); + explicit ResourceTester(QObject* parent = 0); private slots: void doTest(); diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.cpp b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp index d715116..20d0044 100644 --- a/Tests/QtAutogen/same_name/aaa/bbb/item.cpp +++ b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp @@ -3,10 +3,8 @@ namespace aaa { namespace bbb { -void -Item::go ( ) +void Item::go() { } - } } diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.hpp b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp index c82309d..87ac6ea 100644 --- a/Tests/QtAutogen/same_name/aaa/bbb/item.hpp +++ b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp @@ -10,9 +10,8 @@ class Item : public QObject { Q_OBJECT Q_SLOT - void go ( ); + void go(); }; - } } diff --git a/Tests/QtAutogen/same_name/aaa/item.cpp b/Tests/QtAutogen/same_name/aaa/item.cpp index 7887d76..95dd3b6 100644 --- a/Tests/QtAutogen/same_name/aaa/item.cpp +++ b/Tests/QtAutogen/same_name/aaa/item.cpp @@ -2,9 +2,7 @@ namespace aaa { -void -Item::go ( ) +void Item::go() { } - } diff --git a/Tests/QtAutogen/same_name/aaa/item.hpp b/Tests/QtAutogen/same_name/aaa/item.hpp index 3c24275..68476ce 100644 --- a/Tests/QtAutogen/same_name/aaa/item.hpp +++ b/Tests/QtAutogen/same_name/aaa/item.hpp @@ -9,9 +9,8 @@ class Item : public QObject { Q_OBJECT Q_SLOT - void go ( ); + void go(); }; - } #endif diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.cpp b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp index 36d5b6d..ac4b2c2 100644 --- a/Tests/QtAutogen/same_name/bbb/aaa/item.cpp +++ b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp @@ -3,10 +3,8 @@ namespace bbb { namespace aaa { -void -Item::go ( ) +void Item::go() { } - } } diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.hpp b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp index 35a3686..0a8e024 100644 --- a/Tests/QtAutogen/same_name/bbb/aaa/item.hpp +++ b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp @@ -10,9 +10,8 @@ class Item : public QObject { Q_OBJECT Q_SLOT - void go ( ); + void go(); }; - } } diff --git a/Tests/QtAutogen/same_name/bbb/item.cpp b/Tests/QtAutogen/same_name/bbb/item.cpp index 064295b..f97a143 100644 --- a/Tests/QtAutogen/same_name/bbb/item.cpp +++ b/Tests/QtAutogen/same_name/bbb/item.cpp @@ -2,9 +2,7 @@ namespace bbb { -void -Item::go ( ) +void Item::go() { } - } diff --git a/Tests/QtAutogen/same_name/bbb/item.hpp b/Tests/QtAutogen/same_name/bbb/item.hpp index eda84a2..3da5837 100644 --- a/Tests/QtAutogen/same_name/bbb/item.hpp +++ b/Tests/QtAutogen/same_name/bbb/item.hpp @@ -9,9 +9,8 @@ class Item : public QObject { Q_OBJECT Q_SLOT - void go ( ); + void go(); }; - } #endif diff --git a/Tests/QtAutogen/same_name/ccc/item.cpp b/Tests/QtAutogen/same_name/ccc/item.cpp index 12c71d0..d90b2b8 100644 --- a/Tests/QtAutogen/same_name/ccc/item.cpp +++ b/Tests/QtAutogen/same_name/ccc/item.cpp @@ -2,8 +2,7 @@ namespace ccc { -void -Item::go ( ) +void Item::go() { } @@ -11,14 +10,12 @@ class MocTest : public QObject { Q_OBJECT; Q_SLOT - void go ( ); + void go(); }; -void -MocTest::go() +void MocTest::go() { } - } // Include own moc files diff --git a/Tests/QtAutogen/same_name/ccc/item.hpp b/Tests/QtAutogen/same_name/ccc/item.hpp index 6386dc6..c855936 100644 --- a/Tests/QtAutogen/same_name/ccc/item.hpp +++ b/Tests/QtAutogen/same_name/ccc/item.hpp @@ -9,9 +9,8 @@ class Item : public QObject { Q_OBJECT Q_SLOT - void go ( ); + void go(); }; - } #endif diff --git a/Tests/QtAutogen/same_name/main.cpp b/Tests/QtAutogen/same_name/main.cpp index fc77a99..a4ffcb3 100644 --- a/Tests/QtAutogen/same_name/main.cpp +++ b/Tests/QtAutogen/same_name/main.cpp @@ -4,7 +4,7 @@ #include "bbb/item.hpp" #include "ccc/item.hpp" -int main(int argv, char **args) +int main(int argv, char** args) { // Object instances ::aaa::Item aaa_item; diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp index 65ba962..c575f10 100644 --- a/Tests/QtAutogen/second_widget.cpp +++ b/Tests/QtAutogen/second_widget.cpp @@ -2,8 +2,9 @@ #include "second_widget.h" #include "ui_second_widget.h" -SecondWidget::SecondWidget(QWidget *parent) - : QWidget(parent), ui(new Ui::SecondWidget) +SecondWidget::SecondWidget(QWidget* parent) + : QWidget(parent) + , ui(new Ui::SecondWidget) { ui->setupUi(this); } diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h index fe4d175..c7929c4 100644 --- a/Tests/QtAutogen/second_widget.h +++ b/Tests/QtAutogen/second_widget.h @@ -1,8 +1,7 @@ #include <QWidget> -namespace Ui -{ +namespace Ui { class SecondWidget; } @@ -10,7 +9,7 @@ class SecondWidget : public QWidget { Q_OBJECT public: - explicit SecondWidget(QWidget *parent = 0); + explicit SecondWidget(QWidget* parent = 0); ~SecondWidget(); diff --git a/Tests/QtAutogen/sub/bar.h b/Tests/QtAutogen/sub/bar.h index db56b8e..c96e123 100644 --- a/Tests/QtAutogen/sub/bar.h +++ b/Tests/QtAutogen/sub/bar.h @@ -19,10 +19,10 @@ class Bar : public QObject { Q_OBJECT - public: - Bar(); - public slots: - void doBar(); +public: + Bar(); +public slots: + void doBar(); }; #endif diff --git a/Tests/QtAutogen/sub/uiconly.cpp b/Tests/QtAutogen/sub/uiconly.cpp index cdb3318..ac22789 100644 --- a/Tests/QtAutogen/sub/uiconly.cpp +++ b/Tests/QtAutogen/sub/uiconly.cpp @@ -1,10 +1,10 @@ #include "uiconly.h" -UicOnly::UicOnly(QWidget *parent) - : QWidget(parent), ui(new Ui::UicOnly) +UicOnly::UicOnly(QWidget* parent) + : QWidget(parent) + , ui(new Ui::UicOnly) { - } int main() diff --git a/Tests/QtAutogen/sub/uiconly.h b/Tests/QtAutogen/sub/uiconly.h index 9e21f82..9b0b1b4 100644 --- a/Tests/QtAutogen/sub/uiconly.h +++ b/Tests/QtAutogen/sub/uiconly.h @@ -11,7 +11,7 @@ class UicOnly : public QWidget { Q_OBJECT public: - explicit UicOnly(QWidget *parent = 0); + explicit UicOnly(QWidget* parent = 0); private: const std::auto_ptr<Ui::UicOnly> ui; diff --git a/Tests/QtAutogen/xyz.cpp b/Tests/QtAutogen/xyz.cpp index a3562a3..c3c598e 100644 --- a/Tests/QtAutogen/xyz.cpp +++ b/Tests/QtAutogen/xyz.cpp @@ -11,17 +11,15 @@ See the License for more information. ============================================================================*/ - #include "xyz.h" #include <stdio.h> Xyz::Xyz() -:QObject() + : QObject() { } - void Xyz::doXyz() { printf("This is xyz !\n"); diff --git a/Tests/QtAutogen/xyz.h b/Tests/QtAutogen/xyz.h index 8175d37..1ba09a3 100644 --- a/Tests/QtAutogen/xyz.h +++ b/Tests/QtAutogen/xyz.h @@ -19,10 +19,10 @@ class Xyz : public QObject { Q_OBJECT - public: - Xyz(); - public slots: - void doXyz(); +public: + Xyz(); +public slots: + void doXyz(); }; #endif diff --git a/Tests/QtAutogen/yaf.cpp b/Tests/QtAutogen/yaf.cpp index d278ab4..09335a9 100644 --- a/Tests/QtAutogen/yaf.cpp +++ b/Tests/QtAutogen/yaf.cpp @@ -11,7 +11,6 @@ See the License for more information. ============================================================================*/ - #include "yaf.h" #include "yaf_p.h" @@ -21,7 +20,6 @@ Yaf::Yaf() { } - void Yaf::doYaf() { YafP yafP; diff --git a/Tests/QtAutogen/yaf.h b/Tests/QtAutogen/yaf.h index 8689f83..9755ca0 100644 --- a/Tests/QtAutogen/yaf.h +++ b/Tests/QtAutogen/yaf.h @@ -16,10 +16,11 @@ class Yaf { - public: - Yaf(); - public: - void doYaf(); +public: + Yaf(); + +public: + void doYaf(); }; #endif diff --git a/Tests/QtAutogen/yaf_p.h b/Tests/QtAutogen/yaf_p.h index f0368ad..cf317b8 100644 --- a/Tests/QtAutogen/yaf_p.h +++ b/Tests/QtAutogen/yaf_p.h @@ -21,10 +21,10 @@ class YafP : public QObject { Q_OBJECT - public: - YafP() {} - public slots: - void doYafP() { printf("I am yet another file !\n"); } +public: + YafP() {} +public slots: + void doYafP() { printf("I am yet another file !\n"); } }; #endif |