summaryrefslogtreecommitdiffstats
path: root/knode/knarticlewindow.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /knode/knarticlewindow.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
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
Diffstat (limited to 'knode/knarticlewindow.cpp')
-rw-r--r--knode/knarticlewindow.cpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/knode/knarticlewindow.cpp b/knode/knarticlewindow.cpp
new file mode 100644
index 000000000..3e6898182
--- /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 <kwin.h>
+
+#include <kstdaction.h>
+#include <kconfig.h>
+#include <kaccel.h>
+#include <kaction.h>
+
+#include "knarticle.h"
+#include "articlewidget.h"
+#include "utilities.h"
+#include "knglobals.h"
+#include "knmainwidget.h"
+#include "knarticlewindow.h"
+
+using namespace KNode;
+
+QValueList<KNArticleWindow*> KNArticleWindow::mInstances;
+
+
+bool KNArticleWindow::closeAllWindowsForCollection( KNArticleCollection *col, bool force )
+{
+ QValueList<KNArticleWindow*> list = mInstances;
+ for ( QValueList<KNArticleWindow*>::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<KNArticleWindow*> list = mInstances;
+ for ( QValueList<KNArticleWindow*>::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<KNArticleWindow*>::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<KNArticleWindow*>::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"