void AutoFillManager::editPass() { QTreeWidgetItem* curItem = ui->treePass->currentItem(); if (!curItem) { return; } bool ok; QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"******"SELECT data, password FROM autofill WHERE id=?"); query.addBindValue(curItem->whatsThis(0)); query.exec(); query.next(); QByteArray data = query.value(0).toByteArray(); QByteArray oldPass = "******" + QUrl::toPercentEncoding(query.value(1).toByteArray()); data.replace(oldPass, "=" + QUrl::toPercentEncoding(text.toUtf8())); query.prepare("UPDATE autofill SET data=?, password=? WHERE id=?"); query.bindValue(0, data); query.bindValue(1, text); query.bindValue(2, curItem->whatsThis(0)); query.exec(); if (m_passwordsShown) { curItem->setText(1, text); } curItem->setWhatsThis(1, text); } }
void ColorDialog::loadColors(){ QStringList contents = LUtils::readFile(filepath); for(int i=0; i<ui->tree_color->topLevelItemCount(); i++){ QTreeWidgetItem *it = ui->tree_color->topLevelItem(i); //Get the current value and update the item QStringList fil = contents.filter(it->whatsThis(0)+"="); QString val; for(int i=0; i<fil.length(); i++){ if( fil[i].startsWith(it->whatsThis(0)+"=") ){ val = fil[i]; } } updateItem(it, val.section("=",1,1)); } }
void MainUI::slotInstalledAppRightClicked(const QPoint &pt){ //Get the item under the mouse click QTreeWidgetItem *it = ui->tree_install_apps->itemAt(pt); if(it==0){ return; } // no item selected QString pbiID = it->whatsThis(0); qDebug() << "Get context menu for:" << pbiID; //Now Update the context menu appropriately NGApp info = PBI->singleAppInfo(pbiID); //QStringList info = PBI->PBIInfo(pbiID, QStringList() << "hasdesktopicons" << "hasmenuicons" << "hasmimetypes"); if( info.origin.isEmpty() ){ return; } //invalid application bool pending = PBI->isWorking(pbiID); contextActionMenu->clear(); if(info.hasDE && VISJAIL.isEmpty() ){ QMenu *dmenu = contextActionMenu->addMenu( QIcon(":icons/xdg_desktop.png"), tr("Desktop Icons")); dmenu->addAction( QIcon(":icons/add.png"),tr("Add"),this,SLOT(slotActionAddDesktop()) ); dmenu->addAction( QIcon(":icons/remove.png"),tr("Remove"),this,SLOT(slotActionRemoveDesktop()) ); } if(info.isLocked){ contextActionMenu->addAction( QIcon(":icons/unlock.png"), tr("Unlock Application"), this, SLOT(slotActionUnlock()) ); }else{ contextActionMenu->addAction( QIcon(":icons/lock.png"), tr("Lock Current Version"), this, SLOT(slotActionLock()) ); } if(!pending && PBI->safeToRemove(pbiID)){ //Remove option is only available if not currently pending actions contextActionMenu->addSeparator(); contextActionMenu->addAction( QIcon(":icons/remove.png"), tr("Uninstall"), this, SLOT(slotActionRemove()) ); }else if(pending){ //Cancel option is only available if actions are currently pending contextActionMenu->addSeparator(); contextActionMenu->addAction( QIcon(":icons/dialog-cancel.png"), tr("Cancel Actions"), this, SLOT(slotActionCancel()) ); } //Now show the menu cDetails = pbiID; //save this so we know which app is currently being modified contextActionMenu->popup(ui->tree_install_apps->mapToGlobal(pt)); }
void AutoFillManager::showPasswords() { if (m_passwordsShown) { for (int i = 0; i < ui->treePass->topLevelItemCount(); i++) { QTreeWidgetItem* item = ui->treePass->topLevelItem(i); if (!item) { continue; } item->setText(2, "*****"); } ui->showPasswords->setText(tr("Show Passwords")); m_passwordsShown = false; return; } m_passwordsShown = true; int result = QMessageBox::question(this, tr("Show Passwords"), tr("Are you sure that you want to show all passwords?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (result != QMessageBox::Yes) { return; } for (int i = 0; i < ui->treePass->topLevelItemCount(); i++) { QTreeWidgetItem* item = ui->treePass->topLevelItem(i); if (!item) { continue; } item->setText(2, item->whatsThis(1)); } ui->showPasswords->setText(tr("Hide Passwords")); }
// ================= // PRIVATE SLOTS // ================= void DirWidget::startLoadThumbs(){ //This just runs through the dir and loads all the thumbnails as needed if(DEBUG){ qDebug() << "Start Loading Thumbnails:" << needThumbs; } if(needThumbs.isEmpty()){ return; } needThumbs.removeDuplicates(); //just in case //QTime updatetime = QTime::currentTime().addMSecs(500); for(int i=0; i<needThumbs.length() && !stopload; i++){ if(showDetails){ //Use the tree widget QList<QTreeWidgetItem*> items = treeWidget->findItems(needThumbs[i], Qt::MatchExactly); if(items.isEmpty()){ continue; } //invalid item for some reason if(stopload){ return; } //stop right now QTreeWidgetItem *it = items.first(); it->setIcon(0, QIcon( QPixmap(it->whatsThis(0).section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); }else{ //Use the list widget QList<QListWidgetItem*> items = listWidget->findItems(needThumbs[i], Qt::MatchExactly); if(items.isEmpty()){ continue; } if(stopload){ return; } //stop right now QListWidgetItem *it = items.first(); it->setIcon(QIcon( QPixmap(it->whatsThis().section("::::",1,100)).scaled(listWidget->iconSize(),Qt::IgnoreAspectRatio, Qt::FastTransformation) ) ); } //if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory } }
QString QTreeWidgetItemProto::whatsThis(int column) const { QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject()); if (item) return item->whatsThis(column); return QString(); }
void NotebookList::renameNote() { bool ok; QString relativeDirectory = ""; QString extName; QString newName = QInputDialog::getText(this, tr("rename"), tr("Rename to"), QLineEdit::Normal, "", &ok); QTreeWidgetItem* selectedItem = currentItem(); if(selectedItem == 0) return; if(newName.length() == 0) return; if(selectedItem->parent()) relativeDirectory = selectedItem->parent()->text(0) + "/"; if(selectedItem->whatsThis(0) == "folder") extName=""; else extName=".w"; QString srcFileName = relativeDirectory + selectedItem->text(0) + extName; QString dstFileName = relativeDirectory + newName + extName; SwissKnife::printString("from: "+ srcFileName); SwissKnife::printString("to: " + dstFileName); SwissKnife::renameFile(baseDirectory, srcFileName, dstFileName); // // svnController->doMove(srcFileName,dstFileName); selectedItem->setText(0,newName); }
void ColorDialog::saveColors(){ QString name = ui->line_name->text(); QStringList contents; for(int i=0; i<ui->tree_color->topLevelItemCount(); i++){ QTreeWidgetItem *it = ui->tree_color->topLevelItem(i); contents << it->whatsThis(0)+"="+it->text(1); } bool ok = LTHEME::saveLocalColors(name, contents); if(!ok){ qDebug() << "Could not save colors:" << name; } }
void AutoFillManager::removeExcept() { QTreeWidgetItem* curItem = ui->treeExcept->currentItem(); if (!curItem) { return; } QString id = curItem->whatsThis(0); QSqlQuery query; query.exec("DELETE FROM autofill_exceptions WHERE id=" + id); delete curItem; }
void CookieManager::removeCookie() { QTreeWidgetItem* current = ui->cookieTree->currentItem(); if (!current) { return; } QList<QNetworkCookie> allCookies = mApp->cookieJar()->getAllCookies(); if (current->text(1).isEmpty()) { //Remove whole cookie group QString domain = current->whatsThis(0); foreach(const QNetworkCookie & cookie, allCookies) { if (cookie.domain() == domain || cookie.domain() == domain.mid(1)) { allCookies.removeOne(cookie); } } ui->cookieTree->deleteItem(current); }
void ColorDialog::on_tool_getcolor_clicked(){ QTreeWidgetItem *it = ui->tree_color->currentItem(); if(it==0){ return; } //no item selected QColor ccol = StringToColor(it->text(1)); QColor ncol; if(it->whatsThis(0).contains("BASE")){ ncol = QColorDialog::getColor(ccol, this, tr("Select Color")); } else{ ncol = QColorDialog::getColor(ccol, this, tr("Select Color"), QColorDialog::ShowAlphaChannel ); } if(ncol.isValid()){ QString out; if(ncol.alpha()!=255){ //Convert to rgba out = "rgba("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+","+QString::number(ncol.alpha())+")"; }else{ //Convert to rgb out = "rgb("+QString::number(ncol.red())+","+QString::number(ncol.green())+","+QString::number(ncol.blue())+")"; } updateItem(it, out); } }
//---------------------------------------------------------------------------------------- void ScriptTreeWidget::mouseDoubleClickEvent(QMouseEvent *event) { QList<QTreeWidgetItem*> list = selectedItems(); if(list.size() == 0) return; QTreeWidgetItem *item = list[0]; if(item->parent() == 0) return; while(item->parent() != 0 && item->parent()->parent() != 0) item = item->parent(); Ogre::String scriptname = item->text(0).toStdString(); Ogre::String scriptfilename = item->whatsThis(0).toStdString(); GenericTextEditor::getSingletonPtr()->displayTextFromFile(scriptfilename.c_str()); }
void NotebookList::notebookSelected(QModelIndex idx) { QTreeWidgetItem *item = itemFromIndex(idx); QString fullFilePath=""; if(lastSelectedItem) lastSelectedItem->setBackground(0,QBrush(QColor(Qt::white))); item->setBackground(0,QBrush(QColor(Qt::yellow))); lastSelectedItem = item; if(item->whatsThis(0) == "folder"){ if(item->isExpanded()) item->setExpanded(false); else item->setExpanded(true); return; } if (textEditorWindow->textEdit->document()->isModified()) textEditorWindow->fileSave(); while (idx != QModelIndex()) { QString itemName = this->model()->data(idx).toString(); if (fullFilePath == "") fullFilePath = itemName; else fullFilePath = itemName + "/" + fullFilePath; idx = idx.parent(); } fullFilePath = baseDirectory + fullFilePath + extensionName; cout << "full path : "<<fullFilePath.toAscii().data()<<endl; QString lastModifiedDate = svnController->getDateInfo(fullFilePath); textEditorWindow->statusBar()->showMessage(lastModifiedDate,0); textEditorWindow->load(fullFilePath); }
// === SLOTS === void MainUI::slotRefreshInstallTab(){ //Update the list of installed PBI's w/o clearing the list (loses selections) //Get the list we need (in order) slotUpdateJailMenu(); if(VISJAIL.isEmpty()){ ui->label_install_jail->setText( tr("Showing: Local System") ); } else{ ui->label_install_jail->setText( QString(tr("Showing Jail: %1")).arg(VISJAIL) ); } QStringList installList = PBI->installedList(VISJAIL, ui->actionRaw_Inst_Packages->isChecked()); //qDebug() << "Installed Pkgs:" << installList; installList.append( PBI->pendingInstallList() ); installList.removeDuplicates(); if( !ui->actionShow_Base_Packages->isChecked() ){ installList = PBI->filterBasePkgs(installList); //don't show base dependencies } //Quick finish if no items installed/pending if(installList.isEmpty()){ ui->tree_install_apps->clear(); return; } //Get the list we have now and handle items as needed //QStringList cList; for(int i=0; i<ui->tree_install_apps->topLevelItemCount(); i++){ QString item = ui->tree_install_apps->topLevelItem(i)->whatsThis(0); //Update item if necessary if(installList.contains(item)){ formatInstalledItemDisplay( ui->tree_install_apps->topLevelItem(i) ); installList.removeAll(item); //Remove it from the list - since already handled //Remove item if necessary }else{ delete ui->tree_install_apps->takeTopLevelItem(i); i--; //make sure to back up once to prevent missing the next item } } //Now add any new items to the list //qDebug() << "New Items:" << installList; for(int i=0; i<installList.length(); i++){ QTreeWidgetItem *item = new QTreeWidgetItem; //create the item //qDebug() << "New Item:" << installList[i]; item->setWhatsThis(0,installList[i]); //Now format the display formatInstalledItemDisplay(item); //qDebug() << "New Item:" << installList[i] << item->text(0); if(item->whatsThis(0).isEmpty()){ //Do not put invalid items into the display delete item; }else{ //Now insert this item onto the list ui->tree_install_apps->addTopLevelItem(item); } } ui->tree_install_apps->sortItems(0, Qt::AscendingOrder); //Make sure that there is an item selected if(ui->tree_install_apps->topLevelItemCount() > 0 ){ if( ui->tree_install_apps->selectedItems().isEmpty() ){ ui->tree_install_apps->setCurrentItem( ui->tree_install_apps->topLevelItem(0) ); } //Now re-size the columns to the minimum required width for(int i=0; i<6; i++){ ui->tree_install_apps->resizeColumnToContents(i); } } //slotUpdateSelectedPBI();; //Update the info boxes slotDisplayStats(); slotCheckSelectedItems(); if(PBI->checkForUpdates(VISJAIL)){ ui->group_updates->setVisible(true); if(VISJAIL.isEmpty()){ ui->tool_start_updates->setIcon(QIcon(":icons/view-refresh.png")); } else{ ui->tool_start_updates->setIcon(QIcon(":icons/view-jail.png")); } }else{ ui->group_updates->setVisible(false); } ui->group_jailwarn->setVisible( !VISJAIL.isEmpty() ); //If the browser app page is currently visible for this app if( (ui->stacked_browser->currentWidget() == ui->page_app) && ui->page_app->isVisible() ){ slotGoToApp(cApp); } }