From: Nikolay Tischenko Date: Sat, 4 Sep 2010 13:10:47 +0000 (+0700) Subject: Initial structure. New abstract levels: dataobjecst, storage X-Git-Tag: release-1.0~23 X-Git-Url: http://git.maemo.org/git/?p=someplayer;a=commitdiff_plain;h=bb42bbd3ed98dacfdbaaddb688b992e145861412 Initial structure. New abstract levels: dataobjecst, storage --- diff --git a/someplayer.pro b/someplayer.pro index 27ee601..2a3ceb9 100644 --- a/someplayer.pro +++ b/someplayer.pro @@ -4,16 +4,33 @@ # #------------------------------------------------- -QT += core gui +QT += core gui phonon TARGET = someplayer TEMPLATE = app SOURCES += src/main.cpp\ - src/mainwindow.cpp - -HEADERS += src/mainwindow.h + src/mainwindow.cpp \ + src/player.cpp \ + src/track.cpp \ + src/trackmetainformation.cpp \ + src/playlist.cpp \ + src/library.cpp \ + src/storage.cpp \ + src/filestorage.cpp \ + src/dbstorage.cpp + +HEADERS += src/mainwindow.h \ + src/player.h \ + src/track.h \ + src/trackmetainformation.h \ + src/playlist.h \ + src/someplayer.h \ + src/library.h \ + src/storage.h \ + src/filestorage.h \ + src/dbstorage.h FORMS += src/ui/mainwindow.ui diff --git a/someplayer.pro.user b/someplayer.pro.user index 37e020b..ff27c4c 100644 --- a/someplayer.pro.user +++ b/someplayer.pro.user @@ -2,7 +2,7 @@ ProjectExplorer.Project.ActiveTarget - 2 + 1 ProjectExplorer.Project.EditorSettings @@ -107,7 +107,7 @@ Maemo Qt4ProjectManager.Target.MaemoDeviceTarget - 0 + 1 0 @@ -126,8 +126,8 @@ Qt4ProjectManager.MaemoPackageCreationStep - true - + false + /usr/local/bin/someplayer 3 @@ -168,8 +168,8 @@ Qt4ProjectManager.MaemoPackageCreationStep - true - + false + /opt/someplayer/someplayer 3 @@ -196,12 +196,14 @@ 2 someplayer.pro - New Maemo Run Configuration + N900 Qt4ProjectManager.MaemoRunConfiguration 1 - + + 2010-09-04T19:46:35 + 1 diff --git a/src/dbstorage.cpp b/src/dbstorage.cpp new file mode 100644 index 0000000..764f616 --- /dev/null +++ b/src/dbstorage.cpp @@ -0,0 +1 @@ +#include "dbstorage.h" diff --git a/src/dbstorage.h b/src/dbstorage.h new file mode 100644 index 0000000..21f0572 --- /dev/null +++ b/src/dbstorage.h @@ -0,0 +1,18 @@ +#ifndef DB_STORAGE +#define DB_STORAGE + +#include "someplayer.h" +#include "storage.h" + +// represents database storage +// it store date into some database (e.g. tracks) + +namespace SomePlayer { + namespace Storage { + + class DbStorage : public Storage { + }; + }; +}; + +#endif diff --git a/src/filestorage.cpp b/src/filestorage.cpp new file mode 100644 index 0000000..966af8c --- /dev/null +++ b/src/filestorage.cpp @@ -0,0 +1 @@ +#include "filestorage.h" diff --git a/src/filestorage.h b/src/filestorage.h new file mode 100644 index 0000000..bc9c803 --- /dev/null +++ b/src/filestorage.h @@ -0,0 +1,19 @@ +#ifndef FILE_STORAGE +#define FILE_STORAGE + +#include "someplayer.h" +#include "storage.h" + +// represents file-level storage +// it store data into separate files (e.g. playlist) + +namespace SomePlayer { + namespace Storage { + + class FileStorage : public Storage { + }; + + }; +}; + +#endif diff --git a/src/library.cpp b/src/library.cpp new file mode 100644 index 0000000..6d25561 --- /dev/null +++ b/src/library.cpp @@ -0,0 +1 @@ +#include "library.h" diff --git a/src/library.h b/src/library.h new file mode 100644 index 0000000..b98aabe --- /dev/null +++ b/src/library.h @@ -0,0 +1,19 @@ +#ifndef LIBRARY +#define LIBRARY + +#include "someplayer.h" + +// represents media library: tracks, playlists +// it uses different media storages for tracks and playlists +// but dinamyc playlits will be stored with tracks into the same storage + +namespace SomePlayer { + namespace DataObjects { + + class Library { + }; + + }; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index 5360a7c..68544fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,13 +3,14 @@ int main(int argc, char *argv[]) { - QApplication a(argc, argv); - MainWindow w; + QApplication a(argc, argv); + a.setApplicationName("someplayer"); + MainWindow w; #if defined(Q_WS_S60) - w.showMaximized(); + w.showMaximized(); #else - w.show(); + w.show(); #endif - return a.exec(); + return a.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49d64fc..67141bc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,14 +1,26 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include +#include +#include "player.h" MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) + QMainWindow(parent), + ui(new Ui::MainWindow) { - ui->setupUi(this); + ui->setupUi(this); + connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openMedia())); + player = new Player(); } MainWindow::~MainWindow() { - delete ui; + delete ui; +} + +void MainWindow::openMedia() +{ + QString filename = QFileDialog::getOpenFileName(this, "Open media", "/home/user/"); + player->playSong(filename); + } diff --git a/src/mainwindow.h b/src/mainwindow.h index c9fd6a9..1a9e1f4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,21 +2,26 @@ #define MAINWINDOW_H #include +#include "player.h" namespace Ui { - class MainWindow; + class MainWindow; } class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); private: - Ui::MainWindow *ui; + Ui::MainWindow *ui; + Player *player; + +public slots: + void openMedia(); }; #endif // MAINWINDOW_H diff --git a/src/player.cpp b/src/player.cpp new file mode 100644 index 0000000..2b1caaa --- /dev/null +++ b/src/player.cpp @@ -0,0 +1,18 @@ +#include "player.h" + +Player::Player() : QObject() +{ +object = new Phonon::MediaObject(this); + output = new Phonon::AudioOutput(Phonon::MusicCategory, this); + Phonon::createPath(object, output); +} + +Player::~Player() +{ +} + +void Player::playSong(QString filename) +{ + object->setCurrentSource(Phonon::MediaSource(filename)); + object->play(); +} diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..0350e02 --- /dev/null +++ b/src/player.h @@ -0,0 +1,24 @@ +#ifndef PLAYER_H +#define PLAYER_H +#include +#include +#include +#include +#include +#include + +class Player : public QObject +{ + Q_OBJECT +public: + explicit Player(); + ~Player(); +private: + Phonon::MediaObject *object; + Phonon::AudioOutput *output; + +public slots: + void playSong(QString filename); +}; + +#endif // PLAYER_H diff --git a/src/playlist.cpp b/src/playlist.cpp new file mode 100644 index 0000000..86a4ae6 --- /dev/null +++ b/src/playlist.cpp @@ -0,0 +1,25 @@ +#include "playlist.h" + +using namespace SomePlayer::DataObjects; + +Playlist::Playlist() +{ + _name = "New playlist"; +} + +QString Playlist::name() const { + return _name; +} + +QList Playlist::tracks() const { + return _tracks; +} + +void Playlist::setName(QString name) { + _name = name; +} + +void Playlist::addTrack(Track track) { + _tracks.append(track); +} + diff --git a/src/playlist.h b/src/playlist.h new file mode 100644 index 0000000..6898eae --- /dev/null +++ b/src/playlist.h @@ -0,0 +1,30 @@ +#ifndef PLAYLIST +#define PLAYLIST + +#include +#include +#include "track.h" +#include "someplayer.h" + +// represents playlist: list of tracks, name + +namespace SomePlayer { + namespace DataObjects { + class Playlist { + public: + Playlist(); + + QString name() const; + QList tracks() const; + + void setName(QString name); + void addTrack(Track track); + + private: + QString _name; + QList _tracks; + }; + }; +}; + +#endif diff --git a/src/someplayer.h b/src/someplayer.h new file mode 100644 index 0000000..3213fea --- /dev/null +++ b/src/someplayer.h @@ -0,0 +1,13 @@ +#ifndef SOMEPLAYER +#define SOMEPLAYER + +// common settings, constants and so on + +namespace SomePlayer { + namespace DataObjects { + }; + namespace Storage { + }; +}; + +#endif diff --git a/src/storage.cpp b/src/storage.cpp new file mode 100644 index 0000000..85252e6 --- /dev/null +++ b/src/storage.cpp @@ -0,0 +1 @@ +#include "storage.h" diff --git a/src/storage.h b/src/storage.h new file mode 100644 index 0000000..5f66bb1 --- /dev/null +++ b/src/storage.h @@ -0,0 +1,18 @@ +#ifndef STORAGE +#define STORAGE + +#include "someplayer.h" + +// represent abstract storage +// abstract class + +namespace SomePlayer{ + namespace Storage { + + class Storage { + }; + + }; +}; + +#endif diff --git a/src/track.cpp b/src/track.cpp new file mode 100644 index 0000000..728056c --- /dev/null +++ b/src/track.cpp @@ -0,0 +1,23 @@ +#include "track.h" + +using namespace SomePlayer::DataObjects; + +Track::Track() { +} + +Track::Track(TrackMetadata metadata, QUrl source) { + _metadata = metadata; + _source = source; +} + +TrackMetadata Track::metadata() { + return _metadata; +} + +QUrl Track::source() const { + return _source; +} + +void Track::setSource(QUrl source) { + _source = source; +} diff --git a/src/track.h b/src/track.h new file mode 100644 index 0000000..36c2278 --- /dev/null +++ b/src/track.h @@ -0,0 +1,31 @@ +#ifndef TRACK_H +#define TRACK_H + +#include "someplayer.h" +#include "trackmetainformation.h" +#include + +// represents some track: metainformation + source url + +namespace SomePlayer { + namespace DataObjects { + + class Track + { + public: + Track(); + Track(TrackMetadata metadata, QUrl source); + TrackMetadata metadata(); //read-write + QUrl source() const; + void setSource (QUrl source); + + private: + TrackMetadata _metadata; + QUrl _source; + }; + + }; +}; + + +#endif // TRACK_H diff --git a/src/trackmetainformation.cpp b/src/trackmetainformation.cpp new file mode 100644 index 0000000..0ef9e5c --- /dev/null +++ b/src/trackmetainformation.cpp @@ -0,0 +1,61 @@ +#include "trackmetainformation.h" + +using namespace SomePlayer::DataObjects; + +TrackMetadata::TrackMetadata() { +} + +TrackMetadata::TrackMetadata(QString title = "", QString artist = "", QString album = "", QString genre = "") { + _metadata["TITLE"] = title; + _metadata["ARTIST"] = artist; + _metadata["ALBUM"] = album; + _metadata["GENRE"] = genre; +} + +QString TrackMetadata::title() { + if (_metadata.contains("TITLE")) { + return _metadata["TITLE"]; + } else { + return "Unknown title"; + } +} + +QString TrackMetadata::artist() { + if (_metadata.contains("ARTIST")) { + return _metadata["ARTIST"]; + } else { + return "Unknown artist"; + } +} + +QString TrackMetadata::album() { + if (_metadata.contains("ALBUM")) { + return _metadata["ALBUM"]; + } else { + return "Unknown album"; + } +} + +QString TrackMetadata::genre() { + if (_metadata.contains("GENRE")) { + return _metadata["GENRE"]; + } else { + return "Unknown genre"; + } +} + +void TrackMetadata::setTitle(QString title) { + _metadata["TITLE"] = title; +} + +void TrackMetadata::setArtist(QString artist) { + _metadata["ARTIST"] = artist; +} + +void TrackMetadata::setAlbum(QString album) { + _metadata["ALBUM"] = album; +} + +void TrackMetadata::setGenre(QString genre) { + _metadata["GENRE"] = genre; +} diff --git a/src/trackmetainformation.h b/src/trackmetainformation.h new file mode 100644 index 0000000..2010fa4 --- /dev/null +++ b/src/trackmetainformation.h @@ -0,0 +1,35 @@ +#ifndef TRACK_METAINFORMATION +#define TRACK_METAINFORMATION + +#include +#include +#include "someplayer.h" + +// represents track metainformation only. +// now it contains TITLE, ARTIST, ALBUM, GENRE + +namespace SomePlayer { + namespace DataObjects { + class TrackMetadata { + + public: + TrackMetadata(); + TrackMetadata(QString title, QString artist, QString album, QString genre); + + QString title(); + QString artist(); + QString album(); + QString genre(); + + void setTitle(QString title); + void setArtist(QString artist); + void setAlbum(QString album); + void setGenre(QString genre); + + private: + QMap _metadata; + }; + }; +}; + +#endif diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index 7ebf873..38afdfc 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -1,7 +1,8 @@ + MainWindow - - + + 0 0 @@ -9,13 +10,56 @@ 480 - - MainWindow + + someplayer - + + + + + 0 + 0 + 800 + 23 + + + + + File + + + + + + + + Open media + + + + + Quit + + - - + - + + + actionQuit + triggered() + MainWindow + close() + + + -1 + -1 + + + 399 + 239 + + + +