1
/***************************************************************************
2
* Copyright (C) 2005 by Nicolas Ternisien *
3
* nicolas.ternisien@gmail.com *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
24
#include <qwhatsthis.h>
27
#include <kstdguiitem.h>
28
#include <ktextedit.h>
30
#include <kpushbutton.h>
35
#include "parentLogLine.h"
37
#include "detailDialog.h"
39
DetailDialog::DetailDialog(View* v, QWidget *parent, const char *name) :
40
//KDialogBase(parent, name, false, i18n("Log Line Details"), 0 /*KDialogBase::Ok*/),
41
DetailDialogBase(parent, name, false, 0),
46
previous->setText(i18n("&Previous"));
47
connect(previous, SIGNAL(clicked()), this, SLOT(previousItem()));
49
next->setText(i18n("&Next"));
50
connect(next, SIGNAL(clicked()), this, SLOT(nextItem()));
52
//close->setText(KStdGuiItem::close().text());
53
//close->setIcon(KStdGuiItem::close().iconSet());
54
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeDetails()));
58
/* This code has been replaced by a pretty drawing of the Detail Dialog with Qt Designer
60
setMinimumHeight(200);
63
QWhatsThis::add(this, i18n("This dialog displays detailed information about the currently selected log line."));
65
QWidget* widget=new QWidget(this);
67
QVBoxLayout* mainLayout = new QVBoxLayout(widget, 0, 10);
69
QHBoxLayout* l1 = new QHBoxLayout(0, 0, 5);
71
icon=new QLabel(widget);
72
//icon->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
73
l1->addWidget(icon, 0, Qt::AlignVCenter);
75
//header=new KActiveLabel(widget, "header");
76
header=new QLabel(widget, "header");
77
//header->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum) );
78
//header->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ) );
79
l1->addWidget(header, 0, Qt::AlignVCenter || Qt::AlignHCenter);
81
mainLayout->addLayout(l1);
83
message=new QTextEdit(widget);
84
message->setReadOnly(true);
85
//message->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum) );
86
//message->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
87
//message->setMinimumHeight(40);
88
//message->setMinimumHeight(60);
89
//message->setMinimumWidth(400);
91
mainLayout->addWidget(message);
93
QHBoxLayout* buttons=new QHBoxLayout(0, 0, 10);
96
previous=new QPushButton(KStdGuiItem::back().iconSet(), i18n("&Previous"), widget);
97
connect(previous, SIGNAL(clicked()), this, SLOT(previousItem()));
98
//1=Stretch factor (ratio between object in the QHBoxLayout)
99
buttons->addWidget(previous, 1, Qt::AlignRight);
101
QToolTip::add(previous, i18n("Move to the previous line"));
102
QWhatsThis::add(previous, i18n("Moves to the previous line. This button is deactivated if there is no previous log line."));
104
buttons->setStretchFactor(previous, 1);
105
next=new QPushButton(KStdGuiItem::forward().iconSet(), i18n("&Next"), widget);
106
connect(next, SIGNAL(clicked()), this, SLOT(nextItem()));
107
//1=Stretch factor (ratio between object in the QHBoxLayout)
108
buttons->addWidget(next, 1, Qt::AlignLeft);
111
QToolTip::add(next, i18n("Move to the next line"));
112
QWhatsThis::add(next, i18n("Moves to the next line. This button is deactivated if there is no next log line."));
115
QPushButton* close=new QPushButton(KStdGuiItem::close().iconSet(), KStdGuiItem::close().text(), widget);
116
connect(close, SIGNAL(clicked()), this, SLOT(closeDetails()));
117
buttons->addWidget(close, 0, Qt::AlignRight);
119
QToolTip::add(next, i18n("Close the Detail dialog."));
120
QWhatsThis::add(next, i18n("Closes this Detail dialog."));
122
mainLayout->addLayout(buttons);
124
this->setMainWidget(widget);
126
//TODO Try to find a better solution (if it exists!)
132
DetailDialog::~DetailDialog() {
136
void DetailDialog::setView(View* view) {
141
void DetailDialog::selectionChanged() {
145
//TODO Try to find a method that reload (an resize) correctly the content of the detail dialog
146
void DetailDialog::updateDetails() {
147
//Get the current-last item selected
148
currentLine=view->getLastSelectedItem();
149
if (currentLine==NULL) {
150
//If no item are selected and the dialog is still open, we try to select the first
152
currentLine=static_cast<LogListItem*> (view->getLogList()->firstChild());
153
if (currentLine==NULL) {
162
LogLine* logLine=currentLine->getLogLine();
164
//Special case if this is a ParentLogLine (Group By feature)
165
if (logLine->isParentLogLine()) {
166
icon->setPixmap(DesktopIcon(GROUP_BY_ICON));
167
header->setText(currentLine->getFormattedText());
168
message->setText("");
172
icon->setPixmap(DesktopIcon(logLine->getLogLevel()->icon));
174
header->setText(currentLine->getFormattedText());
176
message->setText(logLine->getItemList().last());
180
if (currentLine->itemAbove()==NULL)
181
previous->setEnabled(false);
183
previous->setEnabled(true);
186
if (currentLine->itemBelow()==NULL)
187
next->setEnabled(false);
189
next->setEnabled(true);
192
header->adjustSize();
196
void DetailDialog::previousItem() {
197
//This case should not occurs
198
if (currentLine==NULL)
201
//This case should not occurs
202
if (currentLine->itemAbove()==NULL) {
207
currentLine->setSelected(false);
208
currentLine->repaint();
209
currentLine=static_cast<LogListItem*> (currentLine->itemAbove());
210
currentLine->setSelected(true);
211
currentLine->repaint();
217
void DetailDialog::closeDetails() {
221
void DetailDialog::nextItem() {
222
//This case should not occurs
223
if (currentLine==NULL)
226
//This case should not occurs
227
if (currentLine->itemBelow()==NULL) {
232
currentLine->setSelected(false);
233
currentLine->repaint();
234
currentLine=static_cast<LogListItem*> (currentLine->itemBelow());
235
currentLine->setSelected(true);
236
currentLine->repaint();
242
#include "detailDialog.moc"