HaikuDepot: Add interface for PackageInfoListener.

Also defines PackageInfoEvent.
This commit is contained in:
Stephan Aßmus 2013-09-15 17:24:15 +02:00 committed by Rene Gollent
parent 779d8213e9
commit 9202a719e1
3 changed files with 139 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Application HaikuDepot :
MainWindow.cpp
Model.cpp
PackageInfo.cpp
PackageInfoListener.cpp
PackageInfoView.cpp
PackageListView.cpp
PackageManager.cpp

View File

@ -0,0 +1,84 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "PackageInfoListener.h"
#include <stdio.h>
// #pragma mark - PackageInfoEvent
PackageInfoEvent::PackageInfoEvent()
:
fPackage(),
fChanges(0)
{
}
PackageInfoEvent::PackageInfoEvent(const PackageInfoRef& package,
uint32 changes)
:
fPackage(package),
fChanges(changes)
{
}
PackageInfoEvent::PackageInfoEvent(const PackageInfoEvent& other)
:
fPackage(other.fPackage),
fChanges(other.fChanges)
{
}
PackageInfoEvent::~PackageInfoEvent()
{
}
bool
PackageInfoEvent::operator==(const PackageInfoEvent& other)
{
if (this == &other)
return true;
return fPackage == other.fPackage
&& fChanges == other.fChanges;
}
bool
PackageInfoEvent::operator!=(const PackageInfoEvent& other)
{
return !(*this == other);
}
PackageInfoEvent&
PackageInfoEvent::operator=(const PackageInfoEvent& other)
{
if (this != &other) {
fPackage = other.fPackage;
fChanges = other.fChanges;
}
return *this;
}
// #pragma mark - PackageInfoListener
PackageInfoListener::PackageInfoListener()
{
}
PackageInfoListener::~PackageInfoListener()
{
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef PACKAGE_INFO_LISTENER_H
#define PACKAGE_INFO_LISTENER_H
#include "PackageInfo.h"
enum {
PKG_CHANGED_DESCRIPTION = 1 << 0,
PKG_CHANGED_RATINGS = 1 << 1,
PKG_CHANGED_SCREENSHOTS = 1 << 2,
// ...
};
class PackageInfoEvent {
public:
PackageInfoEvent();
PackageInfoEvent(const PackageInfoRef& package,
uint32 changes);
PackageInfoEvent(const PackageInfoEvent& other);
virtual ~PackageInfoEvent();
bool operator==(const PackageInfoEvent& other);
bool operator!=(const PackageInfoEvent& other);
PackageInfoEvent& operator=(const PackageInfoEvent& other);
inline const PackageInfoRef& Package() const
{ return fPackage; }
inline uint32 Changes() const
{ return fChanges; }
private:
PackageInfoRef fPackage;
uint32 fChanges;
};
class PackageInfoListener {
public:
PackageInfoListener();
virtual ~PackageInfoListener();
virtual void PackageChanged(
const PackageInfoEvent& event) = 0;
};
#endif // PACKAGE_INFO_LISTENER_H