ImportMegaLinksDialog::ImportMegaLinksDialog(MegaApi *megaApi, Preferences *preferences, LinkProcessor *processor, QWidget *parent) : QDialog(parent), ui(new Ui::ImportMegaLinksDialog) { ui->setupUi(this); setAttribute(Qt::WA_QuitOnClose, false); const int SLOT_HEIGHT = 35; this->megaApi = megaApi; this->linkProcessor = processor; for (int i = 0; i < linkProcessor->size(); i++) { ImportListWidgetItem *customItem = new ImportListWidgetItem(linkProcessor->getLink(i), i, ui->linkList); connect(customItem, SIGNAL(stateChanged(int,int)), this, SLOT(onLinkStateChanged(int, int))); QListWidgetItem *item = new QListWidgetItem(ui->linkList); ui->linkList->addItem(item); item->setSizeHint(customItem->size()); ui->linkList->setItemWidget(item, customItem); } int extraSlots = linkProcessor->size() - 1; if (extraSlots > 7) { extraSlots = 7; } ui->linkList->setMinimumHeight(ui->linkList->minimumHeight() + SLOT_HEIGHT * extraSlots); this->setMinimumHeight(this->minimumHeight() + SLOT_HEIGHT * extraSlots); ui->linkList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setMaximumHeight(this->minimumHeight()); QString defaultFolderPath; QString downloadFolder = QDir::toNativeSeparators(preferences->downloadFolder()); QFileInfo test(downloadFolder); if (!test.isDir()) { #ifdef WIN32 #if QT_VERSION < 0x050000 QDir defaultFolder(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + QString::fromUtf8("/MEGAsync Downloads")); #else QDir defaultFolder(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0] + QString::fromUtf8("/MEGAsync Downloads")); #endif #else #if QT_VERSION < 0x050000 QDir defaultFolder(QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + QString::fromUtf8("/MEGAsync Downloads")); #else QDir defaultFolder(QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0] + QString::fromUtf8("/MEGAsync Downloads")); #endif #endif defaultFolder.mkpath(QString::fromAscii(".")); defaultFolderPath = defaultFolder.absolutePath(); defaultFolderPath = QDir::toNativeSeparators(defaultFolderPath); } else { defaultFolderPath = downloadFolder; } ui->eLocalFolder->setText(defaultFolderPath); if (preferences->logged()) { MegaNode *testNode = megaApi->getNodeByHandle(preferences->importFolder()); if (testNode) { const char *tPath = megaApi->getNodePath(testNode); if (tPath) { ui->eMegaFolder->setText(QString::fromUtf8(tPath)); delete [] tPath; } else { delete testNode; ui->eMegaFolder->setText(tr("/MEGAsync Imports")); testNode = megaApi->getNodeByPath(tr("/MEGAsync Imports").toUtf8().constData()); } } else { ui->eMegaFolder->setText(tr("/MEGAsync Imports")); testNode = megaApi->getNodeByPath(tr("/MEGAsync Imports").toUtf8().constData()); } if (!testNode) { testNode = megaApi->getRootNode(); } MegaNode *p = testNode; while (p) { if (megaApi->isSynced(p)) { ui->cDownload->setChecked(false); this->on_cDownload_clicked(); delete p; break; } testNode = p; p = megaApi->getParentNode(testNode); delete testNode; } } else { ui->cImport->setChecked(false); ui->cImport->setVisible(false); ui->wImport->setVisible(false); ui->cDownload->setVisible(false); } connect(linkProcessor, SIGNAL(onLinkInfoAvailable(int)), this, SLOT(onLinkInfoAvailable(int))); connect(linkProcessor, SIGNAL(onLinkInfoRequestFinish()), this, SLOT(onLinkInfoRequestFinish())); finished = false; linkProcessor->requestLinkInfo(); ui->bOk->setDefault(true); }
void KIconCanvas::KIconCanvasPrivate::_k_slotLoadFiles() { q->setResizeMode(QListWidget::Fixed); QApplication::setOverrideCursor(Qt::WaitCursor); // disable updates to not trigger paint events when adding child items q->setUpdatesEnabled(false); m_bLoading = true; int i; QStringList::ConstIterator it; uint emitProgress = 10; // so we will emit it once in the beginning QStringList::ConstIterator end(mFiles.end()); for (it=mFiles.begin(), i=0; it!=end; ++it, i++) { if ( emitProgress >= 10 ) { emit q->progress(i); emitProgress = 0; } emitProgress++; if (!m_bLoading) { // user clicked on a button that will load another set of icons break; } QImage img; // Use the extension as the format. Works for XPM and PNG, but not for SVG QString path= *it; QString ext = path.right(3).toUpper(); if (ext != "SVG" && ext != "VGZ") img.load(*it); else { // Special stuff for SVG icons img = QImage(60, 60, QImage::Format_ARGB32_Premultiplied); img.fill(0); KSvgRenderer renderer(*it); if (renderer.isValid()) { QPainter p(&img); renderer.render(&p); } } if (img.isNull()) continue; if (img.width() > 60 || img.height() > 60) { if (img.width() > img.height()) { int height = (int) ((60.0 / img.width()) * img.height()); img = img.scaled(60, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } else { int width = (int) ((60.0 / img.height()) * img.width()); img = img.scaled(width, 60, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } } QPixmap pm = QPixmap::fromImage(img); QFileInfo fi(*it); QListWidgetItem *item = new QListWidgetItem(pm, fi.completeBaseName(), q); item->setData(Qt::UserRole, *it); item->setToolTip(fi.completeBaseName()); } // enable updates since we have to draw the whole view now q->setUpdatesEnabled(true); QApplication::restoreOverrideCursor(); m_bLoading = false; emit q->finished(); q->setResizeMode(QListWidget::Adjust); }
Configuration::Configuration(Applet *applet, KConfigDialog *parent) : QObject(parent), m_applet(applet) { KConfigGroup configuration = m_applet->config(); KMenu* addLauncherMenu = new KMenu(parent); QWidget* generalWidget = new QWidget; QWidget* appearanceWidget = new QWidget; QWidget* arrangementWidget = new QWidget; QWidget* actionsWidget = new QWidget; QWidget* findApplicationWidget = new QWidget; QAction* addLauncherApplicationAction = addLauncherMenu->addAction(KIcon("application-x-executable"), i18n("Add Application...")); QAction* addLauncherFromFileAction = addLauncherMenu->addAction(KIcon("inode-directory"), i18n("Add File or Directory...")); QAction* addMenuLauncher = addLauncherMenu->addAction(KIcon("start-here"), i18n("Add Menu")); KMenu* addMenuLauncherMenu = new KMenu(addLauncherMenu); addMenuLauncher->setMenu(addMenuLauncherMenu); QAction *action = addMenuLauncherMenu->addAction(QString()); action->setData("/"); action->setVisible(false); m_generalUi.setupUi(generalWidget); m_appearanceUi.setupUi(appearanceWidget); m_arrangementUi.setupUi(arrangementWidget); m_actionsUi.setupUi(actionsWidget); m_findApplicationUi.setupUi(findApplicationWidget); m_findApplicationDialog = new KDialog(parent); m_findApplicationDialog->setCaption(i18n("Find Application")); m_findApplicationDialog->setMainWidget(findApplicationWidget); m_findApplicationDialog->setButtons(KDialog::Close); m_arrangementUi.addLauncherButton->setMenu(addLauncherMenu); m_generalUi.groupingStrategy->addItem(i18n("Do Not Group"), QVariant(TaskManager::GroupManager::NoGrouping)); m_generalUi.groupingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualGrouping)); m_generalUi.groupingStrategy->addItem(i18n("By Program Name"), QVariant(TaskManager::GroupManager::ProgramGrouping)); m_generalUi.groupingStrategy->setCurrentIndex(m_generalUi.groupingStrategy->findData(QVariant(configuration.readEntry("groupingStrategy", static_cast<int>(TaskManager::GroupManager::NoGrouping))))); m_generalUi.sortingStrategy->addItem(i18n("Do Not Sort"), QVariant(TaskManager::GroupManager::NoSorting)); m_generalUi.sortingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualSorting)); m_generalUi.sortingStrategy->addItem(i18n("Alphabetically"), QVariant(TaskManager::GroupManager::AlphaSorting)); m_generalUi.sortingStrategy->addItem(i18n("By Desktop"), QVariant(TaskManager::GroupManager::DesktopSorting)); m_generalUi.sortingStrategy->setCurrentIndex(m_generalUi.sortingStrategy->findData(QVariant(configuration.readEntry("sortingStrategy", static_cast<int>(TaskManager::GroupManager::ManualSorting))))); m_generalUi.showOnlyCurrentDesktop->setChecked(configuration.readEntry("showOnlyCurrentDesktop", false)); m_generalUi.showOnlyCurrentScreen->setChecked(configuration.readEntry("showOnlyCurrentScreen", false)); m_generalUi.showOnlyMinimized->setChecked(configuration.readEntry("showOnlyMinimized", false)); m_generalUi.showOnlyTasksWithLaunchers->setChecked(configuration.readEntry("showOnlyTasksWithLaunchers", false)); m_generalUi.connectJobsWithTasks->setChecked(configuration.readEntry("connectJobsWithTasks", false)); m_generalUi.groupJobs->setChecked(configuration.readEntry("groupJobs", true)); m_generalUi.jobCloseMode->addItem(i18n("Instantly"), QVariant(InstantClose)); m_generalUi.jobCloseMode->addItem(i18n("After delay"), QVariant(DelayedClose)); m_generalUi.jobCloseMode->addItem(i18n("Manually"), QVariant(ManualClose)); m_generalUi.jobCloseMode->setCurrentIndex(m_generalUi.jobCloseMode->findData(QVariant(configuration.readEntry("jobCloseMode", static_cast<int>(DelayedClose))))); QStringList moveAnimationNames; moveAnimationNames << i18n("None") << i18n("Zoom") << i18n("Jump") << i18n("Spotlight") << i18n("Glow") << i18n("Fade"); QList<AnimationType> moveAnimationIds; moveAnimationIds << NoAnimation << ZoomAnimation << JumpAnimation << SpotlightAnimation << GlowAnimation << FadeAnimation; for (int i = 0; i < moveAnimationIds.count(); ++i) { m_appearanceUi.moveAnimation->addItem(moveAnimationNames.at(i), QVariant(moveAnimationIds.at(i))); } QStringList iconAnimationNames; iconAnimationNames << i18n("None") << i18n("Bounce") << i18n("Zoom") << i18n("Blink") << i18n("Spotlight") << i18n("Rotate") << i18n("Glow"); QList<AnimationType> iconAnimationIds; iconAnimationIds << NoAnimation << BounceAnimation << ZoomAnimation << BlinkAnimation << SpotlightAnimation << RotateAnimation << GlowAnimation; for (int i = 0; i < iconAnimationIds.count(); ++i) { m_appearanceUi.demandsAttentionAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i))); m_appearanceUi.startupAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i))); } m_appearanceUi.titleLabelMode->addItem(i18n("Never"), QVariant(NoLabel)); m_appearanceUi.titleLabelMode->addItem(i18n("On mouse-over"), QVariant(LabelOnMouseOver)); m_appearanceUi.titleLabelMode->addItem(i18n("For active icon"), QVariant(LabelForActiveIcon)); m_appearanceUi.titleLabelMode->addItem(i18n("Always"), QVariant(AlwaysShowLabel)); m_appearanceUi.titleLabelMode->setCurrentIndex(m_appearanceUi.titleLabelMode->findData(QVariant(configuration.readEntry("titleLabelMode", static_cast<int>(NoLabel))))); m_appearanceUi.activeIconIndication->addItem(i18n("No indication"), QVariant(NoIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication)); m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication))))); m_appearanceUi.useThumbnails->setChecked(configuration.readEntry("useThumbnails", false)); m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString()))); m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed"); m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(ZoomAnimation))))); m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", true)); m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation))))); m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation))))); m_arrangementUi.removeButton->setIcon(KIcon("go-previous")); m_arrangementUi.addButton->setIcon(KIcon("go-next")); m_arrangementUi.moveUpButton->setIcon(KIcon("go-up")); m_arrangementUi.moveDownButton->setIcon(KIcon("go-down")); m_arrangementUi.availableActionsListWidget->addItem(i18n("--- separator ---")); QStringList arrangement = configuration.readEntry("arrangement", QStringList("tasks")); if (!arrangement.contains("tasks")) { m_arrangementUi.availableActionsListWidget->addItem(i18n("--- tasks area ---")); } if (!arrangement.contains("jobs")) { m_arrangementUi.availableActionsListWidget->addItem(i18n("--- jobs area ---")); } for (int i = 0; i < arrangement.count(); ++i) { QListWidgetItem *item; if (arrangement.at(i) == "tasks") { item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentActionsListWidget); } else if (arrangement.at(i) == "jobs") { item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentActionsListWidget); } else if (arrangement.at(i) == "separator") { item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentActionsListWidget); } else { Launcher *launcher = m_applet->launcherForUrl(KUrl(arrangement.at(i))); if (!launcher) { continue; } item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentActionsListWidget); item->setToolTip(launcher->launcherUrl().pathOrUrl()); } m_arrangementUi.currentActionsListWidget->addItem(item); } QStringList actionNames; actionNames << i18n("Activate Item") << i18n("Activate Task") << i18n("Activate Launcher") << i18n("Show Item Menu") << i18n("Show Item Children List") << i18n("Show Item Windows") << i18n("Close Task"); QStringList actionOptions; actionOptions << "activateItem" << "activateTask" << "activateLauncher" << "showItemMenu" << "showItemChildrenList" << "showItemWindows" << "closeTask"; QStringList actionDefaults; actionDefaults << "left+" << QString('+') << "middle+" << QString('+') << QString('+') << "middle+shift" << "left+shift"; m_actionsUi.actionsTableWidget->setRowCount(actionNames.count()); m_actionsUi.actionsTableWidget->setItemDelegate(new ActionDelegate(this)); for (int i = 0; i < actionOptions.count(); ++i) { QTableWidgetItem *descriptionItem = new QTableWidgetItem(actionNames.at(i)); descriptionItem->setToolTip(actionNames.at(i)); descriptionItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QTableWidgetItem *editingItem = new QTableWidgetItem(configuration.readEntry((actionOptions.at(i) + "Action"), actionDefaults.at(i))); editingItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); m_actionsUi.actionsTableWidget->setItem(i, 0, descriptionItem); m_actionsUi.actionsTableWidget->setItem(i, 1, editingItem); } moveAnimationTypeChanged(m_appearanceUi.moveAnimation->currentIndex()); parent->addPage(generalWidget, i18n("General"), "go-home"); parent->addPage(appearanceWidget, i18n("Appearance"), "preferences-desktop-theme"); parent->addPage(arrangementWidget, i18n("Arrangement"), "format-list-unordered"); parent->addPage(actionsWidget, i18n("Actions"), "configure-shortcuts"); connect(parent, SIGNAL(okClicked()), this, SLOT(accepted())); connect(m_appearanceUi.moveAnimation, SIGNAL(currentIndexChanged(int)), this, SLOT(moveAnimationTypeChanged(int))); connect(m_arrangementUi.availableActionsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(availableActionsCurrentItemChanged(int))); connect(m_arrangementUi.currentActionsListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentActionsCurrentItemChanged(int))); connect(m_arrangementUi.removeButton, SIGNAL(clicked()), this, SLOT(removeItem())); connect(m_arrangementUi.addButton, SIGNAL(clicked()), this, SLOT(addItem())); connect(m_arrangementUi.moveUpButton, SIGNAL(clicked()), this, SLOT(moveUpItem())); connect(m_arrangementUi.moveDownButton, SIGNAL(clicked()), this, SLOT(moveDownItem())); connect(m_findApplicationUi.query, SIGNAL(textChanged(QString)), this, SLOT(findApplication(QString))); connect(addLauncherApplicationAction, SIGNAL(triggered()), m_findApplicationDialog, SLOT(show())); connect(addLauncherApplicationAction, SIGNAL(triggered()), m_findApplicationUi.query, SLOT(setFocus())); connect(addLauncherFromFileAction, SIGNAL(triggered()), this, SLOT(addLauncher())); connect(addMenuLauncherMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu())); connect(addMenuLauncherMenu, SIGNAL(triggered(QAction*)), this, SLOT(addMenu(QAction*))); connect(m_findApplicationDialog, SIGNAL(finished()), this, SLOT(closeFindApplicationDialog())); }
Configuration::Configuration(Applet *applet, KConfigDialog *parent) : QObject(parent), m_applet(applet), m_editedLauncher(NULL) { KConfigGroup configuration = m_applet->config(); KMenu *addLauncherMenu = new KMenu(parent); QWidget *generalWidget = new QWidget; QWidget *appearanceWidget = new QWidget; QWidget *arrangementWidget = new QWidget; QWidget *actionsWidget = new QWidget; QAction *addLauncherApplicationAction = addLauncherMenu->addAction(KIcon("application-x-executable"), i18n("Add Application...")); QAction *addLauncherFromFileAction = addLauncherMenu->addAction(KIcon("inode-directory"), i18n("Add File or Directory...")); QAction *addMenuLauncher = addLauncherMenu->addAction(KIcon("start-here"), i18n("Add Menu")); KMenu *addMenuLauncherMenu = new KMenu(addLauncherMenu); addMenuLauncher->setMenu(addMenuLauncherMenu); QAction *action = addMenuLauncherMenu->addAction(QString()); action->setData("/"); action->setVisible(false); m_generalUi.setupUi(generalWidget); m_appearanceUi.setupUi(appearanceWidget); m_arrangementUi.setupUi(arrangementWidget); m_actionsUi.setupUi(actionsWidget); connectWidgets(generalWidget); connectWidgets(appearanceWidget); m_arrangementUi.addLauncherButton->setMenu(addLauncherMenu); m_generalUi.groupingStrategy->addItem(i18n("Do Not Group"), QVariant(TaskManager::GroupManager::NoGrouping)); m_generalUi.groupingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualGrouping)); m_generalUi.groupingStrategy->addItem(i18n("By Program Name"), QVariant(TaskManager::GroupManager::ProgramGrouping)); m_generalUi.groupingStrategy->setCurrentIndex(m_generalUi.groupingStrategy->findData(QVariant(configuration.readEntry("groupingStrategy", static_cast<int>(TaskManager::GroupManager::NoGrouping))))); m_generalUi.sortingStrategy->addItem(i18n("Do Not Sort"), QVariant(TaskManager::GroupManager::NoSorting)); m_generalUi.sortingStrategy->addItem(i18n("Manually"), QVariant(TaskManager::GroupManager::ManualSorting)); m_generalUi.sortingStrategy->addItem(i18n("Alphabetically"), QVariant(TaskManager::GroupManager::AlphaSorting)); m_generalUi.sortingStrategy->addItem(i18n("By Desktop"), QVariant(TaskManager::GroupManager::DesktopSorting)); m_generalUi.sortingStrategy->setCurrentIndex(m_generalUi.sortingStrategy->findData(QVariant(configuration.readEntry("sortingStrategy", static_cast<int>(TaskManager::GroupManager::ManualSorting))))); m_generalUi.showOnlyCurrentDesktop->setChecked(configuration.readEntry("showOnlyCurrentDesktop", false)); m_generalUi.showOnlyCurrentActivity->setChecked(configuration.readEntry("showOnlyCurrentActivity", true)); m_generalUi.showOnlyCurrentScreen->setChecked(configuration.readEntry("showOnlyCurrentScreen", false)); m_generalUi.showOnlyMinimized->setChecked(configuration.readEntry("showOnlyMinimized", false)); m_generalUi.showOnlyTasksWithLaunchers->setChecked(configuration.readEntry("showOnlyTasksWithLaunchers", false)); m_generalUi.connectJobsWithTasks->setChecked(configuration.readEntry("connectJobsWithTasks", false)); m_generalUi.groupJobs->setChecked(configuration.readEntry("groupJobs", true)); m_generalUi.jobCloseMode->addItem(i18n("Instantly"), QVariant(InstantClose)); m_generalUi.jobCloseMode->addItem(i18n("After delay"), QVariant(DelayedClose)); m_generalUi.jobCloseMode->addItem(i18n("Manually"), QVariant(ManualClose)); m_generalUi.jobCloseMode->setCurrentIndex(m_generalUi.jobCloseMode->findData(QVariant(configuration.readEntry("jobCloseMode", static_cast<int>(DelayedClose))))); QStringList moveAnimationNames; moveAnimationNames << i18n("None") << i18n("Zoom") << i18n("Jump") << i18n("Spotlight") << i18n("Glow") << i18n("Fade"); QList<AnimationType> moveAnimationIds; moveAnimationIds << NoAnimation << ZoomAnimation << JumpAnimation << SpotlightAnimation << GlowAnimation << FadeAnimation; for (int i = 0; i < moveAnimationIds.count(); ++i) { m_appearanceUi.moveAnimation->addItem(moveAnimationNames.at(i), QVariant(moveAnimationIds.at(i))); } QStringList iconAnimationNames; iconAnimationNames << i18n("None") << i18n("Bounce") << i18n("Zoom") << i18n("Blink") << i18n("Spotlight") << i18n("Rotate") << i18n("Glow"); QList<AnimationType> iconAnimationIds; iconAnimationIds << NoAnimation << BounceAnimation << ZoomAnimation << BlinkAnimation << SpotlightAnimation << RotateAnimation << GlowAnimation; for (int i = 0; i < iconAnimationIds.count(); ++i) { m_appearanceUi.demandsAttentionAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i))); m_appearanceUi.startupAnimation->addItem(iconAnimationNames.at(i), QVariant(iconAnimationIds.at(i))); } m_appearanceUi.titleLabelMode->addItem(i18n("Never"), QVariant(NoLabel)); m_appearanceUi.titleLabelMode->addItem(i18n("On mouse-over"), QVariant(MouseOverLabel)); m_appearanceUi.titleLabelMode->addItem(i18n("For active icon"), QVariant(ActiveIconLabel)); m_appearanceUi.titleLabelMode->addItem(i18n("Always"), QVariant(AlwaysShowLabel)); m_appearanceUi.titleLabelMode->setCurrentIndex(m_appearanceUi.titleLabelMode->findData(QVariant(configuration.readEntry("titleLabelMode", static_cast<int>(AlwaysShowLabel))))); m_appearanceUi.activeIconIndication->addItem(i18n("None"), QVariant(NoIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Zoom"), QVariant(ZoomIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Glow"), QVariant(GlowIndication)); m_appearanceUi.activeIconIndication->addItem(i18n("Fade"), QVariant(FadeIndication)); m_appearanceUi.activeIconIndication->setCurrentIndex(m_appearanceUi.activeIconIndication->findData(QVariant(configuration.readEntry("activeIconIndication", static_cast<int>(FadeIndication))))); m_appearanceUi.customBackgroundImage->setUrl(KUrl(configuration.readEntry("customBackgroundImage", QString()))); m_appearanceUi.customBackgroundImage->setFilter("image/svg+xml image/svg+xml-compressed"); if (m_applet->location() != Plasma::Floating && (!m_applet->containment() || m_applet->containment()->objectName() != "FancyPanel")) { m_appearanceUi.customBackgroundImageLabel->hide(); m_appearanceUi.customBackgroundImage->hide(); } m_appearanceUi.moveAnimation->setCurrentIndex(moveAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("moveAnimation", static_cast<int>(GlowAnimation))))); m_appearanceUi.parabolicMoveAnimation->setChecked(configuration.readEntry("parabolicMoveAnimation", false)); m_appearanceUi.demandsAttentionAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("demandsAttentionAnimation", static_cast<int>(BlinkAnimation))))); m_appearanceUi.startupAnimation->setCurrentIndex(iconAnimationIds.indexOf(static_cast<AnimationType>(configuration.readEntry("startupAnimation", static_cast<int>(BounceAnimation))))); m_arrangementUi.removeButton->setIcon(KIcon("go-previous")); m_arrangementUi.addButton->setIcon(KIcon("go-next")); m_arrangementUi.moveUpButton->setIcon(KIcon("go-up")); m_arrangementUi.moveDownButton->setIcon(KIcon("go-down")); KConfig kickoffConfiguration("kickoffrc", KConfig::NoGlobals); KConfigGroup favoritesGroup(&kickoffConfiguration, "Favorites"); const QStringList currentEntries = configuration.readEntry("arrangement", QStringList("tasks")); QStringList availableEntries; availableEntries << i18n("--- separator ---") << i18n("--- tasks area ---") << i18n("--- jobs area ---") << "menu:/"; availableEntries.append(favoritesGroup.readEntry("FavoriteURLs", QStringList())); for (int i = 0; i < currentEntries.count(); ++i) { QListWidgetItem *item = NULL; if (currentEntries.at(i) == "tasks") { item = new QListWidgetItem(i18n("--- tasks area ---"), m_arrangementUi.currentEntriesListWidget); } else if (currentEntries.at(i) == "jobs") { item = new QListWidgetItem(i18n("--- jobs area ---"), m_arrangementUi.currentEntriesListWidget); } else if (currentEntries.at(i) == "separator") { item = new QListWidgetItem(i18n("--- separator ---"), m_arrangementUi.currentEntriesListWidget); } else { if (hasEntry(currentEntries.at(i), false)) { continue; } Launcher *launcher = m_applet->launcherForUrl(KUrl(currentEntries.at(i))); if (!launcher) { continue; } item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.currentEntriesListWidget); item->setToolTip(launcher->launcherUrl().pathOrUrl()); m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded()); } m_arrangementUi.currentEntriesListWidget->addItem(item); } for (int i = 0; i < availableEntries.count(); ++i) { if (i > 0 && hasEntry(availableEntries.at(i), false)) { continue; } QListWidgetItem *item = NULL; if (availableEntries.at(i).startsWith("--- ")) { item = new QListWidgetItem(availableEntries.at(i), m_arrangementUi.availableEntriesListWidget); } else { Launcher *launcher = m_applet->launcherForUrl(KUrl(availableEntries.at(i))); if (!launcher) { continue; } item = new QListWidgetItem(launcher->icon(), launcher->title(), m_arrangementUi.availableEntriesListWidget); item->setToolTip(launcher->launcherUrl().pathOrUrl()); m_rules[launcher->launcherUrl().pathOrUrl()] = qMakePair(launcher->rules(), launcher->isExcluded()); } m_arrangementUi.availableEntriesListWidget->addItem(item); } QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction> iconActions = m_applet->iconActions(); QMap<QPair<Qt::MouseButtons, Qt::KeyboardModifiers>, IconAction>::iterator iterator; int i = 0; m_actionsUi.actionsTableWidget->setItemDelegateForColumn(0, new ActionDelegate(this)); m_actionsUi.actionsTableWidget->setItemDelegateForColumn(1, new TriggerDelegate(this)); for (iterator = iconActions.begin(); iterator != iconActions.end(); ++iterator) { if (iterator.key().first == Qt::NoButton) { continue; } QStringList action; if (iterator.key().first & Qt::LeftButton) { action.append("left"); } if (iterator.key().first & Qt::MiddleButton) { action.append("middle"); } if (iterator.key().first & Qt::RightButton) { action.append("right"); } if (iterator.key().second & Qt::ShiftModifier) { action.append("shift"); } if (iterator.key().second & Qt::ControlModifier) { action.append("ctrl"); } if (iterator.key().second & Qt::AltModifier) { action.append("alt"); } QTableWidgetItem *triggerItem = new QTableWidgetItem(action.join(QChar('+'))); triggerItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); QTableWidgetItem *actionItem = new QTableWidgetItem(QString::number(static_cast<int>(iterator.value()))); actionItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled); m_actionsUi.actionsTableWidget->setRowCount(i + 1); m_actionsUi.actionsTableWidget->setItem(i, 0, actionItem); m_actionsUi.actionsTableWidget->setItem(i, 1, triggerItem); ++i; } moveAnimationTypeChanged(m_appearanceUi.moveAnimation->currentIndex()); parent->addPage(generalWidget, i18n("General"), "go-home"); parent->addPage(appearanceWidget, i18n("Appearance"), "preferences-desktop-theme"); parent->addPage(arrangementWidget, i18n("Arrangement"), "format-list-unordered"); parent->addPage(actionsWidget, i18n("Actions"), "configure-shortcuts"); connect(parent, SIGNAL(applyClicked()), this, SLOT(save())); connect(parent, SIGNAL(okClicked()), this, SLOT(save())); connect(m_appearanceUi.moveAnimation, SIGNAL(currentIndexChanged(int)), this, SLOT(moveAnimationTypeChanged(int))); connect(m_appearanceUi.customBackgroundImage, SIGNAL(textChanged(QString)), this, SLOT(modify())); connect(m_arrangementUi.availableEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(availableEntriesCurrentItemChanged(int))); connect(m_arrangementUi.currentEntriesListWidget, SIGNAL(currentRowChanged(int)), this, SLOT(currentEntriesCurrentItemChanged(int))); connect(m_arrangementUi.removeButton, SIGNAL(clicked()), this, SLOT(removeItem())); connect(m_arrangementUi.addButton, SIGNAL(clicked()), this, SLOT(addItem())); connect(m_arrangementUi.moveUpButton, SIGNAL(clicked()), this, SLOT(moveUpItem())); connect(m_arrangementUi.moveDownButton, SIGNAL(clicked()), this, SLOT(moveDownItem())); connect(m_arrangementUi.editLauncherButton, SIGNAL(clicked()), this, SLOT(editLauncher())); connect(m_actionsUi.actionsTableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(actionClicked(QModelIndex))); connect(m_actionsUi.actionsTableWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(actionSelectionChanged())); connect(m_actionsUi.addButton, SIGNAL(clicked()), this, SLOT(addAction())); connect(m_actionsUi.removeButton, SIGNAL(clicked()), this, SLOT(removeAction())); connect(addLauncherApplicationAction, SIGNAL(triggered()), this, SLOT(findLauncher())); connect(addLauncherFromFileAction, SIGNAL(triggered()), this, SLOT(addLauncher())); connect(addMenuLauncherMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu())); connect(addMenuLauncherMenu, SIGNAL(triggered(QAction*)), this, SLOT(addMenu(QAction*))); }
//------------------------------------------------------------------------------ // Name: on_btnAdd_clicked() // Desc: //------------------------------------------------------------------------------ void DialogArguments::on_btnAdd_clicked() { QListWidgetItem *p = new QListWidgetItem(tr("New Argument"), ui->listWidget); p->setFlags(p->flags() | Qt::ItemIsEditable); }
wxString wxListBox::GetString(unsigned int n) const { QListWidgetItem* item = m_qtListWidget->item(n); wxCHECK_MSG(item != NULL, wxString(), wxT("wrong listbox index") ); return wxQtConvertString( item->text() ); }
void *wxListBox::DoGetItemClientData(unsigned int n) const { QListWidgetItem* item = m_qtListWidget->item(n); QVariant variant = item->data(Qt::UserRole); return variant.value<void *>(); }
// // user_edit_dialog // user_edit_dialog::user_edit_dialog(int role_oid) { m_role_oid = role_oid; setWindowTitle(role_oid==0?tr("Add a database user"):tr("Edit a database user")); m_mode = (role_oid==0)?new_user:existing_user; user u; if (m_mode == existing_user) u.fetch_by_oid(role_oid); QVBoxLayout* top_layout = new QVBoxLayout; db_cnx db; QString dbname=QString(tr("Current database: <b>%1</b>")).arg(db.dbname().toHtmlEscaped()); QLabel* ldb = new QLabel(dbname); ldb->setTextFormat(Qt::RichText); top_layout->addWidget(ldb, 0, Qt::AlignHCenter); QFormLayout* layout = new QFormLayout; m_fullname = new QLineEdit; #ifdef PERM_LOGIN m_perm_login = new QCheckBox; #endif m_perm_connect = new QCheckBox; m_registered = new QCheckBox; m_email = new QLineEdit; /* m_login, m_password and m_password2 should keep the same width even though m_password is part of a QHBoxLayout and the others are not (as they're tied to the outer QFormLayout). This is why they're implemented as instance of the "field_follow_size" class */ m_login = new field_follow_size; //QLineEdit; m_login->setMaxLength(name_maxlength); m_password = new field_follow_size; m_password2 = new field_follow_size; connect(m_password, SIGNAL(resized(const QSize)), m_password2, SLOT(follow_resize(const QSize))); connect(m_password, SIGNAL(resized(const QSize)), m_login, SLOT(follow_resize(const QSize))); m_change_password_btn = new QCheckBox(tr("Change")); m_password->setEchoMode(QLineEdit::Password); m_password2->setEchoMode(QLineEdit::Password); m_password->setMaxLength(name_maxlength); m_password2->setMaxLength(name_maxlength); QHBoxLayout* vlpassw = new QHBoxLayout; vlpassw->addWidget(m_password); vlpassw->addWidget(m_change_password_btn); if (m_mode==existing_user) { m_password->setEnabled(false); m_password2->setEnabled(false); m_change_password_btn->setEnabled(true); connect(m_change_password_btn, SIGNAL(clicked()), this, SLOT(enable_alter_user())); } else { m_change_password_btn->setEnabled(false); } m_qlist_roles = new QListWidget; QList<user> roles_list = users_repository::get_list(); QList<QString> assigned_roles = user::granted_roles(m_role_oid); for (int ri=0; ri<roles_list.size(); ri++) { const user& u = roles_list.at(ri); if (!u.m_can_login && u.m_role_oid>0) { // keep only entries from pg_roles without the LOGIN privilege // they're supposed to be roles to assign rather than users QListWidgetItem* item = new QListWidgetItem(u.m_db_login, m_qlist_roles); item->setFlags(Qt::ItemIsUserCheckable|/*Qt::ItemIsSelectable|*/Qt::ItemIsEnabled); item->setCheckState(assigned_roles.indexOf(u.m_db_login) >= 0 ? Qt::Checked : Qt::Unchecked); } } // m_case_sensitive = new QCheckBox; m_custom1 = new custom_user_field; m_custom2 = new custom_user_field; m_custom3 = new custom_user_field; if (u.m_is_superuser) { QLabel* label = new QLabel(tr("<b>Superuser account: unrestricted permissions.</b>")); layout->addRow(QString(), label); } layout->addRow(tr("Login <sup>(*)</sup>:"), m_login); layout->addRow(tr("Password <sup>(*)</sup>:"), /*m_password*/ vlpassw); layout->addRow(tr("Retype password <sup>(*)</sup>:"), m_password2); /* m_password2->resize(QSize(m_password->width(), m_password2->height())); m_password2->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); */ #ifdef PERM_LOGIN add_field_with_help(layout, tr("Active <sup>(*)</sup>:"), m_perm_login, tr("The database role has the LOGIN capability.")); #endif add_field_with_help(layout, tr("Can connect <sup>(**)</sup>:"), m_perm_connect, tr("The login has CONNECT permission on this database.")); add_field_with_help(layout, tr("Registered <sup>(**)</sup>:"), m_registered, tr("The user account corresponds to an operator in this database.")); layout->addRow(tr("Operator name <sup>(*)</sup>:"), m_fullname); layout->addRow(tr("Groups <sup>(*)</sup>:"), m_qlist_roles); layout->addRow(tr("Custom field #1 <sup>(**)</sup>:"), m_custom1); layout->addRow(tr("Custom field #2 <sup>(**)</sup>:"), m_custom2); layout->addRow(tr("Custom field #3 <sup>(**)</sup>:"), m_custom3); top_layout->addLayout(layout); QLabel* lremark = new QLabel(tr("(*) Fields marked with <sup>(*)</sup> apply across all databases of this server.<br>(**) Fields marked with <sup>(**)</sup> apply only to the current database: <b>%1</b>.").arg(db.dbname().toHtmlEscaped())); QFont smf = lremark->font(); smf.setPointSize((smf.pointSize()*8)/10); lremark->setFont(smf); top_layout->addWidget(lremark); m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); top_layout->addWidget(m_buttons); connect(m_buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject())); setLayout(top_layout); m_user_id = 0; if (role_oid!=0) { /* set readOnly but not disabled because disabled is hard to read and the login is the major information */ m_login->setReadOnly(true); //m_login->setEnabled(false); // u is loaded (for an existing role) at the top of the function m_user_id = u.m_user_id; m_fullname->setText(u.m_fullname); m_login->setText(u.m_login); m_initial_login = u.m_login; m_custom1->setPlainText(u.m_custom_field1); m_custom2->setPlainText(u.m_custom_field2); m_custom3->setPlainText(u.m_custom_field3); #ifdef PERM_LOGIN m_perm_login->setChecked(u.m_can_login); #endif m_perm_connect->setChecked(u.m_can_connect); m_registered->setChecked(u.m_user_id!=0); } connect(m_registered, SIGNAL(clicked()), this, SLOT(enable_fields())); enable_fields(); }
void SvgCanvas::actionExport_to_callback() { QDialog dialog; ExportToDialog export_to_dialog; export_to_dialog.setupUi(&dialog); QListWidget *list = export_to_dialog.formats_listWidget; QListWidgetItem *item; //Pixmaps formats QList<QByteArray> formats=QImageWriter::supportedImageFormats(); for(int i=0;i<formats.size();i++) { QString text(formats[i]); item=new QListWidgetItem(text,list); item->setData(1,QVariant(PIXMAP)); } //Vector formats formats= QPicture::outputFormats(); for(int i=0;i<formats.size();i++) { QString text(formats[i]); item=new QListWidgetItem(text,list); item->setData(1,QVariant(PICTURE)); } item=new QListWidgetItem("ps",list); item->setData(1,QVariant(PRINTER)); item=new QListWidgetItem("pdf",list); item->setData(1,QVariant(PDF)); item=new QListWidgetItem("svg",list); item->setData(1,QVariant(SVG)); int ok=dialog.exec(); if(ok==QDialog::Rejected) return; item =list->currentItem(); int format=item->data(1).toInt(); QPainter plot; switch(format) { case PIXMAP: { bool ok; int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok); if(!ok) return; h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok); if(!ok) return; QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save"); if(s.isEmpty()) return; QImage image(w,h,QImage::Format_RGB32); plot.begin(&image); svg_plot->renderer()->render(&plot); plot.end(); image.save(s,item->data(0).toString().toLocal8Bit().data()); } break; case PICTURE: { bool ok; int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok); if(!ok) return; h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok); if(!ok) return; QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save"); if(s.isEmpty()) return; QPicture image; const QRect r(0,0,w,h); image.setBoundingRect(r); plot.begin(&image); svg_plot->renderer()->render(&plot); plot.end(); image.save(s,item->data(0).toString().toLocal8Bit().data()); } break; case PRINTER: { QPrinter p; QPrintDialog printDialog(&p, this); if (printDialog.exec() != QDialog::Accepted) return; plot.begin(&p); svg_plot->renderer()->render(&plot); plot.end(); } break; case PDF: { QPrinter p; QPrintDialog printDialog(&p, this); p.setOutputFormat(QPrinter::PdfFormat); if (printDialog.exec() != QDialog::Accepted) return; plot.begin(&p); svg_plot->renderer()->render(&plot); plot.end(); } break; case SVG: { QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", tr("*.svg")); QSvgGenerator p; p.setFileName(fileName); plot.begin(&p); svg_plot->renderer()->render(&plot); plot.end(); } } }
role_perms_edit_dialog::role_perms_edit_dialog(int role_oid) { m_role_oid = role_oid; db_ctxt dbc; setWindowTitle(role_oid==0?tr("Add a group"):tr("Edit group permissions")); QVBoxLayout* top_layout = new QVBoxLayout(this); db_role role(m_role_oid); if (role_oid > 0) role.fetch_properties(&dbc); top_layout->addWidget(new QLabel(tr("Name of role:"))); m_role_name = new QLineEdit(role.name()); m_role_name->setMaxLength(name_maxlength); top_layout->addWidget(m_role_name); top_layout->addWidget(new QLabel(tr("Access to restricted identities:"))); m_list_idents = new QListWidget(); top_layout->addWidget(m_list_idents); identities idents; idents.fetch(); m_a_ids = accessible_identities(m_role_oid, &dbc); identities::const_iterator iter1; if (!dbc.m_db->datab()->has_row_level_security()) { m_list_idents->addItem(tr("Row level security is unavailable on this server.")); m_list_idents->setEnabled(false); } else for (iter1 = idents.begin(); iter1 != idents.end(); ++iter1) { /* Only the restricted identities are shown in the list, since access control through RLS policies applies only with them. That may disconcert users, but showing non-restricted identities without the possibility of unchecking them would probably be worst. */ if (!iter1->second.m_is_restricted) continue; QListWidgetItem* item = new QListWidgetItem(iter1->second.m_email_addr); m_list_idents->addItem(item); item->setCheckState(m_a_ids.contains(iter1->second.m_identity_id) ? Qt::Checked : Qt::Unchecked); item->setData(Qt::UserRole, iter1->second.m_identity_id); } if (m_role_oid > 0 && role.is_superuser()) { QLabel* label = new QLabel(tr("<b>This role is superuser, implying all permissions on all database objects.</b>")); top_layout->addWidget(label); } #if 0 m_description = new QPlainTextEdit; top_layout->addWidget(m_description); #endif top_layout->addWidget(new QLabel(tr("Permissions:"))); m_perm_read = new QCheckBox(tr("Read messages")); m_perm_update = new QCheckBox(tr("Modify messages (status)")); m_perm_trash = new QCheckBox(tr("Trash messages")); m_perm_delete = new QCheckBox(tr("Delete messages")); m_perm_compose = new QCheckBox(tr("Write new messages")); m_perm_basic_management = new QCheckBox(tr("Define tags and filters")); QCheckBox* tab[] = {m_perm_read, m_perm_update, m_perm_trash, m_perm_delete, m_perm_compose, m_perm_basic_management}; for (uint i=0; i<sizeof(tab)/sizeof(tab[0]); i++) { top_layout->addWidget(tab[i]); if (role.is_superuser()) tab[i]->setEnabled(false); } m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); top_layout->addStretch(1); top_layout->addWidget(m_buttons); connect(m_buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(m_buttons, SIGNAL(rejected()), this, SLOT(reject())); set_checkboxes(); }
void role_perms_edit_dialog::set_grants() { db_ctxt dbc(true); struct { QCheckBox* checkbox; const char* ability; } mail_perms[] = { {m_perm_read, "read"}, {m_perm_update, "update"}, {m_perm_trash, "trash"}, {m_perm_delete, "delete"}, {m_perm_compose, "compose"}, {m_perm_basic_management, "admin-level1"}, }; QString rolname = m_role_name->text().trimmed(); try { dbc.m_db->begin_transaction(); if (!m_role_oid) { // Create the new role user::create_db_user(rolname, QString(), false, &dbc); m_role_oid = user::oid_db_role(rolname, true); if (!m_role_oid) { QMessageBox::critical(this, tr("Error"), tr("The role could not be created.")); return; } } db_role role(m_role_oid); role.fetch_properties(&dbc); if (rolname != role.name()) { // Rename it in the db role.rename(rolname, &dbc); } for (uint iperm=0; iperm<sizeof(mail_perms)/sizeof(mail_perms[0]); iperm++) { // Set or unset permissions to exercise ability on messages DBG_PRINTF(5, "processing permissions for ability: %s", mail_perms[iperm].ability); QList<db_obj_privilege> privs = db_obj_privilege::ability_privileges(mail_perms[iperm].ability, &dbc); for (int pi=0; pi < privs.size(); pi++) { if (mail_perms[iperm].checkbox->isChecked()) role.grant(privs.at(pi), &dbc); else role.revoke(privs.at(pi), &dbc); } } if (dbc.m_db->datab()->has_row_level_security()) { QList<int> list_ids; // list of checked private identities bool ids_changed = false; // did any checkbox switch state? for (int row=0; row < m_list_idents->count(); row++) { QListWidgetItem* item = m_list_idents->item(row); int iid = item->data(Qt::UserRole).toInt(); // identity_id if ((item->checkState() == Qt::Checked) != m_a_ids.contains(iid)) // compare 2 states ids_changed = true; if (item->checkState() == Qt::Checked) list_ids.append(iid); } if (ids_changed) { // call set_identity_permissions(in_oid, in_identities int[], in_perms char[] = ['A']); sql_stream s("select set_identity_permissions(:o, :t, null)", *dbc.m_db); s << m_role_oid << list_ids; } } dbc.m_db->commit_transaction(); } catch(db_excpt& p) { dbc.m_db->rollback_transaction(); DBEXCPT (p); } }
QWidget* ExtensionDialog::CreateWidget( extension_widget_t *p_widget ) { QLabel *label = NULL; QPushButton *button = NULL; QTextBrowser *textArea = NULL; QLineEdit *textInput = NULL; QCheckBox *checkBox = NULL; QComboBox *comboBox = NULL; QListWidget *list = NULL; struct extension_widget_t::extension_widget_value_t *p_value = NULL; assert( p_widget->p_sys_intf == NULL ); switch( p_widget->type ) { case EXTENSION_WIDGET_LABEL: label = new QLabel( qfu( p_widget->psz_text ), this ); p_widget->p_sys_intf = label; label->setTextFormat( Qt::RichText ); label->setOpenExternalLinks( true ); return label; case EXTENSION_WIDGET_BUTTON: button = new QPushButton( qfu( p_widget->psz_text ), this ); clickMapper->setMapping( button, new WidgetMapper( p_widget ) ); CONNECT( button, clicked(), clickMapper, map() ); p_widget->p_sys_intf = button; return button; case EXTENSION_WIDGET_IMAGE: label = new QLabel( this ); label->setPixmap( QPixmap( qfu( p_widget->psz_text ) ) ); if( p_widget->i_width > 0 ) label->setMaximumWidth( p_widget->i_width ); if( p_widget->i_height > 0 ) label->setMaximumHeight( p_widget->i_height ); label->setScaledContents( true ); p_widget->p_sys_intf = label; return label; case EXTENSION_WIDGET_HTML: textArea = new QTextBrowser( this ); textArea->setOpenExternalLinks( true ); textArea->setHtml( qfu( p_widget->psz_text ) ); p_widget->p_sys_intf = textArea; return textArea; case EXTENSION_WIDGET_TEXT_FIELD: textInput = new QLineEdit( this ); textInput->setText( qfu( p_widget->psz_text ) ); textInput->setReadOnly( false ); textInput->setEchoMode( QLineEdit::Normal ); inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) ); /// @note: maybe it would be wiser to use textEdited here? CONNECT( textInput, textChanged(const QString &), inputMapper, map() ); p_widget->p_sys_intf = textInput; return textInput; case EXTENSION_WIDGET_PASSWORD: textInput = new QLineEdit( this ); textInput->setText( qfu( p_widget->psz_text ) ); textInput->setReadOnly( false ); textInput->setEchoMode( QLineEdit::Password ); inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) ); /// @note: maybe it would be wiser to use textEdited here? CONNECT( textInput, textChanged(const QString &), inputMapper, map() ); p_widget->p_sys_intf = textInput; return textInput; case EXTENSION_WIDGET_CHECK_BOX: checkBox = new QCheckBox( this ); checkBox->setText( qfu( p_widget->psz_text ) ); checkBox->setChecked( p_widget->b_checked ); clickMapper->setMapping( checkBox, new WidgetMapper( p_widget ) ); CONNECT( checkBox, stateChanged( int ), clickMapper, map() ); p_widget->p_sys_intf = checkBox; return checkBox; case EXTENSION_WIDGET_DROPDOWN: comboBox = new QComboBox( this ); comboBox->setEditable( false ); for( p_value = p_widget->p_values; p_value != NULL; p_value = p_value->p_next ) { comboBox->addItem( qfu( p_value->psz_text ), p_value->i_id ); } /* Set current item */ if( p_widget->psz_text ) { int idx = comboBox->findText( qfu( p_widget->psz_text ) ); if( idx >= 0 ) comboBox->setCurrentIndex( idx ); } selectMapper->setMapping( comboBox, new WidgetMapper( p_widget ) ); CONNECT( comboBox, currentIndexChanged( const QString& ), selectMapper, map() ); return comboBox; case EXTENSION_WIDGET_LIST: list = new QListWidget( this ); list->setSelectionMode( QAbstractItemView::ExtendedSelection ); for( p_value = p_widget->p_values; p_value != NULL; p_value = p_value->p_next ) { QListWidgetItem *item = new QListWidgetItem( qfu( p_value->psz_text ) ); item->setData( Qt::UserRole, p_value->i_id ); list->addItem( item ); } selectMapper->setMapping( list, new WidgetMapper( p_widget ) ); CONNECT( list, itemSelectionChanged(), selectMapper, map() ); return list; default: msg_Err( p_intf, "Widget type %d unknown", p_widget->type ); return NULL; } }
QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ) , mMapCanvas( mapCanvas ) { setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) ); /////////////////////////////////////////////////////////// // Properties stored in map canvas's QgsMapRenderer // these ones are propagated to QgsProject by a signal QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer(); QGis::UnitType myUnit = myRenderer->mapUnits(); setMapUnits( myUnit ); // we need to initialize it, since the on_cbxProjectionEnabled_stateChanged() // callback triggered by setChecked() might use it. mProjectSrsId = myRenderer->destinationCrs().srsid(); //see if the user wants on the fly projection enabled bool myProjectionEnabled = myRenderer->hasCrsTransformEnabled(); cbxProjectionEnabled->setChecked( myProjectionEnabled ); QgsDebugMsg( "Read project CRSID: " + QString::number( mProjectSrsId ) ); projectionSelector->setSelectedCrsId( mProjectSrsId ); projectionSelector->setEnabled( myProjectionEnabled ); /////////////////////////////////////////////////////////// // Properties stored in QgsProject title( QgsProject::instance()->title() ); // get the manner in which the number of decimal places in the mouse // position display is set (manual or automatic) bool automaticPrecision = QgsProject::instance()->readBoolEntry( "PositionPrecision", "/Automatic" ); if ( automaticPrecision ) { radAutomatic->setChecked( true ); spinBoxDP->setDisabled( true ); labelDP->setDisabled( true ); } else { radManual->setChecked( true ); } cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 ); int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); spinBoxDP->setValue( dp ); QString format = QgsProject::instance()->readEntry( "PositionPrecision", "/DegreeFormat", "D" ); if ( format == "DM" ) radDM->setChecked( true ); else if ( format == "DMS" ) radDMS->setChecked( true ); else radD->setChecked( true ); //get the color selections and set the button color accordingly int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 ); int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 ); int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 ); int myAlphaInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 ); QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt, myAlphaInt ); pbnSelectionColor->setColor( myColor ); //get the color for map canvas background and set button color accordingly (default white) myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 ); myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 ); myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 ); myColor = QColor( myRedInt, myGreenInt, myBlueInt ); pbnCanvasColor->setColor( myColor ); //get project scales QStringList myScales = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ); if ( !myScales.isEmpty() ) { QStringList::const_iterator scaleIt = myScales.constBegin(); for ( ; scaleIt != myScales.constEnd(); ++scaleIt ) { QListWidgetItem* newItem = new QListWidgetItem( lstScales ); newItem->setText( *scaleIt ); newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); lstScales->addItem( newItem ); } } grpProjectScales->setChecked( QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" ) ); QgsMapLayer* currentLayer = 0; QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); if ( mMapCanvas->currentLayer() ) { mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid(); } else if ( mapLayers.size() > 0 ) { mLayerSrsId = mapLayers.begin().value()->crs().srsid(); } else { mLayerSrsId = mProjectSrsId; } twIdentifyLayers->setColumnCount( 3 ); twIdentifyLayers->horizontalHeader()->setVisible( true ); twIdentifyLayers->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Layer" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "Type" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "Identifiable" ) ) ); twIdentifyLayers->setRowCount( mapLayers.size() ); twIdentifyLayers->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); int i = 0; for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ ) { currentLayer = it.value(); QTableWidgetItem *twi = new QTableWidgetItem( QString::number( i ) ); twIdentifyLayers->setVerticalHeaderItem( i, twi ); twi = new QTableWidgetItem( currentLayer->name() ); twi->setData( Qt::UserRole, it.key() ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 0, twi ); QString type; if ( currentLayer->type() == QgsMapLayer::VectorLayer ) { type = tr( "Vector" ); } else if ( currentLayer->type() == QgsMapLayer::RasterLayer ) { QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( currentLayer ); if ( rl && rl->providerType() == "wms" ) { type = tr( "WMS" ); } else { type = tr( "Raster" ); } } twi = new QTableWidgetItem( type ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 1, twi ); QCheckBox *cb = new QCheckBox(); cb->setChecked( !noIdentifyLayerIdList.contains( currentLayer->id() ) ); twIdentifyLayers->setCellWidget( i, 2, cb ); } grpOWSServiceCapabilities->setChecked( QgsProject::instance()->readBoolEntry( "WMSServiceCapabilities", "/", false ) ); mWMSTitle->setText( QgsProject::instance()->readEntry( "WMSServiceTitle", "/" ) ); mWMSContactOrganization->setText( QgsProject::instance()->readEntry( "WMSContactOrganization", "/", "" ) ); mWMSContactPerson->setText( QgsProject::instance()->readEntry( "WMSContactPerson", "/", "" ) ); mWMSContactMail->setText( QgsProject::instance()->readEntry( "WMSContactMail", "/", "" ) ); mWMSContactPhone->setText( QgsProject::instance()->readEntry( "WMSContactPhone", "/", "" ) ); mWMSAbstract->setPlainText( QgsProject::instance()->readEntry( "WMSServiceAbstract", "/", "" ) ); mWMSOnlineResourceLineEdit->setText( QgsProject::instance()->readEntry( "WMSOnlineResource", "/", "" ) ); mWMSUrlLineEdit->setText( QgsProject::instance()->readEntry( "WMSUrl", "/", "" ) ); bool ok; QStringList values; mWMSExtMinX->setValidator( new QDoubleValidator( mWMSExtMinX ) ); mWMSExtMinY->setValidator( new QDoubleValidator( mWMSExtMinY ) ); mWMSExtMaxX->setValidator( new QDoubleValidator( mWMSExtMaxX ) ); mWMSExtMaxY->setValidator( new QDoubleValidator( mWMSExtMaxY ) ); values = QgsProject::instance()->readListEntry( "WMSExtent", "/", &ok ); grpWMSExt->setChecked( ok && values.size() == 4 ); if ( grpWMSExt->isChecked() ) { mWMSExtMinX->setText( values[0] ); mWMSExtMinY->setText( values[1] ); mWMSExtMaxX->setText( values[2] ); mWMSExtMaxY->setText( values[3] ); } values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", &ok ); grpWMSList->setChecked( ok && values.size() > 0 ); if ( grpWMSList->isChecked() ) { mWMSList->addItems( values ); } else { values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok ); grpWMSList->setChecked( ok && values.size() > 0 ); if ( grpWMSList->isChecked() ) { QStringList list; foreach ( QString value, values ) { list << QString( "EPSG:%1" ).arg( value ); } mWMSList->addItems( list ); }
void Details :: describePlanet() { fileIndex = qBound(0, fileIndex, filesCount() - 1); bool exists = planet != A::Planet_None; positionLabel -> setVisible(exists); aspectsList -> setVisible(exists); powerLabel -> setVisible(exists); if (!exists) return; const A::Planet& p = file(fileIndex)->horoscope().planets[planet]; QString powerText = A::describePowerInHtml(p, file(fileIndex)->horoscope()); if (!powerText.isEmpty()) powerText = "<p align='center'><b><i>" + QString("<font color='#71aeec' size='+2'>+%1</font> | " "<font color='#dfb096' size='+2'>%2</font>") .arg(p.power.dignity) .arg(p.power.deficient) + "</i></b></p>" + powerText; positionLabel -> setText(A::describePlanetCoordInHtml(p)); powerLabel -> setText(powerText); aspectsList->clear(); A::AspectList list; QString tag1, tag2; if (filesCount() == 1) { list = file()->horoscope().aspects; aspects->setTitle(tr("Aspects")); } else { list = calculateSynastryAspects(); aspects->setTitle(tr("Synastry aspects")); tag1 = "#1"; tag2 = "#2"; } foreach (const A::Aspect& asp, list) { if (*asp.planet1 != p && *asp.planet2 != p) continue; QListWidgetItem* item = new QListWidgetItem; item->setIcon(QIcon(asp.d->userData["icon"].toString())); item->setText(A::describeAspect(asp)); item->setToolTip(A::describeAspectFull(asp, tag1, tag2)); item->setStatusTip(QString("%1+%2+%3").arg(asp.d->name) .arg(asp.planet1->name) .arg(asp.planet2->name)); aspectsList->addItem(item); } QListWidgetItem* item = new QListWidgetItem("..."); item->setToolTip(tr("more")); item->setWhatsThis("more"); item->setTextAlignment(Qt::AlignCenter); aspectsList->addItem(item); if (expandedAspects) expandAspects(); else updateListHeight(aspectsList); }
void cutDialog::edit_current_row() { QItemSelectionModel *selectionModel = listWidget->selectionModel(); QModelIndexList selected = selectionModel->selectedIndexes(); int row = listWidget ->currentRow(); QListWidgetItem * item = listWidget ->item(row); if(selected.length() != 1) { QMessageBox message(QMessageBox::Critical, "编辑错误 ", "<p>请选择单条文本内容进行编辑 !</font></strong></p>" ,QMessageBox::Ok ,this,Qt::Tool); this ->activateWindow(); message.exec(); return; } if(row >= 0 && item ->isSelected()) { editDialog = new QDialog(this); cutEdit = new QTextEdit(editDialog); QPushButton *okButton = new QPushButton("确定",editDialog); connect(okButton,SIGNAL(clicked()),this,SLOT(ok_edit_button())); QPushButton *cancelButton = new QPushButton("取消",editDialog); connect(cancelButton,SIGNAL(clicked()),this,SLOT(cancel_edit_button())); QListWidgetItem * item = listWidget ->item(row); int key = item->data(Qt::UserRole).toInt(); QString sqlStr = "select * from info where id = " + QString::number(key); QSqlQuery query; query.exec(sqlStr); while(query.next()) { if(query.value(2).toString() == "文本") { cutEdit ->setPlainText(query.value(3).toString()); } else { QMessageBox message(QMessageBox::Warning, "编辑提示 ", "文件不能编辑 !" ,QMessageBox::Ok ,this,Qt::Tool); this ->activateWindow(); message.exec(); return; } } QHBoxLayout *hboxLayout = new QHBoxLayout; hboxLayout ->addWidget(okButton); hboxLayout ->addStretch(); hboxLayout ->addWidget(cancelButton); QVBoxLayout *vboxLayout = new QVBoxLayout; vboxLayout ->addWidget(cutEdit); vboxLayout ->addLayout(hboxLayout); editDialog ->setLayout(vboxLayout); editDialog ->setWindowTitle("编辑"); //editDialog ->resize(400,500); editDialog ->setFixedSize(400,500); editDialog ->exec(); } else { QMessageBox message(QMessageBox::Critical, "编辑错误 ", "<p>请选择编辑的内容 !</font></strong></p>" ,QMessageBox::Ok ,this,Qt::Tool); this ->activateWindow(); message.exec(); } }
/** Creates intems into \a listWidget. */ void OptionsDialog::insertItems(QListWidget *listWidget) { QString imagesDirPath = QCoreApplication::applicationDirPath() + "/../share/sir/images/"; // General QIcon icon = QIcon::fromTheme("preferences-system", QIcon(imagesDirPath + "options_general.png")); QListWidgetItem *listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("General")); // File list icon = QIcon::fromTheme("preferences-desktop", QIcon(imagesDirPath + "options_list.png")); listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("File list")); #ifdef SIR_METADATA_SUPPORT // Metadata icon = QIcon::fromTheme("document-properties", QIcon(imagesDirPath + "options_metadata.png")); listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("Metadata")); // File details icon = QIcon::fromTheme("x-office-document", QIcon(imagesDirPath + "options_details.png")); listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("File details")); #endif // SIR_METADATA_SUPPORT // Selection icon = QIcon::fromTheme("edit-find", QIcon(imagesDirPath + "options_selection.png")); listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("Selection")); // Raw icon = QIcon::fromTheme("emblem-photos", QIcon(imagesDirPath + "options_raw.png")); listWidgetItem = new QListWidgetItem(listWidget); listWidgetItem->setIcon(icon); listWidgetItem->setText(tr("Raw")); }
bool wxListBox::IsSelected(int n) const { QListWidgetItem* item = m_qtListWidget->item(n); return item->isSelected(); }
void ConfigDialog::createIcons() { QListWidgetItem *proteinButton = new QListWidgetItem(contentsWidget); proteinButton->setIcon(QIcon("images/protein.png1")); proteinButton->setText(tr("protein")); proteinButton->setTextAlignment(Qt::AlignHCenter); proteinButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QListWidgetItem *bindingSiteButton = new QListWidgetItem(contentsWidget); bindingSiteButton->setIcon(QIcon("images/bindingSite.png1")); bindingSiteButton->setText(tr("bindingSite")); bindingSiteButton->setTextAlignment(Qt::AlignHCenter); bindingSiteButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QListWidgetItem *ligandButton = new QListWidgetItem(contentsWidget); ligandButton->setIcon(QIcon("images/ligand.png1")); ligandButton->setText(tr("lignd")); ligandButton->setTextAlignment(Qt::AlignHCenter); ligandButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QListWidgetItem *scoreButton = new QListWidgetItem(contentsWidget); scoreButton->setIcon(QIcon("images/score.png1")); scoreButton->setText(tr("score")); scoreButton->setTextAlignment(Qt::AlignHCenter); scoreButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QListWidgetItem *algorithmButton = new QListWidgetItem(contentsWidget); algorithmButton->setIcon(QIcon("images/algorithm.png1")); algorithmButton->setText(tr("algorithm")); algorithmButton->setTextAlignment(Qt::AlignHCenter); algorithmButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QListWidgetItem *runButton = new QListWidgetItem(contentsWidget); runButton->setIcon(QIcon("images/run.png1")); runButton->setText(tr("run")); runButton->setTextAlignment(Qt::AlignHCenter); runButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); connect(contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); }
void wxListBox::DoSetItemClientData(unsigned int n, void *clientData) { QListWidgetItem* item = m_qtListWidget->item(n); QVariant variant = qVariantFromValue(clientData); item->setData(Qt::UserRole, variant); }
QPixmap MapElementList::findTileByID(int tileID) { QListWidgetItem* searchedItem = this->item(tileID); QPixmap pixmap = searchedItem->icon().pixmap(QSize(32, 32)); return pixmap; }
void Configuration::save() { KConfigGroup configuration = m_applet->config(); QStringList arrangement; closeActionEditors(); for (int i = 0; i < m_arrangementUi.currentEntriesListWidget->count(); ++i) { QListWidgetItem *item = m_arrangementUi.currentEntriesListWidget->item(i); if (!item->toolTip().isEmpty()) { if (arrangement.contains(item->toolTip())) { continue; } arrangement.append(item->toolTip()); const KUrl url(item->toolTip()); Launcher *launcher = new Launcher(url, m_applet); if (m_rules.contains(item->toolTip()) && !launcher->isMenu()) { launcher->setRules(m_rules[item->toolTip()].first); launcher->setExcluded(m_rules[item->toolTip()].second); } m_applet->changeLauncher(launcher, url, true); launcher->deleteLater(); } else if (item->text() == i18n("--- tasks area ---")) { arrangement.append("tasks"); } else if (item->text() == i18n("--- jobs area ---")) { arrangement.append("jobs"); } else { arrangement.append("separator"); } } configuration.deleteGroup("Actions"); KConfigGroup actionsConfiguration = configuration.group("Actions"); for (int i = 0; i < m_actionsUi.actionsTableWidget->rowCount(); ++i) { QTableWidgetItem *actionItem = m_actionsUi.actionsTableWidget->item(i, 0); QTableWidgetItem *triggerItem = m_actionsUi.actionsTableWidget->item(i, 1); if (triggerItem->data(Qt::EditRole).toString().isEmpty() || actionItem->data(Qt::EditRole).toInt() == 0) { continue; } actionsConfiguration.writeEntry(triggerItem->data(Qt::EditRole).toString(), actionItem->data(Qt::EditRole).toInt()); } configuration.writeEntry("moveAnimation", m_appearanceUi.moveAnimation->itemData(m_appearanceUi.moveAnimation->currentIndex()).toInt()); configuration.writeEntry("parabolicMoveAnimation", m_appearanceUi.parabolicMoveAnimation->isChecked()); configuration.writeEntry("demandsAttentionAnimation", m_appearanceUi.demandsAttentionAnimation->itemData(m_appearanceUi.demandsAttentionAnimation->currentIndex()).toInt()); configuration.writeEntry("startupAnimation", m_appearanceUi.startupAnimation->itemData(m_appearanceUi.startupAnimation->currentIndex()).toInt()); configuration.writeEntry("activeIconIndication", m_appearanceUi.activeIconIndication->itemData(m_appearanceUi.activeIconIndication->currentIndex()).toInt()); configuration.writeEntry("titleLabelMode", m_appearanceUi.titleLabelMode->itemData(m_appearanceUi.titleLabelMode->currentIndex()).toInt()); configuration.writeEntry("customBackgroundImage", (m_appearanceUi.customBackgroundImage->url().isValid()?m_appearanceUi.customBackgroundImage->url().path():QString())); configuration.writeEntry("showOnlyCurrentDesktop", m_generalUi.showOnlyCurrentDesktop->isChecked()); configuration.writeEntry("showOnlyCurrentActivity", m_generalUi.showOnlyCurrentActivity->isChecked()); configuration.writeEntry("showOnlyCurrentScreen", m_generalUi.showOnlyCurrentScreen->isChecked()); configuration.writeEntry("showOnlyMinimized", m_generalUi.showOnlyMinimized->isChecked()); configuration.writeEntry("showOnlyTasksWithLaunchers", m_generalUi.showOnlyTasksWithLaunchers->isChecked()); configuration.writeEntry("connectJobsWithTasks", m_generalUi.connectJobsWithTasks->isChecked()); configuration.writeEntry("groupJobs", m_generalUi.groupJobs->isChecked()); configuration.writeEntry("groupingStrategy", m_generalUi.groupingStrategy->itemData(m_generalUi.groupingStrategy->currentIndex()).toInt()); configuration.writeEntry("sortingStrategy", m_generalUi.sortingStrategy->itemData(m_generalUi.sortingStrategy->currentIndex()).toInt()); configuration.writeEntry("jobCloseMode", m_generalUi.jobCloseMode->itemData(m_generalUi.jobCloseMode->currentIndex()).toInt()); configuration.writeEntry("arrangement", arrangement); static_cast<KConfigDialog*>(parent())->enableButtonApply(false); emit accepted(); }
void ChooseConnectionDlg::focusNewConn(Connection * conn) { QListWidgetItem * item = m_connectionItemMap[conn]; item->setSelected(true); ui->connectionsList->scrollToItem(item); }
void SubtotalDialog::accept() { Sheet *const sheet = d->selection->lastSheet(); QRect range = d->selection->lastRange(); int numOfCols = range.width(); QVector<int> columns(numOfCols); bool empty = true; int left = range.left(); for (int i = 0; i < d->mainWidget.m_columnList->count(); ++i) { QListWidgetItem* item = d->mainWidget.m_columnList->item(i); if (item->checkState() == Qt::Checked) { columns[i] = left + i; empty = false; } else columns[i] = -1; } if (empty) { KMessageBox::sorry(this, i18n("You need to select at least one column for adding subtotals.")); return; } if (d->detailsWidget.m_replaceSubtotals->isChecked()) removeSubtotalLines(); range = d->selection->lastRange(); int mainCol = left + d->mainWidget.m_columnBox->currentIndex(); int bottom = range.bottom(); int top = range.top(); int newBottom = bottom; left = range.left(); QString oldText = Cell(sheet, mainCol, top).displayText(); QString newText; QString result(' ' + i18n("Result")); int lastChangedRow = top; bool ignoreEmptyCells = d->detailsWidget.m_IgnoreBox->isChecked(); bool addRow; if (!d->detailsWidget.m_summaryOnly->isChecked()) { int y = top + 1; kDebug() << "Starting in row" << y; while (y <= bottom) { addRow = true; newText = Cell(sheet, mainCol, y).displayText(); if (ignoreEmptyCells && (newText.length() == 0)) { ++y; kDebug() << "Still the same ->" << y; continue; } if (newText != oldText) { int saveY = y; for (int x = 0; x < numOfCols; ++x) { kDebug() << "Column:" << x << "," << columns[x]; if (columns[x] != -1) { if (!addSubtotal(mainCol, columns[x], y - 1, lastChangedRow, addRow, oldText + result)) reject(); if (addRow) { ++saveY; ++bottom; } addRow = false; } } y = saveY; lastChangedRow = y; } oldText = newText; ++y; } addRow = true; for (int x = 0; x < numOfCols; ++x) { if (columns[x] != -1) { if (!addSubtotal(mainCol, columns[x], y - 1, lastChangedRow, addRow, oldText + result)) reject(); addRow = false; } } newBottom = y; } if (d->detailsWidget.m_summaryBelow->isChecked()) { addRow = true; int bottom = newBottom; for (int x = 0; x < numOfCols; ++x) { if (columns[x] != -1) { addSubtotal(mainCol, columns[x], bottom, top, addRow, i18n("Grand Total")); addRow = false; } } } KDialog::accept(); }
void UI_Annotationswindow::updateList(void) { char str[MAX_ANNOTATION_LEN + 32], *str_tmp; int i, len, sequence_nr=0, jump=0, modified=0; QListWidgetItem *listitem; QString string; QByteArray ba; selected = -1; #ifdef Q_OS_WIN32 QFont specialfont("courier", 11, QFont::Normal, true); #else QFont specialfont("andale mono", 12, QFont::Normal, true); #endif specialfont.setPixelSize(12); list->clear(); edfplus_annotation_sort(&mainwindow->annotationlist[file_num]); annotation = mainwindow->annotationlist[file_num]; while(annotation != NULL) { if(annotation->hided_in_list) { annotation = annotation->next_annotation; sequence_nr++; continue; } string = QString::fromUtf8(annotation->annotation); ba = string.toUtf8(); str_tmp = ba.data(); len = 0; for(i=0; ; i++) { if(str_tmp[i]==0) break; if(((((unsigned char *)str_tmp)[i])&224)==192) len++; } for(i=0; i<len; i++) string.append(' '); if(relative) { if((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) < 0LL) { snprintf(str, (MAX_ANNOTATION_LEN + 32) / 2, " -%2i:%02i:%02i.%04i", (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION)/ 3600), (int)(((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 3600) / 60), (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 60), (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) % TIME_DIMENSION) / 1000LL)); } else { snprintf(str, (MAX_ANNOTATION_LEN + 32) / 2, " %3i:%02i:%02i.%04i", (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION)/ 3600), (int)((((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 3600) / 60), (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 60), (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) % TIME_DIMENSION) / 1000LL)); } } else { snprintf(str, MAX_ANNOTATION_LEN + 32, " %3i:%02i:%02i.%04i", (int)((((annotation->onset + mainwindow->edfheaderlist[file_num]->l_starttime) / TIME_DIMENSION)/ 3600) % 24), (int)((((annotation->onset + mainwindow->edfheaderlist[file_num]->l_starttime) / TIME_DIMENSION) % 3600) / 60), (int)(((annotation->onset + mainwindow->edfheaderlist[file_num]->l_starttime) / TIME_DIMENSION) % 60), (int)(((annotation->onset + mainwindow->edfheaderlist[file_num]->l_starttime) % TIME_DIMENSION) / 1000LL)); } str[MAX_ANNOTATION_LEN + 31] = 0; remove_trailing_zeros(str); if(string.size() < 20) { string = string.leftJustified(20, ' '); } string.append(QString::fromLatin1(str)); listitem = new QListWidgetItem(string, list); listitem->setData(Qt::UserRole, QVariant(sequence_nr)); if(annotation->modified==1) { listitem->setFont(specialfont); listitem->setForeground(Qt::red); modified = 1; } if((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) < 0LL) { snprintf(str, (MAX_ANNOTATION_LEN + 32) / 2, "onset: -%i:%02i:%02i.%04i", (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION)/ 3600), (int)(((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 3600) / 60), (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 60), (int)((-(annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) % TIME_DIMENSION) / 1000LL)); } else { snprintf(str, (MAX_ANNOTATION_LEN + 32) / 2, "onset: %2i:%02i:%02i.%04i", (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION)/ 3600), (int)((((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 3600) / 60), (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) / TIME_DIMENSION) % 60), (int)(((annotation->onset - mainwindow->edfheaderlist[file_num]->starttime_offset) % TIME_DIMENSION) / 1000LL)); } if(annotation->duration[0]!=0) { snprintf(str + strlen(str), (MAX_ANNOTATION_LEN + 32) / 2, "\nduration: %s",annotation->duration); } str[MAX_ANNOTATION_LEN + 31] = 0; remove_trailing_zeros(str); strcat(str, "\n\n"); string = QString::fromLatin1(str); string.append(QString::fromUtf8(annotation->annotation)); listitem->setToolTip(string); if(annotation->selected) { selected = sequence_nr; annotation->selected = 0; if(annotation->jump) { jump = 1; annotation->jump = 0; } } annotation = annotation->next_annotation; sequence_nr++; } if(mainwindow->annot_editor_active) { if(selected>=0) { list->setCurrentRow(selected, QItemSelectionModel::ClearAndSelect); mainwindow->annotationEditDock->set_selected_annotation(file_num, selected); if(jump) { jump = 0; annotation_selected(list->currentItem()); } selected = -1; } if(modified) { mainwindow->annotations_edited = 1; mainwindow->save_act->setEnabled(true); } } }
void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer ) { if ( layer == mCurrentLayer ) return; if ( mCurrentLayer ) { disconnect( mCurrentLayer, &QgsMapLayer::styleChanged, this, &QgsLayerStylingWidget::updateCurrentWidgetLayer ); } if ( !layer || !layer->isSpatial() ) { mLayerCombo->setLayer( nullptr ); mStackedWidget->setCurrentIndex( mNotSupportedPage ); mLastStyleXml.clear(); mCurrentLayer = nullptr; return; } bool sameLayerType = false; if ( mCurrentLayer ) { sameLayerType = mCurrentLayer->type() == layer->type(); } mCurrentLayer = layer; mUndoWidget->setUndoStack( layer->undoStackStyles() ); connect( mCurrentLayer, &QgsMapLayer::styleChanged, this, &QgsLayerStylingWidget::updateCurrentWidgetLayer ); int lastPage = mOptionsListWidget->currentIndex().row(); mOptionsListWidget->blockSignals( true ); mOptionsListWidget->clear(); mUserPages.clear(); if ( layer->type() == QgsMapLayer::VectorLayer ) { QListWidgetItem *symbolItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/symbology.svg" ) ), QString() ); symbolItem->setData( Qt::UserRole, Symbology ); symbolItem->setToolTip( tr( "Symbology" ) ); mOptionsListWidget->addItem( symbolItem ); QListWidgetItem *labelItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "labelingSingle.svg" ) ), QString() ); labelItem->setData( Qt::UserRole, VectorLabeling ); labelItem->setToolTip( tr( "Labels" ) ); mOptionsListWidget->addItem( labelItem ); } else if ( layer->type() == QgsMapLayer::RasterLayer ) { QListWidgetItem *symbolItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/symbology.svg" ) ), QString() ); symbolItem->setData( Qt::UserRole, Symbology ); symbolItem->setToolTip( tr( "Symbology" ) ); mOptionsListWidget->addItem( symbolItem ); QListWidgetItem *transparencyItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/transparency.png" ) ), QString() ); transparencyItem->setToolTip( tr( "Transparency" ) ); transparencyItem->setData( Qt::UserRole, RasterTransparency ); mOptionsListWidget->addItem( transparencyItem ); if ( static_cast<QgsRasterLayer *>( layer )->dataProvider()->capabilities() & QgsRasterDataProvider::Size ) { QListWidgetItem *histogramItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/histogram.png" ) ), QString() ); histogramItem->setData( Qt::UserRole, RasterHistogram ); mOptionsListWidget->addItem( histogramItem ); histogramItem->setToolTip( tr( "Histogram" ) ); } } Q_FOREACH ( QgsMapLayerConfigWidgetFactory *factory, mPageFactories ) { if ( factory->supportsStyleDock() && factory->supportsLayer( layer ) ) { QListWidgetItem *item = new QListWidgetItem( factory->icon(), QString() ); item->setToolTip( factory->title() ); mOptionsListWidget->addItem( item ); int row = mOptionsListWidget->row( item ); mUserPages[row] = factory; } } QListWidgetItem *historyItem = new QListWidgetItem( QgsApplication::getThemeIcon( QStringLiteral( "mActionHistory.svg" ) ), QString() ); historyItem->setData( Qt::UserRole, History ); historyItem->setToolTip( tr( "History" ) ); mOptionsListWidget->addItem( historyItem ); mOptionsListWidget->blockSignals( false ); if ( sameLayerType ) { mOptionsListWidget->setCurrentRow( lastPage ); } else { mOptionsListWidget->setCurrentRow( 0 ); } mStackedWidget->setCurrentIndex( 1 ); QString errorMsg; QDomDocument doc( QStringLiteral( "style" ) ); mLastStyleXml = doc.createElement( QStringLiteral( "style" ) ); doc.appendChild( mLastStyleXml ); mCurrentLayer->writeStyle( mLastStyleXml, doc, errorMsg, QgsReadWriteContext() ); }
QgsZonalStatisticsDialog::QgsZonalStatisticsDialog( QgisInterface* iface ): QDialog( iface->mainWindow() ), mIface( iface ) { setupUi( this ); QListWidgetItem* countItem = new QListWidgetItem( tr( "Count" ), mStatsListWidget ); countItem->setFlags( countItem->flags() | Qt::ItemIsUserCheckable ); countItem->setCheckState( Qt::Checked ); countItem->setData( Qt::UserRole, QgsZonalStatistics::Count ); mStatsListWidget->addItem( countItem ); QListWidgetItem* sumItem = new QListWidgetItem( tr( "Sum" ), mStatsListWidget ); sumItem->setFlags( sumItem->flags() | Qt::ItemIsUserCheckable ); sumItem->setCheckState( Qt::Checked ); sumItem->setData( Qt::UserRole, QgsZonalStatistics::Sum ); mStatsListWidget->addItem( sumItem ); QListWidgetItem* meanItem = new QListWidgetItem( tr( "Mean" ), mStatsListWidget ); meanItem->setFlags( meanItem->flags() | Qt::ItemIsUserCheckable ); meanItem->setCheckState( Qt::Checked ); meanItem->setData( Qt::UserRole, QgsZonalStatistics::Mean ); mStatsListWidget->addItem( meanItem ); QListWidgetItem* medianItem = new QListWidgetItem( tr( "Median" ), mStatsListWidget ); medianItem->setFlags( medianItem->flags() | Qt::ItemIsUserCheckable ); medianItem->setCheckState( Qt::Unchecked ); medianItem->setData( Qt::UserRole, QgsZonalStatistics::Median ); mStatsListWidget->addItem( medianItem ); QListWidgetItem* stdevItem = new QListWidgetItem( tr( "Standard deviation" ), mStatsListWidget ); stdevItem->setFlags( stdevItem->flags() | Qt::ItemIsUserCheckable ); stdevItem->setCheckState( Qt::Unchecked ); stdevItem->setData( Qt::UserRole, QgsZonalStatistics::StDev ); mStatsListWidget->addItem( stdevItem ); QListWidgetItem* minItem = new QListWidgetItem( tr( "Minimum" ), mStatsListWidget ); minItem->setFlags( minItem->flags() | Qt::ItemIsUserCheckable ); minItem->setCheckState( Qt::Checked ); minItem->setData( Qt::UserRole, QgsZonalStatistics::Min ); mStatsListWidget->addItem( minItem ); QListWidgetItem* maxItem = new QListWidgetItem( tr( "Maximum" ), mStatsListWidget ); maxItem->setFlags( maxItem->flags() | Qt::ItemIsUserCheckable ); maxItem->setCheckState( Qt::Checked ); maxItem->setData( Qt::UserRole, QgsZonalStatistics::Max ); mStatsListWidget->addItem( maxItem ); QListWidgetItem* rangeItem = new QListWidgetItem( tr( "Range" ), mStatsListWidget ); rangeItem->setFlags( rangeItem->flags() | Qt::ItemIsUserCheckable ); rangeItem->setCheckState( Qt::Unchecked ); rangeItem->setData( Qt::UserRole, QgsZonalStatistics::Range ); mStatsListWidget->addItem( rangeItem ); QListWidgetItem* minorityItem = new QListWidgetItem( tr( "Minority" ), mStatsListWidget ); minorityItem->setFlags( minorityItem->flags() | Qt::ItemIsUserCheckable ); minorityItem->setCheckState( Qt::Unchecked ); minorityItem->setData( Qt::UserRole, QgsZonalStatistics::Minority ); mStatsListWidget->addItem( minorityItem ); QListWidgetItem* majorityItem = new QListWidgetItem( tr( "Majority" ), mStatsListWidget ); majorityItem->setFlags( majorityItem->flags() | Qt::ItemIsUserCheckable ); majorityItem->setCheckState( Qt::Unchecked ); majorityItem->setData( Qt::UserRole, QgsZonalStatistics::Majority ); mStatsListWidget->addItem( majorityItem ); QListWidgetItem* varietyItem = new QListWidgetItem( tr( "Variety" ), mStatsListWidget ); varietyItem->setFlags( varietyItem->flags() | Qt::ItemIsUserCheckable ); varietyItem->setCheckState( Qt::Unchecked ); varietyItem->setData( Qt::UserRole, QgsZonalStatistics::Variety ); mStatsListWidget->addItem( varietyItem ); QSettings settings; restoreGeometry( settings.value( "Plugin-ZonalStatistics/geometry" ).toByteArray() ); insertAvailableLayers(); mColumnPrefixLineEdit->setText( proposeAttributePrefix() ); }
// ================ // PUBLIC SLOTS // ================ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ if(dir.isEmpty()){ return; } //nothing to do QTime time; if(DEBUG){time.start(); } qDebug() << "Load Dir:" << dir; QString lastdir = CDIR; //for some checks later QString lastbasedir = normalbasedir; CDIR = dir; if(CDIR.endsWith("/") && CDIR.length() > 1){ CDIR.chop(1); } CLIST = list; //save for later canmodify = QFileInfo(CDIR).isWritable(); if(DEBUG){ qDebug() << "Clear UI:" <<time.elapsed(); } //Clear the status text if(!canmodify){ui->label_status->setText(tr("(Limited Access) ")); } else{ ui->label_status->setText(""); } //Hide the extra buttons for a moment ui->tool_goToPlayer->setVisible(false); ui->tool_goToImages->setVisible(false); ui->tool_new_dir->setVisible(canmodify); ui->tool_new_file->setVisible(canmodify); //Set the drag/drop info as appripriate if(canmodify){ listWidget->setWhatsThis(CDIR); treeWidget->setWhatsThis(CDIR); }else{ listWidget->setWhatsThis(""); treeWidget->setWhatsThis(""); } bool updateThumbs = (lastdir != CDIR); //Determine if this is an internal ZFS snapshot bool loadsnaps = false; if(DEBUG){ qDebug() << "Load Snap Info:" << time.elapsed(); } if( dir.contains(ZSNAPDIR) ){ //This is a zfs snapshot - only update the saved paths necessary to rotate between snapshots/system snaprelpath = dir.section(ZSNAPDIR,1,1000).section("/",1,1000); //the relative path inside the snapshot if(snaprelpath.endsWith("/")){ snaprelpath.chop(1); } normalbasedir = dir.section(ZSNAPDIR,0,0)+"/"+snaprelpath; //Update the new base directory if(normalbasedir.endsWith("/")){ normalbasedir.chop(1); } line_dir->setText(normalbasedir); //See if this was a manual move to the directory, or an internal move QString tmp = dir.section(ZSNAPDIR,0,0); if(tmp != snapbasedir.section(ZSNAPDIR,0,0)){ loadsnaps = true; //different snapshot loaded - need to update internally } }else{ //This is a normal directory - prompt for snapshot information line_dir->setText(CDIR); normalbasedir = CDIR; if(!snapbasedir.isEmpty()){ watcher->removePath(snapbasedir); } snapbasedir.clear(); loadsnaps = true; } if(loadsnaps){ //kick this off while still loading the dir contents ui->group_snaps->setEnabled(false); //to prevent the snap updates to be automatically used ui->group_snaps->setVisible(false); ui->slider_snap->setRange(1,1); emit findSnaps(ID, normalbasedir); } if(DEBUG){ qDebug() << "Update History:" <<time.elapsed(); } //Now update the history for this browser //qDebug() << "History:" << history << normalbasedir << lastbasedir; if(!history.isEmpty() && history.last() == normalbasedir && lastbasedir!=normalbasedir ){ //We went back one - remove this from the history history.takeLast(); ui->actionBack->setEnabled(!history.isEmpty()); //qDebug() << " - Duplicate: removed item"; }else if(lastbasedir!=normalbasedir){ //not a refresh or internal snapshot change //qDebug() << " - New History Item:" << normalbasedir; history << normalbasedir; ui->actionBack->setEnabled(history.length()>1); } if(DEBUG){ qDebug() << "Update Watcher:" << time.elapsed(); } //Clear the current watcher if(!watcher->directories().isEmpty()){ watcher->removePaths(watcher->directories()); } if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } watcher->addPath(CDIR); // add sessionsettings to watcher so date_format can be update based on user settings watcher->addPath(sessionsettings_config_file); ui->actionStopLoad->setVisible(true); stopload = false; //Clear the display widget (if a new directory) if(DEBUG){ qDebug() << "Clear Browser Widget:" << time.elapsed(); } double scrollpercent = -1; if(updateThumbs){ needThumbs.clear(); } if(lastbasedir != normalbasedir){ if(showDetails){ treeWidget->clear(); } else{ listWidget->clear(); } QApplication::processEvents(); //make sure it is cleared right away }else{ //Need to be smarter about which items need to be removed // - compare the old/new lists and remove any items not in the new listing (new items taken care of below) QStringList newfiles; //just the filenames for(int i=0; i<CLIST.length(); i++){ newfiles << CLIST[i].fileName(); } if(showDetails){ for(int i=0; i<treeWidget->topLevelItemCount(); i++){ if( !newfiles.contains(treeWidget->topLevelItem(i)->whatsThis(0).section("/",-1)) ){ if(!updateThumbs){ needThumbs.removeAll( treeWidget->topLevelItem(i)->whatsThis(0).section("::::",1,50)); } delete treeWidget->takeTopLevelItem(i); i--; } } QApplication::processEvents(); //make sure the scrollbar is up to date after removals scrollpercent = treeWidget->verticalScrollBar()->value()/( (double) treeWidget->verticalScrollBar()->maximum()); }else{ for(int i=0; i<listWidget->count(); i++){ if( !newfiles.contains(listWidget->item(i)->text()) ){ if(!updateThumbs){ needThumbs.removeAll( listWidget->item(i)->whatsThis().section("::::",1,50)); } delete listWidget->takeItem(i); i--; } } QApplication::processEvents(); //make sure the scrollbar is up to date after removals scrollpercent = listWidget->horizontalScrollBar()->value()/( (double) listWidget->horizontalScrollBar()->maximum()); } } //end check for CDIR reload //Now fill the display widget bool hasimages, hasmultimedia; hasimages = hasmultimedia = false; int numdirs = 0; qint64 filebytes = 0; //Setup the timer to see when we should process events /*QTimer updatetime; updatetime.setInterval(1000); //1 second updates updatetime.setSingleShot(true); updatetime.start();*/ QTime updatetime = QTime::currentTime().addMSecs(500); if(DEBUG){ qDebug() << "Start Loop over items:" << time.elapsed(); } for(int i=0; i<list.length(); i++){ if(stopload){ ui->actionStopLoad->setVisible(false); return; } //stop right now if(!hasimages && list[i].isImage()){ hasimages = true; ui->tool_goToImages->setVisible(true); } else if(!hasmultimedia && list[i].isAVFile()){ hasmultimedia = true; ui->tool_goToPlayer->setVisible(true); } //Update statistics if(list[i].isDir()){ numdirs++; } else{ filebytes += list[i].size(); } watcher->addPath(list[i].absoluteFilePath()); if(showDetails){ //Now create all the individual items for the details tree CQTreeWidgetItem *it; bool addnew = false; //See if an item already exists for this file QList<QTreeWidgetItem*> items = treeWidget->findItems(list[i].fileName(),Qt::MatchExactly,0); //NOTE: This requires column 0 to be the name if(items.isEmpty()){ it = new CQTreeWidgetItem(); addnew = true; }else{ // Safe downcasting because CQTreeWidgetItem only redefines the virtual function bool opearot<. Not new methos added. it = static_cast<CQTreeWidgetItem *> (items.first()); } //Now update the entry contents it->setWhatsThis(0, QString(canmodify ? "cut": "copy")+"::::"+list[i].absoluteFilePath()); for(int t=0; t<listDetails.length(); t++){ switch(listDetails[t]){ case NAME: it->setText(t,list[i].fileName()); it->setStatusTip(t, list[i].fileName()); //Since the icon/image is based on the filename - only update this for a new item // (This is the slowest part of the routine) if(list[i].isImage()&& (addnew || updateThumbs)){ if(showThumbs){ it->setIcon(t, LXDG::findIcon("fileview-preview","image-x-generic") ); needThumbs << list[i].fileName(); }else{ it->setIcon(t, LXDG::findIcon(list[i].iconfile(),"image-x-generic") ); } }else if(addnew){ it->setIcon(t, LXDG::findIcon(list[i].iconfile(),"unknown") ); } break; case SIZE: if(!list[i].isDir()){ it->setText(t, LUtils::BytesToDisplaySize(list[i].size()) ); } break; case TYPE: it->setText(t, list[i].mimetype()); break; case DATEMOD: { QStringList datetime_format = getDateFormat(); // Save datetime in WhatThis value. Lately will be used by CQTreeWidgetItem for sorting by date it->setWhatsThis(t, list[i].lastModified().toString("yyyyMMddhhmmsszzz")); // Default configurition. Fallback to Qt::DefaultLocaleShortDate for formats if(datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) ); // Date is setted but time not. Time goes to default else if(!datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(Qt::DefaultLocaleShortDate)); // Time is setted but date not. Date goes to default else if(datetime_format.at(0).isEmpty() && !datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().date().toString(Qt::DefaultLocaleShortDate) + " " + list[i].lastModified().time().toString(datetime_format.at(1))); // Both time and date setted. else it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(datetime_format.at(1))); break; } case DATECREATE: { QStringList datetime_format = getDateFormat(); it->setWhatsThis(DATECREATE, list[i].lastModified().toString("yyyyMMddhhmmsszzz")); if(datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) ); else if(!datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(Qt::DefaultLocaleShortDate)); else if(datetime_format.at(0).isEmpty() && !datetime_format.at(1).isEmpty()) it->setText(t, list[i].lastModified().date().toString(Qt::DefaultLocaleShortDate) + " " + list[i].lastModified().time().toString(datetime_format.at(1))); else it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(datetime_format.at(1))); break; } } } if(addnew){ treeWidget->addTopLevelItem(it); } if(tmpSel.contains(list[i].absoluteFilePath())){ it->setSelected(true); } if(lastdir == CDIR+"/"+list[i].fileName()){ treeWidget->setCurrentItem(it); treeWidget->scrollToItem(it); } }else{ //Create all the individual items for the basic list QListWidgetItem *it; //See if there is an existing item to re-use bool addnew = false; QList<QListWidgetItem*> items = listWidget->findItems(list[i].fileName(), Qt::MatchExactly); if(items.isEmpty()){ it = new QListWidgetItem(); addnew = true; }else{ it = items.first(); } it->setWhatsThis( QString(canmodify ? "cut": "copy")+"::::"+list[i].absoluteFilePath()); //used for drag and drop it->setText(list[i].fileName()); it->setStatusTip(list[i].fileName()); //Since the icon/image is based on the filename - only update this for a new items (non-thumbnail) // (This is the slowest part of the routine) if(list[i].isImage() && (addnew || updateThumbs) ){ if(showThumbs){ it->setIcon(LXDG::findIcon("fileview-preview","image-x-generic") ); needThumbs << list[i].fileName(); }else{ it->setIcon(LXDG::findIcon(list[i].iconfile(),"image-x-generic") ); } }else if(addnew){ it->setIcon(LXDG::findIcon(list[i].iconfile(),"unknown") ); } listWidget->addItem(it); if(tmpSel.contains(list[i].absoluteFilePath())){ it->setSelected(true); } if(lastdir == CDIR+"/"+list[i].fileName()){ listWidget->setCurrentItem(it); listWidget->scrollToItem(it); } } if(QTime::currentTime() > updatetime){ QApplication::processEvents(); updatetime = QTime::currentTime().addMSecs(500); }//keep the UI snappy while loading a directory if(DEBUG){ qDebug() << " - item finished:" << i << time.elapsed(); } } tmpSel.clear(); if(DEBUG){ qDebug() << "Done with item loop:" << time.elapsed() << list.length(); } ui->actionStopLoad->setVisible(false); //Another check to ensure the current item is visible (or return to the same scroll position) if(stopload){ return; } //stop right now if(scrollpercent<0){ if(showDetails){ for(int t=0; t<treeWidget->columnCount(); t++){treeWidget->resizeColumnToContents(t); } if(treeWidget->currentItem()!=0){ treeWidget->scrollToItem(treeWidget->currentItem()); } }else{ if(listWidget->currentItem()!=0){ listWidget->scrollToItem(listWidget->currentItem()); } } }else{ if(showDetails){ treeWidget->verticalScrollBar()->setValue( qRound(treeWidget->verticalScrollBar()->maximum()*scrollpercent) ); }else{ listWidget->horizontalScrollBar()->setValue( qRound(listWidget->horizontalScrollBar()->maximum()*scrollpercent) ); } } if(stopload){ return; } //stop right now if(DEBUG){ qDebug() << "Assemble Status Message:" << time.elapsed(); } //Assemble any status message QString stats = QString(tr("Capacity: %1")).arg(LOS::FileSystemCapacity(CDIR)); if(list.length()>0){ stats.prepend("\t"); if(numdirs < list.length()){ //Has Files stats.prepend( QString(tr("Files: %1 (%2)")).arg(QString::number(list.length()-numdirs), LUtils::BytesToDisplaySize(filebytes)) ); } if(numdirs > 0){ //Has Dirs if(numdirs<list.length()){ stats.prepend(" / "); }//has files output already stats.prepend( QString(tr("Dirs: %1")).arg(QString::number(numdirs)) ); } } if(stopload){ return; } //stop right now if(!canmodify){ stats.prepend(tr("(Limited Access) ")); } ui->label_status->setText( stats.simplified() ); if(DEBUG){ qDebug() << "DONE:" << time.elapsed(); } if(showThumbs){ thumbThread = QtConcurrent::run(this, &DirWidget::startLoadThumbs); } }
void LogExplorerDialog::rebuildFilters() { QStringList Types; QStringList Simulators; QStringList Observers; ui->TypeFilterListWidget->clear(); ui->SimulatorFilterListWidget->clear(); ui->ObserverFilterListWidget->clear(); for (int i=0; i< m_LogInfos.count(); i++) { LogItemInfos Item = m_LogInfos[i]; QString TypeStr = m_LogInfos[i]["type"]; if (!(TypeStr.isEmpty() || Types.contains(TypeStr))) Types.append(TypeStr); if (m_LogInfos[i].contains("context.source") && m_LogInfos[i]["context.source"] == "ware" && m_LogInfos[i].contains("context.waretype") && m_LogInfos[i].contains("context.wareid")) { QString WareTypeStr = m_LogInfos[i]["context.waretype"]; QString WareIDStr = m_LogInfos[i]["context.wareid"]; if (WareTypeStr.toLower() == "simulator" && !Simulators.contains(WareIDStr)) Simulators.append(WareIDStr); else if (WareTypeStr.toLower() == "observer" && !Observers.contains(WareIDStr)) Observers.append(WareIDStr); } } Types.sort(); Simulators.sort(); Observers.sort(); for (int i=0; i< Types.count(); i++) { QListWidgetItem* ListItem = new QListWidgetItem(Types[i]); ListItem->setFlags(ListItem->flags() | Qt::ItemIsUserCheckable); ListItem->setCheckState(Qt::Checked); ui->TypeFilterListWidget->addItem(ListItem); } for (int i=0; i< Simulators.count(); i++) { QListWidgetItem* ListItem = new QListWidgetItem(Simulators[i]); ListItem->setFlags(ListItem->flags() | Qt::ItemIsUserCheckable); ListItem->setCheckState(Qt::Checked); ui->SimulatorFilterListWidget->addItem(ListItem); } for (int i=0; i< Observers.count(); i++) { QListWidgetItem* ListItem = new QListWidgetItem(Observers[i]); ListItem->setFlags(ListItem->flags() | Qt::ItemIsUserCheckable); ListItem->setCheckState(Qt::Checked); ui->ObserverFilterListWidget->addItem(ListItem); } ui->FrameworkFilterCheckBox->setCheckState(Qt::Checked); ui->AppFilterCheckBox->setCheckState(Qt::Checked); ui->ApplyFilteringButton->setEnabled(false); }
/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::IconMode ); setSpacing( 8 ); setGridSize( QSize(90, 50) ); setWrapping( true ); setWordWrap( true ); setTextElideMode( Qt::ElideNone ); setDragEnabled( true ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); QPixmap pix( iconL[i] ); widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem( this ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); prevSectionButton->setToolTip( qtr("Previous chapter") ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); menuButton->setToolTip( qtr("Go to the DVD menu") ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); nextButton->setToolTip( qtr("Next chapter") ); discLayout->addWidget( nextButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexTransparent->setToolTip( qtr("Teletext transparency") ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; case PLAYBACK_BUTTONS: { widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); } widgetItem->setText( qtr("Playback Buttons") ); break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widgetItem->setText( qtr("Aspect ratio selector") ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Speed selector") ); break; case TIME_LABEL_ELAPSED: widget = new QLabel( "2:42", this ); widgetItem->setText( qtr("Elapsed time") ); break; case TIME_LABEL_REMAINING: widget = new QLabel( "-2:42", this ); widgetItem->setText( qtr("Total/Remaining time") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
void FilterDialog::setFields(const wsWeatherDataSourceFilter& filterParams, std::vector<struct wsTheme> themes) { bool lOldStat = _ignoreChangeEvents; _ignoreChangeEvents = true; //Preenche as listas contendo os temas disponiveis para filtro por area e pre-analise fillThemeList(themes); //Filtro por data if(filterParams.dateBeforeEnabled) { dateBeforeFilterCbx->setCheckState(Qt::Checked); dateBeforeFilterDed->setDate(QDate(filterParams.dateBeforeYear, filterParams.dateBeforeMonth, filterParams.dateBeforeDay)); } if(filterParams.dateAfterEnabled) { dateAfterFilterCbx->setCheckState(Qt::Checked); dateAfterFilterDed->setDate(QDate(filterParams.dateAfterYear, filterParams.dateAfterMonth, filterParams.dateAfterDay)); } //Filtro por area if(filterParams.areaFilterType == WS_AreaFilter) { areaRdb->setChecked(true); xMinLed->setText(QString::number(filterParams.xMin, 'f')); xMaxLed->setText(QString::number(filterParams.xMax, 'f')); yMinLed->setText(QString::number(filterParams.yMin, 'f')); yMaxLed->setText(QString::number(filterParams.yMax, 'f')); } else if(filterParams.areaFilterType == WS_PlaneFilter) { planeRdb->setChecked(true); QListWidgetItem *item; int i=0; for(; i<themeListWidget->count(); ++i) { item = themeListWidget->item(i); if(item->data(Qt::UserRole).toInt() == filterParams.themeID) break; } themeListWidget->setCurrentRow(i); } else noAreaFilterRdb->setChecked(true); //Filtro por pre-analise if(filterParams.preAnalysisType == WS_PATYPE_NoPreAnalysis) noPreAnalysisRdb->setChecked(true); else { preAnalysisThemeBox->setDisabled(false); if(filterParams.preAnalysisType == WS_PATYPE_AllSmallerThan) { allSmallerThanRdb->setChecked(true); allSmallerThanLed->setText(QString::number(filterParams.preAnalysisValue, 'f')); } else if(filterParams.preAnalysisType == WS_PATYPE_AllLargerThan) { allLargerThanRdb->setChecked(true); allLargerThanLed->setText(QString::number(filterParams.preAnalysisValue, 'f')); } else if(filterParams.preAnalysisType == WS_PATYPE_BelowAverage) { belowAverageRdb->setChecked(true); belowAverageLed->setText(QString::number(filterParams.preAnalysisValue, 'f')); } else if(filterParams.preAnalysisType == WS_PATYPE_AboveAverage) { aboveAverageRdb->setChecked(true); aboveAverageLed->setText(QString::number(filterParams.preAnalysisValue, 'f')); } if(filterParams.preAnalysisThemeEnabled) { preAnalysisThemeBox->setChecked(true); QListWidgetItem *item; int i = 0; for(; i<preAnalysisThemeList->count(); ++i) { item = preAnalysisThemeList->item(i); if(item->data(Qt::UserRole).toInt() == filterParams.preAnalysisTheme) break; } preAnalysisThemeList->setCurrentRow(i); } } //Filtro por banda bandFilterLed->setText(QString(filterParams.bandFilterString.c_str())); dummyValueSpb->setValue(filterParams.newDummy); newDummyChk->setCheckState(filterParams.useNewDummy ? Qt::Checked : Qt::Unchecked); _ignoreChangeEvents = lOldStat; }