From bc2ea013aca7b0bc722e54e2ae78c0bed0bed4d9 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 19 Aug 2011 13:41:01 -0400 Subject: [PATCH] delete maclineedit --- src/libtomahawk/CMakeLists.txt | 2 - src/libtomahawk/widgets/maclineedit.h | 84 --------------- src/libtomahawk/widgets/maclineedit.mm | 140 ------------------------- 3 files changed, 226 deletions(-) delete mode 100644 src/libtomahawk/widgets/maclineedit.h delete mode 100644 src/libtomahawk/widgets/maclineedit.mm diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index a2b7823e1..a8f54f923 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -451,11 +451,9 @@ IF( APPLE ) SET( libSources ${libSources} infosystem/infoplugins/mac/adium.mm infosystem/infoplugins/mac/adiumplugin.cpp - widgets/maclineedit.mm utils/tomahawkutils_mac.mm ) SET( libHeaders ${libHeaders} - widgets/maclineedit.h infosystem/infoplugins/mac/adium.h infosystem/infoplugins/mac/adiumplugin.h ) diff --git a/src/libtomahawk/widgets/maclineedit.h b/src/libtomahawk/widgets/maclineedit.h deleted file mode 100644 index 1e3320993..000000000 --- a/src/libtomahawk/widgets/maclineedit.h +++ /dev/null @@ -1,84 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - Clementine is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Clementine is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Clementine. If not, see . -*/ - -#ifndef MACLINEEDIT_H -#define MACLINEEDIT_H - -#include - -#include "dllmacro.h" - -class SearchTargetWrapper; - -class DLLEXPORT LineEditInterface { -public: - LineEditInterface(QWidget* widget) : widget_(widget) {} - - QWidget* widget() const { return widget_; } - - virtual ~LineEditInterface() {} - - virtual void clear() { set_text(QString()); } - virtual void set_focus() = 0; - virtual QString text() const = 0; - virtual void set_text(const QString& text) = 0; - - virtual QString hint() const = 0; - virtual void set_hint(const QString& hint) = 0; - virtual void clear_hint() = 0; - - virtual void set_enabled(bool enabled) = 0; - -protected: - QWidget* widget_; -}; - -class DLLEXPORT MacLineEdit : public QMacCocoaViewContainer, public LineEditInterface { - Q_OBJECT - Q_PROPERTY(QString hint READ hint WRITE set_hint); - - public: - MacLineEdit(QWidget* parent = 0); - ~MacLineEdit(); - - QString hint() const { return hint_; } - void set_hint(const QString& hint); - void clear_hint() { set_hint(QString()); } - - void paintEvent(QPaintEvent* e); - - void set_text(const QString&); - QString text() const; - void set_focus() {} - - void set_enabled(bool enabled); - - signals: - void textChanged(const QString& text); - void textEdited(const QString& text); - - private: - // Called by NSSearchFieldCell when the text changes. - void TextChanged(const QString& text); - - QString hint_; - - friend class SearchTargetWrapper; - SearchTargetWrapper* wrapper_; -}; - -#endif // MACLINEEDIT_H diff --git a/src/libtomahawk/widgets/maclineedit.mm b/src/libtomahawk/widgets/maclineedit.mm deleted file mode 100644 index e391613be..000000000 --- a/src/libtomahawk/widgets/maclineedit.mm +++ /dev/null @@ -1,140 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, David Sansome - - Clementine is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Clementine is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Clementine. If not, see . -*/ - -#include "maclineedit.h" - -#import - -#include - -@interface SearchTarget : NSObject { - SearchTargetWrapper* wrapper_; -} - -- (id) initWithWrapper: (SearchTargetWrapper*)wrapper; -- (void) action; -@end - -class SearchTargetWrapper { - public: - explicit SearchTargetWrapper(NSSearchField* search, MacLineEdit* lineedit); - void TextChanged(); - - QString text() const; - void setText(const QString& text); - - void SetHint(const QString& hint); - - void SetEnabled(bool enabled); - - private: - NSSearchField* search_; - SearchTarget* target_; - MacLineEdit* lineedit_; -}; - - -@implementation SearchTarget -- (id) initWithWrapper: (SearchTargetWrapper*)wrapper { - wrapper_ = wrapper; - return self; -} - -- (void) action { - wrapper_->TextChanged(); -} -@end - -SearchTargetWrapper::SearchTargetWrapper(NSSearchField* search, MacLineEdit* lineedit) - : search_(search), - lineedit_(lineedit) { - target_ = [[SearchTarget alloc] initWithWrapper:this]; - - [[search cell] setSendsWholeSearchString:true]; - - [[search cell] setTarget:target_]; - [[search cell] setAction:@selector(action)]; -} - -void SearchTargetWrapper::TextChanged() { - NSString* text = [[search_ cell] stringValue]; - lineedit_->TextChanged(QString::fromUtf8([text UTF8String])); -} - -QString SearchTargetWrapper::text() const { - NSString* text = [[search_ cell] stringValue]; - return QString::fromUtf8([text UTF8String]); -} - -void SearchTargetWrapper::setText(const QString& text) { - NSString* t = [[NSString alloc] initWithUTF8String:text.toUtf8().constData()]; - [[search_ cell] setStringValue:t]; - [t release]; -} - -void SearchTargetWrapper::SetHint(const QString& hint) { - NSString* t = [[NSString alloc] initWithUTF8String:hint.toUtf8().constData()]; - [[search_ cell] setPlaceholderString:t]; - [t release]; -} - -void SearchTargetWrapper::SetEnabled(bool enabled) { - [search_ setEnabled:enabled]; -} - -MacLineEdit::MacLineEdit(QWidget* parent) - : QMacCocoaViewContainer(0, parent), - LineEditInterface(this) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSSearchField* search = [[NSSearchField alloc] init]; - setCocoaView(search); - - wrapper_ = new SearchTargetWrapper(search, this); - - [search release]; - [pool release]; // Pool's closed. -} - -MacLineEdit::~MacLineEdit() { - delete wrapper_; -} - -void MacLineEdit::paintEvent(QPaintEvent* e) { - QMacCocoaViewContainer::paintEvent(e); -} - -void MacLineEdit::TextChanged(const QString& text) { - emit textChanged(text); - emit textEdited(text); -} - -QString MacLineEdit::text() const { - return wrapper_->text(); -} - -void MacLineEdit::set_text(const QString& text) { - wrapper_->setText(text); -} - -void MacLineEdit::set_enabled(bool enabled) { - wrapper_->SetEnabled(enabled); -} - -void MacLineEdit::set_hint(const QString& hint) { - wrapper_->SetHint(hint); -}