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 <QApplication>
19 #include <QtDeclarative>
20 #include <QDeclarativeContext>
23 //#include <QDesktopWidget>
24 //#include "DownloadView.h"
25 #include <QtDeclarative/qdeclarative.h>
26 #include "models/QDeclarativeDownloadListModel.h"
28 #include "MainWindow.h"
29 #include "../include/qtrapids/dbus.hpp"
31 using qtrapids::MainWindow;
33 int main(int argc, char *argv[])
38 QCoreApplication::setOrganizationName("Ixonos");
39 QCoreApplication::setOrganizationDomain("ixonos.com");
40 QCoreApplication::setApplicationName("QtRapids");
42 // Q_INIT_RESOURCE(application);
43 QApplication app(argc, argv);
44 //MainWindow mainWindow;
45 app.setProperty("NoMStyle", true);
47 // Register our types:
48 qmlRegisterType<qtrapids::QDeclarativeDownloadListModel>("QtRapids", 1, 0, "DownloadListModel");
50 QDir::setCurrent(app.applicationDirPath());
52 QDeclarativeView window;
53 //QDeclarativeEngine engine;
54 qtrapids::QDeclarativeDownloadListModel downloadModel;
55 QDeclarativeContext *context = window.rootContext();
56 context->setContextProperty("downloadModel", &downloadModel);
57 window.setSource(QUrl("qrc:/main.qml"));
59 window.showFullScreen();
63 /* TODO: Enable this once we have the views up & running
64 QDBusConnection dbus = QDBusConnection::sessionBus();
65 dbus.registerObject("/qtrapids_gui", &mainWindow);
66 dbus.registerService("com.ixonos.qtrapids_gui");
68 mainWindow.connectToServer();
69 mainWindow.RestoreSettings();
71 // mainWindow->setGeometry(QApplication::desktop()->screenGeometry());
76 DownloadView* dlw = new DownloadView(NULL);
77 //qtrapids * mw = new qtrapids();
79 DownloadViewItem* dlwItem = new DownloadViewItem(QStringList() << "Name"
81 << "Progress" << "DL speed"
82 << "UL speed" << "Seeds/Leechers"
84 DownloadViewItem* dlwItem2 = new DownloadViewItem(QStringList() << "Name"
85 << "1000" << "Downloading"
89 //dlwItem->insertChild(0, new DownloadViewItem(QStringList() << "Name"));
90 dlw->insertTopLevelItem(0,dlwItem);
91 dlw->insertTopLevelItem(1,dlwItem2);
93 for (unsigned i = 0; i < 10; ++i)
95 DownloadViewItem *editItem = dynamic_cast<DownloadViewItem*>
96 (dlw->itemAt(QPoint(0,0)));
97 editItem->setData ( 8, Qt::DisplayRole, QVariant("EDITED" + QString::number(i, 'g', 2)));
102 qtrapids::TorrentState editItem;
103 for (unsigned i = 0; i < 10; ++i)
105 editItem.hash = QString("asdfasdfasdfasdfasfsd-") + QString::number(i);
106 editItem.name = QString("Lassi-") + QString::number(i);
107 editItem.action = qtrapids::TorrentState::action_add;
109 editItem.progress = 10+i;
110 editItem.down_rate = 10+i;
111 editItem.up_rate = 10+i;
112 editItem.seeds = 10+i;
113 editItem.leeches = 10+i;
114 editItem.ratio = 10+i;
115 editItem.total_size = 100000+i;
116 editItem.total_done = 10000+i;
117 downloadModel.updateItem(editItem, qtrapids::ParamsMap_t());