mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-26 10:50:54 +00:00
Fixed: Wrong EOL
This commit is contained in:
parent
baa6564551
commit
2da56dfa3e
1 changed files with 166 additions and 166 deletions
|
@ -1,167 +1,167 @@
|
||||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2010 Winch Gate Property Limited
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "context_manager.h"
|
#include "context_manager.h"
|
||||||
#include "icontext.h"
|
#include "icontext.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QTabWidget>
|
#include <QtGui/QTabWidget>
|
||||||
#include <QtGui/QGridLayout>
|
#include <QtGui/QGridLayout>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ContextManagerPrivate
|
struct ContextManagerPrivate
|
||||||
{
|
{
|
||||||
explicit ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget);
|
explicit ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget);
|
||||||
Core::MainWindow *m_mainWindow;
|
Core::MainWindow *m_mainWindow;
|
||||||
QTabWidget *m_tabWidget;
|
QTabWidget *m_tabWidget;
|
||||||
QVector<IContext *> m_contexts;
|
QVector<IContext *> m_contexts;
|
||||||
int m_oldCurrent;
|
int m_oldCurrent;
|
||||||
};
|
};
|
||||||
|
|
||||||
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||||
: m_mainWindow(mainWindow),
|
: m_mainWindow(mainWindow),
|
||||||
m_tabWidget(tabWidget),
|
m_tabWidget(tabWidget),
|
||||||
m_oldCurrent(-1)
|
m_oldCurrent(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextManager::ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
ContextManager::ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||||
: d(new ContextManagerPrivate(mainWindow, tabWidget))
|
: d(new ContextManagerPrivate(mainWindow, tabWidget))
|
||||||
{
|
{
|
||||||
QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(objectAdded(QObject *)),
|
QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(objectAdded(QObject *)),
|
||||||
this, SLOT(objectAdded(QObject *)));
|
this, SLOT(objectAdded(QObject *)));
|
||||||
QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(aboutToRemoveObject(QObject *)),
|
QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(aboutToRemoveObject(QObject *)),
|
||||||
this, SLOT(aboutToRemoveObject(QObject *)));
|
this, SLOT(aboutToRemoveObject(QObject *)));
|
||||||
|
|
||||||
QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextManager::~ContextManager()
|
ContextManager::~ContextManager()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IContext *ContextManager::currentContext() const
|
Core::IContext *ContextManager::currentContext() const
|
||||||
{
|
{
|
||||||
int currentIndex = d->m_tabWidget->currentIndex();
|
int currentIndex = d->m_tabWidget->currentIndex();
|
||||||
if (currentIndex < 0)
|
if (currentIndex < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return d->m_contexts.at(currentIndex);
|
return d->m_contexts.at(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IContext *ContextManager::context(const QString &id) const
|
Core::IContext *ContextManager::context(const QString &id) const
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
const int index = indexOf(id);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
return d->m_contexts.at(index);
|
return d->m_contexts.at(index);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::registerUndoStack(QUndoStack *stack)
|
void ContextManager::registerUndoStack(QUndoStack *stack)
|
||||||
{
|
{
|
||||||
nlassert(stack);
|
nlassert(stack);
|
||||||
d->m_mainWindow->undoGroup()->addStack(stack);
|
d->m_mainWindow->undoGroup()->addStack(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::unregisterUndoStack(QUndoStack *stack)
|
void ContextManager::unregisterUndoStack(QUndoStack *stack)
|
||||||
{
|
{
|
||||||
nlassert(stack);
|
nlassert(stack);
|
||||||
d->m_mainWindow->undoGroup()->removeStack(stack);
|
d->m_mainWindow->undoGroup()->removeStack(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::activateContext(const QString &id)
|
void ContextManager::activateContext(const QString &id)
|
||||||
{
|
{
|
||||||
const int index = indexOf(id);
|
const int index = indexOf(id);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
d->m_tabWidget->setCurrentIndex(index);
|
d->m_tabWidget->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::updateCurrentContext()
|
void ContextManager::updateCurrentContext()
|
||||||
{
|
{
|
||||||
d->m_mainWindow->updateContext(currentContext());
|
d->m_mainWindow->updateContext(currentContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::objectAdded(QObject *obj)
|
void ContextManager::objectAdded(QObject *obj)
|
||||||
{
|
{
|
||||||
IContext *context = qobject_cast<IContext *>(obj);
|
IContext *context = qobject_cast<IContext *>(obj);
|
||||||
if (context)
|
if (context)
|
||||||
addContextObject(context);
|
addContextObject(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::aboutToRemoveObject(QObject *obj)
|
void ContextManager::aboutToRemoveObject(QObject *obj)
|
||||||
{
|
{
|
||||||
IContext *context = qobject_cast<IContext *>(obj);
|
IContext *context = qobject_cast<IContext *>(obj);
|
||||||
if (context)
|
if (context)
|
||||||
removeContextObject(context);
|
removeContextObject(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::addContextObject(IContext *context)
|
void ContextManager::addContextObject(IContext *context)
|
||||||
{
|
{
|
||||||
d->m_contexts.push_back(context);
|
d->m_contexts.push_back(context);
|
||||||
d->m_mainWindow->addContextObject(context);
|
d->m_mainWindow->addContextObject(context);
|
||||||
|
|
||||||
QWidget *tabWidget = new QWidget(d->m_tabWidget);
|
QWidget *tabWidget = new QWidget(d->m_tabWidget);
|
||||||
d->m_tabWidget->addTab(tabWidget, context->icon(), context->trName());
|
d->m_tabWidget->addTab(tabWidget, context->icon(), context->trName());
|
||||||
QGridLayout *gridLayout = new QGridLayout(tabWidget);
|
QGridLayout *gridLayout = new QGridLayout(tabWidget);
|
||||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + context->id());
|
gridLayout->setObjectName(QString::fromUtf8("gridLayout_") + context->id());
|
||||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
gridLayout->addWidget(context->widget(), 0, 0, 1, 1);
|
gridLayout->addWidget(context->widget(), 0, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::removeContextObject(IContext *context)
|
void ContextManager::removeContextObject(IContext *context)
|
||||||
{
|
{
|
||||||
d->m_mainWindow->removeContextObject(context);
|
d->m_mainWindow->removeContextObject(context);
|
||||||
|
|
||||||
const int index = indexOf(context->id());
|
const int index = indexOf(context->id());
|
||||||
QWidget *widget = d->m_tabWidget->widget(index);
|
QWidget *widget = d->m_tabWidget->widget(index);
|
||||||
d->m_tabWidget->removeTab(index);
|
d->m_tabWidget->removeTab(index);
|
||||||
d->m_contexts.remove(index);
|
d->m_contexts.remove(index);
|
||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextManager::currentTabChanged(int index)
|
void ContextManager::currentTabChanged(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
IContext *context = d->m_contexts.at(index);
|
IContext *context = d->m_contexts.at(index);
|
||||||
IContext *oldContext = 0;
|
IContext *oldContext = 0;
|
||||||
if (d->m_oldCurrent >= 0)
|
if (d->m_oldCurrent >= 0)
|
||||||
oldContext = d->m_contexts.at(d->m_oldCurrent);
|
oldContext = d->m_contexts.at(d->m_oldCurrent);
|
||||||
d->m_oldCurrent = index;
|
d->m_oldCurrent = index;
|
||||||
Q_EMIT currentContextChanged(context, oldContext);
|
Q_EMIT currentContextChanged(context, oldContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ContextManager::indexOf(const QString &id) const
|
int ContextManager::indexOf(const QString &id) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < d->m_contexts.count(); ++i)
|
for (int i = 0; i < d->m_contexts.count(); ++i)
|
||||||
{
|
{
|
||||||
if (d->m_contexts.at(i)->id() == id)
|
if (d->m_contexts.at(i)->id() == id)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
nlwarning(QString("Warning, no such context: %1").arg(id).toUtf8().constData());
|
nlwarning(QString("Warning, no such context: %1").arg(id).toUtf8().constData());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace Core */
|
} /* namespace Core */
|
Loading…
Reference in a new issue