From: lucijan b. <lu...@kd...> - 2005-02-23 21:05:23
|
CVS commit by luci: wow... THERE IS SOME VERY STRANGE BUG IN DScheduler ON THE RECEIVING SIDE => LEADS _SOMETIMES_ TO A SIG11 - diskothek has a face now! (some hacky bits are still around) - artists are transmitted to the client - thanks to Transaction class the artist_list=>client transaction shows a small progressbar in the statusbar - reader now strips white spaces from artists A diskothek/diskothek/diskothekbar.cpp 1.1 [no copyright] A diskothek/diskothek/diskothekbar.h 1.1 [no copyright] A diskothek/diskothek/diskothekbarbutton.cpp 1.1 [no copyright] A diskothek/diskothek/diskothekbarbutton.h 1.1 [no copyright] A diskothek/diskothek/iconloader.cpp 1.1 [no copyright] A diskothek/diskothek/iconloader.h 1.1 [no copyright] A diskothek/diskothek/navbar.cpp 1.1 [POSSIBLY UNSAFE: qDebug] [no copyright] A diskothek/diskothek/navbar.h 1.1 [no copyright] A diskothek/diskothek/player.cpp 1.1 [no copyright] A diskothek/diskothek/player.h 1.1 [no copyright] A diskothek/diskothek/searchbar.cpp 1.1 [no copyright] A diskothek/diskothek/searchbar.h 1.1 [no copyright] A diskothek/diskothek/transaction.cpp 1.1 [POSSIBLY UNSAFE: qDebug] [no copyright] A diskothek/diskothek/transaction.h 1.1 [no copyright] M +10 -1 diskothek/diskothek/connection.cpp 1.8 M +8 -0 diskothek/diskothek/connection.h 1.6 M +1 -0 diskothek/diskothek/dcore.cpp 1.3 M +6 -2 diskothek/diskothek/diskothek.pro 1.7 M +99 -2 diskothek/diskothek/mainwindow.cpp 1.2 [POSSIBLY UNSAFE: qDebug] M +23 -0 diskothek/diskothek/mainwindow.h 1.2 --- diskothek/diskothek/connection.cpp #1.7:1.8 @@ -85,8 +85,11 @@ Connection::protocolVersionResult(const Diskothek::DCore core(this); + DCall *cs = core.call("serviceName"); + cs->connect("result", this, SLOT(serviceNameResult(const QVariant &))); + DCall *c = core.call("objectList", QVariant(DObject::NDiskothek)); c->connect("recordSet", this, SLOT(objectListRecordSet(const QVariant &))); c->connect("resultSetEnd", this, SIGNAL(connectionReady())); -// emit connectionReady(); + } @@ -177,4 +180,10 @@ Connection::bindError() qApp->exit_loop(); +} + +void +Connection::serviceNameResult(const QVariant &args) +{ + m_service = ARGV(0).toString(); } --- diskothek/diskothek/connection.h #1.5:1.6 @@ -56,4 +56,9 @@ class Connection : public QSocket, publi DObject *importObject(int ns, const QString &obj); + /** + * @returns the name of connected service + */ + QString service() const { return m_service; } + protected slots: void socketError(int error); @@ -65,4 +70,5 @@ class Connection : public QSocket, publi void protocolVersionResult(const QVariant &v); void objectListRecordSet(const QVariant &v); + void serviceNameResult(const QVariant &v); void bindFunction(const QVariant &v); @@ -86,6 +92,8 @@ class Connection : public QSocket, publi void connectionReady(); + private: DObject *m_cbindingobject; + QString m_service; }; --- diskothek/diskothek/dcore.cpp #1.2:1.3 @@ -10,4 +10,5 @@ DCore::DCore(DScheduler *sched) registerNotification("objectList", 1); registerNotification("methodList", 2); + registerNotification("serviceName", 3); } --- diskothek/diskothek/diskothek.pro #1.6:1.7 @@ -9,6 +9,10 @@ mac:TARGET = Diskothek -SOURCES = main.cpp connectiondialog.cpp connection.cpp dcore.cpp mainwindow.cpp -HEADERS = connectiondialog.h connection.h dcore.h mainwindow.h +SOURCES = main.cpp connectiondialog.cpp connection.cpp dcore.cpp mainwindow.cpp \ + diskothekbar.cpp diskothekbarbutton.cpp iconloader.cpp \ + player.cpp searchbar.cpp navbar.cpp transaction.cpp +HEADERS = connectiondialog.h connection.h dcore.h mainwindow.h \ + diskothekbar.h diskothekbarbutton.h iconloader.h \ + player.h searchbar.h navbar.h transaction.h FORMS = connectiondlg.ui --- diskothek/diskothek/mainwindow.cpp #1.1:1.2 @@ -1,11 +1,30 @@ +#include <qlistview.h> +#include <qvbox.h> +#include <qhbox.h> +#include <qlineedit.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qstatusbar.h> + +#include "navbar.h" #include "connection.h" +#include "iconloader.h" +#include "diskothekbar.h" +#include "diskothekbarbutton.h" +#include "player.h" +#include "searchbar.h" #include "mainwindow.h" MainWindow::MainWindow(Connection *c) { + resize(800,600); + m_connection = c; + setCaption(tr("Diskothek - %1").arg(c->service())); +// statusBar()->message(tr("Connected to '%1'").arg(c->service())); + qDebug("=== MAINWINDOW ==="); - qDebug("importing object ..."); + qDebug("importing object from (%p)...", c); DObject *player = c->importObject(DObject::NDiskothek, "Player"); - qDebug("importing done: %p", player); + qDebug("importing done from (%p): %p", c, player); if(player) { @@ -13,4 +32,37 @@ MainWindow::MainWindow(Connection *c) player->debugFunc(); } + qDebug("we are: %p", this); + + QVBox *central = new QVBox(this); + central->setSpacing(3); + + DiskothekBar *b = new DiskothekBar(central); + b->addWidget(new DiskothekBarButton(b, IconLoader::barIcon("rew"), "History")); + b->addWidget(new DiskothekBarButton(b, IconLoader::barIcon("pause"), "Pause")); + b->addWidget(new DiskothekBarButton(b, IconLoader::barIcon("fwd"), "Skip")); + b->addWidget(new DiskothekBarButton(b, IconLoader::barIcon("queue"), "Queue (1)")); + b->addWidget(new Player(b)); + b->addWidget(new SearchBar(b, tr("Search Song"))); + + QHBox *hb = new QHBox(central); + hb->setSpacing(3); + new NavBar(hb); + + //FIXME + QWidget *view = new QWidget(hb); + QGridLayout *gv = new QGridLayout(view); + gv->setSpacing(3); + gv->setMargin(3); + + QLabel *lView = new QLabel(tr("Tracks from Ulu-Kyll"), view); + QListView *vview = new QListView(view); + vview->addColumn("Artist"); + vview->addColumn("Title"); + vview->addColumn("Length"); + + gv->addWidget(lView, 0, 0); + gv->addWidget(vview, 1, 0); + + setCentralWidget(central); } @@ -19,2 +71,47 @@ MainWindow::~MainWindow() } + +Connection *connection(QObject *start) +{ + if(!start) + return 0; + + const QObject *it=start->parent(); + + while(it) + { + if(it->isA("MainWindow")) + break; + else + it = it->parent(); + } + + if(it) + { + const MainWindow *win = dynamic_cast<const MainWindow *>(it); + return win->connection(); + } + else + return 0; +} + +MainWindow *mainWin(QObject *start) +{ + if(!start) + return 0; + + const QObject *it=start->parent(); + + while(it) + { + if(it->isA("MainWindow")) + break; + else + it = it->parent(); + } + + if(it) + return const_cast<MainWindow *>(dynamic_cast<const MainWindow *>(it)); + else + return 0; +} --- diskothek/diskothek/mainwindow.h #1.1:1.2 @@ -13,5 +13,28 @@ class MainWindow : public QMainWindow MainWindow(Connection *c); ~MainWindow(); + + + /** + * returns the connection of this mainwindow + */ + Connection *connection() const { return m_connection; } + + private: + Connection *m_connection; }; + +/** + * @returns a connection associated with a widget or null if not found + * it iterates through the tree of parents from \a start + * mostly used like that: <code>Connection *c = MainWindow::connection(this);</code> + * @note: this function searches for a mainwindow in object hirachy + */ +Connection *connection(QObject *start); + +/** + * @returns the mainwindow of a widget or null if not found + * @note: this function searches for a mainwindow in object hirachy + */ +MainWindow *mainWin(QObject *start); #endif |