Commit 90dd2442 authored by Kurt Hindenburg's avatar Kurt Hindenburg

uncrustify using kf5 config

parent a1aec1f3
...@@ -30,21 +30,22 @@ ...@@ -30,21 +30,22 @@
using Konsole::ViewSplitter; using Konsole::ViewSplitter;
using Konsole::ViewContainer; using Konsole::ViewContainer;
ViewSplitter::ViewSplitter(QWidget* parent) ViewSplitter::ViewSplitter(QWidget *parent) :
: QSplitter(parent) QSplitter(parent),
, _recursiveSplitting(true) _recursiveSplitting(true)
{ {
} }
void ViewSplitter::childEmpty(ViewSplitter* splitter) void ViewSplitter::childEmpty(ViewSplitter *splitter)
{ {
delete splitter; delete splitter;
if (count() == 0) if (count() == 0) {
emit empty(this); emit empty(this);
}
} }
void ViewSplitter::adjustContainerSize(ViewContainer* container , int percentage) void ViewSplitter::adjustContainerSize(ViewContainer *container, int percentage)
{ {
int containerIndex = indexOf(container->containerWidget()); int containerIndex = indexOf(container->containerWidget());
...@@ -57,24 +58,25 @@ void ViewSplitter::adjustContainerSize(ViewContainer* container , int percentage ...@@ -57,24 +58,25 @@ void ViewSplitter::adjustContainerSize(ViewContainer* container , int percentage
const int perContainerDelta = (count() == 1) ? 0 : ((newSize - oldSize) / (count() - 1)) * (-1); const int perContainerDelta = (count() == 1) ? 0 : ((newSize - oldSize) / (count() - 1)) * (-1);
for (int i = 0 ; i < containerSizes.count() ; i++) { for (int i = 0; i < containerSizes.count(); i++) {
if (i == containerIndex) if (i == containerIndex) {
containerSizes[i] = newSize; containerSizes[i] = newSize;
else } else {
containerSizes[i] = containerSizes[i] + perContainerDelta; containerSizes[i] = containerSizes[i] + perContainerDelta;
}
} }
setSizes(containerSizes); setSizes(containerSizes);
} }
ViewSplitter* ViewSplitter::activeSplitter() ViewSplitter *ViewSplitter::activeSplitter()
{ {
QWidget* widget = focusWidget() != nullptr ? focusWidget() : this; QWidget *widget = focusWidget() != nullptr ? focusWidget() : this;
ViewSplitter* splitter = 0; ViewSplitter *splitter = 0;
while ((splitter == nullptr) && (widget != nullptr)) { while ((splitter == nullptr) && (widget != nullptr)) {
splitter = qobject_cast<ViewSplitter*>(widget); splitter = qobject_cast<ViewSplitter *>(widget);
widget = widget->parentWidget(); widget = widget->parentWidget();
} }
...@@ -82,7 +84,7 @@ ViewSplitter* ViewSplitter::activeSplitter() ...@@ -82,7 +84,7 @@ ViewSplitter* ViewSplitter::activeSplitter()
return splitter; return splitter;
} }
void ViewSplitter::registerContainer(ViewContainer* container) void ViewSplitter::registerContainer(ViewContainer *container)
{ {
_containers << container; _containers << container;
// Connecting to container::destroyed() using the new-style connection // Connecting to container::destroyed() using the new-style connection
...@@ -90,14 +92,15 @@ void ViewSplitter::registerContainer(ViewContainer* container) ...@@ -90,14 +92,15 @@ void ViewSplitter::registerContainer(ViewContainer* container)
// syntax works. // syntax works.
//connect(container , static_cast<void(ViewContainer::*)(ViewContainer*)>(&Konsole::ViewContainer::destroyed) , this , &Konsole::ViewSplitter::containerDestroyed); //connect(container , static_cast<void(ViewContainer::*)(ViewContainer*)>(&Konsole::ViewContainer::destroyed) , this , &Konsole::ViewSplitter::containerDestroyed);
//connect(container , &Konsole::ViewContainer::empty , this , &Konsole::ViewSplitter::containerEmpty); //connect(container , &Konsole::ViewContainer::empty , this , &Konsole::ViewSplitter::containerEmpty);
connect(container , SIGNAL(destroyed(ViewContainer*)) , this , SLOT(containerDestroyed(ViewContainer*))); connect(container, SIGNAL(destroyed(ViewContainer *)), this,
connect(container , SIGNAL(empty(ViewContainer*)) , this , SLOT(containerEmpty(ViewContainer*))); SLOT(containerDestroyed(ViewContainer *)));
connect(container, SIGNAL(empty(ViewContainer *)), this, SLOT(containerEmpty(ViewContainer *)));
} }
void ViewSplitter::unregisterContainer(ViewContainer* container) void ViewSplitter::unregisterContainer(ViewContainer *container)
{ {
_containers.removeAll(container); _containers.removeAll(container);
disconnect(container , 0 , this , 0); disconnect(container, 0, this, 0);
} }
void ViewSplitter::updateSizes() void ViewSplitter::updateSizes()
...@@ -111,8 +114,9 @@ void ViewSplitter::updateSizes() ...@@ -111,8 +114,9 @@ void ViewSplitter::updateSizes()
} }
QList<int> widgetSizes; QList<int> widgetSizes;
for (int i = 0; i < count(); i++) for (int i = 0; i < count(); i++) {
widgetSizes << space; widgetSizes << space;
}
setSizes(widgetSizes); setSizes(widgetSizes);
} }
...@@ -121,38 +125,40 @@ void ViewSplitter::setRecursiveSplitting(bool recursive) ...@@ -121,38 +125,40 @@ void ViewSplitter::setRecursiveSplitting(bool recursive)
{ {
_recursiveSplitting = recursive; _recursiveSplitting = recursive;
} }
bool ViewSplitter::recursiveSplitting() const bool ViewSplitter::recursiveSplitting() const
{ {
return _recursiveSplitting; return _recursiveSplitting;
} }
void ViewSplitter::removeContainer(ViewContainer* container) void ViewSplitter::removeContainer(ViewContainer *container)
{ {
Q_ASSERT(containers().contains(container)); Q_ASSERT(containers().contains(container));
unregisterContainer(container); unregisterContainer(container);
} }
void ViewSplitter::addContainer(ViewContainer* container , void ViewSplitter::addContainer(ViewContainer *container, Qt::Orientation containerOrientation)
Qt::Orientation containerOrientation)
{ {
ViewSplitter* splitter = activeSplitter(); ViewSplitter *splitter = activeSplitter();
if (splitter->count() < 2 || if (splitter->count() < 2
containerOrientation == splitter->orientation() || || containerOrientation == splitter->orientation()
!_recursiveSplitting) { || !_recursiveSplitting) {
splitter->registerContainer(container); splitter->registerContainer(container);
splitter->addWidget(container->containerWidget()); splitter->addWidget(container->containerWidget());
if (splitter->orientation() != containerOrientation) if (splitter->orientation() != containerOrientation) {
splitter->setOrientation(containerOrientation); splitter->setOrientation(containerOrientation);
}
splitter->updateSizes(); splitter->updateSizes();
} else { } else {
auto newSplitter = new ViewSplitter(this); auto newSplitter = new ViewSplitter(this);
connect(newSplitter , &Konsole::ViewSplitter::empty , splitter , &Konsole::ViewSplitter::childEmpty); connect(newSplitter, &Konsole::ViewSplitter::empty, splitter,
&Konsole::ViewSplitter::childEmpty);
ViewContainer* oldContainer = splitter->activeContainer(); ViewContainer *oldContainer = splitter->activeContainer();
const int oldContainerIndex = splitter->indexOf(oldContainer->containerWidget()); const int oldContainerIndex = splitter->indexOf(oldContainer->containerWidget());
splitter->unregisterContainer(oldContainer); splitter->unregisterContainer(oldContainer);
...@@ -170,18 +176,19 @@ void ViewSplitter::addContainer(ViewContainer* container , ...@@ -170,18 +176,19 @@ void ViewSplitter::addContainer(ViewContainer* container ,
} }
} }
void ViewSplitter::containerEmpty(ViewContainer* /*container*/) void ViewSplitter::containerEmpty(ViewContainer * /*container*/)
{ {
int children = 0; int children = 0;
foreach(ViewContainer* container, _containers) { foreach (ViewContainer *container, _containers) {
children += container->views().count(); children += container->views().count();
} }
if (children == 0) if (children == 0) {
emit allContainersEmpty(); emit allContainersEmpty();
}
} }
void ViewSplitter::containerDestroyed(ViewContainer* container) void ViewSplitter::containerDestroyed(ViewContainer *container)
{ {
Q_ASSERT(_containers.contains(container)); Q_ASSERT(_containers.contains(container));
...@@ -194,50 +201,54 @@ void ViewSplitter::containerDestroyed(ViewContainer* container) ...@@ -194,50 +201,54 @@ void ViewSplitter::containerDestroyed(ViewContainer* container)
void ViewSplitter::activateNextContainer() void ViewSplitter::activateNextContainer()
{ {
ViewContainer* active = activeContainer(); ViewContainer *active = activeContainer();
int index = _containers.indexOf(active); int index = _containers.indexOf(active);
if (index == -1) if (index == -1) {
return; return;
}
if (index == _containers.count() - 1) if (index == _containers.count() - 1) {
index = 0; index = 0;
else } else {
index++; index++;
}
setActiveContainer(_containers.at(index)); setActiveContainer(_containers.at(index));
} }
void ViewSplitter::activatePreviousContainer() void ViewSplitter::activatePreviousContainer()
{ {
ViewContainer* active = activeContainer(); ViewContainer *active = activeContainer();
int index = _containers.indexOf(active); int index = _containers.indexOf(active);
if (index == 0) if (index == 0) {
index = _containers.count() - 1; index = _containers.count() - 1;
else } else {
index--; index--;
}
setActiveContainer(_containers.at(index)); setActiveContainer(_containers.at(index));
} }
void ViewSplitter::setActiveContainer(ViewContainer* container) void ViewSplitter::setActiveContainer(ViewContainer *container)
{ {
QWidget* activeView = container->activeView(); QWidget *activeView = container->activeView();
if (activeView != nullptr) if (activeView != nullptr) {
activeView->setFocus(Qt::OtherFocusReason); activeView->setFocus(Qt::OtherFocusReason);
}
} }
ViewContainer* ViewSplitter::activeContainer() const ViewContainer *ViewSplitter::activeContainer() const
{ {
if (QWidget* focusW = focusWidget()) { if (QWidget *focusW = focusWidget()) {
ViewContainer* focusContainer = 0; ViewContainer *focusContainer = 0;
while (focusW != 0) { while (focusW != 0) {
foreach(ViewContainer* container, _containers) { foreach (ViewContainer *container, _containers) {
if (container->containerWidget() == focusW) { if (container->containerWidget() == focusW) {
focusContainer = container; focusContainer = container;
break; break;
...@@ -246,19 +257,20 @@ ViewContainer* ViewSplitter::activeContainer() const ...@@ -246,19 +257,20 @@ ViewContainer* ViewSplitter::activeContainer() const
focusW = focusW->parentWidget(); focusW = focusW->parentWidget();
} }
if (focusContainer != nullptr) if (focusContainer != nullptr) {
return focusContainer; return focusContainer;
}
} }
QList<ViewSplitter*> splitters = findChildren<ViewSplitter*>(); QList<ViewSplitter *> splitters = findChildren<ViewSplitter *>();
if (splitters.count() > 0) { if (splitters.count() > 0) {
return splitters.last()->activeContainer(); return splitters.last()->activeContainer();
} else { } else {
if (_containers.count() > 0) if (_containers.count() > 0) {
return _containers.last(); return _containers.last();
else } else {
return 0; return 0;
}
} }
} }
...@@ -24,4 +24,3 @@ ...@@ -24,4 +24,3 @@
using Konsole::WindowSystemInfo; using Konsole::WindowSystemInfo;
bool WindowSystemInfo::HAVE_TRANSPARENCY = false; bool WindowSystemInfo::HAVE_TRANSPARENCY = false;
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
using Konsole::ZModemDialog; using Konsole::ZModemDialog;
ZModemDialog::ZModemDialog(QWidget* aParent, bool modal, const QString& caption) ZModemDialog::ZModemDialog(QWidget *aParent, bool modal, const QString &caption) :
: QDialog(aParent) QDialog(aParent)
{ {
setObjectName(QStringLiteral("zmodem_progress")); setObjectName(QStringLiteral("zmodem_progress"));
setModal(modal); setModal(modal);
...@@ -54,11 +54,14 @@ ZModemDialog::ZModemDialog(QWidget* aParent, bool modal, const QString& caption) ...@@ -54,11 +54,14 @@ ZModemDialog::ZModemDialog(QWidget* aParent, bool modal, const QString& caption)
_textEdit->setReadOnly(true); _textEdit->setReadOnly(true);
mainLayout->addWidget(_textEdit); mainLayout->addWidget(_textEdit);
connect(this, &Konsole::ZModemDialog::user1Clicked, this, &Konsole::ZModemDialog::slotUser1Clicked); connect(this, &Konsole::ZModemDialog::user1Clicked, this,
connect(mButtonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &Konsole::ZModemDialog::slotClose); &Konsole::ZModemDialog::slotUser1Clicked);
connect(mButtonBox->button(QDialogButtonBox::Close),
&QPushButton::clicked, this,
&Konsole::ZModemDialog::slotClose);
} }
void ZModemDialog::addProgressText(const QString& text) void ZModemDialog::addProgressText(const QString &text)
{ {
QTextCursor currentCursor = _textEdit->textCursor(); QTextCursor currentCursor = _textEdit->textCursor();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment