ShareWidget::ShareWidget(QSharedPointer<Share> share, QWidget *parent) : QWidget(parent), _ui(new Ui::ShareWidget), _share(share), _showDetailedPermissions(false) { _ui->setupUi(this); _ui->sharedWith->setText(share->getShareWith()->format()); // Set the permissions checkboxes displayPermissions(); // Hide "detailed permissions" by default _ui->permissionDelete->setHidden(true); _ui->permissionUpdate->setHidden(true); _ui->permissionCreate->setHidden(true); connect(_ui->permissionUpdate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionCreate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionDelete, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionShare, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionsEdit, SIGNAL(clicked(bool)), SLOT(slotEditPermissionsChanged())); connect(share.data(), SIGNAL(permissionsSet()), SLOT(slotPermissionsSet())); connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted())); _ui->deleteShareButton->setIcon(QIcon::fromTheme(QLatin1String("user-trash"), QIcon(QLatin1String(":/client/resources/delete.png")))); }
ShareWidget::ShareWidget(QSharedPointer<Share> share, bool isFile, QWidget *parent) : QWidget(parent), _ui(new Ui::ShareWidget), _share(share), _isFile(isFile) { _ui->setupUi(this); _ui->sharedWith->setText(share->getShareWith()->format()); // Create detailed permissions menu QMenu *menu = new QMenu(this); _permissionCreate = new QAction(tr("create"), this); _permissionCreate->setCheckable(true); _permissionUpdate = new QAction(tr("change"), this); _permissionUpdate->setCheckable(true); _permissionDelete = new QAction(tr("delete"), this); _permissionDelete->setCheckable(true); menu->addAction(_permissionUpdate); /* * Files can't have create or delete permissions */ if (!_isFile) { menu->addAction(_permissionCreate); menu->addAction(_permissionDelete); } _ui->permissionToolButton->setMenu(menu); _ui->permissionToolButton->setPopupMode(QToolButton::InstantPopup); QIcon icon(QLatin1String(":/client/resources/more.png")); _ui->permissionToolButton->setIcon(icon); // Set the permissions checkboxes displayPermissions(); connect(_permissionUpdate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged())); connect(_permissionCreate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged())); connect(_permissionDelete, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionShare, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionsEdit, SIGNAL(clicked(bool)), SLOT(slotEditPermissionsChanged())); connect(share.data(), SIGNAL(permissionsSet()), SLOT(slotPermissionsSet())); connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted())); _ui->deleteShareButton->setIcon(QIcon::fromTheme(QLatin1String("user-trash"), QIcon(QLatin1String(":/client/resources/delete.png")))); if (!share->account()->capabilities().shareResharing()) { _ui->permissionShare->hide(); } }
void ShareWidget::slotPermissionsSet() { displayPermissions(); setEnabled(true); }
void displayFileInfo ( struct fileInfo* const table, const int entries, const int displayMode ){ //used later for loops int i; //used later with ctime char* time; //used in string manip char* ptr; char* ptr2; char* ptr3; //for time since 01/01/1970 struct timeval now; /* Sorting by Name */ if((displayMode & SFLAG) == 0){ //if r flag is set if((displayMode & RFLAG) == RFLAG){ qsort(table, entries, sizeof(struct fileInfo), nameSortDescending); } else{ //default (sort name in ascending order) qsort(table, entries, sizeof(struct fileInfo), nameSortAscending); } } /* Sorting by Size */ if((displayMode & SFLAG) == SFLAG){ //if r flag is set if((displayMode & RFLAG) == RFLAG){ qsort(table, entries, sizeof(struct fileInfo), sizeSortAscending); } //if r flag is not set else{ qsort(table, entries, sizeof(struct fileInfo), sizeSortDescending); } } for(i = 0; i < entries; i++){ /* A flag */ if( ((displayMode & AFLAG) == 0) && (table[i].name[0] == '.') ){ //ignore invisible files continue; } /* B flag */ if( ((displayMode & BFLAG) == BFLAG) && (table[i].name [strlen(table[i].name)-1] == '~') ){ //ignore files ending in ~ continue; } /* if l flag was set */ if((displayMode & LFLAG) == LFLAG){ //if file is directory if(S_ISDIR(table[i].stbuf.st_mode)){ (void) fprintf(stdout, "%c", 'd'); } //if file is symbolic link else if(S_ISLNK(table[i].stbuf.st_mode)){ (void) fprintf(stdout, "%c", 'l'); } //if file is a block special file else if(S_ISBLK(table[i].stbuf.st_mode)){ (void) fprintf(stdout, "%c", 'b'); } //if file is a character special file else if(S_ISCHR(table[i].stbuf.st_mode)){ (void) fprintf(stdout, "%c", 'c'); } //default else{ (void) fprintf(stdout, "%c", '-'); } //display Permissions displayPermissions(table[i].stbuf.st_mode); //print number of links (void) fprintf(stdout, STR_NLINK, table[i].stbuf.st_nlink); //display OwnerName displayOwnerName(table[i].stbuf.st_uid); //display GroupName displayGroupName(table[i].stbuf.st_gid); //print size (major minor) for block and char special files if((S_ISBLK(table[i].stbuf.st_mode)) || (S_ISCHR(table[i].stbuf.st_mode))){ (void) fprintf(stdout, STR_MAJOR_MINOR, major(table[i].stbuf.st_rdev), minor(table[i].stbuf.st_rdev)); } //otherwise just print the size else{ (void) fprintf(stdout, STR_SIZE, table[i].stbuf.st_size); } //print modification time (Month Day Hour:Min) // [15724800] seconds in six months time = ctime(&(table[i].stbuf.st_mtime)); ptr = strchr(time, ' '); //get current time (void) gettimeofday (&now, NULL); //print month day year if the file's mod time is 6 months or older if(table[i].stbuf.st_mtime < (now.tv_sec-15724800)){ ptr2 = strrchr(time,' '); ptr3 = strchr(time, ':'); *(ptr3-3) = '\0'; *(ptr2+(((int)strlen(ptr2))-1)) = '\0'; (void) fprintf(stdout, "%s ", ptr+1); (void) fprintf(stdout, "%s ", ptr2); } //otherwise just print month day and time else{ ptr2 = strrchr(time,':'); *ptr2 = '\0'; (void) fprintf(stdout, "%s ", ptr+1); } } //print every file (void) fprintf(stdout, "%s\n", table[i].name); } return; }