• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
knarticlewindow.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 2 -*-
2 /*
3  KNode, the KDE newsreader
4  Copyright (c) 1999-2005 the KNode authors.
5  See file AUTHORS for details
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  You should have received a copy of the GNU General Public License
12  along with this program; if not, write to the Free Software Foundation,
13  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
14 */
15 
16 #include "knarticlewindow.h"
17 
18 #include "articlewidget.h"
19 #include "utilities.h"
20 #include "knglobals.h"
21 #include "knmainwidget.h"
22 
23 #include <kwindowsystem.h>
24 #include <kstandardaction.h>
25 #include <kconfig.h>
26 #include <kaction.h>
27 #include <kactioncollection.h>
28 
29 using namespace KNode;
30 
31 QList<KNode::ArticleWindow*> ArticleWindow::mInstances;
32 
33 
34 bool ArticleWindow::closeAllWindowsForCollection( KNArticleCollection::Ptr col, bool force )
35 {
36  ArticleWindow::List list = mInstances;
37  for ( ArticleWindow::List::Iterator it = list.begin(); it != list.end(); ++it )
38  if ( (*it)->mArticleWidget->article() && (*it)->mArticleWidget->article()->collection() == col ) {
39  if ( force )
40  (*it)->close();
41  else
42  return false;
43  }
44  return true;
45 }
46 
47 
48 bool ArticleWindow::closeAllWindowsForArticle( KNArticle::Ptr art, bool force )
49 {
50  ArticleWindow::List list = mInstances;
51  for ( ArticleWindow::List::Iterator it = list.begin(); it != list.end(); ++it )
52  if ( (*it)->mArticleWidget->article() && (*it)->mArticleWidget->article() == art ) {
53  if ( force )
54  (*it)->close();
55  else
56  return false;
57  }
58  return true;
59 }
60 
61 
62 bool ArticleWindow::raiseWindowForArticle( KNArticle::Ptr art )
63 {
64  for ( ArticleWindow::List::Iterator it = mInstances.begin(); it != mInstances.end(); ++it )
65  if ( (*it)->mArticleWidget->article() && (*it)->mArticleWidget->article() == art ) {
66 #ifdef Q_OS_UNIX
67  KWindowSystem::activateWindow( (*it)->winId() );
68 #endif
69  return true;
70  }
71  return false;
72 }
73 
74 
75 bool ArticleWindow::raiseWindowForArticle( const QByteArray &mid )
76 {
77  for ( ArticleWindow::List::Iterator it = mInstances.begin(); it != mInstances.end(); ++it )
78  if ( (*it)->mArticleWidget->article() &&
79  (*it)->mArticleWidget->article()->messageID()->as7BitString( false ) == mid ) {
80 #ifdef Q_OS_UNIX
81  KWindowSystem::activateWindow( (*it)->winId() );
82 #endif
83  return true;
84  }
85 
86  return false;
87 }
88 
89 
90 //==================================================================================
91 
92 ArticleWindow::ArticleWindow( KNArticle::Ptr art )
93  : KXmlGuiWindow( 0 )
94 {
95  setObjectName( "articleWindow" );
96  if ( knGlobals.componentData().isValid() )
97  setComponentData( knGlobals.componentData() );
98 
99  if ( art )
100  setCaption( art->subject()->asUnicodeString() );
101 
102  mArticleWidget = new ArticleWidget( this, this, actionCollection() );
103  mArticleWidget->setArticle( art );
104  setCentralWidget( mArticleWidget );
105 
106  mInstances.append( this );
107 
108  // file menu
109  KStandardAction::close( this, SLOT(close()), actionCollection() );
110 
111  // settings menu
112  KStandardAction::preferences(knGlobals.top, SLOT(slotSettings()), actionCollection());
113 
114  setupGUI( ToolBar|Keys|Create, "knreaderui.rc");
115 
116  resize(500,400); // default optimized for 800x600
117  applyMainWindowSettings(KConfigGroup( knGlobals.config(), "articleWindow_options") );
118 
119  // this will enable keyboard-only actions like that don't appear in any menu
120  actionCollection()->addAssociatedWidget( this );
121  foreach (QAction* action, actionCollection()->actions())
122  action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
123 }
124 
125 
126 ArticleWindow::~ArticleWindow()
127 {
128  mInstances.removeAll( this );
129  saveMainWindowSettings(knGlobals.config()->group( "articleWindow_options") );
130 }
131 
132 //--------------------------------
133 
134 #include "knarticlewindow.moc"
KNode::ArticleWindow::mArticleWidget
ArticleWidget * mArticleWidget
The article widget of this window.
Definition: knarticlewindow.h:73
utilities.h
articlewidget.h
knarticlewindow.h
KNode::ArticleWindow::~ArticleWindow
~ArticleWindow()
Destroy this article viewer window.
Definition: knarticlewindow.cpp:126
KXmlGuiWindow
knmainwidget.h
KNode::ArticleWindow::closeAllWindowsForArticle
static bool closeAllWindowsForArticle(KNArticle::Ptr art, bool force=true)
Clise all windows showing the given article.
Definition: knarticlewindow.cpp:48
KNode::ArticleWidget
Widget to display a news article.
Definition: articlewidget.h:47
knglobals.h
KNArticle::Ptr
boost::shared_ptr< KNArticle > Ptr
Shared pointer to a KNArticle. To be used instead of raw KNArticle*.
Definition: knarticle.h:39
KNode::ArticleWindow::mInstances
static List mInstances
List of all article windows.
Definition: knarticlewindow.h:75
KNode::ArticleWindow::closeAllWindowsForCollection
static bool closeAllWindowsForCollection(KNArticleCollection::Ptr col, bool force=true)
Close all article windows showing articles from the given collection.
Definition: knarticlewindow.cpp:34
KNArticleCollection::Ptr
boost::shared_ptr< KNArticleCollection > Ptr
Shared pointer to a KNArticle.
Definition: knarticlecollection.h:82
KNode::ArticleWindow::ArticleWindow
ArticleWindow(KNArticle::Ptr art)
Create a new article window.
Definition: knarticlewindow.cpp:92
knGlobals
#define knGlobals
Keep compatibility with the old way.
Definition: knglobals.h:28
QList
KNode::ArticleWindow::raiseWindowForArticle
static bool raiseWindowForArticle(KNArticle::Ptr art)
Raise the article window for the given article.
Definition: knarticlewindow.cpp:62
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal