From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- knode/knarticlewindow.cpp | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 knode/knarticlewindow.cpp (limited to 'knode/knarticlewindow.cpp') diff --git a/knode/knarticlewindow.cpp b/knode/knarticlewindow.cpp new file mode 100644 index 00000000..3e689818 --- /dev/null +++ b/knode/knarticlewindow.cpp @@ -0,0 +1,131 @@ +// -*- c-basic-offset: 2 -*- +/* + KNode, the KDE newsreader + Copyright (c) 1999-2005 the KNode authors. + See file AUTHORS for details + + 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. + 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, US +*/ + +#include + +#include +#include +#include +#include + +#include "knarticle.h" +#include "articlewidget.h" +#include "utilities.h" +#include "knglobals.h" +#include "knmainwidget.h" +#include "knarticlewindow.h" + +using namespace KNode; + +QValueList KNArticleWindow::mInstances; + + +bool KNArticleWindow::closeAllWindowsForCollection( KNArticleCollection *col, bool force ) +{ + QValueList list = mInstances; + for ( QValueList::Iterator it = list.begin(); it != list.end(); ++it ) + if ( (*it)->artW->article() && (*it)->artW->article()->collection() == col ) { + if ( force ) + (*it)->close(); + else + return false; + } + return true; +} + + +bool KNArticleWindow::closeAllWindowsForArticle( KNArticle *art, bool force ) +{ + QValueList list = mInstances; + for ( QValueList::Iterator it = list.begin(); it != list.end(); ++it ) + if ( (*it)->artW->article() && (*it)->artW->article() == art ) { + if ( force ) + (*it)->close(); + else + return false; + } + return true; +} + + +bool KNArticleWindow::raiseWindowForArticle( KNArticle *art ) +{ + for ( QValueList::Iterator it = mInstances.begin(); it != mInstances.end(); ++it ) + if ( (*it)->artW->article() && (*it)->artW->article() == art ) { + KWin::activateWindow( (*it)->winId() ); + return true; + } + return false; +} + + +bool KNArticleWindow::raiseWindowForArticle(const QCString &mid) +{ + for ( QValueList::Iterator it = mInstances.begin(); it != mInstances.end(); ++it ) + if ( (*it)->artW->article() && (*it)->artW->article()->messageID()->as7BitString( false ) == mid ) { + KWin::activateWindow( (*it)->winId() ); + return true; + } + + return false; +} + + +//================================================================================== + +KNArticleWindow::KNArticleWindow(KNArticle *art) + : KMainWindow(0, "articleWindow") +{ + if(knGlobals.instance) + setInstance(knGlobals.instance); + + if(art) + setCaption(art->subject()->asUnicodeString()); + + artW = new ArticleWidget( this, this, actionCollection() ); + artW->setArticle(art); + setCentralWidget(artW); + + mInstances.append( this ); + + // file menu + KStdAction::close( this, SLOT(close()), actionCollection() ); + + // settings menu + KStdAction::preferences(knGlobals.top, SLOT(slotSettings()), actionCollection()); + + KAccel *accel = new KAccel( this ); + artW->setCharsetKeyboardAction()->plugAccel( accel ); + + setupGUI( ToolBar|Keys|Create, "knreaderui.rc"); + + KConfig *conf = knGlobals.config(); + conf->setGroup("articleWindow_options"); + resize(500,400); // default optimized for 800x600 + applyMainWindowSettings(conf); +} + + +KNArticleWindow::~KNArticleWindow() +{ + mInstances.remove( this ); + KConfig *conf = knGlobals.config(); + conf->setGroup("articleWindow_options"); + saveMainWindowSettings(conf); +} + +//-------------------------------- + +#include "knarticlewindow.moc" -- cgit v1.2.3