1 /***************************************************************************
2 * Copyright (C) 2010 by Ixonos Plc *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; version 2 of the License. *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
13 * You should have received a copy of the GNU General Public License *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
17 ***************************************************************************/
18 #include <QtDeclarative>
19 #include <QDeclarativeContext>
22 #include <QtDeclarative/qdeclarative.h>
23 #include <meegotouch/mapplicationpage.h>
24 #include <meegotouch/mapplicationwindow.h>
26 #include "models/QDeclarativeDownloadListModel.h"
27 #include "MainPageHandler.h"
28 #include "../include/qtrapids/dbus.hpp"
30 int main(int argc, char *argv[])
33 // TODO: Check: could we use MApplication:: instead?
34 QCoreApplication::setOrganizationName("Ixonos");
35 QCoreApplication::setOrganizationDomain("ixonos.com");
36 QCoreApplication::setApplicationName("QtRapids");
38 // Q_INIT_RESOURCE(application);
39 QApplication app(argc, argv);
40 //MainWindow mainWindow;
41 app.setProperty("NoMStyle", true);
43 // Register our types (e.g. models and stuff):
44 qmlRegisterType<qtrapids::QDeclarativeDownloadListModel>("QtRapids", 1, 0, "DownloadListModel");
46 QDir::setCurrent(app.applicationDirPath());
48 QDeclarativeView window;
49 // Setting the root context properties. Create an QObject-derived
51 qtrapids::QDeclarativeDownloadListModel downloadModel;
52 qtrapids::MainPageHandler mainPageHandler;
53 // ... and add to QML context. This can then be used in QML context.
54 QDeclarativeContext *context = window.rootContext();
55 context->setContextProperty("downloadModel", &downloadModel);
56 context->setContextProperty("mainPageHandler", &mainPageHandler);
58 // Initial QML file/resource:
59 window.setSource(QUrl("qrc:/main.qml"));
61 window.showFullScreen();
64 /* TODO: Enable this once we have the views up & running
65 * TODO: We can add this to mainPageHandler now...
66 QDBusConnection dbus = QDBusConnection::sessionBus();
67 dbus.registerObject("/qtrapids_gui", &mainWindow);
68 dbus.registerService("com.ixonos.qtrapids_gui");
70 mainWindow.connectToServer();
71 mainWindow.RestoreSettings();
73 // mainWindow->setGeometry(QApplication::desktop()->screenGeometry());
78 DownloadView* dlw = new DownloadView(NULL);
79 //qtrapids * mw = new qtrapids();
81 DownloadViewItem* dlwItem = new DownloadViewItem(QStringList() << "Name"
83 << "Progress" << "DL speed"
84 << "UL speed" << "Seeds/Leechers"
86 DownloadViewItem* dlwItem2 = new DownloadViewItem(QStringList() << "Name"
87 << "1000" << "Downloading"
91 //dlwItem->insertChild(0, new DownloadViewItem(QStringList() << "Name"));
92 dlw->insertTopLevelItem(0,dlwItem);
93 dlw->insertTopLevelItem(1,dlwItem2);
95 for (unsigned i = 0; i < 10; ++i)
97 DownloadViewItem *editItem = dynamic_cast<DownloadViewItem*>
98 (dlw->itemAt(QPoint(0,0)));
99 editItem->setData ( 8, Qt::DisplayRole, QVariant("EDITED" + QString::number(i, 'g', 2)));
104 qtrapids::TorrentState editItem;
105 for (unsigned i = 0; i < 10; ++i)
107 editItem.hash = QString("asdfasdfasdfasdfasfsd-") + QString::number(i);
108 editItem.name = QString("Lassi-") + QString::number(i);
109 editItem.action = qtrapids::TorrentState::action_add;
111 editItem.progress = 10+i;
112 editItem.down_rate = 10+i;
113 editItem.up_rate = 10+i;
114 editItem.seeds = 10+i;
115 editItem.leeches = 10+i;
116 editItem.ratio = 10+i;
117 editItem.total_size = 100000+i;
118 editItem.total_done = 10000+i;
119 downloadModel.updateItem(editItem, qtrapids::ParamsMap_t());