summaryrefslogtreecommitdiffstats
path: root/digikam/libs/imageproperties/navigatebartab.cpp
blob: d40ae13408659485682c8ace5346dd4776e9aea1 (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2007-01-04
 * Description : A parent tab class with a navigation bar
 *
 * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * Copyright (C) 2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

// TQt includes.

#include <tqlayout.h>
#include <tqwidgetstack.h>
#include <tqlabel.h>

// Local includes.

#include "statusnavigatebar.h"
#include "navigatebarwidget.h"
#include "navigatebartab.h"
#include "navigatebartab.moc"

namespace Digikam
{

class NavigateBarTabPriv
{
public:

    NavigateBarTabPriv()
    {
        stack       = 0;
        navigateBar = 0;
        label       = 0;
    }

    TQWidgetStack      *stack;

    TQLabel            *label;

    NavigateBarWidget *navigateBar;
};

NavigateBarTab::NavigateBarTab(TQWidget* parent)
              : TQWidget(parent, 0, TQt::WDestructiveClose)
{
    d = new NavigateBarTabPriv;
    m_navigateBarLayout = 0;
}

NavigateBarTab::~NavigateBarTab()
{
    delete d;
}

void NavigateBarTab::setupNavigateBar(bool withBar)
{
    m_navigateBarLayout = new TQVBoxLayout(this);

    if (withBar)
    {
        d->stack = new TQWidgetStack(this);
        m_navigateBarLayout->addWidget(d->stack);

        d->navigateBar  = new NavigateBarWidget(d->stack, withBar);
        d->stack->addWidget(d->navigateBar);

        connect(d->navigateBar, TQ_SIGNAL(signalFirstItem()),
                this, TQ_SIGNAL(signalFirstItem()));

        connect(d->navigateBar, TQ_SIGNAL(signalPrevItem()),
                this, TQ_SIGNAL(signalPrevItem()));

        connect(d->navigateBar, TQ_SIGNAL(signalNextItem()),
                this, TQ_SIGNAL(signalNextItem()));

        connect(d->navigateBar, TQ_SIGNAL(signalLastItem()),
                this, TQ_SIGNAL(signalLastItem()));

        d->label = new TQLabel(d->stack);
        d->label->setAlignment(TQt::AlignCenter);
        d->stack->addWidget(d->label);
    }
}

void NavigateBarTab::setNavigateBarState(bool hasPrevious, bool hasNext)
{
    if (!d->navigateBar)
        return;

    d->stack->raiseWidget(d->navigateBar);

    if (hasPrevious && hasNext)
        d->navigateBar->setButtonsState(StatusNavigateBar::ItemCurrent);
    else if (!hasPrevious && hasNext)
        d->navigateBar->setButtonsState(StatusNavigateBar::ItemFirst);
    else if (hasPrevious && !hasNext)
        d->navigateBar->setButtonsState(StatusNavigateBar::ItemLast);
    else
        d->navigateBar->setButtonsState(StatusNavigateBar::NoNavigation);
}

void NavigateBarTab::setNavigateBarState(int itemType)
{
    if (!d->navigateBar)
        return;

    d->stack->raiseWidget(d->navigateBar);
    d->navigateBar->setButtonsState(itemType);
}

void NavigateBarTab::setNavigateBarFileName(const TQString &name)
{
    if (!d->navigateBar)
        return;

    d->stack->raiseWidget(d->navigateBar);
    d->navigateBar->setFileName(name);
}

void NavigateBarTab::setLabelText(const TQString &text)
{
    if (!d->label)
        return;

    d->stack->raiseWidget(d->label);
    d->label->setText(text);
}

}  // NameSpace Digikam