diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-02-28 13:01:34 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-02-28 13:01:34 +0000 |
| commit | 0102019be5e123a5f069e02bf9566b811a681b81 (patch) | |
| tree | ecd7c14226c7ecf35e859a6b5ad8f6ca17435390 | |
| parent | 875efcc8a05794964e1a995a4d624167e4a63f0a (diff) | |
| download | qmmp-0102019be5e123a5f069e02bf9566b811a681b81.tar.gz qmmp-0102019be5e123a5f069e02bf9566b811a681b81.tar.bz2 qmmp-0102019be5e123a5f069e02bf9566b811a681b81.zip | |
history support for url dialog
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@256 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/ui/addurldialog.cpp | 34 | ||||
| -rw-r--r-- | src/ui/addurldialog.h | 13 |
2 files changed, 28 insertions, 19 deletions
diff --git a/src/ui/addurldialog.cpp b/src/ui/addurldialog.cpp index 6746a2de1..6fab029ea 100644 --- a/src/ui/addurldialog.cpp +++ b/src/ui/addurldialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2008 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -18,46 +18,54 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <QSettings> +#include <QDir> #include "addurldialog.h" - #include "playlistmodel.h" +#define HISTORY_SIZE 10 + AddUrlDialog::AddUrlDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent,f) { - setupUi(this); - setAttribute(Qt::WA_DeleteOnClose); + setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat); + m_history = settings.value("URLDialog/history").toStringList(); + urlComboBox->addItems(m_history); } AddUrlDialog::~AddUrlDialog() -{} - - +{ + if ( m_history.size() > HISTORY_SIZE) + m_history.removeLast(); + QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat); + settings.setValue("URLDialog/history", m_history); +} QPointer<AddUrlDialog> AddUrlDialog::instance = 0; void AddUrlDialog::popup(QWidget* parent,PlayListModel* model ) { - if(!instance) + if (!instance) { instance = new AddUrlDialog(parent); instance->setModel(model); } - instance->show(); instance->raise(); } void AddUrlDialog::accept( ) { - if(!urlComboBox->currentText().isEmpty()) + if (!urlComboBox->currentText().isEmpty()) { QString s = urlComboBox->currentText(); - if(!s.startsWith("http://")) + if (!s.startsWith("http://")) s.prepend("http://"); - m_model->addFile(s); + m_history.removeAll(s); + m_history.prepend(s); } - QDialog::accept(); } diff --git a/src/ui/addurldialog.h b/src/ui/addurldialog.h index 86a065703..e3bcdf22e 100644 --- a/src/ui/addurldialog.h +++ b/src/ui/addurldialog.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * + * Copyright (C) 2006-2008 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef ADDURLDIALOG_H #define ADDURLDIALOG_H @@ -34,18 +34,19 @@ class PlayListModel; class AddUrlDialog : public QDialog , private Ui::AddUrlDialog { - Q_OBJECT + Q_OBJECT public: static void popup(QWidget* parent ,PlayListModel*); protected: - AddUrlDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ); - ~AddUrlDialog(); + AddUrlDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ); + ~AddUrlDialog(); protected slots: - virtual void accept(); + virtual void accept(); private: void setModel(PlayListModel*); static QPointer<AddUrlDialog> instance; PlayListModel* m_model; + QStringList m_history; }; #endif //ADDURLDIALOG_H |
