size32_t CThorStreamDeserializerSource::readUtf8(ARowBuilder & target, size32_t offset, size32_t fixedSize, size32_t len) { //The len is the number of utf characters, size depends on which characters are included. size32_t totalSize = 0; loop { if (len == 0) return totalSize; size32_t available; const byte * cur = doPeek(1, available); size32_t copyLen; for (copyLen = 0; copyLen < available;) { copyLen += readUtf8Size(cur+copyLen); // This function only accesses the first byte if (--len == 0) break; } byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL); doRead(copyLen, self+offset+totalSize); totalSize += copyLen; } }
size32_t CThorStreamDeserializerSource::readVUni(ARowBuilder & target, size32_t offset, size32_t fixedSize) { size32_t totalSize = 0; bool done = false; loop { size32_t available; const byte * cur = doPeek(2, available); size32_t copyLen = 0; for (copyLen = 0; copyLen+1 < available; copyLen+=2) { if (cur[copyLen] == 0 && cur[copyLen+1] == 0) { copyLen += 2; done = true; break; } } byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL); doRead(copyLen, self+offset+totalSize); totalSize += copyLen; if (done) return totalSize; } }
size32_t CThorStreamDeserializerSource::readPackedInt(void * ptr) { size32_t available; const byte * temp = doPeek(1, available); size32_t size = rtlGetPackedSizeFromFirst(*temp); doRead(size, ptr); return size; }
void CThorStreamDeserializerSource::skipPackedInt() { throwUnexpected(); size32_t available; const byte * temp = doPeek(1, available); size32_t size = rtlGetPackedSizeFromFirst(*temp); in->skip(size); }
size32_t CThorStreamDeserializerSource::readVStr(ARowBuilder & target, size32_t offset, size32_t fixedSize) { size32_t totalSize = 0; loop { size32_t available; const byte * cur = doPeek(1, available); const byte * end = static_cast<const byte *>(memchr(cur, 0, available)); size32_t copyLen = end ? (end+1) - cur : available; byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL); doRead(copyLen, self+offset+totalSize); totalSize += copyLen; if (end) return totalSize; } }
void CThorStreamDeserializerSource::skipUtf8(size32_t len) { throwUnexpected(); loop { if (len == 0) return; size32_t available; const byte * cur = doPeek(1, available); size32_t copyLen; for (copyLen = 0; copyLen < available;) { copyLen += readUtf8Size(cur+copyLen); // This function only accesses the first byte len--; } in->skip(copyLen); } }
void NBFolderView::createAndSetupActions() { connect( IconView, SIGNAL( peek( QModelIndex ) ), this, SLOT( doPeek( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QModelIndex ) ), this, SLOT( doOpen( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QString ) ), this, SLOT( doOpen( QString ) ) ); connect( IconView, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) ); connect( IconView, SIGNAL( actionsMenuRequested( QPoint ) ), this, SLOT( showActionsMenu( QPoint ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) ); connect( IconView, SIGNAL( link( QStringList, QString ) ), this, SLOT( link( QStringList, QString ) ) ); // DragDrop copy connect( IconView, SIGNAL( copy( QStringList, QString ) ), this, SLOT( copy( QStringList, QString ) ) ); // DragDrop move connect( IconView, SIGNAL( move( QStringList, QString ) ), this, SLOT( move( QStringList, QString ) ) ); // Update actions once the directory is loaded connect( fsModel, SIGNAL( directoryLoaded( QString ) ), this, SLOT( updateActions() ) ); // Peek peekAct = new QAction( QIcon( ":/icons/peek.png" ), "Pee&k", this ); peekAct->setShortcuts( Settings->shortcuts( "Peek" ) ); connect( peekAct, SIGNAL( triggered() ), this, SLOT( doPeek() ) ); addAction( peekAct ); // Home Dir actHomeDir = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actHomeDir->setShortcuts( Settings->shortcuts( "GoHome" ) ); connect( actHomeDir, SIGNAL( triggered() ), this, SLOT( loadHomeDir() ) ); addAction( actHomeDir ); // Home actGoHome = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actGoHome->setShortcut( tr( "Alt+Shift+Home" ) ); connect( actGoHome, SIGNAL( triggered() ), this, SLOT( doOpenHome() ) ); addAction( actGoHome ); // Up actParDir = new QAction( QIcon( ":/icons/up.png" ), "&Up", this ); actParDir->setShortcuts( Settings->shortcuts( "GoUp" ) ); connect( actParDir, SIGNAL( triggered() ), fsModel, SLOT( goUp() ) ); addAction( actParDir ); // Back actPrevDir = new QAction( QIcon( ":/icons/prev.png" ), "&Back", this ); actPrevDir->setShortcuts( Settings->shortcuts( "GoLeft" ) ); connect( actPrevDir, SIGNAL( triggered() ), fsModel, SLOT( goBack() ) ); addAction( actPrevDir ); // Forward actNextDir = new QAction( QIcon( ":/icons/next.png" ), "&Forward", this ); actNextDir->setShortcuts( Settings->shortcuts( "GoRight" ) ); connect( actNextDir, SIGNAL( triggered() ), fsModel, SLOT( goForward() ) ); addAction( actNextDir ); // New Folder actNewDir = new QAction( QIcon::fromTheme( "folder-new" ), "New folder", this ); actNewDir->setShortcuts( Settings->shortcuts( "NewFolder" ) ); connect( actNewDir, SIGNAL( triggered() ), this, SLOT( newFolder() ) ); addAction( actNewDir ); // New file actNewFile = new QAction( QIcon::fromTheme( "document-new" ), "New File", this ); actNewFile->setShortcuts( Settings->shortcuts( "NewFile" ) ); connect( actNewFile, SIGNAL( triggered() ), this, SLOT( newFile() ) ); addAction( actNewFile ); // New file actNewEncFS = new QAction( QIcon::fromTheme( "document-new" ), "New Encrypted Directory", this ); actNewEncFS->setShortcuts( Settings->shortcuts( "NewEncFS" ) ); connect( actNewEncFS, SIGNAL( triggered() ), this, SLOT( createEncFS() ) ); addAction( actNewEncFS ); // Copy copyAct = new QAction( QIcon( ":/icons/copy.png" ), "&Copy", this ); copyAct->setShortcuts( Settings->shortcuts( "Copy" ) ); connect( copyAct, SIGNAL( triggered() ), this, SLOT( prepareCopy() ) ); addAction( copyAct ); // Move moveAct = new QAction( QIcon( ":/icons/cut.png" ), "Cu&t", this ); moveAct->setShortcuts( Settings->shortcuts( "Cut" ) ); connect( moveAct, SIGNAL( triggered() ), this, SLOT( prepareMove() ) ); addAction( moveAct ); // Paste pasteAct = new QAction( QIcon( ":/icons/paste.png" ), "&Paste", this ); pasteAct->setShortcuts( Settings->shortcuts( "Paste" ) ); connect( pasteAct, SIGNAL( triggered() ), this, SLOT( prepareIO() ) ); addAction( pasteAct ); // Rename renameAct = new QAction( QIcon( ":/icons/rename.png" ), "&Rename", this ); renameAct->setShortcuts( Settings->shortcuts( "Rename" ) ); connect( renameAct, SIGNAL( triggered() ), this, SLOT( doRename() ) ); addAction( renameAct ); // Reload reloadAct = new QAction( QIcon( ":/icons/reload.png" ), "Re&fresh", this ); reloadAct->setShortcuts( Settings->shortcuts( "Reload" ) ); connect( reloadAct, SIGNAL( triggered() ), this, SLOT( doReload() ) ); addAction( reloadAct ); // showDotFiles showHideDotFiles = new QAction( QIcon( ":/icons/showDotFiles.png" ), "Show &Hidden", this ); showHideDotFiles->setShortcuts( Settings->shortcuts( "ToggleHidden" ) ); connect( showHideDotFiles, SIGNAL( triggered() ), this, SLOT( doToggleHidden() ) ); addAction( showHideDotFiles ); // Trash trashAct = new QAction( QIcon( ":/icons/trash.png" ), "Move to trash", this ); trashAct->setShortcuts( Settings->shortcuts( "Trash" ) ); connect( trashAct, SIGNAL( triggered() ), this, SLOT( doSendToTrash() ) ); addAction( trashAct ); // Delete delAct = new QAction( QIcon( ":/icons/delete.png" ), "Delete", this ); delAct->setShortcuts( Settings->shortcuts( "Delete" ) ); connect( delAct, SIGNAL( triggered() ), this, SLOT( doDelete() ) ); addAction( delAct ); // Properties propertiesAct = new QAction( QIcon( ":/icons/props.png" ), "&Properties", this ); propertiesAct->setShortcuts( Settings->shortcuts( "Properties" ) ); connect( propertiesAct, SIGNAL( triggered() ), this, SIGNAL( showProperties() ) ); addAction( propertiesAct ); // Permissions permissionsAct = new QAction( QIcon::fromTheme( "system-users" ), "P&ermissions", this ); permissionsAct->setShortcuts( Settings->shortcuts( "Permissions" ) ); connect( permissionsAct, SIGNAL( triggered() ), this, SIGNAL( showPermissions() ) ); addAction( permissionsAct ); // Open a virtual terminal emulator openVTE = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE", this ); openVTE->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTE, SIGNAL( triggered() ), this, SLOT( openTerminal() ) ); addAction( openVTE ); // Open a virtual terminal emulator openVTEin = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE Here", this ); // openVTEin->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTEin, SIGNAL( triggered() ), this, SLOT( openTerminalIn() ) ); // Select All QAction *selectAllAct = new QAction( "&Select All", this ); selectAllAct->setShortcuts( Settings->shortcuts( "SelectAll" ) ); connect( selectAllAct, SIGNAL( triggered() ), this, SLOT( selectAll() ) ); addAction( selectAllAct ); // Sorting sortByNameAct = new QAction( QIcon::fromTheme( "format-text-underline" ), "&Name", this ); sortByNameAct->setCheckable( true ); connect( sortByNameAct, SIGNAL( triggered() ), this, SLOT( sortByName() ) ); sortByTypeAct = new QAction( QIcon::fromTheme( "preferences-other" ), "&Type", this ); sortByTypeAct->setCheckable( true ); connect( sortByTypeAct, SIGNAL( triggered() ), this, SLOT( sortByType() ) ); sortBySizeAct = new QAction( QIcon( ":/icons/size.png" ), "&Size", this ); sortBySizeAct->setCheckable( true ); connect( sortBySizeAct, SIGNAL( triggered() ), this, SLOT( sortBySize() ) ); sortByDateAct = new QAction( QIcon::fromTheme( "office-calendar" ), "&Date", this ); sortByDateAct->setCheckable( true ); connect( sortByDateAct, SIGNAL( triggered() ), this, SLOT( sortByDate() ) ); QActionGroup *sortGroup = new QActionGroup( this ); sortGroup->addAction( sortByNameAct ); sortGroup->addAction( sortByTypeAct ); sortGroup->addAction( sortBySizeAct ); sortGroup->addAction( sortByDateAct ); switch( ( int )Settings->value( "SortColumn" ) ) { case 0: { sortByNameAct->setChecked( true ); break; } case 1: { sortBySizeAct->setChecked( true ); break; } case 2: { sortByTypeAct->setChecked( true ); break; } case 4: { sortByDateAct->setChecked( true ); break; } } groupsAct = new QAction( QIcon::fromTheme( "view-group", QIcon( ":/icons/groups.png" ) ), "Show in &Groups", this ); groupsAct->setCheckable( true ); groupsAct->setChecked( Settings->value( "Grouping" ) ); connect( groupsAct, SIGNAL( triggered() ), this, SIGNAL( toggleGroups() ) ); // Add bookmark addBookMarkAct = new QAction( QIcon( ":/icons/bookmark.png" ), "Add &Bookmark", this ); addBookMarkAct->setShortcuts( Settings->shortcuts( "AddBookmark" ) ); connect( addBookMarkAct, SIGNAL( triggered() ), this, SLOT( addBookMark() ) ); addAction( addBookMarkAct ); /* Add to SuperStart */ addToSuperStartAct = new QAction( QIcon( ":/icons/superstart.png" ), "Add to S&uperStart", this ); addToSuperStartAct->setShortcut( tr( "Ctrl+U" ) ); connect( addToSuperStartAct, SIGNAL( triggered() ), this, SLOT( addToSuperStart() ) ); addAction( addToSuperStartAct ); updateActions(); };
const byte * CThorContiguousRowBuffer::peek(size32_t maxSize) { if (maxSize+readOffset > maxOffset) doPeek(maxSize+readOffset); return buffer + readOffset; }