Added Q_FUNC_INFO macros to some functions.
[qtrapids] / src / qml-client / main.cpp
1 /***************************************************************************
2  *   Copyright (C) 2010 by Ixonos Plc   *
3  *                                                                         *
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.               *
7  *                                                                         *
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.                          *
12  *                                                                         *
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>
20 #include <QTest>
21 #include <QDebug>
22 #include <QtDeclarative/qdeclarative.h>
23 #include <meegotouch/mapplicationpage.h>
24 #include <meegotouch/mapplicationwindow.h>
25
26 #include "models/QDeclarativeDownloadListModel.h"
27 #include "MainPageHandler.h"
28 #include "../include/qtrapids/dbus.hpp"
29
30 int main(int argc, char *argv[])
31 {
32
33     // TODO: Check: could we use MApplication:: instead?
34     QCoreApplication::setOrganizationName("Ixonos");
35     QCoreApplication::setOrganizationDomain("ixonos.com");
36     QCoreApplication::setApplicationName("QtRapids");
37
38     // Q_INIT_RESOURCE(application);
39     QApplication app(argc, argv);
40     //MainWindow mainWindow;
41     app.setProperty("NoMStyle", true);
42
43     // Register our types (e.g. models and stuff):
44     qmlRegisterType<qtrapids::QDeclarativeDownloadListModel>("QtRapids", 1, 0, "DownloadListModel");
45
46     QDir::setCurrent(app.applicationDirPath());
47
48     QDeclarativeView window;
49     // Setting the root context properties. Create an QObject-derived
50     // object:
51     //qtrapids::QDeclarativeDownloadListModel downloadModel;
52     qtrapids::MainPageHandler mainPageHandler(window.engine());
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);
57
58     // Initial QML file/resource:
59     window.setSource(QUrl("qrc:/main.qml"));
60
61     window.showFullScreen();
62
63     
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");
69
70     mainWindow.connectToServer();
71     mainWindow.RestoreSettings();
72
73     // mainWindow->setGeometry(QApplication::desktop()->screenGeometry());
74
75     mainWindow.show();
76     */
77     /*
78     DownloadView* dlw = new DownloadView(NULL);
79       //qtrapids * mw = new qtrapids();
80     dlw->show();
81     DownloadViewItem* dlwItem = new DownloadViewItem(QStringList() << "Name"
82                 << "Size" << "Status"
83                 << "Progress" << "DL speed"
84                 << "UL speed" << "Seeds/Leechers"
85                 << "ratio");
86     DownloadViewItem* dlwItem2 = new DownloadViewItem(QStringList() << "Name"
87                 << "1000" << "Downloading"
88                 << "23%" << "11"
89                 << "0.1" << "0/2"
90                 << "1.10");
91     //dlwItem->insertChild(0, new DownloadViewItem(QStringList() << "Name"));
92     dlw->insertTopLevelItem(0,dlwItem);
93     dlw->insertTopLevelItem(1,dlwItem2);
94
95     for (unsigned i = 0; i < 10; ++i)
96     {
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)));
100         QTest::qSleep(2000);
101     }
102     */
103 /*
104     qtrapids::TorrentState editItem;
105     for (unsigned i = 0; i < 10; ++i)
106     {
107         editItem.hash = QString("asdfasdfasdfasdfasfsd-") + QString::number(i);
108         editItem.name = QString("Lassi-") + QString::number(i);
109         editItem.action = qtrapids::TorrentState::action_add;
110         editItem.state = 0;
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());
120     }
121     */
122
123     return app.exec();
124 }