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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
// Copyright (c) 2003-2005 Charles Samuels <[email protected]>
// See the file COPYING for redistribution terms.
#include "view.h"
#include "oblique.h"
#include "menu.h"
#include <noatun/app.h>
#include <kstdaction.h>
#include <klocale.h>
#include <kedittoolbar.h>
#include <kfiledialog.h>
#include <tqlabel.h>
#include <klineeditdlg.h>
#include <kmessagebox.h>
#include <ktabwidget.h>
#include <tqtabbar.h>
class TabWidget : public KTabWidget
{
public:
TabWidget(TQWidget *parent)
: KTabWidget(parent)
{
}
public:
TQTabBar *tabBar() const { return KTabWidget::tabBar(); }
};
View::View(Oblique *oblique)
: KMainWindow(0, 0)
{
mOblique = oblique;
mTree = 0;
mTabs = new TabWidget(this);
mTabs->tabBar()->hide();
connect(mTabs, TQT_SIGNAL(currentChanged(TQWidget*)), TQT_SLOT(currentTabChanged(TQWidget*)));
setCentralWidget(mTabs);
KAction *ac;
ac = new KAction(i18n("Add &Files..."), "queue", 0, TQT_TQOBJECT(this), TQT_SLOT(addFiles()), actionCollection(), "add_files");
ac->setWhatsThis(i18n("Add a reference to a media file on disk to this collection."));
ac = new KAction(i18n("Add Fol&ders..."), "folder", 0, TQT_TQOBJECT(this), TQT_SLOT(addDirectory()), actionCollection(), "add_dir");
// ac = new KAction(i18n("&Reload"), "reload", 0, oblique, TQT_SLOT(reload()), actionCollection(), "reload");
// ac->setWhatsThis(i18n("Reread the collection and meta-information from its files."));
ac = new SliceListAction(
i18n("&Slices"), oblique,
TQT_TQOBJECT(this), TQT_SLOT(use(Slice*)), TQValueList<File>(), actionCollection(), "slices"
);
ac->setWhatsThis(i18n("Select a sub-collection to display"));
mSchemaListAction = new SchemaListAction(
i18n("&Schemas"), TQT_TQOBJECT(this), TQT_SLOT(setSchema(const TQString&)), actionCollection(), "schemas"
);
mSchemaListAction->setWhatsThis(i18n("Select a schema to use to collate the tree."));
ac = new KAction(
i18n("&New Tab"), "tab_new", "CTRL+SHIFT+N;CTRL+T", TQT_TQOBJECT(this), TQT_SLOT(addTab()),
actionCollection(), "newtab"
);
mRemoveTabAction = new KAction(
i18n("&Close Current Tab"), "tab_remove", CTRL+Key_W, TQT_TQOBJECT(this), TQT_SLOT(removeTab()),
actionCollection(), "removecurrenttab"
);
{
TQLabel *l = new TQLabel(i18n("&Jump:"), 0, "kde toolbar widget");
l->setBackgroundMode( TQt::PaletteButton );
l->setAlignment(
(TQApplication::reverseLayout() ? TQt::AlignRight : TQt::AlignLeft) |
TQt::AlignVCenter | TQt::ShowPrefix
);
l->adjustSize();
new KWidgetAction(l, i18n("&Jump:"), KShortcut(ALT + Key_J), 0, 0, actionCollection(), "jump_label");
LineEditAction *jumpAction = new LineEditAction(i18n("Jump Bar"), 0, 0, actionCollection(), "jump_text");
jumpAction->setWhatsThis(i18n("Only display items which contain this string"));
l->setBuddy(jumpAction->lineEdit());
connect(jumpAction->lineEdit(), TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(jumpTextChanged(const TQString&)));
}
KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(configureToolBars()), actionCollection());
applyMainWindowSettings(KGlobal::config(), "Oblique View");
createGUI("obliqueui.rc");
KConfigGroup g(KGlobal::config(), "oblique");
TQStringList tabids = g.readListEntry("tabids");
for (TQStringList::Iterator i(tabids.begin()); i != tabids.end(); ++i)
{
TQString t = *i;
int sliceid = t.section(':', 0, 0).toInt();
TQString fileOfQuery = t.section(':', 1, 1);
Slice *slice = oblique->base()->sliceById(sliceid);
if (!slice)
slice = oblique->base()->defaultSlice();
Tree *tree = new Tree(oblique, mTabs);
mTrees.append(tree);
tree->setSlice(slice);
tree->setSchema(fileOfQuery);
mTabs->addTab(tree, slice->name());
}
if (mTabs->count() == 0)
{ // no tabs, so use the "normal" route
addTab();
}
else
{
// ok, there's a tab, so make it present
if (mTabs->count() >= 1)
{
mTree = static_cast<Tree*>(mTrees.first());
currentTabChanged(mTrees.first());
}
if (mTabs->count() > 1)
mTabs->tabBar()->show();
}
}
View::~View()
{
TQStringList tabids;
for (int i=0; i < mTabs->count(); i++)
{
Tree *tree = static_cast<Tree*>(mTabs->page(i));
int slice = tree->slice()->id();
TQString query = tree->fileOfQuery();
TQString t = TQString("%1:%2").arg(slice).arg(query);
tabids.append(t);
}
KConfigGroup g(KGlobal::config(), "oblique");
g.writeEntry("tabids", tabids);
g.sync();
}
void View::configureToolBars()
{
saveMainWindowSettings(KGlobal::config(), "Oblique View");
KEditToolbar dlg(actionCollection(), "obliqueui.rc");
connect(&dlg, TQT_SIGNAL(newToolbarConfig()), TQT_SLOT(newToolBarConfig()));
dlg.exec();
}
void View::newToolBarConfig()
{
createGUI("obliqueui.rc");
applyMainWindowSettings(KGlobal::config(), "Oblique View");
}
void View::closeEvent(TQCloseEvent*)
{
hide();
}
void View::addFiles()
{
KURL::List files=KFileDialog::getOpenURLs(":mediadir", napp->mimeTypes(), this, i18n("Select Files to Add"));
for(KURL::List::Iterator it=files.begin(); it!=files.end(); ++it)
oblique()->addFile(KURL(*it));
}
void View::addDirectory()
{
TQString folder = KFileDialog::getExistingDirectory(":mediadir:", this,
i18n("Select Folder to Add"));
if (!folder)
return;
KURL url;
url.setPath(folder);
oblique()->beginDirectoryAdd(url);
}
void View::addTab()
{
Tree *t = new Tree(oblique(), mTabs);
if (!mTree) mTree = t;
mTrees.append(t);
mTabs->addTab(t, t->slice()->name());
mTabs->showPage(t);
if (mTabs->count() > 1)
mTabs->tabBar()->show();
currentTabChanged(t);
}
void View::removeTab()
{
Tree *current = static_cast<Tree*>(mTabs->currentPage());
if (current == mTree) return;
mTabs->removePage(current);
mTrees.remove(current);
delete current;
if (mTabs->count() == 1)
mTabs->tabBar()->hide();
}
void View::currentTabChanged(TQWidget *w)
{
mRemoveTabAction->setEnabled(w != mTree);
mSchemaListAction->setTree(static_cast<Tree*>(w));
}
void View::setSchema(const TQString &file)
{
Tree *current = static_cast<Tree*>(mTabs->currentPage());
current->setSchema(file);
}
void View::jumpTextChanged(const TQString &text)
{
Tree *current = static_cast<Tree*>(mTabs->currentPage());
current->setLimit(text);
}
void View::use(Slice *s)
{
Tree *current = static_cast<Tree*>(mTabs->currentPage());
current->setSlice(s);
mTabs->setTabLabel(current, current->slice()->name());
}
LineEditAction::LineEditAction(const TQString &text, const TQObject *reciever, const char *slot, KActionCollection *parent, const char *name)
: KWidgetAction(new KLineEdit(0), text, KShortcut(0), reciever, slot, parent, name)
{
setAutoSized(true);
}
#include "view.moc"
|