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
|
/***************************************************************************
* Copyright (C) 2005 by Nicolas Ternisien *
* nicolas.ternisien@gmail.com *
* *
* 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. *
***************************************************************************/
//TQt includes
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
//KDE includes
#include <kstdguiitem.h>
#include <ktextedit.h>
#include <kguiitem.h>
#include <kpushbutton.h>
#include <tdelocale.h>
#include <kdebug.h>
//Project includes
#include "parentLogLine.h"
#include "detailDialog.h"
DetailDialog::DetailDialog(View* v, TQWidget *parent, const char *name) :
//KDialogBase(parent, name, false, i18n("Log Line Details"), 0 /*KDialogBase::Ok*/),
DetailDialogBase(parent, name, false, 0),
view(v),
currentLine(NULL) {
previous->setText(i18n("&Previous"));
connect(previous, TQT_SIGNAL(clicked()), this, TQT_SLOT(previousItem()));
next->setText(i18n("&Next"));
connect(next, TQT_SIGNAL(clicked()), this, TQT_SLOT(nextItem()));
//close->setText(KStdGuiItem::close().text());
//close->setIcon(KStdGuiItem::close().iconSet());
connect(closeButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(closeDetails()));
updateDetails();
/* This code has been replaced by a pretty drawing of the Detail Dialog with TQt Designer
setMinimumHeight(200);
setMinimumWidth(450);
TQWhatsThis::add(this, i18n("This dialog displays detailed information about the currently selected log line."));
TQWidget* widget=new TQWidget(this);
TQVBoxLayout* mainLayout = new TQVBoxLayout(widget, 0, 10);
TQHBoxLayout* l1 = new TQHBoxLayout(0, 0, 5);
icon=new TQLabel(widget);
//icon->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum ) );
l1->addWidget(icon, 0, TQt::AlignVCenter);
//header=new KActiveLabel(widget, "header");
header=new TQLabel(widget, "header");
//header->setSizePolicy( TQSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Minimum) );
//header->setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, TQSizePolicy::Minimum ) );
l1->addWidget(header, 0, TQt::AlignVCenter || TQt::AlignHCenter);
mainLayout->addLayout(l1);
message=new TQTextEdit(widget);
message->setReadOnly(true);
//message->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Minimum) );
//message->setSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding ) );
//message->setMinimumHeight(40);
//message->setMinimumHeight(60);
//message->setMinimumWidth(400);
mainLayout->addWidget(message);
TQHBoxLayout* buttons=new TQHBoxLayout(0, 0, 10);
previous=new TQPushButton(KStdGuiItem::back().iconSet(), i18n("&Previous"), widget);
connect(previous, TQT_SIGNAL(clicked()), this, TQT_SLOT(previousItem()));
//1=Stretch factor (ratio between object in the TQHBoxLayout)
buttons->addWidget(previous, 1, TQt::AlignRight);
TQToolTip::add(previous, i18n("Move to the previous line"));
TQWhatsThis::add(previous, i18n("Moves to the previous line. This button is deactivated if there is no previous log line."));
buttons->setStretchFactor(previous, 1);
next=new TQPushButton(KStdGuiItem::forward().iconSet(), i18n("&Next"), widget);
connect(next, TQT_SIGNAL(clicked()), this, TQT_SLOT(nextItem()));
//1=Stretch factor (ratio between object in the TQHBoxLayout)
buttons->addWidget(next, 1, TQt::AlignLeft);
TQToolTip::add(next, i18n("Move to the next line"));
TQWhatsThis::add(next, i18n("Moves to the next line. This button is deactivated if there is no next log line."));
TQPushButton* close=new TQPushButton(KStdGuiItem::close().iconSet(), KStdGuiItem::close().text(), widget);
connect(close, TQT_SIGNAL(clicked()), this, TQT_SLOT(closeDetails()));
buttons->addWidget(close, 0, TQt::AlignRight);
TQToolTip::add(next, i18n("Close the Detail dialog."));
TQWhatsThis::add(next, i18n("Closes this Detail dialog."));
mainLayout->addLayout(buttons);
this->setMainWidget(widget);
//TODO Try to find a better solution (if it exists!)
//resize(500, 200);
*/
}
DetailDialog::~DetailDialog() {
}
void DetailDialog::setView(View* view) {
this->view=view;
updateDetails();
}
void DetailDialog::selectionChanged() {
updateDetails();
}
//TODO Try to find a method that reload (an resize) correctly the content of the detail dialog
void DetailDialog::updateDetails() {
//Get the current-last item selected
currentLine=view->getLastSelectedItem();
if (currentLine==NULL) {
//If no item are selected and the dialog is still open, we try to select the first
//item of the list.
currentLine=static_cast<LogListItem*> (view->getLogList()->firstChild());
if (currentLine==NULL) {
close();
return;
}
}
LogLine* logLine=currentLine->getLogLine();
//Special case if this is a ParentLogLine (Group By feature)
if (logLine->isParentLogLine()) {
icon->setPixmap(DesktopIcon(GROUP_BY_ICON));
header->setText(currentLine->getFormattedText());
message->setText("");
}
//Normal Log Line
else {
icon->setPixmap(DesktopIcon(logLine->getLogLevel()->icon));
header->setText(currentLine->getFormattedText());
message->setText(logLine->getItemList().last());
}
if (currentLine->itemAbove()==NULL)
previous->setEnabled(false);
else
previous->setEnabled(true);
if (currentLine->itemBelow()==NULL)
next->setEnabled(false);
else
next->setEnabled(true);
header->adjustSize();
this->adjustSize();
}
void DetailDialog::previousItem() {
//This case should not occurs
if (currentLine==NULL)
return;
//This case should not occurs
if (currentLine->itemAbove()==NULL) {
close();
return;
}
currentLine->setSelected(false);
currentLine->repaint();
currentLine=static_cast<LogListItem*> (currentLine->itemAbove());
currentLine->setSelected(true);
currentLine->repaint();
updateDetails();
}
void DetailDialog::closeDetails() {
this->close();
}
void DetailDialog::nextItem() {
//This case should not occurs
if (currentLine==NULL)
return;
//This case should not occurs
if (currentLine->itemBelow()==NULL) {
close();
return;
}
currentLine->setSelected(false);
currentLine->repaint();
currentLine=static_cast<LogListItem*> (currentLine->itemBelow());
currentLine->setSelected(true);
currentLine->repaint();
updateDetails();
}
#include "detailDialog.moc"
|