[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons] applets/comic: Moves subclasses of Plasma widgets to own header file.
From:       Matthias Fuchs <mat69 () gmx ! net>
Date:       2012-01-31 18:13:38
Message-ID: 20120131181338.D3C64A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit c141aac3e93290d19bf32abe9283e1cb2e47c9c6 by Matthias Fuchs.
Committed on 29/01/2012 at 15:13.
Pushed by mfuchs into branch 'master'.

Moves subclasses of Plasma widgets to own header file.

M  +1    -0    applets/comic/comic.cpp
M  +2    -94   applets/comic/comic.h
A  +124  -0    applets/comic/comicwidgets.h     [License: GPL (v2+)]

http://commits.kde.org/kdeplasma-addons/c141aac3e93290d19bf32abe9283e1cb2e47c9c6

diff --git a/applets/comic/comic.cpp b/applets/comic/comic.cpp
index d9ac5c1..aaa37f3 100644
--- a/applets/comic/comic.cpp
+++ b/applets/comic/comic.cpp
@@ -23,6 +23,7 @@
 #include "comicarchivedialog.h"
 #include "comicarchivejob.h"
 #include "checknewstrips.h"
+#include "comicwidgets.h"
 
 #include <QtCore/QPropertyAnimation>
 #include <QtCore/QTimer>
diff --git a/applets/comic/comic.h b/applets/comic/comic.h
index 6d31492..c74b840 100644
--- a/applets/comic/comic.h
+++ b/applets/comic/comic.h
@@ -29,13 +29,13 @@
 
 #include <KUrl>
 #include <Plasma/DataEngine>
-#include <Plasma/Label>
 #include <Plasma/PopupApplet>
-#include <Plasma/TabBar>
 
 class ArrowWidget;
 class CheckNewStrips;
+class ComicLabel;
 class ComicModel;
+class ComicTabBar;
 class ConfigWidget;
 class FullViewWidget;
 class ImageWidget;
@@ -52,98 +52,6 @@ class Frame;
 class PushButton;
 }
 
-//Helper class, sets the sizeHint to 0 if the TabBar is hidden
-class ComicTabBar : public Plasma::TabBar
-{
-    public:
-        ComicTabBar( QGraphicsWidget *parent = 0 ) : TabBar( parent ) {}
-        ~ComicTabBar() {}
-
-        void removeAllTabs()
-        {
-            while ( this->count() ) {
-                this->removeTab( 0 );
-            }
-        }
-
-        bool hasHighlightedTabs() const
-        {
-            for ( int i = 0; i < count(); ++i ) {
-                if ( isTabHighlighted( i ) ) {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        int nextHighlightedTab( int index ) const
-        {
-            int firstHighlighted = -1;
-            for ( int i = 0; i < count(); ++i ) {
-                if ( isTabHighlighted( i ) ) {
-                    if ( i > index ) {
-                        return i;
-                    } else if ( firstHighlighted == -1 ) {
-                        firstHighlighted = i;
-                    }
-                }
-            }
-
-            return ( firstHighlighted != -1 ? firstHighlighted : index );
-        }
-
-    protected:
-        QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const
-        {
-            if ( !isVisible() ) {
-                return QSizeF( 0, 0 );
-            }
-            return QGraphicsWidget::sizeHint( which, constraint );
-        }
-
-        void hideEvent( QHideEvent *event )
-        {
-            updateGeometry();
-            QGraphicsWidget::hideEvent( event );
-        }
-
-        void showEvent( QShowEvent *event )
-        {
-            updateGeometry();
-            QGraphicsWidget::showEvent( event );
-        }
-};
-
-//Helper class, sets the sizeHint to 0 if the Label is hidden
-class ComicLabel : public Plasma::Label
-{
-    public:
-        ComicLabel( QGraphicsWidget *parent = 0 ) : Plasma::Label( parent ) {}
-        ~ComicLabel() {}
-
-    protected:
-        QSizeF sizeHint( Qt::SizeHint which, const QSizeF &constraint = QSizeF() ) const
-        {
-            if ( !isVisible() ) {
-                return QSizeF( 0, 0 );
-            }
-            return QGraphicsProxyWidget::sizeHint( which, constraint );
-        }
-
-        void hideEvent( QHideEvent *event )
-        {
-            updateGeometry();
-            QGraphicsProxyWidget::hideEvent( event );
-        }
-
-        void showEvent( QShowEvent *event )
-        {
-            updateGeometry();
-            QGraphicsProxyWidget::showEvent( event );
-        }
-};
-
 class ComicApplet : public Plasma::PopupApplet
 {
     Q_OBJECT
diff --git a/applets/comic/comicwidgets.h b/applets/comic/comicwidgets.h
new file mode 100644
index 0000000..4320c58
--- /dev/null
+++ b/applets/comic/comicwidgets.h
@@ -0,0 +1,124 @@
+/***************************************************************************
+ *   Copyright (C) 2008-2012 Matthias Fuchs <mat69@gmx.net>                *
+ *                                                                         *
+ *   This program 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 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program 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 this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
+ ***************************************************************************/
+
+#ifndef COMIC_WIDGETS_H
+#define COMIC_WIDGETS_H
+
+#include <Plasma/Label>
+#include <Plasma/TabBar>
+
+/**
+ * The following classes are helper classes adpated to the desired
+ * handling of the comic applet.
+ */
+
+
+//Helper class, sets the sizeHint to 0 if the TabBar is hidden
+class ComicTabBar : public Plasma::TabBar
+{
+    public:
+        ComicTabBar(QGraphicsWidget *parent = 0) : TabBar(parent) {}
+        ~ComicTabBar() {}
+
+        void removeAllTabs()
+        {
+            while (count()) {
+                removeTab(0);
+            }
+        }
+
+        bool hasHighlightedTabs() const
+        {
+            for (int i = 0; i < count(); ++i) {
+                if (isTabHighlighted(i)) {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        int nextHighlightedTab(int index) const
+        {
+            int firstHighlighted = -1;
+            for (int i = 0; i < count(); ++i) {
+                if (isTabHighlighted(i)) {
+                    if (i > index) {
+                        return i;
+                    } else if (firstHighlighted == -1) {
+                        firstHighlighted = i;
+                    }
+                }
+            }
+
+            return (firstHighlighted != -1 ? firstHighlighted : index);
+        }
+
+    protected:
+        QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
+        {
+            if (!isVisible()) {
+                return QSizeF(0, 0);
+            }
+            return QGraphicsWidget::sizeHint(which, constraint);
+        }
+
+        void hideEvent(QHideEvent *event)
+        {
+            updateGeometry();
+            QGraphicsWidget::hideEvent(event);
+        }
+
+        void showEvent(QShowEvent*event)
+        {
+            updateGeometry();
+            QGraphicsWidget::showEvent(event);
+        }
+};
+
+//Helper class, sets the sizeHint to 0 if the Label is hidden
+class ComicLabel : public Plasma::Label
+{
+    public:
+        ComicLabel(QGraphicsWidget *parent = 0) : Plasma::Label(parent) {}
+        ~ComicLabel() {}
+
+    protected:
+        QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const
+        {
+            if (!isVisible()) {
+                return QSizeF(0, 0);
+            }
+            return QGraphicsProxyWidget::sizeHint(which, constraint);
+        }
+
+        void hideEvent(QHideEvent *event)
+        {
+            updateGeometry();
+            QGraphicsProxyWidget::hideEvent(event);
+        }
+
+        void showEvent(QShowEvent *event)
+        {
+            updateGeometry();
+            QGraphicsProxyWidget::showEvent(event);
+        }
+};
+
+#endif

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic