1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/*
SPDX-FileCopyrightText: 2006-2007 Alexander Dymo <adymo@kdevelop.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "areaprinter.h"
#include <sublime/view.h>
#include <sublime/areaindex.h>
using namespace Sublime;
// class AreaViewsPrinter
AreaViewsPrinter::AreaViewsPrinter()
{
result = QStringLiteral("\n");
}
Area::WalkerMode AreaViewsPrinter::operator()(Sublime::AreaIndex *index)
{
result += printIndentation(index) + "[ ";
if (index->views().isEmpty())
result += printOrientation(index->orientation()) + ' ';
else
{
for (View* view : qAsConst(index->views())) {
result += view->objectName() + ' ';
}
}
result += QLatin1String("]\n");
return Area::ContinueWalker;
}
QString AreaViewsPrinter::printIndentation(Sublime::AreaIndex *index) const
{
QString i;
while ((index = index->parent()))
i += QLatin1String(" ");
return i;
}
QString AreaViewsPrinter::printOrientation(Qt::Orientation o) const
{
if (o == Qt::Vertical)
return QStringLiteral("vertical splitter");
else
return QStringLiteral("horizontal splitter");
}
// class AreaToolViewsPrinter
AreaToolViewsPrinter::AreaToolViewsPrinter()
{
result = QStringLiteral("\n");
}
Area::WalkerMode AreaToolViewsPrinter::operator()(Sublime::View *view, Sublime::Position position)
{
result += view->objectName() + " [ " + printPosition(position) + " ]" + '\n';
return Area::ContinueWalker;
}
QString AreaToolViewsPrinter::printPosition(Sublime::Position position)
{
switch (position)
{
case Sublime::Left: return QStringLiteral("left");
case Sublime::Right: return QStringLiteral("right");
case Sublime::Bottom: return QStringLiteral("bottom");
case Sublime::Top: return QStringLiteral("top");
default: return QStringLiteral("wrong position");
}
}
|