code review

This commit is contained in:
Paweł Bara 2011-03-13 13:02:48 +00:00
parent 8690438ad4
commit ad7223f8b3
5 changed files with 18 additions and 18 deletions

View File

@ -63,6 +63,9 @@ using boost::shared_ptr;
const char* Playlist::kRowsMimetype = "application/x-clementine-playlist-rows";
const char* Playlist::kPlayNowMimetype = "application/x-clementine-play-now";
const int Playlist::kDynamicHistoryPriority = 100;
const QRgb Playlist::kDynamicHistoryColor = qRgb(0x80, 0x80, 0x80);
Playlist::Playlist(PlaylistBackend* backend,
TaskManager* task_manager,
LibraryBackend* library,
@ -83,9 +86,7 @@ Playlist::Playlist(PlaylistBackend* backend,
has_scrobbled_(false),
playlist_sequence_(NULL),
ignore_sorting_(false),
undo_stack_(new QUndoStack(this)),
dynamic_history_priority_(100),
dynamic_history_color_(Qt::darkGray)
undo_stack_(new QUndoStack(this))
{
connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), SIGNAL(PlaylistChanged()));
connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), SIGNAL(PlaylistChanged()));
@ -524,8 +525,8 @@ void Playlist::set_current_row(int i) {
if (old_current.isValid()) {
if (dynamic_playlist_) {
items_[old_current.row()]->SetForegroundColor(dynamic_history_priority_,
dynamic_history_color_);
items_[old_current.row()]->SetForegroundColor(kDynamicHistoryPriority,
kDynamicHistoryColor);
}
emit dataChanged(old_current, old_current.sibling(old_current.row(), ColumnCount-1));
@ -720,7 +721,7 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
// Put the items back in
const int start = pos == -1 ? items_.count() : pos;
for (int i=start ; i<start+moved_items.count() ; ++i) {
moved_items[i - start]->RemoveForegroundColor(dynamic_history_priority_);
moved_items[i - start]->RemoveForegroundColor(kDynamicHistoryPriority);
items_.insert(i, moved_items[i - start]);
}

View File

@ -324,8 +324,8 @@ class Playlist : public QAbstractListModel {
QUndoStack* undo_stack_;
const int dynamic_history_priority_;
const QColor dynamic_history_color_;
static const int kDynamicHistoryPriority;
static const QRgb kDynamicHistoryColor;
smart_playlists::GeneratorPtr dynamic_playlist_;
ColumnAlignmentMap column_alignments_;

View File

@ -32,9 +32,7 @@ class SqlRow;
class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
public:
PlaylistItem(const QString& type)
: type_(type),
background_colors_(QMap<short, QColor>()),
foreground_colors_(QMap<short, QColor>()) {}
: type_(type) {}
virtual ~PlaylistItem() {}
static PlaylistItem* NewFromType(const QString& type);

View File

@ -30,6 +30,9 @@
using smart_playlists::GeneratorPtr;
const int PlaylistManagerInterface::kInvalidSongPriority = 200;
const QRgb PlaylistManagerInterface::kInvalidSongColor = qRgb(0xC0, 0xC0, 0xC0);
PlaylistManager::PlaylistManager(TaskManager* task_manager, QObject *parent)
: PlaylistManagerInterface(parent),
task_manager_(task_manager),
@ -346,9 +349,9 @@ void PlaylistManager::SongChangeRequestProcessed(const QUrl& url, bool valid) {
// gray out the song if it's now broken; otherwise undo the gray color
if(valid) {
current->RemoveForegroundColor(invalid_song_priority_);
current->RemoveForegroundColor(kInvalidSongPriority);
} else {
current->SetForegroundColor(invalid_song_priority_, invalid_song_color_);
current->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
}
// we have at most one current item

View File

@ -41,9 +41,7 @@ class PlaylistManagerInterface : public QObject {
public:
PlaylistManagerInterface(QObject* parent)
: QObject(parent),
invalid_song_priority_(200),
invalid_song_color_(Qt::lightGray) {}
: QObject(parent) {}
virtual int current_id() const = 0;
virtual int active_id() const = 0;
@ -119,8 +117,8 @@ signals:
void PlayRequested(const QModelIndex& index);
protected:
const int invalid_song_priority_;
const QColor invalid_song_color_;
static const int kInvalidSongPriority;
static const QRgb kInvalidSongColor;
};
class PlaylistManager : public PlaylistManagerInterface {