All pastes #960909 Raw Edit

Someone

public text v1 · immutable
#960909 ·published 2008-03-28 15:19 UTC
rendered paste body
/* 
 *	ViewScheduledItems.h class
 *
 */

#ifndef VIEWSCHEDULEDITEMS
#define VIEWSCHEDULEDITEMS

#include <iostream>
#include <QString>
#include <qnamespace.h>
#include <QSettings>
#include <QDate>
#include <QTime>
#include <QProcess>
#include <QDateTime>
#include <QCopChannel>
#include <QApplication>
#include <QObject>

const QString SELECT = "select(QString,QString,QString,QString,QString,QString)";
const QString SUCCESS = "success(QString)";
const QString CHANNEL = "Scheduler";
const QString DELETE = "delete(QString,QString,QString,QString,QString,QString)";
const QString DELETE_ALL = "delete all";
const QString SYSTEM_CONFIG = "/media/ext/data/sysconfig.ini";
const QString CLOCK_TYPE = "datetime/clock-type";

class ViewScheduledItems {

	Q_OBJECT
	
public:
	ViewScheduledItems(QWidget *parent = 0);
	~ViewScheduledItems();
	
signals:

	
protected:
	private slots:
	void receive(const QString& message, const QByteArray& data);
	
private:
	QCopChannel *channel;
};


#endif //VIEWSCHEDULEDITEMS


/* 
 * ViewScheduledItems.cpp - Gets scheduled items from scheduler & prints them out
 *  
 *
 */

#include "viewscheduleditems.h"

//Constructor - connect the recieve function to the QCopChannel
ViewScheduledItems::ViewScheduledItems(QWidget *parent){
	
	channel = new QCopChannel(CHANNEL);
	QCopChannel::connect(channel, SIGNAL(received(const QString &, const QByteArray &)), this, SLOT(receive(const QString &, const QByteArray &)));
	//Ask for Scheduler info
	QCopChannel::send(CHANNEL, SELECT);
}	

//Deconstructor - clean up
ViewScheduledItems::~ViewScheduledItems(){
	delete channel;
}


//recieves data from Scheduler channel
void ViewScheduledItems::receive(const QString &msg, const QByteArray &data)
{
	QDataStream in(data);
	if (msg == SUCCESS)
	{	//TEMP: Dodgy print everything to console routine
		QDataStream in(data);
		QString status;
		in >> status;
		if (status == "select")
		{
			while (!in.atEnd())
			{
				QStringList list;
				in >> list;
                
				for (int i = 0; i < list.size(); ++i)
					std::cout << list.at(i).toLocal8Bit().constData() << std::endl;
			}
		}
		else{
			std::cout << "Other status: " << status << std::endl;
		}
	}
	else {
		std::cout << "Uh oh" << std::endl;
	}
}