From ed77ae37d66e164795d4353bd4bd24aa2d7ef276 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sat, 24 Dec 2011 10:37:22 -0500 Subject: [PATCH] Apply astyle-kdelibs Over the years, the coding style is all over the place. Use 'git diff -w --ignore-all-space' to see non-whitespace changes. --- src/KeyBindingEditor.cpp | 122 ++++++++++++++++++--------------------- src/KeyBindingEditor.h | 6 +- 2 files changed, 60 insertions(+), 68 deletions(-) diff --git a/src/KeyBindingEditor.cpp b/src/KeyBindingEditor.cpp index f4c312bf8..e4d1d9c8c 100644 --- a/src/KeyBindingEditor.cpp +++ b/src/KeyBindingEditor.cpp @@ -32,13 +32,13 @@ using namespace Konsole; KeyBindingEditor::KeyBindingEditor(QWidget* parent) : QWidget(parent) - , _translator(new KeyboardTranslator( QString() )) + , _translator(new KeyboardTranslator(QString())) { _ui = new Ui::KeyBindingEditor(); _ui->setupUi(this); // description edit - connect( _ui->descriptionEdit , SIGNAL(textChanged(QString)) , this , SLOT(setDescription(QString)) ); + connect(_ui->descriptionEdit , SIGNAL(textChanged(QString)) , this , SLOT(setDescription(QString))); // key bindings table _ui->keyBindingTable->setColumnCount(2); @@ -52,11 +52,11 @@ KeyBindingEditor::KeyBindingEditor(QWidget* parent) _ui->keyBindingTable->setSelectionBehavior(QAbstractItemView::SelectRows); // add and remove buttons - _ui->addEntryButton->setIcon( KIcon("list-add") ); - _ui->removeEntryButton->setIcon( KIcon("list-remove") ); + _ui->addEntryButton->setIcon(KIcon("list-add")); + _ui->removeEntryButton->setIcon(KIcon("list-remove")); - connect( _ui->removeEntryButton , SIGNAL(clicked()) , this , SLOT(removeSelectedEntry()) ); - connect( _ui->addEntryButton , SIGNAL(clicked()) , this , SLOT(addNewEntry()) ); + connect(_ui->removeEntryButton , SIGNAL(clicked()) , this , SLOT(removeSelectedEntry())); + connect(_ui->addEntryButton , SIGNAL(clicked()) , this , SLOT(addNewEntry())); // test area _ui->testAreaInputEdit->installEventFilter(this); @@ -74,97 +74,90 @@ void KeyBindingEditor::removeSelectedEntry() QList uniqueList; //Filter unique items - QListIterator iter( selectedList ); - while ( iter.hasNext() ) - { + QListIterator iter(selectedList); + while (iter.hasNext()) { QTableWidgetItem* item = iter.next(); if (item->column() == 1) //Select item at the first column - item = _ui->keyBindingTable->item(item->row(),0); + item = _ui->keyBindingTable->item(item->row(), 0); - if ( !uniqueList.contains(item) ) + if (!uniqueList.contains(item)) uniqueList.append(item); } - iter = QListIterator( uniqueList ); - while ( iter.hasNext() ) - { + iter = QListIterator(uniqueList); + while (iter.hasNext()) { // get the first item in the row which has the entry QTableWidgetItem* item = iter.next(); KeyboardTranslator::Entry existing = item->data(Qt::UserRole). - value(); + value(); _translator->removeEntry(existing); - _ui->keyBindingTable->removeRow( item->row() ); + _ui->keyBindingTable->removeRow(item->row()); } } void KeyBindingEditor::addNewEntry() { - _ui->keyBindingTable->insertRow( _ui->keyBindingTable->rowCount() ); + _ui->keyBindingTable->insertRow(_ui->keyBindingTable->rowCount()); - int newRowCount = _ui->keyBindingTable->rowCount(); + int newRowCount = _ui->keyBindingTable->rowCount(); - // block signals here to avoid triggering bindingTableItemChanged() slot call - _ui->keyBindingTable->blockSignals(true); + // block signals here to avoid triggering bindingTableItemChanged() slot call + _ui->keyBindingTable->blockSignals(true); - _ui->keyBindingTable->setItem(newRowCount-1,0,new QTableWidgetItem() ); - _ui->keyBindingTable->setItem(newRowCount-1,1,new QTableWidgetItem() ); + _ui->keyBindingTable->setItem(newRowCount - 1, 0, new QTableWidgetItem()); + _ui->keyBindingTable->setItem(newRowCount - 1, 1, new QTableWidgetItem()); - _ui->keyBindingTable->blockSignals(false); + _ui->keyBindingTable->blockSignals(false); - // make sure user can see new row - _ui->keyBindingTable->scrollToItem(_ui->keyBindingTable->item(newRowCount-1,0)); + // make sure user can see new row + _ui->keyBindingTable->scrollToItem(_ui->keyBindingTable->item(newRowCount - 1, 0)); } -bool KeyBindingEditor::eventFilter( QObject* watched , QEvent* event ) +bool KeyBindingEditor::eventFilter(QObject* watched , QEvent* event) { - if ( watched == _ui->testAreaInputEdit ) - { - if ( event->type() == QEvent::KeyPress ) - { + if (watched == _ui->testAreaInputEdit) { + if (event->type() == QEvent::KeyPress) { QKeyEvent* keyEvent = (QKeyEvent*)event; - // The state here is currently set to the state that a newly started - // terminal in Konsole will be in ( which is also the same as the + // The state here is currently set to the state that a newly started + // terminal in Konsole will be in ( which is also the same as the // state just after a reset ), this has 'Ansi' turned on and all other // states off. // - // TODO: It may be useful to be able to specify the state in the 'test input' - // area, but preferably not in a way which clutters the UI with lots of + // TODO: It may be useful to be able to specify the state in the 'test input' + // area, but preferably not in a way which clutters the UI with lots of // checkboxes. // const KeyboardTranslator::States states = KeyboardTranslator::AnsiState; - KeyboardTranslator::Entry entry = _translator->findEntry( keyEvent->key() , - keyEvent->modifiers(), - states ); + KeyboardTranslator::Entry entry = _translator->findEntry(keyEvent->key() , + keyEvent->modifiers(), + states); - if ( !entry.isNull() ) - { + if (!entry.isNull()) { _ui->testAreaInputEdit->setText(entry.conditionToString()); - _ui->testAreaOutputEdit->setText(entry.resultToString(true,keyEvent->modifiers())); - } - else - { + _ui->testAreaOutputEdit->setText(entry.resultToString(true, keyEvent->modifiers())); + } else { _ui->testAreaInputEdit->setText(keyEvent->text()); _ui->testAreaOutputEdit->setText(keyEvent->text()); } keyEvent->accept(); return true; - } + } } return false; } void KeyBindingEditor::setDescription(const QString& newDescription) { - _ui->descriptionEdit->setText(newDescription); + _ui->descriptionEdit->setText(newDescription); - if ( _translator ) - _translator->setDescription(newDescription); + if (_translator) + _translator->setDescription(newDescription); } QString KeyBindingEditor::description() const { @@ -192,47 +185,46 @@ KeyboardTranslator* KeyBindingEditor::translator() const void KeyBindingEditor::bindingTableItemChanged(QTableWidgetItem* item) { - QTableWidgetItem* key = _ui->keyBindingTable->item( item->row() , 0 ); - KeyboardTranslator::Entry existing = key->data(Qt::UserRole).value(); + QTableWidgetItem* key = _ui->keyBindingTable->item(item->row() , 0); + KeyboardTranslator::Entry existing = key->data(Qt::UserRole).value(); - QString condition = key->text(); - QString result = _ui->keyBindingTable->item( item->row() , 1 )->text(); + QString condition = key->text(); + QString result = _ui->keyBindingTable->item(item->row() , 1)->text(); - KeyboardTranslator::Entry entry = KeyboardTranslatorReader::createEntry(condition,result); - _translator->replaceEntry(existing,entry); + KeyboardTranslator::Entry entry = KeyboardTranslatorReader::createEntry(condition, result); + _translator->replaceEntry(existing, entry); // block signals to prevent this slot from being called repeatedly - _ui->keyBindingTable->blockSignals(true); + _ui->keyBindingTable->blockSignals(true); - key->setData(Qt::UserRole,QVariant::fromValue(entry)); + key->setData(Qt::UserRole, QVariant::fromValue(entry)); - _ui->keyBindingTable->blockSignals(false); + _ui->keyBindingTable->blockSignals(false); } void KeyBindingEditor::setupKeyBindingTable(const KeyboardTranslator* translator) { - disconnect( _ui->keyBindingTable , SIGNAL(itemChanged(QTableWidgetItem*)) , this , - SLOT(bindingTableItemChanged(QTableWidgetItem*)) ); + disconnect(_ui->keyBindingTable , SIGNAL(itemChanged(QTableWidgetItem*)) , this , + SLOT(bindingTableItemChanged(QTableWidgetItem*))); QList entries = translator->entries(); _ui->keyBindingTable->setRowCount(entries.count()); - for ( int row = 0 ; row < entries.count() ; row++ ) - { + for (int row = 0 ; row < entries.count() ; row++) { const KeyboardTranslator::Entry& entry = entries.at(row); QTableWidgetItem* keyItem = new QTableWidgetItem(entry.conditionToString()); - keyItem->setData( Qt::UserRole , QVariant::fromValue(entry) ); + keyItem->setData(Qt::UserRole , QVariant::fromValue(entry)); QTableWidgetItem* textItem = new QTableWidgetItem(QString(entry.resultToString())); - _ui->keyBindingTable->setItem(row,0,keyItem); - _ui->keyBindingTable->setItem(row,1,textItem); + _ui->keyBindingTable->setItem(row, 0, keyItem); + _ui->keyBindingTable->setItem(row, 1, textItem); } _ui->keyBindingTable->sortItems(0); - connect( _ui->keyBindingTable , SIGNAL(itemChanged(QTableWidgetItem*)) , this , - SLOT(bindingTableItemChanged(QTableWidgetItem*)) ); + connect(_ui->keyBindingTable , SIGNAL(itemChanged(QTableWidgetItem*)) , this , + SLOT(bindingTableItemChanged(QTableWidgetItem*))); } #include "KeyBindingEditor.moc" diff --git a/src/KeyBindingEditor.h b/src/KeyBindingEditor.h index aa9777d49..6bccc9873 100644 --- a/src/KeyBindingEditor.h +++ b/src/KeyBindingEditor.h @@ -27,7 +27,7 @@ class QTableWidgetItem; namespace Ui { - class KeyBindingEditor; +class KeyBindingEditor; } namespace Konsole @@ -50,7 +50,7 @@ class KeyboardTranslator; */ class KeyBindingEditor : public QWidget { -Q_OBJECT + Q_OBJECT public: /** Constructs a new key bindings editor with the specified parent. */ @@ -75,7 +75,7 @@ public: QString description() const; // reimplemented to handle test area input - virtual bool eventFilter( QObject* watched , QEvent* event ); + virtual bool eventFilter(QObject* watched , QEvent* event); public slots: /**