UNNAMED_READER/corelibrary
readerWidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00056 connect(&fakeTimer, SIGNAL(timeout()), this, SLOT(fakeFinishedLoading()));
00057 fakeTimer.setSingleShot(true);
00058 fakeTimer.start(1000*(qrand()%5));
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 }
00165
00166 #include "readerWidget.moc"