BookmarkItem* ChromeImporter::importBookmarks() { const QByteArray data = m_file.readAll(); m_file.close(); QJsonParseError err; QJsonDocument json = QJsonDocument::fromJson(data, &err); const QVariant res = json.toVariant(); if (err.error != QJsonParseError::NoError || res.type() != QVariant::Map) { setError(BookmarksImporter::tr("Cannot parse JSON file!")); return 0; } QVariantMap rootMap = res.toMap().value("roots").toMap(); BookmarkItem* root = new BookmarkItem(BookmarkItem::Folder); root->setTitle("Chrome Import"); BookmarkItem* toolbar = new BookmarkItem(BookmarkItem::Folder, root); toolbar->setTitle(rootMap.value("bookmark_bar").toMap().value("name").toString()); readBookmarks(rootMap.value("bookmark_bar").toMap().value("children").toList(), toolbar); BookmarkItem* other = new BookmarkItem(BookmarkItem::Folder, root); other->setTitle(rootMap.value("other").toMap().value("name").toString()); readBookmarks(rootMap.value("other").toMap().value("children").toList(), other); BookmarkItem* synced = new BookmarkItem(BookmarkItem::Folder, root); synced->setTitle(rootMap.value("synced").toMap().value("name").toString()); readBookmarks(rootMap.value("synced").toMap().value("synced").toList(), other); return root; }
HelpBrowser::HelpBrowser( QWidget* parent, const QString& /*caption*/, const QString& guiLanguage, const QString& jumpToSection, const QString& jumpToFile) : QMainWindow( parent ) { firstRun=true; setupUi(this); helpNav = new HelpNavigation(this); #if defined(Q_OS_MAC) && defined(HELP_NAV_AS_DRAWER) // TODO #else QDockWidget * dckw = new QDockWidget(tr("Navigation"),this); dckw->setWidget(helpNav); addDockWidget(Qt::LeftDockWidgetArea, dckw); #endif progressBar = new QProgressBar(this); progressBar->setRange(0,100); statusBar()->addPermanentWidget(progressBar); setupLocalUI(); language = guiLanguage.isEmpty() ? QString("en") : guiLanguage.left(2); finalBaseDir = ScPaths::instance().docDir() + "en/"; //Sane default for help location textBrowser->setSearchPaths(QStringList(finalBaseDir)); menuModel=NULL; loadMenu(); if (menuModel!=NULL) { readBookmarks(); readHistory(); jumpToHelpSection(jumpToSection, jumpToFile ); languageChange(); } else { displayNoHelp(); } }
bool OleMainStream::open(bool doReadFormattingData) { if (OleStream::open() == false) { return false; } static const std::size_t HEADER_SIZE = 768; //size of data in header of main stream char headerBuffer[HEADER_SIZE]; seek(0, true); if (read(headerBuffer, HEADER_SIZE) != HEADER_SIZE) { return false; } bool result = readFIB(headerBuffer); if (!result) { return false; } // determining table stream number unsigned int tableNumber = (OleUtil::getU2Bytes(headerBuffer, 0xA) & 0x0200) ? 1 : 0; std::string tableName = tableNumber == 0 ? "0" : "1"; tableName += "Table"; OleEntry tableEntry; result = myStorage->getEntryByName(tableName, tableEntry); if (!result) { // cant't find table stream (that can be only in case if file format is below Word 7/8), so building simple table stream // TODO: CHECK may be not all old documents have ANSI ZLLogger::Instance().println("DocPlugin", "cant't find table stream, building own simple piece table, that includes all charachters"); Piece piece = {myStartOfText, myEndOfText - myStartOfText, true, Piece::PIECE_TEXT, 0}; myPieces.push_back(piece); return true; } result = readPieceTable(headerBuffer, tableEntry); if (!result) { ZLLogger::Instance().println("DocPlugin", "error during reading piece table"); return false; } if (!doReadFormattingData) { return true; } OleEntry dataEntry; if (myStorage->getEntryByName("Data", dataEntry)) { myDataStream = new OleStream(myStorage, dataEntry, myBaseStream); } //result of reading following structures doesn't check, because all these //problems can be ignored, and document can be showed anyway, maybe with wrong formatting readBookmarks(headerBuffer, tableEntry); readStylesheet(headerBuffer, tableEntry); //readSectionsInfoTable(headerBuffer, tableEntry); //it isn't used now readParagraphStyleTable(headerBuffer, tableEntry); readCharInfoTable(headerBuffer, tableEntry); readFloatingImages(headerBuffer, tableEntry); return true; }
void ChromeImporter::readBookmarks(const QVariantList &list, BookmarkItem* parent) { Q_ASSERT(parent); foreach (const QVariant &entry, list) { const QVariantMap map = entry.toMap(); const QString typeString = map.value("type").toString(); BookmarkItem::Type type; if (typeString == QLatin1String("url")) { type = BookmarkItem::Url; } else if (typeString == QLatin1String("folder")) { type = BookmarkItem::Folder; } else { continue; } BookmarkItem* item = new BookmarkItem(type, parent); item->setTitle(map.value("name").toString()); if (item->isUrl()) { item->setUrl(QUrl::fromEncoded(map.value("url").toByteArray())); } if (map.contains("children")) { readBookmarks(map.value("children").toList(), item); } } }
HelpBrowser::HelpBrowser( QWidget* parent, const QString& /*caption*/, const QString& guiLanguage, const QString& jumpToSection, const QString& jumpToFile) : QMainWindow( parent ) { firstRun=true; setupUi(this); setupLocalUI(); language = guiLanguage.isEmpty() ? QString("en") : guiLanguage.left(2); finalBaseDir = ScPaths::instance().docDir() + "en/"; //Sane default for help location menuModel=NULL; loadMenu(); if (menuModel!=NULL) { readBookmarks(); readHistory(); jumpToHelpSection(jumpToSection, jumpToFile ); languageChange(); } else { displayNoHelp(); } }
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() { readHistory(); readBookmarks(); browser = new QTextBrowser( this ); browser->mimeSourceFactory()->setFilePath( _path ); browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); setCentralWidget( browser ); if ( !home_.isEmpty() ) browser->setSource( home_ ); connect( browser, SIGNAL( highlighted( const QString&) ), statusBar(), SLOT( message( const QString&)) ); resize( 640,700 ); QPopupMenu* file = new QPopupMenu( this ); file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); // The same three icons are used twice each. QIconSet icon_back( QPixmap("textdrawing/previous.png") ); QIconSet icon_forward( QPixmap("textdrawing/next.png") ); QIconSet icon_home( QPixmap("textdrawing/home.png") ); QPopupMenu* go = new QPopupMenu( this ); backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); hist = new QPopupMenu( this ); QStringList::Iterator it = history.begin(); for ( ; it != history.end(); ++it ) mHistory[ hist->insertItem( *it ) ] = *it; connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); bookm = new QPopupMenu( this ); bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); bookm->insertSeparator(); QStringList::Iterator it2 = bookmarks.begin(); for ( ; it2 != bookmarks.end(); ++it2 ) mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; connect( bookm, SIGNAL( activated( int ) ), this, SLOT( bookmChosen( int ) ) ); menuBar()->insertItem( tr("&File"), file ); menuBar()->insertItem( tr("&Go"), go ); menuBar()->insertItem( tr( "History" ), hist ); menuBar()->insertItem( tr( "Bookmarks" ), bookm ); menuBar()->setItemEnabled( forwardId, FALSE); menuBar()->setItemEnabled( backwardId, FALSE); connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); QToolBar* toolbar = new QToolBar( this ); addToolBar( toolbar, "Toolbar"); QToolButton* button; button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); toolbar->addSeparator(); pathCombo = new QComboBox( TRUE, toolbar ); connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); toolbar->setStretchableWidget( pathCombo ); setRightJustification( TRUE ); setDockEnabled( DockLeft, FALSE ); setDockEnabled( DockRight, FALSE ); pathCombo->insertItem( home_ ); browser->setFocus(); }
FLHelpWindow::FLHelpWindow(const QString &home_, const QString &_path, QWidget *parent, const char *name) : QMainWindow(parent, name, WDestructiveClose), pathCombo(0), selectedURL() { readHistory(); readBookmarks(); browser = new QTextBrowser(this); browser->mimeSourceFactory() ->setFilePath(_path); browser->setFrameStyle(QFrame::Panel | QFrame::Sunken); connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged())); setCentralWidget(browser); if (!home_.isEmpty()) browser->setSource(home_); connect(browser, SIGNAL(highlighted(const QString &)), statusBar(), SLOT(message(const QString &))); resize(640, 700); QPopupMenu *file = new QPopupMenu(this); file->insertItem(tr("&Imprimir"), this, SLOT(print()), CTRL + Key_I); file->insertSeparator(); file->insertItem(tr("&Cerrar"), this, SLOT(close()), Key_Escape); // The same three icons are used twice each. QIconSet icon_back(QPixmap::fromMimeSource("previous.png")); QIconSet icon_forward(QPixmap::fromMimeSource("next.png")); QIconSet icon_home(QPixmap::fromMimeSource("home.png")); QPopupMenu *go = new QPopupMenu(this); backwardId = go->insertItem(icon_back, tr("&Atrás"), browser, SLOT(backward()), CTRL + Key_Left); forwardId = go->insertItem(icon_forward, tr("&Adelante"), browser, SLOT(forward()), CTRL + Key_Right); go->insertItem(icon_home, tr("&Inicio"), browser, SLOT(home())); QPopupMenu *help = new QPopupMenu(this); help->insertItem(tr("&Acerca ..."), this, SLOT(about())); help->insertItem(tr("Acerca de &Qt ..."), this, SLOT(aboutQt())); hist = new QPopupMenu(this); QStringList::Iterator it = history.begin(); for (; it != history.end(); ++it) mHistory[ hist->insertItem(*it)] = *it; connect(hist, SIGNAL(activated(int)), this, SLOT(histChosen(int))); bookm = new QPopupMenu(this); bookm->insertItem(tr("Agregar Favorito"), this, SLOT(addBookmark())); bookm->insertSeparator(); QStringList::Iterator it2 = bookmarks.begin(); for (; it2 != bookmarks.end(); ++it2) mBookmarks[ bookm->insertItem(*it2)] = *it2; connect(bookm, SIGNAL(activated(int)), this, SLOT(bookmChosen(int))); menuBar() ->insertItem(tr("&Archivo"), file); menuBar() ->insertItem(tr("&Ir"), go); menuBar() ->insertItem(tr("Historial"), hist); menuBar() ->insertItem(tr("Favoritos"), bookm); menuBar() ->insertSeparator(); menuBar() ->insertItem(tr("&Ayuda"), help); menuBar() ->setItemEnabled(forwardId, FALSE); menuBar() ->setItemEnabled(backwardId, FALSE); connect(browser, SIGNAL(backwardAvailable(bool)), this, SLOT(setBackwardAvailable(bool))); connect(browser, SIGNAL(forwardAvailable(bool)), this, SLOT(setForwardAvailable(bool))); QToolBar *toolbar = new QToolBar(this); addToolBar(toolbar, "Toolbar"); QToolButton *button; button = new QToolButton(icon_back, tr("Atrás"), "", browser, SLOT(backward()), toolbar); connect(browser, SIGNAL(backwardAvailable(bool)), button, SLOT(setEnabled(bool))); button->setEnabled(FALSE); button = new QToolButton(icon_forward, tr("Adelante"), "", browser, SLOT(forward()), toolbar); connect(browser, SIGNAL(forwardAvailable(bool)), button, SLOT(setEnabled(bool))); button->setEnabled(FALSE); button = new QToolButton(icon_home, tr("Inicio"), "", browser, SLOT(home()), toolbar); toolbar->addSeparator(); pathCombo = new QComboBox(TRUE, toolbar); connect(pathCombo, SIGNAL(activated(const QString &)), this, SLOT(pathSelected(const QString &))); toolbar->setStretchableWidget(pathCombo); setRightJustification(TRUE); setDockEnabled(DockLeft, FALSE); setDockEnabled(DockRight, FALSE); pathCombo->insertItem(home_); browser->setFocus(); }
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() { readHistory(); readBookmarks(); browser = new QTextBrowser( this ); QStringList Strlist; Strlist.append( home_); browser->mimeSourceFactory()->setFilePath( Strlist ); browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); setCentralWidget( browser ); if ( !home_.isEmpty() ) //////////////////////////////// browser->setSource( home_ ); //////////////////////////////// connect( browser, SIGNAL( highlighted(const QString&) ), statusBar(), SLOT( message(const QString&)) ); setGeometry( 0,0,236,280); QPopupMenu* file = new QPopupMenu( this ); // file->insertItem( tr("&New Window"), this, SLOT( newWindow() ), ALT | Key_N ); file->insertItem( tr("&Open File"), this, SLOT( openFile() ), ALT | Key_O ); // file->insertItem( tr("&Print"), this, SLOT( print() ), ALT | Key_P ); file->insertSeparator(); file->insertItem( tr("&Close"), this, SLOT( close() ), ALT | Key_Q ); // file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), ALT | Key_X ); // The same three icons are used twice each. ////F FIXME QString pixs=(QDir::homeDirPath ()) +"/Applications/gutenbrowser/pix/"; QIconSet icon_back( QPixmap(pixs+"back.png") ); QIconSet icon_forward( QPixmap(pixs+"forward.png") ); QIconSet icon_home( QPixmap(pixs+"home.png") ); QPopupMenu* go = new QPopupMenu( this ); backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), ALT | Key_Left ); forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), ALT | Key_Right ); go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); hist = new QPopupMenu( this ); QStringList::Iterator it = history.begin(); for ( ; it != history.end(); ++it ) mHistory[ hist->insertItem( *it ) ] = *it; connect( hist, SIGNAL( activated(int) ), this, SLOT( histChosen(int) ) ); bookm = new QPopupMenu( this ); bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); bookm->insertSeparator(); QStringList::Iterator it2 = bookmarks.begin(); for ( ; it2 != bookmarks.end(); ++it2 ) mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; connect( bookm, SIGNAL( activated(int) ), this, SLOT( bookmChosen(int) ) ); menuBar()->insertItem( tr("&File"), file ); menuBar()->insertItem( tr("&Go"), go ); menuBar()->insertItem( tr( "History" ), hist ); menuBar()->insertItem( tr( "Bookmarks" ), bookm ); // menuBar()->insertSeparator(); // menuBar()->insertItem( tr("&Help"), help ); menuBar()->setItemEnabled( forwardId, FALSE); menuBar()->setItemEnabled( backwardId, FALSE); connect( browser, SIGNAL( backwardAvailable(bool) ), this, SLOT( setBackwardAvailable(bool) ) ); connect( browser, SIGNAL( forwardAvailable(bool) ), this, SLOT( setForwardAvailable(bool) ) ); QToolBar* toolbar = new QToolBar( this ); addToolBar( toolbar, "Toolbar"); QToolButton* button; button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); toolbar->addSeparator(); pathCombo = new QComboBox( TRUE, toolbar ); connect( pathCombo, SIGNAL( activated(const QString&) ), this, SLOT( pathSelected(const QString&) ) ); toolbar->setStretchableWidget( pathCombo ); // pathCombo->setMaximumWidth(190); // setRightJustification( TRUE ); // setDockEnabled( Left, FALSE ); // setDockEnabled( Right, FALSE ); pathCombo->insertItem( home_ ); browser->setFocus(); }
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name) : Q3MainWindow( parent, name, Qt::WDestructiveClose ), pathCombo( 0 ), selectedURL() { DigitDebug::ctor(QString("helpwindow " + QString::number((ulong) this, 16))); readHistory(); readBookmarks(); browser = new Q3TextBrowser( this ); CHECK_PTR_ENGAUGE(browser); browser->mimeSourceFactory()->setFilePath( _path ); browser->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken ); connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); setCentralWidget( browser ); if ( !home_.isEmpty() ) browser->setSource( home_ ); connect( browser, SIGNAL( highlighted( const QString&) ), statusBar(), SLOT( message( const QString&)) ); // display help window in previous position with same size DefaultSettings& rSettings = DefaultSettings::instance(); move(rSettings.getWindowHelpPosition()); resize(rSettings.getWindowHelpSize()); QMenu* file = new QMenu( this ); CHECK_PTR_ENGAUGE(file); file->insertItem( tr("&Open File"), this, SLOT( openFile() ), Qt::CTRL+Qt::Key_O ); file->insertItem( tr("&Print"), this, SLOT( print() ), Qt::CTRL+Qt::Key_P ); file->insertSeparator(); file->insertItem( tr("&Close"), this, SLOT( close() ), Qt::CTRL+Qt::Key_Q ); //file->insertItem( tr("E&xit"), qApp, SLOT( closeAllWindows() ), Qt::CTRL+Qt::Key_X ); // The same three icons are used twice each. QPixmap helpback (helpback_xpm); QPixmap helpforward (helpforward_xpm); QPixmap helphome (helphome_xpm); QIcon icon_back (helpback); QIcon icon_forward (helpforward); QIcon icon_home (helphome); QMenu* go = new QMenu( this ); CHECK_PTR_ENGAUGE(go); backwardId = go->insertItem( icon_back, tr("&Backward"), browser, SLOT( backward() ), Qt::CTRL+Qt::Key_Left ); forwardId = go->insertItem( icon_forward, tr("&Forward"), browser, SLOT( forward() ), Qt::CTRL+Qt::Key_Right ); go->insertItem( icon_home, tr("&Home"), browser, SLOT( home() ) ); hist = new QMenu( this ); CHECK_PTR_ENGAUGE(hist); QStringList::Iterator it = history.begin(); for ( ; it != history.end(); ++it ) mHistory[ hist->insertItem( *it ) ] = *it; connect( hist, SIGNAL( activated( int ) ), this, SLOT( histChosen( int ) ) ); bookm = new QMenu( this ); CHECK_PTR_ENGAUGE(bookm); bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); bookm->insertSeparator(); QStringList::Iterator it2 = bookmarks.begin(); for ( ; it2 != bookmarks.end(); ++it2 ) mBookmarks[ bookm->insertItem( *it2 ) ] = *it2; connect( bookm, SIGNAL( activated( int ) ), this, SLOT( bookmChosen( int ) ) ); menuBar()->insertItem( tr("&File"), file ); menuBar()->insertItem( tr("&Go"), go ); menuBar()->insertItem( tr( "History" ), hist ); menuBar()->insertItem( tr( "Bookmarks" ), bookm ); menuBar()->setItemEnabled( forwardId, FALSE); menuBar()->setItemEnabled( backwardId, FALSE); connect( browser, SIGNAL( backwardAvailable( bool ) ), this, SLOT( setBackwardAvailable( bool ) ) ); connect( browser, SIGNAL( forwardAvailable( bool ) ), this, SLOT( setForwardAvailable( bool ) ) ); Q3ToolBar* toolbar = new Q3ToolBar( this ); CHECK_PTR_ENGAUGE(toolbar); addToolBar( toolbar, "Toolbar"); QToolButton* button; button = new QToolButton( icon_back, tr("Backward"), "", browser, SLOT(backward()), toolbar ); CHECK_PTR_ENGAUGE(button); connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); button = new QToolButton( icon_forward, tr("Forward"), "", browser, SLOT(forward()), toolbar ); CHECK_PTR_ENGAUGE(button); connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); button->setEnabled( FALSE ); button = new QToolButton( icon_home, tr("Home"), "", browser, SLOT(home()), toolbar ); CHECK_PTR_ENGAUGE(button); toolbar->addSeparator(); pathCombo = new QComboBox( TRUE, toolbar ); CHECK_PTR_ENGAUGE(pathCombo); connect( pathCombo, SIGNAL( activated( const QString & ) ), this, SLOT( pathSelected( const QString & ) ) ); toolbar->setStretchableWidget( pathCombo ); setRightJustification( TRUE ); setDockEnabled( Qt::DockLeft, FALSE ); setDockEnabled( Qt::DockRight, FALSE ); pathCombo->insertItem( home_ ); browser->setFocus(); }