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
|
/* This file is part of the KDE project
Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "utils.h"
#include "utils_p.h"
#include <tqheader.h>
#include <tqlayout.h>
#include <ktabwidget.h>
#include <tdelistview.h>
#include <kiconloader.h>
#include <kdialogbase.h>
#include <kpushbutton.h>
#include <kguiitem.h>
#ifdef KEXI_DEBUG_GUI
static DebugWindowDialog* debugWindow = 0;
static KTabWidget* debugWindowTab = 0;
static TDEListView* kexiDBDebugPage = 0;
static TDEListView* kexiAlterTableActionDebugPage = 0;
TQWidget *KexiUtils::createDebugWindow(TQWidget *parent)
{
// (this is internal code - do not use i18n() here)
debugWindow = new DebugWindowDialog(parent);
debugWindow->setSizeGripEnabled( true );
TQBoxLayout *lyr = new TQVBoxLayout(debugWindow, KDialogBase::marginHint());
debugWindowTab = new KTabWidget(debugWindow, "debugWindowTab");
lyr->addWidget( debugWindowTab );
debugWindow->resize(900, 600);
debugWindow->setIcon( DesktopIcon("info") );
debugWindow->setCaption("Kexi Internal Debugger");
debugWindow->show();
return debugWindow;
}
void KexiUtils::addKexiDBDebug(const TQString& text)
{
// (this is internal code - do not use i18n() here)
if (!debugWindowTab)
return;
if (!kexiDBDebugPage) {
TQWidget *page = new TQWidget(debugWindowTab);
TQVBoxLayout *vbox = new TQVBoxLayout(page);
TQHBoxLayout *hbox = new TQHBoxLayout(page);
vbox->addLayout(hbox);
hbox->addStretch(1);
KPushButton *btn_clear = new KPushButton(KGuiItem("Clear", "clear_left"), page);
hbox->addWidget(btn_clear);
kexiDBDebugPage = new TDEListView(page, "kexiDbDebugPage");
TQObject::connect(btn_clear, TQT_SIGNAL(clicked()), kexiDBDebugPage, TQT_SLOT(clear()));
vbox->addWidget(kexiDBDebugPage);
kexiDBDebugPage->addColumn("");
kexiDBDebugPage->header()->hide();
kexiDBDebugPage->setSorting(-1);
kexiDBDebugPage->setAllColumnsShowFocus ( true );
kexiDBDebugPage->setColumnWidthMode( 0, TQListView::Maximum );
kexiDBDebugPage->setRootIsDecorated( true );
debugWindowTab->addTab( page, "KexiDB" );
debugWindowTab->showPage(page);
kexiDBDebugPage->show();
}
//add \n after (about) every 30 characters
//TODO TQString realText
TDEListViewItem * li = new TDEListViewItem( kexiDBDebugPage, kexiDBDebugPage->lastItem(), text );
li->setMultiLinesEnabled( true );
}
void KexiUtils::addAlterTableActionDebug(const TQString& text, int nestingLevel)
{
// (this is internal code - do not use i18n() here)
if (!debugWindowTab)
return;
if (!kexiAlterTableActionDebugPage) {
TQWidget *page = new TQWidget(debugWindowTab);
TQVBoxLayout *vbox = new TQVBoxLayout(page);
TQHBoxLayout *hbox = new TQHBoxLayout(page);
vbox->addLayout(hbox);
hbox->addStretch(1);
KPushButton *btn_exec = new KPushButton(KGuiItem("Real Alter Table", "filesave"), page);
btn_exec->setName("executeRealAlterTable");
hbox->addWidget(btn_exec);
KPushButton *btn_clear = new KPushButton(KGuiItem("Clear", "clear_left"), page);
hbox->addWidget(btn_clear);
KPushButton *btn_sim = new KPushButton(KGuiItem("Simulate Execution", "exec"), page);
btn_sim->setName("simulateAlterTableExecution");
hbox->addWidget(btn_sim);
kexiAlterTableActionDebugPage = new TDEListView(page, "kexiAlterTableActionDebugPage");
TQObject::connect(btn_clear, TQT_SIGNAL(clicked()), kexiAlterTableActionDebugPage, TQT_SLOT(clear()));
vbox->addWidget(kexiAlterTableActionDebugPage);
kexiAlterTableActionDebugPage->addColumn("");
kexiAlterTableActionDebugPage->header()->hide();
kexiAlterTableActionDebugPage->setSorting(-1);
kexiAlterTableActionDebugPage->setAllColumnsShowFocus ( true );
kexiAlterTableActionDebugPage->setColumnWidthMode( 0, TQListView::Maximum );
kexiAlterTableActionDebugPage->setRootIsDecorated( true );
debugWindowTab->addTab( page, "AlterTable Actions" );
debugWindowTab->showPage(page);
page->show();
}
if (text.isEmpty()) //don't move up!
return;
TDEListViewItem * li;
int availableNestingLevels = 0;
// compute availableNestingLevels
TQListViewItem * lastItem = kexiAlterTableActionDebugPage->lastItem();
//kdDebug() << "lastItem: " << (lastItem ? lastItem->text(0) : TQString()) << endl;
while (lastItem) {
lastItem = lastItem->parent();
availableNestingLevels++;
}
//kdDebug() << "availableNestingLevels: " << availableNestingLevels << endl;
//go up (availableNestingLevels-levelsToGoUp) levels
lastItem = kexiAlterTableActionDebugPage->lastItem();
int levelsToGoUp = availableNestingLevels - nestingLevel;
while (levelsToGoUp > 0 && lastItem) {
lastItem = lastItem->parent();
levelsToGoUp--;
}
//kdDebug() << "lastItem2: " << (lastItem ? lastItem->text(0) : TQString()) << endl;
if (lastItem) {
TQListViewItem *after = lastItem->firstChild(); //find last child so we can insert a new item after it
while (after && after->nextSibling())
after = after->nextSibling();
if (after)
li = new TDEListViewItem( lastItem, after, text ); //child, after
else
li = new TDEListViewItem( lastItem, text ); //1st child
}
else {
lastItem = kexiAlterTableActionDebugPage->lastItem();
while (lastItem && lastItem->parent())
lastItem = lastItem->parent();
//kdDebug() << "lastItem2: " << (lastItem ? lastItem->text(0) : TQString()) << endl;
li = new TDEListViewItem( kexiAlterTableActionDebugPage, lastItem, text ); //after
}
li->setOpen(true);
li->setMultiLinesEnabled( true );
}
void KexiUtils::connectPushButtonActionForDebugWindow(const char* actionName,
const TQObject *receiver, const char* slot)
{
if (debugWindow) {
KPushButton* btn = findFirstChild<KPushButton>(debugWindow, "KPushButton", actionName);
if (btn)
TQObject::connect(btn, TQT_SIGNAL(clicked()), receiver, slot);
}
}
#endif //KEXI_DEBUG_GUI
|