aboutsummaryrefslogtreecommitdiff
path: root/src/addurldialog.cpp
blob: f59dad7ac98446a8664a8c7ed9694f1b81393755 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "addurldialog.h"

#include "playlistmodel.h"

AddUrlDialog::AddUrlDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent,f)
{
  setupUi(this);
  setAttribute(Qt::WA_DeleteOnClose);
}

AddUrlDialog::~AddUrlDialog()
{}



QPointer<AddUrlDialog> AddUrlDialog::instance = 0;

void AddUrlDialog::popup(QWidget* parent,PlayListModel* model )
{
    if(!instance) 
    {
        instance = new AddUrlDialog(parent);
        instance->setModel(model);
    }
    
    instance->show();
    instance->raise();
}

void AddUrlDialog::accept( )
{
    if(!urlComboBox->currentText().isEmpty())
    {
        QString s = urlComboBox->currentText();
        if(!s.startsWith("http://"))
            s.prepend("http://");
        
        m_model->addFile(s);
    }
    
    QDialog::accept();
}

void AddUrlDialog::setModel( PlayListModel *m )
{
    m_model = m;
}