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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/***************************************************************************
* Copyright (C) 2007 by Marcel Juhnke *
* marrat@marrat.homelinux.org *
* Copyright (C) 2006 by Peter Penz *
* peter.penz@gmx.at *
* *
* 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 of the License, 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <tqlayout.h>
#include <tqpixmap.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tqcombobox.h>
#include "dolphinsettings.h"
#include "sidebarssettings.h"
#include "bookmarkssidebarpage.h"
#include "infosidebarpage.h"
#include "sidebars.h"
#include <assert.h>
/**
*
* @param parent
*/
leftSidebar::leftSidebar(TQWidget* parent) :
TQWidget(parent),
m_pagesSelector(0),
m_page(0),
m_layout(0)
{
m_layout = new TQVBoxLayout(this);
m_pagesSelector = new TQComboBox(this);
m_pagesSelector->insertItem(i18n("Bookmarks"));
m_pagesSelector->insertItem(i18n("Information"));
// Assure that the combo box has the same height as the URL navigator for
// a clean layout.
// TODO: the following 2 lines have been copied from the URLNavigator
// constructor (-> provide a shared height setting?)
//TQFontMetrics fontMetrics(font());
TQFontMetrics fontMetrics(font());
m_pagesSelector->setMinimumHeight(fontMetrics.height() + 8);
leftSidebarSettings* settings = DolphinSettings::instance().leftsidebar();
const int selectedIndex = indexForName(settings->selectedPage());
m_pagesSelector->setCurrentItem(selectedIndex);
m_layout->addWidget(m_pagesSelector);
createPage(selectedIndex);
connect(m_pagesSelector, TQ_SIGNAL(activated(int)),
this, TQ_SLOT(createPage(int)));
}
leftSidebar::~leftSidebar()
{
}
TQSize leftSidebar::sizeHint() const
{
TQSize size(TQWidget::sizeHint());
leftSidebarSettings* settings = DolphinSettings::instance().leftsidebar();
size.setWidth(settings->width());
return size;
}
void leftSidebar::createPage(int index)
{
if (m_page != 0) {
m_page->deleteLater();
m_page = 0;
}
switch (index) {
case 0: m_page = new BookmarksSidebarPage(this); break;
case 1: m_page = new InfoSidebarPage(this); break;
default: break;
}
m_layout->addWidget(m_page);
m_page->show();
leftSidebarSettings* settings = DolphinSettings::instance().leftsidebar();
settings->setSelectedPage(m_pagesSelector->text(index));
}
int leftSidebar::indexForName(const TQString& name) const
{
const int count = m_pagesSelector->count();
for (int i = 0; i < count; ++i) {
if (m_pagesSelector->text(i) == name) {
return i;
}
}
return 0;
}
rightSidebar::rightSidebar(TQWidget* parent) :
TQWidget(parent),
m_pagesSelector(0),
m_page(0),
m_layout(0)
{
m_layout = new TQVBoxLayout(this);
m_pagesSelector = new TQComboBox(this);
m_pagesSelector->insertItem(i18n("Bookmarks"));
m_pagesSelector->insertItem(i18n("Information"));
// Assure that the combo box has the same height as the URL navigator for
// a clean layout.
// TODO: the following 2 lines have been copied from the URLNavigator
// constructor (-> provide a shared height setting?)
TQFontMetrics fontMetrics(font());
m_pagesSelector->setMinimumHeight(fontMetrics.height() + 8);
rightSidebarSettings* settings = DolphinSettings::instance().rightsidebar();
const int selectedIndex = indexForName(settings->selectedPage());
m_pagesSelector->setCurrentItem(selectedIndex);
m_layout->addWidget(m_pagesSelector);
createPage(selectedIndex);
connect(m_pagesSelector, TQ_SIGNAL(activated(int)),
this, TQ_SLOT(createPage(int)));
}
rightSidebar::~rightSidebar()
{
}
TQSize rightSidebar::sizeHint() const
{
TQSize size(TQWidget::sizeHint());
rightSidebarSettings* settings = DolphinSettings::instance().rightsidebar();
size.setWidth(settings->width());
return size;
}
void rightSidebar::createPage(int index)
{
if (m_page != 0) {
m_page->deleteLater();
m_page = 0;
}
switch (index) {
case 0: m_page = new BookmarksSidebarPage(this); break;
case 1: m_page = new InfoSidebarPage(this); break;
default: break;
}
m_layout->addWidget(m_page);
m_page->show();
rightSidebarSettings* settings = DolphinSettings::instance().rightsidebar();
settings->setSelectedPage(m_pagesSelector->text(index));
}
int rightSidebar::indexForName(const TQString& name) const
{
const int count = m_pagesSelector->count();
for (int i = 0; i < count; ++i) {
if (m_pagesSelector->text(i) == name) {
return i;
}
}
return 0;
}
#include "sidebars.moc"
|