[prev in list] [next in list] [prev in thread] [next in thread] 

List:       atlantik-devel
Subject:    [atlantik-cvs] CVS: kdegames/atlantik/client event.cpp, NONE,
From:       kde () office ! kde ! org
Date:       2003-11-15 13:38:01
[Download RAW message or body]

Update of /home/kde/kdegames/atlantik/client
In directory office:/tmp/cvs-serv18548

Added Files:
      Tag: atlantik_3_3_branch
	event.cpp event.h eventlogwidget.cpp eventlogwidget.h 
Log Message:
somehow the tag missed these new files

--- NEW FILE: event.cpp ---
// Copyright (c) 2003 Rob Kaper <cap@capsi.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

#include <qdatetime.h>
#include <qstring.h>

#include "event.moc"

Event::Event(const QDateTime &dateTime, const QString &description, const QString \
&icon) {
	m_dateTime = dateTime;
	m_description = description;
	m_icon = icon;
}

QDateTime Event::dateTime() const
{
	return m_dateTime;
}

QString Event::description() const
{
	return m_description;
}

QString Event::icon() const
{
	return m_icon;
}

--- NEW FILE: event.h ---
// Copyright (c) 2003 Rob Kaper <cap@capsi.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

#ifndef ATLANTIK_EVENT_H
#define ATLANTIK_EVENT_H

#include <qobject.h>

class QDateTime;
class QString;

class Event : public QObject
{
Q_OBJECT

public:
	Event(const QDateTime &dateTime, const QString &description, const QString &icon = \
QString::null);  QDateTime dateTime() const;
	QString description() const;
	QString icon() const;

private:
	QDateTime m_dateTime;
	QString m_description, m_icon;
};

#endif

--- NEW FILE: eventlogwidget.cpp ---
// Copyright (c) 2003 Rob Kaper <cap@capsi.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

#include <iostream>

#include <qlayout.h>
#include <qdatetime.h>

#include <klocale.h>
#include <klistview.h>
#include <kdialogbase.h>
#include <kiconloader.h>
#include <kpushbutton.h>

#include "event.h"
#include "eventlogwidget.moc"

EventLog::EventLog()
{
}

void EventLog::addEvent(const QString &description, const QString &icon)
{
	Event *event = new Event(QDateTime::currentDateTime(), description, icon);
	m_events.append(event);
	emit newEvent(event);
}

void EventLog::emitAll()
{
	for (QPtrListIterator<Event> it(m_events); (*it) ; ++it)
		emit newEvent((*it));
}

EventLogWidget::EventLogWidget(EventLog *eventLog, QWidget *parent, const char *name)
	: QWidget(parent, name,
	  WType_Dialog | WStyle_Customize | WStyle_DialogBorder | WStyle_Title |
	  WStyle_Minimize | WStyle_ContextHelp )
{
	m_eventLog = eventLog;

	connect(m_eventLog, SIGNAL(newEvent(Event *)), this, SLOT(addEvent(Event *)));

	setCaption(i18n("Event Log"));

	QVBoxLayout *listCompBox = new QVBoxLayout(this, KDialog::marginHint());

	m_eventList = new KListView(this, "eventList");
	listCompBox->addWidget(m_eventList);

	m_eventList->addColumn(i18n("Date/Time"));
	m_eventList->addColumn(i18n("Description"));

	QHBoxLayout *actionBox = new QHBoxLayout(this, 0, KDialog::spacingHint());
	listCompBox->addItem(actionBox);

	actionBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, \
QSizePolicy::Minimum));

	m_saveButton = new KPushButton(BarIcon("save", KIcon::SizeSmall), i18n("Save"), \
this);  actionBox->addWidget(m_saveButton);

	connect(m_saveButton, SIGNAL(clicked()), this, SLOT(save()));
}

void EventLogWidget::addEvent(Event *event)
{
	KListViewItem *item = new KListViewItem(m_eventList, \
event->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"), event->description());  if \
(event->icon().isEmpty())  item->setPixmap(1, QPixmap(SmallIcon("atlantik")));
	else
		item->setPixmap(1, QPixmap(SmallIcon(event->icon())));

	m_eventList->ensureItemVisible(item);
}

void EventLogWidget::closeEvent(QCloseEvent *e)
{
	e->accept();
}

--- NEW FILE: eventlogwidget.h ---
// Copyright (c) 2003 Rob Kaper <cap@capsi.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License version 2.1 as published by the Free Software Foundation.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; see the file COPYING.LIB.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

#ifndef ATLANTIK_EVENTLOGWIDGET_H
#define ATLANTIK_EVENTLOGWIDGET_H

#include <qwidget.h>
#include <qmap.h>

class QString;

class Event;

class KListView;
class KListViewItem;
class KPushButton;

class EventLog : public QObject
{
Q_OBJECT

public:
	EventLog();
	void emitAll();

public slots:
	void addEvent(const QString &description, const QString &icon = QString::null);

signals:
	void newEvent(Event *event);

private:
	QPtrList<Event> m_events;
};

class EventLogWidget : public QWidget
{
Q_OBJECT

public:
	enum EventLogType { Default, Net_In, Net_Out };

	EventLogWidget(EventLog *eventLog, QWidget *parent=0, const char *name = 0);

public slots:
	void addEvent(Event *event);

protected:
	void closeEvent(QCloseEvent *e);

private:
	EventLog *m_eventLog;
	KListView *m_eventList;
	KPushButton *m_saveButton;
};

#endif

_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@kde.org
https://mail.kde.org/mailman/listinfo/atlantik-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic