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.
This commit is contained in:
Kurt Hindenburg
2011-12-24 10:37:22 -05:00
parent a5eb55d8c0
commit ed77ae37d6
2 changed files with 60 additions and 68 deletions

View File

@@ -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<QTableWidgetItem*> uniqueList;
//Filter unique items
QListIterator<QTableWidgetItem*> iter( selectedList );
while ( iter.hasNext() )
{
QListIterator<QTableWidgetItem*> 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<QTableWidgetItem*>( uniqueList );
while ( iter.hasNext() )
{
iter = QListIterator<QTableWidgetItem*>(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<KeyboardTranslator::Entry>();
value<KeyboardTranslator::Entry>();
_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<KeyboardTranslator::Entry>();
QTableWidgetItem* key = _ui->keyBindingTable->item(item->row() , 0);
KeyboardTranslator::Entry existing = key->data(Qt::UserRole).value<KeyboardTranslator::Entry>();
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<KeyboardTranslator::Entry> 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"