bool FrameAttachmentPoint::attach(AttachableFrame* frame)
{
    QLayout* layout;
    QWidget* attWidget;
    QFrame* attFrame;
    QDockWidget* attDockWidget;
    QTabWidget* attTabWidget;
    QMainWindow* attMainWindow;
    int index = 0;

    if ((int)mAttachedFrames.size() >= mMaxAttachmentCount)
    {
        LOG_ERROR() << "FrameAttachmentPoint::attach(): cannot attach more than " << mMaxAttachmentCount <<
                       " Frame" << (mMaxAttachmentCount > 1 ? "s" : "") << " to Attachment Point " << mName << ".";
       return false;
    }

    //Attach the frame in a way depending on its type
    switch (mType)
    {
    case ATTACHMENT_NONE:
         LOG_ERROR() << "FrameAttachmentPoint::attach(): cannot attach to illegal Attachment Point.";
         return false;
        break;
    case ATTACHMENT_WIDGET:
        //Attach to Widget with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attWidget = (dynamic_cast<QWidget*>(mAttachmentPoint));
        attWidget->setLayout(layout);
        attWidget->show();
        break;
    case ATTACHMENT_FRAME:
        //Attach to Frame with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attFrame = (dynamic_cast<QFrame*>(mAttachmentPoint));
        attFrame->setLayout(layout);
        attFrame->show();
        break;
    case ATTACHMENT_TABWIDGET:
        //Attach to TabWidget with adding a new page and (automatically) a layout
        attTabWidget = (dynamic_cast<QTabWidget*>(mAttachmentPoint));
        index = attTabWidget->addTab(&*frame, frame->getCaption());
        WindowManager::changeToNeutralLayout(attTabWidget->widget(index)->layout());
        break;
    case ATTACHMENT_DOCKWIDGET:
        //Attach to DockWidget with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attDockWidget = (dynamic_cast<QDockWidget*>(mAttachmentPoint));
        attDockWidget->setLayout(layout);
        attDockWidget->show();
        break;
    case ATTACHMENT_MAINWINDOW:
        //Attach to MainWindow with adding a new layout
        layout = WindowManager::createNeutralLayout();
        layout->addWidget(&*frame);
        frame->show();
        attMainWindow = (dynamic_cast<QMainWindow*>(mAttachmentPoint));
        attMainWindow->setLayout(layout);
        attMainWindow->show();
        break;
    default:
         LOG_ERROR() << "FrameAttachmentPoint::attach(): unknown Attachment Point.";
        return false;
        break;
    }

    //Store the attachment pointer
    mAttachedFrames.insert(frame->getPluginId(), frame);

    return true;
}
void CLogisticMainWindow::setupDockWindow(const bool &visible)
{
    if (!visible) return;

    QDockWidget *dockDictionary = new QDockWidget(tr("Справочники"));
                 dockDictionary->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameDictionary = new QFrame(this);

    QCommandLinkButton *client = new QCommandLinkButton(tr("Заказчики"), tr("Справочник клиентов"), frameDictionary);
                        client->setIcon(QIcon("data/picture/sidebar/customer.ico"));
    connect(client, SIGNAL(clicked()), this, SLOT(slotCustomerDictionary()));

    QCommandLinkButton *supplier = new QCommandLinkButton(tr("Поставщики"), tr("Справочник поставщиков"), frameDictionary);
                        supplier->setIcon(QIcon("data/picture/sidebar/suppliers.ico"));
    connect(supplier, SIGNAL(clicked()), this, SLOT(slotSuppliersDictionary()));

    QCommandLinkButton *producer = new QCommandLinkButton(tr("Производители"), tr("Справочник производителей"), frameDictionary);
                        producer->setIcon(QIcon("data/picture/sidebar/producers.ico"));
    connect(producer, SIGNAL(clicked()), this, SLOT(slotProdusersDictionary()));

    QCommandLinkButton *contact = new QCommandLinkButton(tr("Контакты"), tr("Справочник контактов"), frameDictionary);
                        contact->setIcon(QIcon("data/picture/sidebar/contacts.ico"));
    connect(contact, SIGNAL(clicked()), this, SLOT(slotContactsDictionary()));

    QCommandLinkButton *position = new QCommandLinkButton (tr("Должности"), tr("Справочник должностей"), frameDictionary);
                        position->setIcon(QIcon("data/picture/sidebar/positions.ico"));
    connect(position, SIGNAL(clicked()), this, SLOT(slotPositionsDictionary()));

    QCommandLinkButton *tasktype = new QCommandLinkButton (tr("Типы задач"), tr("Справочник типов задач"), frameDictionary);
                        tasktype->setIcon(QIcon("data/picture/sidebar/tasktype.ico"));
    connect(tasktype, SIGNAL(clicked()), this, SLOT(slotTaskTypesDictionary()));

    QCommandLinkButton *contractor = new QCommandLinkButton(tr("Контрагенты"), tr("Справочник контрагентов"), frameDictionary);
                        contractor->setIcon(QIcon("data/picture/sidebar/contractortype.ico"));
    connect(contractor, SIGNAL(clicked()), this, SLOT(slotContractorTypesDictionary()));

    QCommandLinkButton *status = new QCommandLinkButton (tr("Статусы"), tr("Справочник статусов"), frameDictionary);
                        status->setIcon(QIcon("data/picture/sidebar/status.ico"));
    connect(status, SIGNAL(clicked()), this, SLOT(slotStatusDictionary()));

    QCommandLinkButton *priority = new QCommandLinkButton (tr("Приоритеты"), tr("Справочник приоритетов"), frameDictionary);
                        priority->setIcon(QIcon("data/picture/sidebar/priority.ico"));
    connect(priority, SIGNAL(clicked()), this, SLOT(slotPrioritiesDictionary()));

    QCommandLinkButton *countrycity = new QCommandLinkButton (tr("Страны и города"), tr("Справочник стран и городов"), frameDictionary);
                        countrycity->setIcon(QIcon("data/picture/sidebar/countryandcity.ico"));
    connect(countrycity, SIGNAL(clicked()), this, SLOT(slotCountryCityDictionary()));

    QVBoxLayout *vboxDictionary = new QVBoxLayout(frameDictionary);
                 vboxDictionary->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxDictionary->addWidget(client);
                 vboxDictionary->addWidget(supplier);
                 vboxDictionary->addWidget(producer);
                 vboxDictionary->addWidget(contact);
                 vboxDictionary->addWidget(position);
                 vboxDictionary->addWidget(tasktype);
                 vboxDictionary->addWidget(contractor);
                 vboxDictionary->addWidget(status);
                 vboxDictionary->addWidget(priority);
                 vboxDictionary->addWidget(countrycity);

    dockDictionary->setLayout(vboxDictionary);
    dockDictionary->setWidget(frameDictionary);

    QDockWidget *dockFolder = new QDockWidget(tr("Папки"));
                 dockFolder->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameFolder = new QFrame(this);

    QCommandLinkButton *relation = new QCommandLinkButton(tr("Взаимоотношения"), frameFolder);
                        relation->setIcon(QIcon("data/picture/sidebar/relations.ico"));
    connect(relation, SIGNAL(clicked()), this, SLOT(slotRelationsFolder()));

    QCommandLinkButton *calendar = new QCommandLinkButton (tr("Календарь"), frameFolder);
                        calendar->setIcon(QIcon("data/picture/sidebar/calendar.ico"));
    connect(calendar, SIGNAL(clicked()), this, SLOT(slotCalendarFolder()));

    QCommandLinkButton *reminder = new QCommandLinkButton (tr("Напоминания"), frameFolder);
                        reminder->setIcon(QIcon("data/picture/sidebar/reminder.ico"));
    connect(reminder, SIGNAL(clicked()), this, SLOT(slotReminderFolder()));

    QVBoxLayout *vboxFolder = new QVBoxLayout(frameFolder);
                 vboxFolder->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxFolder->addWidget(relation);
                 vboxFolder->addWidget(calendar);
                 vboxFolder->addWidget(reminder);

    dockFolder->setLayout(vboxFolder);
    dockFolder->setWidget(frameFolder);

    QDockWidget *dockAdditionally = new QDockWidget(tr("Дополнительно"));
                 dockAdditionally->setFeatures(QDockWidget::NoDockWidgetFeatures);

    QFrame *frameAdditionally = new QFrame(this);

    QCommandLinkButton *accounting = new QCommandLinkButton(tr("Учетные операции"), tr("Справочник УО"), frameAdditionally);
                        accounting->setIcon(QIcon("data/picture/sidebar/accounting.png"));
    connect(accounting, SIGNAL(clicked()), this, SLOT(slotAccountingAdditionally()));

    QVBoxLayout *vboxAdditionally = new QVBoxLayout(frameAdditionally);
                 vboxAdditionally->setSizeConstraint(QVBoxLayout::SetMinAndMaxSize);
                 vboxAdditionally->addWidget(accounting);

    dockAdditionally->setLayout(vboxAdditionally);
    dockAdditionally->setWidget(frameAdditionally);

    addDockWidget(Qt::LeftDockWidgetArea, dockDictionary);
    addDockWidget(Qt::LeftDockWidgetArea, dockFolder);
    addDockWidget(Qt::LeftDockWidgetArea, dockAdditionally);

    tabifyDockWidget(dockDictionary, dockFolder);
    tabifyDockWidget(dockFolder, dockAdditionally);
}