Exemple #1
0
bool UserTabBar::isBold(UserWnd *wnd)
{
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd() == wnd)
            return tab->isBold();
    }
    return false;
}
Exemple #2
0
void UserTabBar::layoutTabs()
{
    QTabBar::layoutTabs();
#if QT_VERSION < 300
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        t->r.setHeight(height());
    }
#endif
}
Exemple #3
0
void UserTabBar::raiseTab(unsigned id)
{
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id){
            setCurrentTab(tab);
            return;
        }
    }
}
Exemple #4
0
UserWnd *UserTabBar::wnd(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id)
            return tab->wnd();
    }
    return NULL;
}
Exemple #5
0
void UserTabBar::setBold(unsigned id, bool bBold)
{
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id){
            if (tab->setBold(bBold))
                repaint();
            break;
        }
    }
}
Exemple #6
0
void UserTabBar::changeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id){
            tab->setText(tab->wnd()->getName());
            break;
        }
    }
}
Exemple #7
0
void UserTabBar::removeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab == NULL)
            continue;
        if (tab->wnd()->id() == id){
            QTabBar::removeTab(tab);
            break;
        }
    }
}
Exemple #8
0
void UserTabBar::removeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab == NULL)
            continue;
        if (tab->wnd()->id() == id){
            QTabBar::removeTab(tab);
            QTimer::singleShot(0, this, SLOT(slotRepaint()));
            break;
        }
    }
}
Exemple #9
0
// ****************************************************************************
WindowProperties::~WindowProperties(void)
{
    // Delete the menu properties (if available)
    if (mWindowMenuProperties)
        delete mWindowMenuProperties;

    // Delete all objects from the mHToolbarPropertiesList
    QVectorIterator<ToolbarProperties*> hList(mHToolbarPropertiesList);
    ToolbarProperties* toolbarProperties = 0;
    hList.toFront();
    while (hList.hasNext())
    {
        toolbarProperties = hList.next();
        if (toolbarProperties)
            delete toolbarProperties;
    }
    mHToolbarPropertiesList.clear();

    // Delete all objects from the mVToolbarPropertiesList
    QVectorIterator<ToolbarProperties*> vList(mVToolbarPropertiesList);
    vList.toFront();
    while (vList.hasNext())
    {
        toolbarProperties = vList.next();
        if (toolbarProperties)
            delete toolbarProperties;
    }
    mVToolbarPropertiesList.clear();

    // Delete all objects from the mTabPropertiesList
    QVectorIterator<TabProperties*> tabList(mTabPropertiesList);
    TabProperties* tabProperties = 0;
    tabList.toFront();
    while (tabList.hasNext())
    {
        tabProperties = tabList.next();
        if (tabProperties)
            delete tabProperties;
    }
    mTabPropertiesList.clear();
}
void KTabBar::setTabEnabled( int id, bool enabled )
{
    QTab * t = tab( id );
    if ( t ) {
        if ( t->isEnabled() != enabled ) {
            t->setEnabled( enabled );
            QRect r( t->rect() );
            if ( !enabled && id == currentTab() && count()>1 ) {
                int index = indexOf( id );
                index += ( index+1 == count() ) ? -1 : 1;
                t = tabAt( index );

                if ( t->isEnabled() ) {
                    r = r.unite( t->rect() );
                    QPtrList<QTab> *tablist = tabList();
                    tablist->append( tablist->take( tablist->findRef( t ) ) );
                    emit selected( t->identifier() );
                }
            }
            repaint( r );
        }
    }
}
Exemple #11
0
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is part of the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include "qtbuildertab.h"
#include "qtbuilder.h"
#include "applicationtemplate.h"
#include "utils.h"

//****************************************************************************/
QtTabBuilder::QtTabBuilder()
{
}

//****************************************************************************/
QtTabBuilder::~QtTabBuilder()
{
}

//****************************************************************************/
QString QtTabBuilder::createInclude(WindowProperties* windowProperties, const QString &s)
{
    QString str = s;

    // Add the #include
    str = str +
        QString("#include <QTabWidget>") +
        QString("\n");

    return str;
}

//****************************************************************************/
QString QtTabBuilder::createPrivateMembers(WindowProperties* windowProperties, const QString &s)
{
    QString str = s;
    if (windowProperties)
    {
        // Define private members
        if (!windowProperties->mTabPropertiesList.empty())
        {
            str = str +
                TAB +
                TAB +
                QString("QTabWidget* mTabWidget;") +
                QString("\n");
        }
    }

    return str;
}

//****************************************************************************/
QString QtTabBuilder::createPrivateSlots(WindowProperties* windowProperties, const QString &s)
{
    QString str = s;
    if (windowProperties)
    {
        // Define private slots
        if (!windowProperties->mTabPropertiesList.empty())
        {
            str = str +
                TAB +
                TAB +
                QString("void tabSelected(int index);") +
                QString("\n");
        }
    }

    return str;
}

//****************************************************************************/
QString QtTabBuilder::createConnect(WindowProperties* windowProperties, const QString &s)
{
    QString str = s;
    if (windowProperties)
    {
        if (!windowProperties->mTabPropertiesList.empty())
        {
            str = str +
                TAB +
                QString("connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabSelected(int)));") +
                QString("\n");
        }
    }

    return str;
}

//****************************************************************************/
QString QtTabBuilder::createTabs(WindowProperties* windowProperties,
                                 const QString &s,
                                 const QString &iconDir,
                                 const QString &fullOutputIconDir)
{
    QString str = s;
    if (windowProperties)
    {
        if (!windowProperties->mTabPropertiesList.empty())
        {
            if (windowProperties->mOrder != 0)
            {
                // Create the QTabWidget
                str = str +
                    TAB +
                    QString("mTabWidget = new QTabWidget(mInnerMain);") +
                    QString("\n");

                // Loop through the tab list of the window and add new tabs
                QFile fileUtil;
                QVectorIterator<TabProperties*> tabList(windowProperties->mTabPropertiesList);
                TabProperties* tabProperties = 0;
                tabList.toFront();
                while (tabList.hasNext())
                {
                    tabProperties = tabList.next();

                    // Copy the icon
                    fileUtil.copy(iconDir + tabProperties->mIcon, fullOutputIconDir + tabProperties->mIcon);

                    // Add tabs to the QTabWidget
                    str = str +
                        TAB +
                        QString("mTabWidget->addTab(new QWidget(this), QIcon(\"") +
                        iconDir +
                        tabProperties->mIcon +
                        QString("\"), QString(\"") +
                        tabProperties->mName +
                        QString("\"));") +
                        QString("\n");
                }

                // Centralize the QTabWidget in the mInnerMain
                str = str +
                    TAB +
                    QString("mInnerMain->setCentralWidget(mTabWidget);") +
                    QString("\n");

                // Check whether the title must be displayed (do not set the title if it is explicitly set to 'false')
                if (!windowProperties->mDisplayTitle)
                {
                    str = str +
                        TAB +
                        QString("setWindowTitle(QString(\"\"));") +
                        QString("\n");
                }

                str = str +
                    TAB +
                    QString("mTabWidget->show();") +
                    QString("\n");
            }
        }
    }

    return str;
}