Beispiel #1
0
void Toerstein::createShortcuts(void)
{
    QShortcut *shortcut;

    /* In QMenuBar shortcuts won't work if menuBar is not visible,
     * so we'll add them separately here
     */

    /* Shortcuts to File-menu */
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+T", "File|New Tab")),this,SLOT(createNewTab()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+N", "File|New File")),this,SLOT(createNewFile()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open File")),this,SLOT(open()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+P", "File|Enter File Path") ),this,SLOT(search()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+S", "File|Save File") ),this,SLOT(save()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+W", "File|Close File") ),this,SLOT(closeFile()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+Q", "File|Quit")),this,SLOT(close()));
    shortcut->setAutoRepeat(false);

    /* Shortcuts to View-menu */
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+D", "Toggle Diff View|Quit")),this,SLOT(toggleViewMode()));
    shortcut->setAutoRepeat(false);
}
Beispiel #2
0
void Toerstein::open(const QString &path)
{
    ToolArea* toolArea;
    ToolAreaSide side;

    if (!isFileValid(path))
    {
        return;
    }

    for ( int i = 0; i < tabView->count(); i++ )
    {
        toolArea = qobject_cast<ToolArea *>(tabView->widget(i));

        side = toolArea->isFileOpen(path);

        if ( side != ToolAreaNone )
        {
            tabView->setCurrentIndex(i);
            toolArea->setFocusToCodeEditor(side);
            return;
        }
    }

    toolArea = qobject_cast<ToolArea *>(tabView->currentWidget());

    if ( !toolArea->open(path) )
    {
        createNewTab();
    }

    toolArea = qobject_cast<ToolArea *>(tabView->currentWidget());
    toolArea->open(path);
}
Beispiel #3
0
void Manitou::onOpenTab()
{
    BrowserTab *tab = createNewTab();
    BrowserWindow *window = (BrowserWindow*) activeWindow();
    window->addTab(tab);
    window->setCurrentTab(tab);
}
Beispiel #4
0
Listening::Listening(MainWindow *mainWindow, Socket *socket, Book *book)
{
    this->mainWindow = mainWindow;
    this->listenSocket = socket;
    this->book = book;

    this->udp = new NetworkUDP();
    this->rfc = new RFC1664();

    QString global_room_name(this->book->getRooms().at(0).getName().c_str());
    this->mainWindow->getUi()->QTabWidget_onglets->setTabText(0, global_room_name);
    this->keepalive = NULL;

    QObject::connect(this, SIGNAL(statusBarChanged(QString)),this->mainWindow->getUi()->statusBar, SLOT(showMessage(QString)));
    QObject::connect(this, SIGNAL(newRoom(QString)),this, SLOT(createNewTab(QString)));
}
Beispiel #5
0
BrowserWindow* Manitou::createNewWindow(const QUrl &url)
{
    BrowserWindow *window = new BrowserWindow(windowsSequence);
    windowsMap.insert(windowsSequence++, window);
    connect(window, SIGNAL(windowClosed(unsigned long)), SLOT(onWindowClosed(unsigned long)));

    BrowserTab *tab = createNewTab(url);
    window->addTab(tab);

    BrowserWindow *activeWindow = (BrowserWindow*) Manitou::activeWindow();
    if (activeWindow) {
        window->setWindowState(activeWindow->windowState());
    }

    return window;
}
Beispiel #6
0
void Toerstein::open(const QString &path1, const QString &path2)
{
    if (!isFileValid(path1) || !isFileValid(path2))
    {
        return;
    }

    ToolArea* toolArea = qobject_cast<ToolArea *>(tabView->currentWidget());

    if ( !toolArea->open(path1, path2) )
    {
        createNewTab();
    }

    toolArea = qobject_cast<ToolArea *>(tabView->currentWidget());
    toolArea->open(path1, path2);
}
Beispiel #7
0
void Toerstein::createMenuBar(void)
{
    QMenuBar *menuBar = new QMenuBar(this);
    menuBar->setVisible(false);

    /* Create File menu */
    QMenu *fileMenu = menuBar->addMenu(tr("&File"));

    fileMenu->addAction( tr("New &Tab"), this, SLOT(createNewTab()) );
    fileMenu->addAction( tr("&New"), this, SLOT(createNewFile()) );
    fileMenu->addAction( tr("&Open"), this, SLOT(open()) );
    fileMenu->addAction( tr("Enter File &Path"), this, SLOT(search()) );
    fileMenu->addAction( tr("&Save"), this, SLOT(save()) );
    fileMenu->addAction( tr("Save As..."), this, SLOT(saveAs()) );
    fileMenu->addAction( tr("&Close File"), this, SLOT(closeFile()) );
    fileMenu->addAction( tr("&Quit"), this, SLOT(close()) );

    QMenu *viewMenu = menuBar->addMenu(tr("&View"));
    viewMenu->addAction( tr("Toggle &Diff View"), this, SLOT(toggleViewMode()) );

    this->setMenuBar(menuBar);
}
CtrlrLuaMethod *CtrlrLuaMethodEditor::setEditedMethod (const Uuid &methodUuid)
{
	CtrlrLuaMethod *method = getMethodManager().getMethodByUuid(methodUuid);

	if (method != nullptr)
	{
		if (method->getCodeEditor() == nullptr)
		{
			/* the method is not yest beeing edited */
			createNewTab (method);
		}
		else
		{
			/* it looks like the method is edited, switch to the tab that has it */
			setCurrentTab (method);
		}

		return (method);
	}

	return (nullptr); // A method has been selected that's invalid
}
void SignalChainManager::updateVisibleEditors(GenericEditor* activeEditor,
                                              int index, int insertionPoint, int action)

{

    enum actions {ADD, MOVE, REMOVE, ACTIVATE, UPDATE};

    // Step 1: update the editor array
    if (action == ADD)
    {
        std::cout << "    Adding editor." << std::endl;
        editorArray.insert(insertionPoint, activeEditor);

    }
    else if (action == MOVE)
    {
        std::cout << "    Moving editors." << std::endl;
        if (insertionPoint < index)
            editorArray.move(index, insertionPoint);
        else if (insertionPoint > index)
            editorArray.move(index, insertionPoint-1);

    }
    else if (action == REMOVE)
    {

        std::cout << "    Removing editor." << std::endl;

        GenericProcessor* p = (GenericProcessor*) editorArray[index]->getProcessor();

        // if the processor to be removed is a merger,
        // we need to inform the other source that its merger has disappeared
        if (p->isMerger())
        {
            p->switchIO();
            if (p->getSourceNode() != 0)
                p->getSourceNode()->setDestNode(0);
        }

        // if the processor to be removed is a splitter, we need to make sure 
        // there aren't any orphaned processors
        if (p->isSplitter())
        {
            p->switchIO();
            if (p->getDestNode() != 0)
            {
                std::cout << "Found an orphaned signal chain" << std::endl;
                p->getDestNode()->setSourceNode(0);
                createNewTab(p->getDestNode()->getEditor());
            }
        }

        editorArray.remove(index);

        int t = activeEditor->tabNumber();

        // std::cout << editorArray.size() << " " << t << std::endl;

        bool merger;

        if (editorArray.size() > 0)
        {
            GenericProcessor* p = (GenericProcessor*) editorArray[0]->getProcessor();
            merger = (p->isMerger() && p->stillHasSource());
            if (merger)
            {
                std::cout << "We've got a merger!" << std::endl;
                //p->switchSource();
            }
        }

        if (editorArray.size() > 0 && !merger) // if there are still editors in this chain
        {
            if (t > -1)  // pass on tab
            {
                //      std::cout << "passing on the tab." << std::endl;
                int nextEditor = jmax(0,0);//index-1);
                editorArray[nextEditor]->tabNumber(t);
                signalChainArray[t]->setEditor(editorArray[nextEditor]);
            }

            int nextEditor = jmin(index,editorArray.size()-1);
            activeEditor = editorArray[nextEditor];
            activeEditor->select();
            //activeEditor->grabKeyboardFocus();

        }
        else
        {

            std::cout << "Tab number " << t << std::endl;

            removeTab(t);

            if (signalChainArray.size() > 0) // if there are other chains
            {
                int nextTab = jmin(t,signalChainArray.size()-1);
                activeEditor = signalChainArray[nextTab]->getEditor();
                activeEditor->select();
                signalChainArray[nextTab]->setToggleState(true,false); // send it back to update connections
            }
            else
            {
                activeEditor = 0; // nothing is active
                //  signalChainNeedsSource = true;
            }
        }

    }
    else     //no change
    {

        std::cout << "Activating editor" << std::endl;
    }

    // Step 2: update connections
    if (action != ACTIVATE && action != UPDATE && editorArray.size() > 0)
    {

        std::cout << "Updating connections." << std::endl;

        GenericProcessor* source = 0;
        GenericProcessor* dest = (GenericProcessor*) editorArray[0]->getProcessor();

        dest->setSourceNode(source);

        for (int n = 1; n < editorArray.size(); n++)
        {

            dest = (GenericProcessor*) editorArray[n]->getProcessor();
            source = (GenericProcessor*) editorArray[n-1]->getProcessor();

            dest->setSourceNode(source);
        }

        dest->setDestNode(0);

    }

    // Step 3: check for new tabs
    if (action != ACTIVATE && action != UPDATE)
    {

        std::cout << "Checking for new tabs." << std::endl;

        for (int n = 0; n < editorArray.size(); n++)
        {
            GenericProcessor* p = (GenericProcessor*) editorArray[n]->getProcessor();

            if (p->getSourceNode() == 0)// && editorArray[n]->tabNumber() == -1)
            {

                if (editorArray[n]->tabNumber() == -1)

                {
                    if (!p->isMerger())
                    {
                        std::cout << p->getName() << " has no source node. Creating a new tab." << std::endl;
                        createNewTab(editorArray[n]);
                    }
                }

            }
            else
            {
                if (editorArray[n]->tabNumber() > -1)
                {
                    removeTab(editorArray[n]->tabNumber());
                }

                editorArray[n]->tabNumber(-1); // reset tab status
            }

            if (p->isMerger())
            {
                std::cout << "It's a merger!" << std::endl;
                //createNewTab(editorArray[n]);
            }
        }
    }

    // Step 4: Refresh editors in editor array, based on active editor
    for (int n = 0; n < editorArray.size(); n++)
    {
        editorArray[n]->setVisible(false);
    }

    editorArray.clear();
    std::cout << "Cleared editor array." << std::endl;

    GenericEditor* editorToAdd = activeEditor;

    while (editorToAdd != 0)
    {
        std::cout << "Inserting " << editorToAdd->getName() << " at point 0." << std::endl;

        editorArray.insert(0,editorToAdd);
        GenericProcessor* currentProcessor = (GenericProcessor*) editorToAdd->getProcessor();
        GenericProcessor* source = currentProcessor->getSourceNode();

        if (source != 0)
        {
            std::cout << "Source: " << source->getName() << std::endl;

            // need to switch the splitter somehow
            // if (action == ACTIVATE || action == UPDATE)
            // {
            //  if (source->isSplitter())
            //  {
            //      source->setPathToProcessor(currentProcessor);
            //  }
            // }

            editorToAdd = (GenericEditor*) source->getEditor();


        }
        else
        {

            if (editorToAdd->tabNumber() >= 0)
                signalChainArray[editorToAdd->tabNumber()]->setToggleState(true, false);
            std::cout << "No source found." << std::endl;
            editorToAdd = 0;

        }
    }

    editorToAdd = activeEditor;

    while (editorToAdd != 0)
    {

        GenericProcessor* currentProcessor = (GenericProcessor*) editorToAdd->getProcessor();
        GenericProcessor* dest = currentProcessor->getDestNode();

        if (dest != 0)
        {

            std::cout << "Destination: " << dest->getName() << std::endl;
            editorToAdd = (GenericEditor*) dest->getEditor();
            editorArray.add(editorToAdd);
            std::cout << "Inserting " << editorToAdd->getName() << " at the end." << std::endl;

            if (dest->isMerger())
            {
                std::cout << "It's a merger!" << std::endl;

                if (dest->getSourceNode() != currentProcessor)
                    editorToAdd->switchSource();

            }

        }
        else
        {
            std::cout << "No dest found." << std::endl;
            editorToAdd = 0;
        }


    }

    // Step 5: check the validity of the signal chain
    if (true)
    {
        //action != ACTIVATE) {
        bool enable = true;

        if (editorArray.size() == 1)
        {

            GenericProcessor* source = (GenericProcessor*) editorArray[0]->getProcessor();
            if (source->isSource())
                editorArray[0]->setEnabledState(true);
            else
                editorArray[0]->setEnabledState(false);

        }
        else
        {

            for (int n = 0; n < editorArray.size()-1; n++)
            {
                GenericProcessor* source = (GenericProcessor*) editorArray[n]->getProcessor();
                GenericProcessor* dest = (GenericProcessor*) editorArray[n+1]->getProcessor();

                if (n == 0 && !source->isSource())
                    enable = false;

                editorArray[n]->setEnabledState(enable);

                if (source->canSendSignalTo(dest) && source->enabledState())
                    enable = true;
                else
                    enable = false;

                if (source->isSplitter())
                {
                    if (source->getDestNode() != dest)
                    {
                        //source->switchIO();
                        editorArray[n]->switchDest();
                    }
                }

                if (enable)
                    std::cout << "Enabling node." << std::endl;
                else
                    std::cout << "Not enabling node." << std::endl;

                editorArray[n+1]->setEnabledState(enable);

            }
        }
    }

    // Step 6: inform the tabs that something has changed
    for (int n = 0; n < signalChainArray.size(); n++)
    {
        if (signalChainArray[n]->getToggleState())
        {
            signalChainArray[n]->hasNewConnections(true);
        }
    }

    // Step 7: update all settings
    if (action != ACTIVATE)
    {

        std::cout << "Updating settings." << std::endl;

        Array<GenericProcessor*> splitters;

        for (int n = 0; n < signalChainArray.size(); n++)
        {
            // iterate through signal chains

            GenericEditor* source = signalChainArray[n]->getEditor();
            GenericProcessor* p = source->getProcessor();

            p->update();

            if (p->isSplitter())
            {
                splitters.add(p);
            }

            GenericProcessor* dest = p->getDestNode();

            while (dest != 0)
            {
                // iterate through processors
                dest->update();
                dest = dest->getDestNode();

                if (dest == 0 && splitters.size() > 0)
                {
                    splitters.getFirst()->switchIO();
                    dest = splitters[0]->getDestNode();
                    splitters.remove(0);
                }
            }
        }
    }


    std::cout << "Finished adding new editor." << std::endl << std::endl << std::endl;

}
Beispiel #10
0
void PmChart::addTab()
{
    createNewTab(isArchiveTab() == false);
}