From 0102019be5e123a5f069e02bf9566b811a681b81 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Thu, 28 Feb 2008 13:01:34 +0000 Subject: 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 --- src/ui/addurldialog.cpp | 34 +++++++++++++++++++++------------- src/ui/addurldialog.h | 13 +++++++------ 2 files changed, 28 insertions(+), 19 deletions(-) (limited to 'src') 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 +#include #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::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 instance; PlayListModel* m_model; + QStringList m_history; }; #endif //ADDURLDIALOG_H -- cgit v1.2.3-13-gbd6f