Esempio n. 1
0
void BookmarksContextMenu::addSeparatorActions()
{
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));

    addSeparator();

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
}
Esempio n. 2
0
void BookmarksContextMenu::addNullActions()
{
    KBookmarkManager *mngr = manager();
    if (mngr->toolbar().hasParent())
    {
        addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
    }
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));
}
Esempio n. 3
0
void StartPageModel::thumbnailCreated(const QUrl &url, const QPixmap &thumbnail, const QString &title)
{
	if (!m_reloads.contains(url))
	{
		return;
	}

	if (!thumbnail.isNull())
	{
		const QString path(SessionsManager::getWritableDataPath(QLatin1String("thumbnails/")));

		QDir().mkpath(path);

		thumbnail.save(path + QString::number(m_reloads[url].first) + QLatin1String(".png"), "png");
	}

	BookmarksItem *bookmark(BookmarksManager::getModel()->getBookmark(m_reloads[url].first));

	if (bookmark)
	{
		if (m_reloads[url].second)
		{
			bookmark->setData(title, BookmarksModel::TitleRole);
		}

		emit isReloadingTileChanged(index(bookmark->index().row(), bookmark->index().column()));
	}

	m_reloads.remove(url);
}
Esempio n. 4
0
void App::onInit() {
    GApp::onInit();
    // Called before the application loop begins.  Load data here and
    // not in the constructor so that common exceptions will be
    // automatically caught.

    showRenderingStats    = false;
    m_showLightSources    = true;
    m_showAxes            = true;
    m_showWireframe       = false;
    m_preventEntityDrag   = false;
    m_preventEntitySelect = false;

    // For higher-quality screenshots:
    // developerWindow->videoRecordDialog->setScreenShotFormat("PNG");
    // developerWindow->videoRecordDialog->setCaptureGui(false);

    makeGUI();

    // Start wherever the developer HUD last marked as "Home"
    defaultCamera.setCoordinateFrame(bookmark("Home"));

    m_shadowMap = ShadowMap::create();

    loadScene();
}
Esempio n. 5
0
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV
FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
  if (!pDict)
    return nullptr;

  CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict));
  return FPDFActionFromCPDFDictionary(bookmark.GetAction().GetDict());
}
Esempio n. 6
0
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict, void* buffer, unsigned long buflen) {
  if (!pDict)
    return 0;
  CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict));
  WideString title = bookmark.GetTitle();
  return Utf16EncodeMaybeCopyAndReturnLength(title, buffer, buflen);
}
Esempio n. 7
0
FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK pDict) {
  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
  if (!pDoc)
    return nullptr;
  CPDF_BookmarkTree tree(pDoc);
  CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict));
  return FPDFBookmarkFromCPDFDictionary(tree.GetFirstChild(bookmark).GetDict());
}
Esempio n. 8
0
void NotesContentsWidget::openUrl(const QModelIndex &index)
{
	BookmarksItem *bookmark(NotesManager::getModel()->getBookmark(index.isValid() ? index : m_ui->notesViewWidget->currentIndex()));
	WindowsManager *manager(SessionsManager::getWindowsManager());

	if (bookmark && bookmark->data(BookmarksModel::UrlRole).toUrl().isValid() && manager)
	{
		manager->open(bookmark);
	}
}
Esempio n. 9
0
void BookmarksContextMenu::addActions()
{
    if (bookmark().isNull() || m_nullForced)
    {
        addNullActions();
    }
    else if (bookmark().isSeparator())
    {
        addSeparatorActions();
    }
    else if (bookmark().isGroup())
    {
        addFolderActions();
    }
    else
    {
        addBookmarkActions();
    }
}
void BookmarksContentsWidget::bookmarkProperties()
{
	BookmarksItem *bookmark(BookmarksManager::getModel()->getBookmark(m_ui->bookmarksViewWidget->currentIndex()));

	if (bookmark)
	{
		BookmarkPropertiesDialog dialog(bookmark, this);
		dialog.exec();

		updateActions();
	}
}
void BookmarksContentsWidget::openBookmark(const QModelIndex &index)
{
	BookmarksItem *bookmark(BookmarksManager::getModel()->getBookmark(index.isValid() ? index : m_ui->bookmarksViewWidget->currentIndex()));
	WindowsManager *manager(SessionsManager::getWindowsManager());

	if (bookmark && manager)
	{
		QAction *action(qobject_cast<QAction*>(sender()));

		manager->open(bookmark, (action ? static_cast<WindowsManager::OpenHints>(action->data().toInt()) : WindowsManager::DefaultOpen));
	}
}
Esempio n. 12
0
void ZhscWidget::clearBookmark()
{
  if ( bConStatus )
  {
    QString sq = "select * from bookmark";
    QSqlQuery query( sq );

    sq = "delete from bookmark";
    query.exec( sq );

    bookmark();
  }
}
Esempio n. 13
0
void BookmarksContextMenu::addFolderActions()
{
    KBookmarkGroup group = bookmark().toGroup();

    if (bookmark().internalElement().attributeNode("toolbar").value() == "yes")
    {
        addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
    }
    else
    {
        addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER));
    }

    if (!group.first().isNull())
    {
        KBookmark child = group.first();

        while (child.isGroup() || child.isSeparator())
        {
            child = group.next(child);
        }

        if (!child.isNull())
        {
            addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER));
            addSeparator();
        }
    }

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));

    addSeparator();

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
}
Esempio n. 14
0
DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK pDict,
        void* buffer,
        unsigned long buflen) {
    if (!pDict)
        return 0;
    CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
    CFX_WideString title = bookmark.GetTitle();
    CFX_ByteString encodedTitle = title.UTF16LE_Encode();
    unsigned long len = encodedTitle.GetLength();
    if (buffer && buflen >= len) {
        FXSYS_memcpy(buffer, encodedTitle.c_str(), len);
    }
    return len;
}
Esempio n. 15
0
    Solid::Device FilePlacesItem::device() const
    {
        if (m_device.udi().isEmpty()) {
            m_device = Solid::Device(bookmark().metaDataItem("UDI"));
            if (m_device.isValid()) {
                m_access = m_device.as<Solid::StorageAccess>();
                m_volume = m_device.as<Solid::StorageVolume>();
                m_disc = m_device.as<Solid::OpticalDisc>();
            } else {
                m_access = 0;
                m_volume = 0;
                m_disc = 0;
            }
        }

        return m_device;
    }
Esempio n. 16
0
BookmarksItem* NotesManager::addNote(BookmarksModel::BookmarkType type, const QUrl &url, const QString &title, BookmarksItem *parent)
{
	if (!m_model)
	{
		getModel();
	}

	BookmarksItem *bookmark(m_model->addBookmark(type, 0, url, title, parent));

	if (bookmark)
	{
		bookmark->setData(QDateTime::currentDateTime(), BookmarksModel::TimeAddedRole);
		bookmark->setData(QDateTime::currentDateTime(), BookmarksModel::TimeModifiedRole);
	}

	return bookmark;
}
Esempio n. 17
0
void BookmarksContextMenu::addBookmarkActions()
{
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_TAB));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_WINDOW));

    addSeparator();

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER));
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR));

    addSeparator();

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::COPY));

    addSeparator();

    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT));
#ifdef HAVE_NEPOMUK
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::FANCYBOOKMARK));
#endif
    addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE));
}
Esempio n. 18
0
DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
                                                 FPDF_BOOKMARK pDict) {
  if (!pDict)
    return nullptr;
  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
  if (!pDoc)
    return nullptr;
  CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
  CPDF_Dest dest = bookmark.GetDest(pDoc);
  if (dest.GetObject())
    return dest.GetObject();
  // If this bookmark is not directly associated with a dest, we try to get
  // action
  CPDF_Action action = bookmark.GetAction();
  if (!action.GetDict())
    return nullptr;
  return action.GetDest(pDoc).GetObject();
}
Esempio n. 19
0
DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
        FPDF_BOOKMARK pDict) {
    if (!document)
        return NULL;
    if (!pDict)
        return NULL;
    CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
    CPDF_Document* pDoc = (CPDF_Document*)document;
    CPDF_Dest dest = bookmark.GetDest(pDoc);
    if (dest)
        return dest.GetObject();
    // If this bookmark is not directly associated with a dest, we try to get
    // action
    CPDF_Action action = bookmark.GetAction();
    if (!action)
        return NULL;
    return action.GetDest(pDoc).GetObject();
}
Esempio n. 20
0
void BookmarksManager::updateVisits(const QUrl &url)
{
	ensureInitialized();

	if (m_model->hasBookmark(url))
	{
		const QVector<BookmarksModel::Bookmark*> bookmarks(m_model->getBookmarks(url));

		for (int i = 0; i < bookmarks.count(); ++i)
		{
			BookmarksModel::Bookmark *bookmark(bookmarks.at(i));
			bookmark->setData((bookmark->getVisits() + 1), BookmarksModel::VisitsRole);
			bookmark->setData(QDateTime::currentDateTimeUtc(), BookmarksModel::TimeVisitedRole);
		}

		m_instance->scheduleSave();
	}
}
Esempio n. 21
0
void ZhscWidget::addBookmark()
{
  bool bSign = FALSE;

  if ( bConStatus )
  {
    QString sq = "select dynastyno, poetno, poemno from bookmark where dynastyno = '" + smDynasty[nDynasty] + "' and poetno = '" + smPoet[nPoet] + "' and poemno = '" + smPoem[nPoem] + "'";
    QSqlQuery query( sq );

    if ( query.size() > 0 )
    {
      if ( query.next() )
      {
        if ( ( query.value(0).toString() == smDynasty[nDynasty] ) 
          && ( query.value(1).toString() == smPoet[nPoet] )
          && ( query.value(2).toString() == smPoem[nPoem] ) )
        {
          bSign = FALSE;
        }
        else
        {
          bSign = TRUE;
        }
      }
    }
    else
    {
      bSign = TRUE;
    }

    if ( bSign )
    {
      QSqlCursor cur( "bookmark" ); 
      QSqlRecord *buffer = cur.primeInsert();
      buffer->setValue( "dynastyno", smDynasty[nDynasty] );
      buffer->setValue( "poetno", smPoet[nPoet] );
      buffer->setValue( "poemno", smPoem[nPoem] );
      cur.insert();

      bookmark();
    }
  }
}
Esempio n. 22
0
void ZhscWidget::init()
{
  if ( bConStatus ) 
  {
    loadHistory();

    buildCBDynasty();
    buildCBPoet();
    buildCBPoem();
    buildTEPoet();
    buildTEPoem();

    setPoem();

    record();

    bookmark();
  }
}
Esempio n. 23
0
void ZhscWidget::modifyBookmark()
{
  BookmarkList dbml;
  BookmarkList b;
  dbml.clear();

  Bookmark bm;
  BookmarkList::Iterator it;

  BMDialog *dlg = new BMDialog( this, "bmdialog" );
  dlg->setBML( bml );

  if ( dlg->exec() == QDialog::Accepted ) 
  {
    b = dlg->deletedBML();
    for ( it = b.begin(); it != b.end(); ++it )
    {
      bm.dynastyno = (*it).dynastyno;
      bm.poetno = (*it).poetno;
      bm.poemno = (*it).poemno;
      bm.content = (*it).content;

      dbml.append( bm );
    }

    if ( bConStatus )
    {
      QString sq = "select * from bookmark";
      QSqlQuery query( sq );

      for ( it = dbml.begin(); it != dbml.end(); ++it )
      {
        sq = "delete from bookmark where dynastyno = '" + (*it).dynastyno + "' and poetno = '" + (*it).poetno + "' and poemno = '" + (*it).poemno + "'";
        query.exec( sq );
      }
    }

    bookmark();
  }

  delete dlg;
}
Esempio n. 24
0
FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFBookmark_GetDest(FPDF_DOCUMENT document,
                                                         FPDF_BOOKMARK pDict) {
  CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
  if (!pDoc)
    return nullptr;

  if (!pDict)
    return nullptr;

  CPDF_Bookmark bookmark(CPDFDictionaryFromFPDFBookmark(pDict));
  CPDF_Dest dest = bookmark.GetDest(pDoc);
  if (dest.GetArray())
    return FPDFDestFromCPDFArray(dest.GetArray());
  // If this bookmark is not directly associated with a dest, we try to get
  // action
  CPDF_Action action = bookmark.GetAction();
  if (!action.GetDict())
    return nullptr;
  return FPDFDestFromCPDFArray(action.GetDest(pDoc).GetArray());
}
Esempio n. 25
0
void App::onInit() {
    // Called before the application loop beings.  Load data here and
    // not in the constructor so that common exceptions will be
    // automatically caught.

    // Turn on the developer HUD
    debugWindow->setVisible(true);
    developerWindow->cameraControlWindow->setVisible(true);
    developerWindow->videoRecordDialog->setEnabled(true);
    showRenderingStats = true;

    sky = Sky::fromFile(System::findDataFile("sky"));

    skyParameters = SkyParameters(G3D::toSeconds(11, 00, 00, AM));
    lighting = Lighting::fromSky(sky, skyParameters, Color3::white());

    // This simple demo has no shadowing, so make all lights unshadowed
    lighting->lightArray.append(lighting->shadowedLightArray);
    lighting->shadowedLightArray.clear();

    /////////////////////////////////////////////////////////////
    // Example of how to add debugging controls
    debugPane->addButton("Exit", this, &App::endProgram);
    
    // More examples of debugging GUI controls:
    // debugPane->addCheckBox("Use explicit checking", &explicitCheck);
    // debugPane->addTextBox("Name", &myName);
    // debugPane->addNumberBox("height", &height, "m", GuiTheme::LINEAR_SLIDER, 1.0f, 2.5f);
    // button = debugPane->addButton("Run Simulator");

    // Start wherever the developer HUD last marked as "Home"
    defaultCamera.setCoordinateFrame(bookmark("Home"));

    
    //GuiTheme::makeThemeFromSourceFiles(pathConcat(dataDir, "skin"), "osx_white.png", "osx_black.png", "osx.txt", pathConcat(dataDir, "osx_new.gtm"));

    //GuiTheme::Ref theme = GuiTheme::fromFile("osx_new.gtm");
    

    //model = MD3Model::fromDirectory("C:\\dev\\data\\md3\\chaos-marine\\models\\players\\Chaos-Marine");
}
Esempio n. 26
0
///Constructor
HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone)
   : QWidget(parent), m_pItemCall(0),m_pMenu(0),m_pAudioSlider(0),m_pTimeLeftL(0),m_pTimePlayedL(0),m_pPlayer(0),m_pContact(0)
{
   setContextMenuPolicy(Qt::CustomContextMenu);

   m_pCallAgain    = new KAction(this);
   m_pAddContact   = new KAction(this);
   m_pCopy         = new KAction(this);
   m_pEmail        = new KAction(this);
   m_pAddToContact = new KAction(this);
   m_pBookmark     = new KAction(this);

   m_pCallAgain->setShortcut    ( Qt::Key_Enter       );
   m_pCallAgain->setText        ( i18n("Call Again")             );
   m_pCallAgain->setIcon        ( KIcon(ICON_DIALING)            );

   m_pAddToContact->setShortcut ( Qt::CTRL + Qt::Key_E           );
   m_pAddToContact->setText     ( i18n("Add Number to Contact")  );
   m_pAddToContact->setIcon     ( KIcon("list-resource-add")     );
   m_pAddToContact->setDisabled ( true                           );

   m_pAddContact->setShortcut   ( Qt::CTRL + Qt::Key_E           );
   m_pAddContact->setText       ( i18n("Add Contact")            );
   m_pAddContact->setIcon       ( KIcon("contact-new")           );

   m_pCopy->setShortcut         ( Qt::CTRL + Qt::Key_C           );
   m_pCopy->setText             ( i18n("Copy")                   );
   m_pCopy->setIcon             ( KIcon("edit-copy")             );
   m_pCopy->setDisabled         ( true                           );

   m_pEmail->setShortcut        ( Qt::CTRL + Qt::Key_M           );
   m_pEmail->setText            ( i18n("Send Email")             );
   m_pEmail->setIcon            ( KIcon("mail-message-new")      );
   m_pEmail->setDisabled        ( true                           );

   m_pBookmark->setShortcut     ( Qt::CTRL + Qt::Key_D           );
   m_pBookmark->setText         ( i18n("Bookmark")               );
   m_pBookmark->setIcon         ( KIcon("bookmarks")             );

   m_pPlay = new QToolButton(this);

   m_pPlay->setIcon(KIcon("media-playback-start"));
   m_pPlay->setMinimumSize(30,30);
   m_pPlay->setMaximumSize(30,30);
   m_pPlay->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
   m_pPlay->setVisible(false);

   m_pRemove =  new QToolButton(this);
   m_pRemove->setIcon(KIcon("list-remove"));
   m_pRemove->setMinimumSize(30,30);
   m_pRemove->setMaximumSize(30,30);
   m_pRemove->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
   m_pRemove->setVisible(false);

   connect(m_pCallAgain    , SIGNAL(triggered())                        , this , SLOT(callAgain()         ));
   connect(m_pAddContact   , SIGNAL(triggered())                        , this , SLOT(addContact()        ));
   connect(m_pCopy         , SIGNAL(triggered())                        , this , SLOT(copy()              ));
   connect(m_pEmail        , SIGNAL(triggered())                        , this , SLOT(sendEmail()         ));
   connect(m_pAddToContact , SIGNAL(triggered())                        , this , SLOT(addToContact()      ));
   connect(m_pBookmark     , SIGNAL(triggered())                        , this , SLOT(bookmark()          ));
   connect(m_pPlay         , SIGNAL(clicked()  )                        , this , SLOT(showRecordPlayer()  ));
   connect(m_pRemove       , SIGNAL(clicked()  )                        , this , SLOT(removeRecording()   ));
   connect(this            , SIGNAL(customContextMenuRequested(QPoint)) , this , SLOT(showContext(QPoint) ));

   m_pIconL         = new QLabel( this );
   m_pPeerNameL     = new QLabel( this );
   m_pCallNumberL   = new QLabel( this );
   m_pLengthL     = new QLabel( this );
   m_pTimeL         = new QLabel( this );

   m_pIconL->setMinimumSize(70,0);
   m_pIconL->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::MinimumExpanding);
   QSpacerItem* verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);

   m_pMainLayout = new QGridLayout(this);
   m_pMainLayout->addWidget ( m_pIconL       , 0 , 0 , 4 , 1 );
   m_pMainLayout->addWidget ( m_pPeerNameL   , 0 , 1         );
   m_pMainLayout->addWidget ( m_pCallNumberL , 1 , 1         );
   m_pMainLayout->addWidget ( m_pTimeL       , 2 , 1         );
   m_pMainLayout->addItem   ( verticalSpacer , 4 , 1         );
   m_pMainLayout->addWidget ( m_pPlay        , 0 , 2 , 4 , 1 );
   m_pMainLayout->addWidget ( m_pRemove      , 0 , 3 , 4 , 1 );
   m_pMainLayout->addWidget ( m_pLengthL   , 0 , 4 , 4 , 1 );
   setLayout(m_pMainLayout);
   setMinimumSize(QSize(50, 30));
   setMaximumSize(QSize(300,99999));
   setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));

   if (!phone.isEmpty()) {
      getContactInfo(phone);
      m_pCallNumberL->setText(phone);
      m_PhoneNumber = phone;
   }
}
bool OperaBookmarksImporter::import(const QString &path)
{
	QFile file(getSuggestedPath(path));

	if (!file.open(QIODevice::ReadOnly))
	{
		return false;
	}

	QTextStream stream(&file);
	stream.setCodec("UTF-8");

	QString line(stream.readLine());

	if (line != QLatin1String("Opera Hotlist version 2.0"))
	{
		return false;
	}

	if (m_optionsWidget)
	{
		if (m_optionsWidget->hasToRemoveExisting())
		{
			removeAllBookmarks();

			if (m_optionsWidget->isImportingIntoSubfolder())
			{
				setImportFolder(BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), m_optionsWidget->getSubfolderName(), BookmarksManager::getModel()->getRootItem()));
			}
			else
			{
				setImportFolder(BookmarksManager::getModel()->getRootItem());
			}
		}
		else
		{
			setAllowDuplicates(m_optionsWidget->allowDuplicates());
			setImportFolder(m_optionsWidget->getTargetFolder());
		}
	}

	BookmarksItem *bookmark(NULL);
	OperaBookmarkEntry type(NoEntry);
	bool isHeader(true);

	while (!stream.atEnd())
	{
		line = stream.readLine();

		if (isHeader && (line.isEmpty() || line.at(0) != QLatin1Char('#')))
		{
			continue;
		}

		isHeader = false;

		if (line.startsWith(QLatin1String("#URL")))
		{
			bookmark = BookmarksManager::addBookmark(BookmarksModel::UrlBookmark, QUrl(), QString(), getCurrentFolder());
			type = UrlEntry;
		}
		else if (line.startsWith(QLatin1String("#FOLDER")))
		{
			bookmark = BookmarksManager::addBookmark(BookmarksModel::FolderBookmark, QUrl(), QString(), getCurrentFolder());
			type = FolderStartEntry;
		}
		else if (line.startsWith(QLatin1String("#SEPERATOR")))
		{
			bookmark = BookmarksManager::addBookmark(BookmarksModel::SeparatorBookmark, QUrl(), QString(), getCurrentFolder());
			type = SeparatorEntry;
		}
		else if (line == QLatin1String("-"))
		{
			type = FolderEndEntry;
		}
		else if (line.startsWith(QLatin1String("\tURL=")) && bookmark)
		{
			const QUrl url(line.section(QLatin1Char('='), 1, -1));

			if (!allowDuplicates() && BookmarksManager::hasBookmark(url))
			{
				bookmark->remove();
				bookmark = NULL;
			}
			else
			{
				bookmark->setData(url, BookmarksModel::UrlRole);
			}
		}
		else if (line.startsWith(QLatin1String("\tNAME=")) && bookmark)
		{
			bookmark->setData(line.section(QLatin1Char('='), 1, -1), BookmarksModel::TitleRole);
		}
		else if (line.startsWith(QLatin1String("\tDESCRIPTION=")) && bookmark)
		{
			bookmark->setData(line.section(QLatin1Char('='), 1, -1).replace(QLatin1String("\x02\x02"), QLatin1String("\n")), BookmarksModel::DescriptionRole);
		}
		else if (line.startsWith(QLatin1String("\tSHORT NAME=")) && bookmark)
		{
			const QString keyword(line.section(QLatin1Char('='), 1, -1));

			if (!BookmarksManager::hasKeyword(keyword))
			{
				bookmark->setData(keyword, BookmarksModel::KeywordRole);
			}
		}
		else if (line.startsWith(QLatin1String("\tCREATED=")) && bookmark)
		{
			bookmark->setData(QDateTime::fromTime_t(line.section(QLatin1Char('='), 1, -1).toUInt()), BookmarksModel::TimeAddedRole);
		}
		else if (line.startsWith(QLatin1String("\tVISITED=")) && bookmark)
		{
			bookmark->setData(QDateTime::fromTime_t(line.section(QLatin1Char('='), 1, -1).toUInt()), BookmarksModel::TimeVisitedRole);
		}
		else if (line.isEmpty())
		{
			if (bookmark)
			{
				if (type == FolderStartEntry)
				{
					setCurrentFolder(bookmark);
				}

				bookmark = NULL;
			}
			else if (type == FolderEndEntry)
			{
				goToParent();
			}

			type = NoEntry;
		}
	}

	file.close();

	return true;
}
Esempio n. 28
0
QxFileBrowser::QxFileBrowser(QWidget* parent)
	: QWidget(parent),
	  gotoMenu_(0),
	  recentMenu_(0),
	  showHidden_(false),
	  showDetails_(true),
	  createFileDialog_(0),
	  createDirDialog_(0),
	  renameDialog_(0)
{
	//--------------------------------------------------------------------------
	// setup primary model and view
	
	cwdModel_ = new QFileSystemModel(this);
	cwdModel_->setReadOnly(false);
	QModelIndex root = cwdModel_->setRootPath(QDir::currentPath());
	connect( cwdModel_, SIGNAL(fileRenamed(const QString&, const QString&, const QString&)),
	         this, SLOT(fileRenamed(const QString&, const QString&, const QString&)) );
	
	dirView_ = new QxFileSystemView(this);
	dirView_->setModel(cwdModel_);
	dirView_->header()->hide();
	dirView_->setRootIndex(root);
	dirView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	dirView_->setDragDropMode(QAbstractItemView::DragOnly);
	connect(dirView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(cwdSet(const QModelIndex&)));
	connect(dirView_, SIGNAL(escape()), this, SIGNAL(escape()));
	connect(dirView_, SIGNAL(cdUp()), this, SLOT(cdUp()));
	connect(cwdModel_, SIGNAL(layoutChanged()), dirView_, SLOT(resizeColumnsToContents()));
	
	setFocusProxy(dirView_);
	
	// dirView_->setTextElideMode(Qt::ElideMiddle);
	dirView_->setFrameStyle(QFrame::NoFrame);
	// dirView_->setIndentation(18); // together with a branch pixmap could improve branch alignment
	dirView_->setLineWidth(0);
	dirView_->setMidLineWidth(0);
	#ifdef Q_WS_MAC
	dirView_->setStyleSheet(
		"QTreeView {"
		"  font-size: 12px;"
		"}"
		"QTreeView::item {"
		"  padding-top: 1px;"
		"}"
	);
	#endif
	{
		QPalette pal = dirView_->palette();
		pal.setColor(QPalette::Base, styleManager()->color("fileBrowserDirViewBgColor"));
		dirView_->setPalette(pal);
	}
	
	//--------------------------------------------------------------------------
	// setup navigation bar / panel head
	
	gotoButton_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserGotoButton")));
	gotoButton_->setMode(QxControl::MenuMode);
	gotoButton_->visual()->setText(QDir::current().dirName());
	gotoButton_->setMinimumWidth(10); // design HACK
	gotoButton_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
	{
		QPixmap folderIcon = QFileIconProvider().icon(QFileInfo(QDir::currentPath())).pixmap(QSize(16, 16));
		gotoButton_->visual()->setLeadingIcon(folderIcon);
	}
	#ifdef Q_WS_MAC
	#ifdef QT_MAC_USE_COCOA
	connect(gotoButton_, SIGNAL(toggled(bool)), this, SLOT(blockFloating(bool)));
	#endif // QT_MAC_USE_COCOA
	#endif // Q_WS_MAC
	
	updateGotoMenu();
	
	class QxCdUpButton: public QxControl {
	public:
		QxCdUpButton(QWidget* parent)
			: QxControl(parent, new QxVisual(styleManager()->style("fileBrowserCdUpButton")))
		{}
	private:
		// workaround HACK, prevent undocking, map double click event to single click
		virtual void mouseDoubleClickEvent(QMouseEvent* event) { press(); event->accept(); }
	};
	QxControl* cdUpButton = new QxCdUpButton(this);
	cdUpButton->setMode(QxControl::TouchMode);
	connect(cdUpButton, SIGNAL(pressed()), this, SLOT(cdUp()));
	
	//--------------------------------------------------------------------------
	// define context actions
	
	contextMenu_ = new QMenu(this);
	
	// QxDesignHack::beautify(contextMenu_);
	openDefaultAction_ = new QAction(tr("Open in Default App."), this);
	openDefaultAction_->setShortcut(tr("Ctrl+D"));
	openDefaultAction_->setShortcutContext(Qt::WidgetShortcut);
	openFileAction_ = new QAction(tr("Open in %1").arg(qApp->applicationName()), this);
	
	createFileAction_ = contextMenu_->addAction(tr("New File"));
	createDirAction_ = contextMenu_->addAction(tr("New Folder"));
	contextMenu_->addSeparator();
	contextMenu_->addAction(openFileAction_);
	contextMenu_->addAction(openDefaultAction_);
	contextMenu_->addSeparator();
	renameAction_ = contextMenu_->addAction(tr("Rename"));
	deleteAction_ = contextMenu_->addAction(tr("Move To Trash"));
	contextMenu_->addSeparator();
	bookmarkAction_ = contextMenu_->addAction(tr("Bookmark"));
	contextMenu_->addSeparator();
	showHiddenAction_ = contextMenu_->addAction(tr("Show Hidden"));
	showDetailsAction_ = contextMenu_->addAction(tr("Show Details"));
	
	connect(createFileAction_, SIGNAL(triggered()), this, SLOT(createFile()));
	connect(createDirAction_, SIGNAL(triggered()), this, SLOT(createDir()));
	connect(openDefaultAction_, SIGNAL(triggered()), this, SLOT(openDefault()));
	connect(openFileAction_, SIGNAL(triggered()), this, SLOT(openFile()));
	connect(renameAction_, SIGNAL(triggered()), this, SLOT(rename()));
	connect(deleteAction_, SIGNAL(triggered()), this, SLOT(delete_()));
	connect(dirView_, SIGNAL(delKeyPressed()), this, SLOT(delete_()));
	connect(showHiddenAction_, SIGNAL(toggled(bool)), this, SLOT(showHidden(bool)));
	connect(showDetailsAction_, SIGNAL(toggled(bool)), this, SLOT(showDetails(bool)));
	connect(bookmarkAction_, SIGNAL(triggered()), this, SLOT(bookmark()));
	
	showHiddenAction_->setCheckable(true);
	showDetailsAction_->setCheckable(true);
	showHiddenAction_->setChecked(false);
	showDetailsAction_->setChecked(false);
	
	//--------------------------------------------------------------------------
	// setup toolbar
	
	QxControl* plusButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserPlusButton")));
	plusButton->setMode(QxControl::TouchMode);
	connect(plusButton, SIGNAL(pressed()), this, SLOT(createFile()));
	
	QxControl* wheelButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserWheelButton")));
	wheelButton->setMenu(contextMenu_);
	wheelButton->setMenuPopupMode(QxControl::DownsideMenuPopup|QxControl::UpsideMenuPopup|QxControl::PreferUpsideMenuPopup);
	
	QxControl* recentButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserRecentButton")));
	recentButton->setMode(QxControl::TouchMode);
	connect(recentButton, SIGNAL(pressed()), this, SLOT(recentShowOrHide()));
	
	QxControl* bookmarksButton = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserBookmarksButton")));
	bookmarksButton->setMode(QxControl::TouchMode);
	connect(bookmarksButton, SIGNAL(pressed()), this, SLOT(bookmarksShowOrHide()));
	
	statusBar_ = new QxStatusBar(this);
	
	showHidden(false);
	showDetails(false);
	
	//--------------------------------------------------------------------------
	// setup bottom views
	
	recentModel_ = new QxUrlListModel(this);
	
	recentView_ = new QxUrlListView(this);
	// recentView_->header()->hide();
	// recentView_->setViewMode(QListView::IconMode);
	// recentView_->setIconSize(QSize(16, 16));
	recentView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	recentView_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	recentView_->setTextElideMode(Qt::ElideLeft);
	recentView_->setFrameStyle(QFrame::NoFrame);
	recentView_->setLineWidth(0);
	recentView_->setMidLineWidth(0);
	recentView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	// recentView_->setAlternatingRowColors(true);
	recentView_->setModel(recentModel_);
	connect(recentView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoRecent(const QModelIndex&)));
	
	recentContextMenu_ = new QMenu(this);
	recentContextMenu_->addAction(tr("Goto"), this, SLOT(gotoRecent()));
	recentContextMenu_->addAction(tr("Add To Bookmarks"), this, SLOT(recentAddToBookmarks()));
	
	bookmarksModel_ = new QxUrlListModel(this);
	bookmarksModel_->setPathReduction(1);
	
	bookmarksView_ = new QxUrlListView(this);
	bookmarksView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	bookmarksView_->setTextElideMode(Qt::ElideLeft);
	bookmarksView_->setFrameStyle(QFrame::NoFrame);
	bookmarksView_->setLineWidth(0);
	bookmarksView_->setMidLineWidth(0);
	bookmarksView_->setStyleSheet(
		"QListView::item {"
		"  padding-top: 1px;"
		"}"
	);
	bookmarksView_->setModel(bookmarksModel_);
	bookmarksView_->setDragDropMode(QAbstractItemView::InternalMove);
	bookmarksView_->setDragEnabled(true);
	bookmarksView_->setAcceptDrops(true);
	bookmarksView_->setDropIndicatorShown(true);
	connect(bookmarksView_, SIGNAL(activated(const QModelIndex&)), this, SLOT(gotoBookmark(const QModelIndex&)));
	
	bookmarksContextMenu_ = new QMenu(this);
	bookmarksContextMenu_->addAction(tr("Add Current Directory"), this, SLOT(cwdAddToBookmark()));
	bookmarksContextMenu_->addAction(tr("Add Other Directory"), this, SLOT(addDirBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksContextMenu_->addAction(tr("Goto Here"), this, SLOT(gotoBookmark()));
	bookmarksContextMenu_->addAction(tr("Remove From List"), this, SLOT(removeBookmark()));
	bookmarksContextMenu_->addSeparator();
	bookmarksShowFullPathAction_ = bookmarksContextMenu_->addAction(tr("Show Full Path"));
	bookmarksShowFullPathAction_->setCheckable(true);
	bookmarksShowFullPathAction_->setChecked(bookmarksModel_->pathReduction() == -1);
	connect(bookmarksShowFullPathAction_, SIGNAL(toggled(bool)), this, SLOT(bookmarksShowFullPath(bool)));
	
	#ifdef Q_WS_MAC
	{
		QProxyStyle* proxyStyle = qobject_cast<QProxyStyle*>(style());
		QMacStyle* macStyle = qobject_cast<QMacStyle*>((proxyStyle) ? proxyStyle->baseStyle() : style());
		if (macStyle) {
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(recentView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(dirView_, QMacStyle::FocusDisabled);
			macStyle->setFocusRectPolicy(bookmarksView_, QMacStyle::FocusDisabled);
		}
	}
	#endif
	
	//--------------------------------------------------------------------------
	// layout widgets
	
	handle_ = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserSplitter")));
	handle_->visual()->setText("");
	handleTextRecent_ = tr("Recent Places");
	handleTextBookmarks_ = tr("Bookmarks");
	
	bottomStack_ = new QxControl(this);
	bottomStackLayout_ = new QStackedLayout;
	bottomStackLayout_->addWidget(recentView_);
	bottomStackLayout_->addWidget(bookmarksView_);
	bottomStack_->setLayout(bottomStackLayout_);
	bottomStack_->setVisible(false);
	
	splitter_ = new QxSplitter(this);
	splitter_->setOrientation(Qt::Vertical);
	splitter_->setHandle(1, handle_);
	splitter_->setHandleWidth(styleManager()->constant("fileBrowserSplitterWidth"));
	splitter_->addWidget(dirView_);
	/*{
		QxControl* carrier = new QxControl(this, new QxVisual(styleManager()->style("fileBrowserDirView")));
		QGridLayout* layout = new QGridLayout;
		layout->setSpacing(0);
		layout->setMargin(0);
		layout->addWidget(dirView_);
		carrier->setLayout(layout);
		splitter_->addWidget(carrier);
	}*/
	splitter_->addWidget(bottomStack_);
	
	// make dirView_ grow/shrink dynamically, while bottomStack_ keeps user-defined size
	splitter_->setStretchFactor(0, 1);
	splitter_->setStretchFactor(1, 0);
	
	QDockWidget* dock = qobject_cast<QDockWidget*>(parent);
	if (dock) {
		dock->setWidget(this);
		// connect(dock, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(adaptToDockLocation(Qt::DockWidgetArea)));
	}
	
	QVBoxLayout* col = new QVBoxLayout;
	col->setSpacing(0);
	col->setMargin(0);
	{
		QxControl* carrier = new QxControl(parent, new QxVisual(styleManager()->style("fileBrowserNavCarrier")));
		QHBoxLayout* row = new QHBoxLayout;
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(gotoButton_);
		row->addStretch();
		row->addWidget(cdUpButton);
		carrier->setLayout(row);
		
		if (dock)
			dock->setTitleBarWidget(carrier);
		else
			col->addWidget(carrier);
	}
	col->addWidget(splitter_);
	col->addWidget(styleManager()->hl(this));
	{
		QBoxLayout* row = new QBoxLayout(QBoxLayout::LeftToRight);
		row->setSpacing(0);
		row->setMargin(0);
		row->addWidget(plusButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(wheelButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(recentButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(bookmarksButton);
		row->addWidget(styleManager()->vl(this));
		row->addWidget(statusBar_);
		col->addLayout(row);
		
		bottomToolLayout_ = row;
	}
	setLayout(col);
}
Esempio n. 29
0
DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
  if (!pDict)
    return nullptr;
  CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
  return bookmark.GetAction().GetDict();
}
Esempio n. 30
0
DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
    if (!pDict)
        return NULL;
    CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
    return bookmark.GetAction().GetDict();
}