~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to libkcddb/cdinfodialogbase.ui.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
** ui.h extension file, included from the uic-generated form implementation.
 
3
**
 
4
** If you wish to add, delete or rename functions or slots use
 
5
** Qt Designer which will update this file, preserving your code. Create an
 
6
** init() function in place of a constructor, and a destroy() function in
 
7
** place of a destructor.
 
8
*****************************************************************************/
 
9
const char *CDInfoDialogBase::SEPARATOR = " / ";
 
10
 
 
11
void CDInfoDialogBase::init()
 
12
{
 
13
    m_categories = KCDDB::Categories();
 
14
    m_category->insertStringList(m_categories.i18nList());
 
15
    m_genres = KCDDB::Genres();
 
16
    m_genre->insertStringList(m_genres.i18nList());
 
17
 
 
18
    // We want control over the visibility of this column. See artistChanged().
 
19
    m_trackList->setColumnWidthMode(TRACK_ARTIST, QListView::Manual);
 
20
 
 
21
    // Make the user-definable values in-place editable.
 
22
    m_trackList->setRenameable(TRACK_NUMBER, false);
 
23
    m_trackList->setRenameable(TRACK_TIME, false);
 
24
    m_trackList->setRenameable(TRACK_TITLE, true);
 
25
    m_trackList->setRenameable(TRACK_COMMENT, true);
 
26
    m_trackList->setRenameable(TRACK_ARTIST, true);
 
27
}
 
28
 
 
29
void CDInfoDialogBase::destroy()
 
30
{
 
31
}
 
32
 
 
33
void CDInfoDialogBase::slotTrackSelected( QListViewItem *item )
 
34
{
 
35
    emit play(item->text(0).toUInt()-1);
 
36
}
 
37
 
 
38
void CDInfoDialogBase::slotNextTrack()
 
39
{
 
40
    if (m_trackList->currentItem())
 
41
    {
 
42
        QListViewItem *item = m_trackList->currentItem()->nextSibling();
 
43
        m_trackList->setSelected(item, true);
 
44
        m_trackList->ensureItemVisible(item);
 
45
    }
 
46
}
 
47
 
 
48
void CDInfoDialogBase::slotTrackDoubleClicked( QListViewItem *item, const QPoint &, int column)
 
49
{
 
50
    m_trackList->rename(item, column);
 
51
}
 
52
 
 
53
#include <kdebug.h>
 
54
void CDInfoDialogBase::setInfo( const KCDDB::CDInfo &info, KCDDB::TrackOffsetList &trackStartFrames )
 
55
{
 
56
    m_artist->setText(info.artist.stripWhiteSpace());
 
57
    m_title->setText(info.title.stripWhiteSpace());
 
58
    m_category->setCurrentText(m_categories.cddb2i18n(info.category));
 
59
 
 
60
    // Make sure the revision is set before the genre to allow the genreChanged() handler to fire.
 
61
    m_revision->setText(QString::number(info.revision));
 
62
    m_genre->setCurrentText(m_genres.cddb2i18n(info.genre));
 
63
    m_year->setValue(info.year);
 
64
    m_comment->setText(info.extd.stripWhiteSpace());
 
65
    m_id->setText(info.id.stripWhiteSpace());
 
66
 
 
67
    // Now do the individual tracks.
 
68
    unsigned tracks = info.trackInfoList.count();
 
69
    m_length->setText(framesTime(trackStartFrames[tracks + 1] - trackStartFrames[0]));
 
70
    m_trackList->clear();
 
71
    for (unsigned i = 0; i < tracks; i++)
 
72
    {
 
73
        QListViewItem *item = new QListViewItem(m_trackList, 0);
 
74
 
 
75
        item->setText(TRACK_NUMBER, QString().sprintf("%02d", i + 1));
 
76
        item->setText(TRACK_TIME, framesTime(trackStartFrames[i + ((i + 1 < tracks) ? 1 : 2)] - trackStartFrames[i]));
 
77
        QString title = info.trackInfoList[i].title;
 
78
        int separator = title.find(SEPARATOR);
 
79
        if (info.artist != "Various" || separator == -1)
 
80
        {
 
81
            item->setText(TRACK_ARTIST, "");
 
82
            item->setText(TRACK_TITLE, title);
 
83
        }
 
84
        else
 
85
        {
 
86
            // We seem to have a compilation.
 
87
            item->setText(TRACK_ARTIST, title.left(separator));
 
88
            item->setText(TRACK_TITLE, title.mid(separator + 3));
 
89
        }
 
90
        item->setText(TRACK_COMMENT, info.trackInfoList[i].extt);
 
91
    }
 
92
    // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated.
 
93
 
 
94
    if (info.artist == "Various")
 
95
        m_trackList->adjustColumn(TRACK_ARTIST);
 
96
}
 
97
 
 
98
QString CDInfoDialogBase::framesTime(unsigned frames)
 
99
{
 
100
    QTime time;
 
101
    double ms;
 
102
 
 
103
    ms = frames * 1000 / 75.0;
 
104
    time = time.addMSecs((int)ms);
 
105
 
 
106
    // Use ".zzz" for milliseconds...
 
107
    QString temp2;
 
108
    if (time.hour() > 0)
 
109
        temp2 = time.toString("hh:mm:ss");
 
110
    else
 
111
        temp2 = time.toString("mm:ss");
 
112
    return temp2;
 
113
} // framesTime
 
114
 
 
115
KCDDB::CDInfo CDInfoDialogBase::info() const
 
116
{
 
117
    KCDDB::CDInfo info;
 
118
    KCDDB::TrackInfo track;
 
119
 
 
120
    info.artist = m_artist->text().stripWhiteSpace();
 
121
    info.title = m_title->text().stripWhiteSpace();
 
122
    info.category = m_categories.i18n2cddb(m_category->currentText());
 
123
    info.genre = m_genres.i18n2cddb(m_genre->currentText());
 
124
    info.year = m_year->value();
 
125
    info.extd = m_comment->text().stripWhiteSpace();
 
126
    info.revision = m_revision->text().stripWhiteSpace().toUInt();
 
127
    info.id = m_id->text().stripWhiteSpace();
 
128
    for (QListViewItem *item = m_trackList->firstChild(); item; item=item->nextSibling())
 
129
    {
 
130
        // Combine the track artist if present with the title.
 
131
        QString trackArtist = item->text(TRACK_ARTIST).stripWhiteSpace();
 
132
        track.title = trackArtist;
 
133
        if (!trackArtist.isEmpty())
 
134
        {
 
135
            track.title.append(SEPARATOR);
 
136
        }
 
137
        track.title.append(item->text(TRACK_TITLE).stripWhiteSpace());
 
138
        track.extt = item->text(TRACK_COMMENT).stripWhiteSpace();
 
139
        info.trackInfoList.append(track);
 
140
        // FIXME KDE4: handle track lengths here too, once KCDDBInfo::CDInfo is updated.
 
141
    }
 
142
    // FIXME KDE4: handle playorder here too, once KCDDBInfo::CDInfo is updated.
 
143
    return info;
 
144
}
 
145
 
 
146
 
 
147
void CDInfoDialogBase::artistChanged( const QString &newArtist )
 
148
{
 
149
    // Enable special handling of compilations.
 
150
    if (newArtist.stripWhiteSpace().compare("Various") == 0)
 
151
    {
 
152
        for (QListViewItem *item = m_trackList->firstChild(); item; item=item->nextSibling())
 
153
        {
 
154
            QString title = item->text(TRACK_TITLE);
 
155
            int separator = title.find(SEPARATOR);
 
156
            if (separator != -1)
 
157
            {
 
158
                // Artists probably entered already
 
159
                item->setText(TRACK_ARTIST, title.left(separator));
 
160
                item->setText(TRACK_TITLE, title.mid(separator + 3));
 
161
            }
 
162
        }
 
163
        m_trackList->adjustColumn(TRACK_ARTIST);
 
164
        m_trackList->adjustColumn(TRACK_TITLE);
 
165
    }
 
166
    else
 
167
    {
 
168
        for (QListViewItem *item = m_trackList->firstChild(); item; item=item->nextSibling())
 
169
        {
 
170
            QString artist = item->text(TRACK_ARTIST);
 
171
            if (!artist.isEmpty())
 
172
            {
 
173
                item->setText(TRACK_ARTIST, QString::null);
 
174
                item->setText(TRACK_TITLE, artist + SEPARATOR + item->text(TRACK_TITLE));
 
175
            }
 
176
        }
 
177
        m_trackList->hideColumn(TRACK_ARTIST);
 
178
        m_trackList->adjustColumn(TRACK_TITLE);
 
179
    }
 
180
}
 
181
 
 
182
void CDInfoDialogBase::genreChanged( const QString &newGenre )
 
183
{
 
184
    // Disable changes to category if the version number indicates that a record
 
185
    // is already in the database, or if the genre is poorly set. The latter
 
186
    // condition also provides a "back-door" override.
 
187
    m_category->setEnabled((m_revision->text().stripWhiteSpace().toUInt() < 1) ||
 
188
                            (newGenre.compare("Unknown") == 0));
 
189
}