• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

UNNAMED_READER/corelibrary

readerWidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Stefan Kebekus <kebekus@kde.org>                *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program; if not, write to the                         *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 
00020 #include "fullScreenWidget.h"
00021 #include "presentationWidget.h"
00022 #include "readerWidget.h"
00023 #include "ui_readerWidget.h"
00024 #include "UNNAMED_READER_debug.h"
00025 
00026 #include <kmessagebox.h>
00027 #include <kstandarddirs.h>
00028 
00029 namespace UNNAMED_READER {
00030 
00031 #define UNNAMED_READER_DEBUG 1
00032 
00033 
00034 readerWidget::readerWidget(QWidget *parent, KUrl url, bool *ok) 
00035   : QWidget(parent), dropObserver(this)
00036 {
00037   if (ok != 0)
00038     *ok = false;
00039 
00040   documentURL = url;
00041   documentURL.setRef(QString::null);
00042 
00043 #warning store and use the reference part of the url
00044 
00045   dlg = new Ui_readerWidget();
00046   dlg->setupUi(this);
00047 
00048 #warning TODO: open document
00049 
00050   goTo(url.ref());
00051 
00052   if (ok != 0)
00053     *ok = true;
00054 
00055   // Fake loading of the document
00056   connect(&fakeTimer, SIGNAL(timeout()), this, SLOT(fakeFinishedLoading()));
00057   fakeTimer.setSingleShot(true);
00058   fakeTimer.start(1000*(qrand()%5)); // simulate loading for some seconds
00059 
00060   return;
00061 }
00062 
00063  
00064 readerWidget::~readerWidget()
00065 {
00066 }
00067 
00068 
00069 QString readerWidget::documentTitle() const
00070 {
00071   kError(UNNAMED_READER_DEBUG, shell) << "readerWidget::documentTitle() is not implemented yet" << endl;
00072 
00073 #warning TODO: Implement this
00074 
00075   if (isFullyLoaded())
00076     return QString("A treatise of human understanding");
00077   else
00078     return QString::null;
00079 }
00080 
00081 
00082 QString readerWidget::humanReadableDocumentFileName() const
00083 {
00084   if (documentURL.isLocalFile() && documentURL.path().startsWith(KStandardDirs::locateLocal("tmp", QString::null))) 
00085     return i18n("Temporary File");
00086   if (documentURL.fileName().isEmpty())
00087     return documentURL.pathOrUrl();
00088   return documentURL.fileName();
00089 }
00090 
00091 
00092 bool readerWidget::askToClose(void)
00093 {
00094   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::askToClose()" << endl;
00095 
00096 #warning TODO: Ask if the document can be closed.
00097 
00098   deleteLater();
00099   return true;
00100 }
00101 
00102 
00103 void readerWidget::goTo(QString reference)
00104 {
00105   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::goTo(" << reference << ")" << endl;
00106 
00107   if (reference.isEmpty())
00108     return;
00109   
00110 #warning TODO: Check form of reference
00111   
00112 #warning TODO: Not implemented yet
00113   KMessageBox::error(this, i18n("<qt>UNNAMED reader cannot go to the reference <strong>%1</strong> "
00114                 "in the document %2, because this feature is not yet implemented.</qt>",
00115                 reference, documentURL.pathOrUrl()));
00116 }
00117   
00118 
00119 void readerWidget::reload()
00120 {
00121   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::reload()" << endl;
00122 
00123 #warning TODO: Not implemented yet
00124   KMessageBox::error(this, i18n("<qt>UNNAMED reader cannot reload the document %1, because this feature is not yet implemented.</qt>",
00125                 documentURL.pathOrUrl()));
00126 }
00127 
00128 
00129 void readerWidget::showFullScreen()
00130 {
00131   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::showFullScreen()" << endl;
00132   new fullScreenWidget(this);
00133 }
00134 
00135 
00136 void readerWidget::showPresentation()
00137 {
00138   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::showPresentation()" << endl;
00139   new presentationWidget(this);
00140 }
00141 
00142 
00143 readerWidget *readerWidget::duplicate()
00144 {
00145   kDebug(UNNAMED_READER_DEBUG, shell) << "readerWidget::duplicate()" << endl;
00146 
00147   bool ok;
00148   readerWidget *copy =  new readerWidget(parentWidget(), documentURL, &ok);
00149 
00150   if (ok == false) {
00151     delete copy;
00152     return 0;
00153   }
00154   
00155   return copy;  
00156 }
00157 
00158 void readerWidget::fakeFinishedLoading()
00159 {
00160   emit documentFullyLoaded(this);
00161 }
00162 
00163 
00164 } // end: namespace UNNAMED_READER
00165 
00166 #include "readerWidget.moc"

UNNAMED_READER/corelibrary

Skip menu "UNNAMED_READER/corelibrary"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  •   corelibrary
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal