Beispiel #1
0
 LineEdit::LineEdit(QWidget *parent)
     : QLineEdit(parent)
 {

     filterPosition = -1;
     clearButton = new QToolButton(this);
     QPixmap pixmap(":fileclose.png");
     clearButton->setIcon(QIcon(pixmap));
     clearButton->setIconSize(pixmap.size());
     clearButton->setCursor(Qt::ArrowCursor);
     clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
     clearButton->hide();
     connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
     connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
     int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
     setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1));
     QSize msz = minimumSizeHint();
     setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2),
                    qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));

     defaultText = QString(tr("Search"));
     this->setText(defaultText);

     inactiveColor = "QLineEdit {color: gray; font:italic;} ";
     activeColor = "QLineEdit {color: black; font:normal;} ";

     connect(this, SIGNAL(returnPressed()), this, SLOT(buildSelection()));
     connect(this, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
     connect(clearButton, SIGNAL(clicked()), this, SLOT(buildSelection()));
     setStyleSheet(inactiveColor);
 }
Beispiel #2
0
NTrashTree::NTrashTree(QWidget *parent) :
    QTreeWidget(parent)
{
    QFont f = this->font();
    f.setPointSize(8);
    this->setFont(f);

    filterPosition = -1;
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::ExtendedSelection);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(false);
    this->header()->setVisible(false);
    this->setStyleSheet("QTreeWidget {  border: none; background-color:transparent; }");

    // Build the root item
    QIcon icon(":trash.png");
    root = new QTreeWidgetItem(this);
    root->setIcon(0,icon);
    root->setData(0, Qt::UserRole, "root");
    root->setData(0, Qt::DisplayRole, tr("Trash"));
    QFont font = root->font(0);
    font.setBold(true);
    root->setFont(0,font);
    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));

}
Beispiel #3
0
void LineEdit::textChanged(QString text) {
    this->blockSignals(true);
    if (text.trimmed() == "" && !hasFocus())
        this->setText(defaultText);
    this->blockSignals(false);
    if ((text == defaultText || text == "") && savedText != "") {
        buildSelection();
    }
}
Beispiel #4
0
NTrashTree::NTrashTree(QWidget *parent) :
    QTreeWidget(parent)
{
    this->count = 0;
    QFont f = this->font();
    f.setPointSize(8);
    this->setFont(f);

    filterPosition = -1;
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::ExtendedSelection);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(false);
    this->header()->setVisible(false);
    this->setContentsMargins(10,10,10,10);
    //this->setStyleSheet("QTreeWidget {  border: none; background-color:transparent; }");

    // Build the root item
    QIcon icon(":trash.png");
    root = new QTreeWidgetItem(this);
    root->setIcon(0,icon);
    root->setData(0, Qt::UserRole, "root");
    root->setData(0, Qt::DisplayRole, tr("Trash"));
    QFont font = root->font(0);
    font.setBold(true);
    root->setFont(0,font);
    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));

    restoreAction = contextMenu.addAction(tr("Restore Deleted Notes"));
    connect(restoreAction, SIGNAL(triggered()), SLOT(restoreAll()));
    contextMenu.addSeparator();
    expungeAction = contextMenu.addAction(tr("Empty Trash"));
    connect(expungeAction, SIGNAL(triggered()), this, SLOT(expungeAll()));

    setItemDelegate(new NTrashViewDelegate());
    this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    this->setFrameShape(QFrame::NoFrame);
}
FavoritesView::FavoritesView(QWidget *parent) :
    QTreeWidget(parent)
{
    setAcceptDrops(true);
    setDragEnabled(true);
    setDropIndicatorShown(true);
    setSelectionMode(QAbstractItemView::SingleSelection);

    dataStore.clear();
    targetStore.clear();
    this->setFont(global.getGuiFont(font()));

    filterPosition = -1;
    maxCount = 0;  // Highest count of any notebook.  Used in calculating column width
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::SingleSelection);
    this->setDragDropMode(QAbstractItemView::InternalMove);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(true);
    this->header()->setVisible(false);
    this->setStyleSheet("QTreeView {border-image:none; image:none;} ");
    root = new FavoritesViewItem(0);
    root->setData(NAME_POSITION, Qt::UserRole, "root");
    root->setData(NAME_POSITION, Qt::DisplayRole, tr("Shortcuts"));
    QFont rootFont = root->font(NAME_POSITION);
    rootFont.setBold(true);
    root->setFont(NAME_POSITION, rootFont);
    root->setIcon(NAME_POSITION, global.getIconResource(":favoritesIcon"));

    root->setRootColor(false);

    expandedImage = new QImage(":expandedIcon");
    collapsedImage = new QImage(":collapsedIcon");
    this->setAcceptDrops(true);
    this->setItemDelegate(new FavoritesViewDelegate());
    this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    this->setFrameShape(QFrame::NoFrame);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    this->rebuildFavoritesTreeNeeded = true;
    this->loadData();

    context.addSeparator();
    deleteAction = context.addAction(tr("Remove from shortcuts"));
    deleteAction->setShortcut(QKeySequence(Qt::Key_Delete));

    deleteShortcut = new QShortcut(this);
    deleteShortcut->setKey(QKeySequence(Qt::Key_Delete));
    deleteShortcut->setContext(Qt::WidgetShortcut);
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested()));
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));
    connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested()));

    root->setExpanded(true);
    this->setProperty("animated", false);

    resetSize();
}
Beispiel #6
0
NAttributeTree::NAttributeTree(QWidget *parent) :
    QTreeWidget(parent)
{
    this->setFont(global.getGuiFont(font()));

    filterPosition = -1;
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::SingleSelection);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(false);
    this->header()->setVisible(false);
    //this->setStyleSheet("QTreeWidget {  border: none; background-color:transparent; }");

    // Build the root item
    root = new QTreeWidgetItem(this);
    QIcon icon(":attributes.png");
    root->setIcon(0,icon);
    root->setData(0, Qt::UserRole, "root");
    root->setData(0, Qt::DisplayRole, tr("Attributes"));
    QFont font = root->font(0);
    font.setBold(true);
    root->setFont(0,font);
    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));

    // Allocate memory for everything needed

    createdRoot = new QTreeWidgetItem(root);
    lastUpdatedRoot = new QTreeWidgetItem(root);
    containsRoot = new QTreeWidgetItem(root);
    sourceRoot = new QTreeWidgetItem(root);

    createdSinceRoot = new QTreeWidgetItem(createdRoot);
    createdSinceToday = new QTreeWidgetItem(createdSinceRoot);
    createdSinceYesterday = new QTreeWidgetItem(createdSinceRoot);
    createdSinceThisWeek = new QTreeWidgetItem(createdSinceRoot);
    createdSinceLastWeek = new QTreeWidgetItem(createdSinceRoot);
    createdSinceThisMonth = new QTreeWidgetItem(createdSinceRoot);
    createdSinceLastMonth = new QTreeWidgetItem(createdSinceRoot);
    createdSinceThisYear = new QTreeWidgetItem(createdSinceRoot);
    createdSinceLastYear = new QTreeWidgetItem(createdSinceRoot);

    createdBeforeRoot = new QTreeWidgetItem(createdRoot);
    createdBeforeToday = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeYesterday = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeThisWeek = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeLastWeek = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeThisMonth = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeLastMonth = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeThisYear = new QTreeWidgetItem(createdBeforeRoot);
    createdBeforeLastYear = new QTreeWidgetItem(createdBeforeRoot);

    lastUpdatedSinceRoot = new QTreeWidgetItem(lastUpdatedRoot);
    lastUpdatedSinceToday = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceYesterday = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceThisWeek = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceLastWeek = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceThisMonth = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceLastMonth = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceThisYear = new QTreeWidgetItem(lastUpdatedSinceRoot);
    lastUpdatedSinceLastYear = new QTreeWidgetItem(lastUpdatedSinceRoot);

    lastUpdatedBeforeRoot = new QTreeWidgetItem(lastUpdatedRoot);
    lastUpdatedBeforeToday = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeYesterday = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeThisWeek = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeLastWeek = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeThisMonth = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeLastMonth = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeThisYear = new QTreeWidgetItem(lastUpdatedBeforeRoot);
    lastUpdatedBeforeLastYear = new QTreeWidgetItem(lastUpdatedBeforeRoot);

    containsImages = new QTreeWidgetItem(containsRoot);
    containsAudio = new QTreeWidgetItem(containsRoot);
    containsInk = new QTreeWidgetItem(containsRoot);
    containsEncryptedText = new QTreeWidgetItem(containsRoot);
    containsToDoItems = new QTreeWidgetItem(containsRoot);
    containsUnfinishedToDoItems = new QTreeWidgetItem(containsRoot);
    containsFinishedToDoItems = new QTreeWidgetItem(containsRoot);
    containsPDFDocument = new QTreeWidgetItem(containsRoot);
    containsAttachment = new QTreeWidgetItem(containsRoot);

    sourceEmailedToEvernote = new QTreeWidgetItem(sourceRoot);
    sourceEmail = new QTreeWidgetItem(sourceRoot);
    sourceWebPage = new QTreeWidgetItem(sourceRoot);
    sourceMobile = new QTreeWidgetItem(sourceRoot);
    sourceAnotherApplication = new QTreeWidgetItem(sourceRoot);


    // Start building selection criteria
    createdRoot->setText(0, tr("Created"));
    createdRoot->setData(0, Qt::UserRole, 0);

    createdSinceRoot->setText(0, tr("Since"));
    createdSinceRoot->setData(0, Qt::UserRole, 0);
    createdRoot->addChild(createdSinceRoot);

    createdSinceToday->setText(0, tr("Today"));
    createdSinceToday->setData(0, Qt::UserRole, CREATED_SINCE_TODAY);
    createdSinceRoot->addChild(createdSinceToday);

    createdSinceYesterday->setText(0, tr("Yesterday"));
    createdSinceYesterday->setData(0, Qt::UserRole, CREATED_SINCE_YESTERDAY);
    createdSinceRoot->addChild(createdSinceYesterday);

    createdSinceThisWeek->setText(0, tr("This week"));
    createdSinceThisWeek->setData(0, Qt::UserRole, CREATED_SINCE_THIS_WEEK);
    createdSinceRoot->addChild(createdSinceThisWeek);

    createdSinceLastWeek->setText(0, tr("Last week"));
    createdSinceLastWeek->setData(0, Qt::UserRole, CREATED_SINCE_LAST_WEEK);
    createdSinceRoot->addChild(createdSinceLastWeek);

    createdSinceThisMonth->setText(0, tr("This Month"));
    createdSinceThisMonth->setData(0, Qt::UserRole, CREATED_SINCE_THIS_MONTH);
    createdSinceRoot->addChild(createdSinceThisMonth);

    createdSinceLastMonth->setText(0, tr("Last Month"));
    createdSinceLastMonth->setData(0, Qt::UserRole, CREATED_SINCE_LAST_MONTH);
    createdSinceRoot->addChild(createdSinceLastMonth);

    createdSinceThisYear->setText(0, tr("This Year"));
    createdSinceThisYear->setData(0, Qt::UserRole, CREATED_SINCE_THIS_YEAR);
    createdSinceRoot->addChild(createdSinceThisYear);

    createdSinceLastYear->setText(0, tr("Last Year"));
    createdSinceLastYear->setData(0, Qt::UserRole, CREATED_SINCE_LAST_YEAR);
    createdSinceRoot->addChild(createdSinceLastYear);


    createdBeforeRoot->setText(0, tr("Before"));
    createdBeforeRoot->setData(0, Qt::UserRole, 0);
    createdRoot->addChild(createdBeforeRoot);

    createdBeforeToday->setText(0, tr("Today"));
    createdBeforeToday->setData(0, Qt::UserRole, CREATED_BEFORE_TODAY);
    createdBeforeRoot->addChild(createdBeforeToday);

    createdBeforeYesterday->setText(0, tr("Yesterday"));
    createdBeforeYesterday->setData(0, Qt::UserRole, CREATED_BEFORE_YESTERDAY);
    createdBeforeRoot->addChild(createdBeforeYesterday);

    createdBeforeThisWeek->setText(0, tr("This week"));
    createdBeforeThisWeek->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_WEEK);
    createdBeforeRoot->addChild(createdBeforeThisWeek);

    createdBeforeLastWeek->setText(0, tr("Last week"));
    createdBeforeLastWeek->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_WEEK);
    createdBeforeRoot->addChild(createdBeforeLastWeek);

    createdBeforeThisMonth->setText(0, tr("This Month"));
    createdBeforeThisMonth->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_MONTH);
    createdBeforeRoot->addChild(createdSinceThisMonth);

    createdBeforeLastMonth->setText(0, tr("Last Month"));
    createdBeforeLastMonth->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_MONTH);
    createdBeforeRoot->addChild(createdBeforeLastMonth);

    createdBeforeThisYear->setText(0, tr("This Year"));
    createdBeforeThisYear->setData(0, Qt::UserRole, CREATED_BEFORE_THIS_YEAR);
    createdBeforeRoot->addChild(createdBeforeThisYear);

    createdBeforeLastYear->setText(0, tr("Last Year"));
    createdBeforeLastYear->setData(0, Qt::UserRole, CREATED_BEFORE_LAST_YEAR);
    createdBeforeRoot->addChild(createdBeforeLastYear);





    //** Start doing the "Last Modified" selection criteria
    lastUpdatedRoot->setText(0, tr("Last Modified"));
    lastUpdatedRoot->setData(0, Qt::UserRole, 0);

    lastUpdatedSinceRoot->setText(0, tr("Since"));
    lastUpdatedSinceRoot->setData(0, Qt::UserRole, 0);
    lastUpdatedRoot->addChild(lastUpdatedSinceRoot);

    lastUpdatedSinceToday->setText(0, tr("Today"));
    lastUpdatedSinceToday->setData(0, Qt::UserRole, MODIFIED_SINCE_TODAY);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceToday);

    lastUpdatedSinceYesterday->setText(0, tr("Yesterday"));
    lastUpdatedSinceYesterday->setData(0, Qt::UserRole, MODIFIED_SINCE_YESTERDAY);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceYesterday);

    lastUpdatedSinceThisWeek->setText(0, tr("This week"));
    lastUpdatedSinceThisWeek->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_WEEK);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisWeek);

    lastUpdatedSinceLastWeek->setText(0, tr("Last week"));
    lastUpdatedSinceLastWeek->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_WEEK);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastWeek);

    lastUpdatedSinceThisMonth->setText(0, tr("This Month"));
    lastUpdatedSinceThisMonth->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_MONTH);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisMonth);

    lastUpdatedSinceLastMonth->setText(0, tr("Last Month"));
    lastUpdatedSinceLastMonth->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_MONTH);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastMonth);

    lastUpdatedSinceThisYear->setText(0, tr("This Year"));
    lastUpdatedSinceThisYear->setData(0, Qt::UserRole, MODIFIED_SINCE_THIS_YEAR);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceThisYear);

    lastUpdatedSinceLastYear->setText(0, tr("Last Year"));
    lastUpdatedSinceLastYear->setData(0, Qt::UserRole, MODIFIED_SINCE_LAST_YEAR);
    lastUpdatedSinceRoot->addChild(lastUpdatedSinceLastYear);


    lastUpdatedBeforeRoot->setText(0, tr("Before"));
    lastUpdatedBeforeRoot->setData(0, Qt::UserRole, 0);
    lastUpdatedRoot->addChild(lastUpdatedBeforeRoot);

    lastUpdatedBeforeToday->setText(0, tr("Today"));
    lastUpdatedBeforeToday->setData(0, Qt::UserRole, MODIFIED_BEFORE_TODAY);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeToday);

    lastUpdatedBeforeYesterday->setText(0, tr("Yesterday"));
    lastUpdatedBeforeYesterday->setData(0, Qt::UserRole, MODIFIED_BEFORE_YESTERDAY);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeYesterday);

    lastUpdatedBeforeThisWeek->setText(0, tr("This week"));
    lastUpdatedBeforeThisWeek->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_WEEK);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisWeek);

    lastUpdatedBeforeLastWeek->setText(0, tr("Last week"));
    lastUpdatedBeforeLastWeek->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_WEEK);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastWeek);

    lastUpdatedBeforeThisMonth->setText(0, tr("This Month"));
    lastUpdatedBeforeThisMonth->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_MONTH);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisMonth);

    lastUpdatedBeforeLastMonth->setText(0, tr("Last Month"));
    lastUpdatedBeforeLastMonth->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_MONTH);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastMonth);

    lastUpdatedBeforeThisYear->setText(0, tr("This Year"));
    lastUpdatedBeforeThisYear->setData(0, Qt::UserRole, MODIFIED_BEFORE_THIS_YEAR);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeThisYear);

    lastUpdatedBeforeLastYear->setText(0, tr("Last Year"));
    lastUpdatedBeforeLastYear->setData(0, Qt::UserRole, MODIFIED_BEFORE_LAST_YEAR);
    lastUpdatedBeforeRoot->addChild(lastUpdatedBeforeLastYear);



    //*** Contains selection criteria
    this->containsRoot->setText(0, tr("Contains"));
    this->containsRoot->setData(0,Qt::UserRole, 0);

    this->containsImages->setText(0, tr("Images"));
    this->containsImages->setData(0, Qt::UserRole, CONTAINS_IMAGES);
    this->containsRoot->addChild(containsImages);

    this->containsAudio->setText(0, tr("Audio"));
    this->containsAudio->setData(0, Qt::UserRole, CONTAINS_AUDIO);
    this->containsRoot->addChild(containsAudio);

    this->containsInk->setText(0, tr("Ink"));
    this->containsInk->setData(0, Qt::UserRole, CONTAINS_INK);
    this->containsRoot->addChild(containsInk);

    this->containsEncryptedText->setText(0, tr("Encrypted Text"));
    this->containsEncryptedText->setData(0, Qt::UserRole, CONTAINS_ENCRYPTED_TEXT);
    this->containsRoot->addChild(containsEncryptedText);

    this->containsToDoItems->setText(0, tr("To-do items"));
    this->containsToDoItems->setData(0, Qt::UserRole, CONTAINS_TODO_ITEMS);
    this->containsRoot->addChild(containsUnfinishedToDoItems);

    this->containsUnfinishedToDoItems->setText(0, tr("Unfinished to-do items"));
    this->containsUnfinishedToDoItems->setData(0, Qt::UserRole, CONTAINS_UNFINISHED_TODO_ITEMS);
    this->containsRoot->addChild(containsUnfinishedToDoItems);

    this->containsFinishedToDoItems->setText(0, tr("Finished to-do items"));
    this->containsFinishedToDoItems->setData(0, Qt::UserRole, CONTAINS_FINISHED_TODO_ITEMS);
    this->containsRoot->addChild(containsFinishedToDoItems);

    this->containsPDFDocument->setText(0, tr("PDF document"));
    this->containsPDFDocument->setData(0, Qt::UserRole, CONTAINS_PDF_DOCUMENT);
    this->containsRoot->addChild(containsPDFDocument);

    this->containsAttachment->setText(0, tr("Attachment"));
    this->containsAttachment->setData(0, Qt::UserRole, CONTAINS_ATTACHMENT);
    this->containsRoot->addChild(containsAttachment);



    //*** Source selection criteria
    this->sourceRoot->setText(0, tr("Source"));
    this->sourceRoot->setData(0,Qt::UserRole, 0);

    this->sourceEmailedToEvernote->setText(0, tr("Emailed to Evernote"));
    this->sourceEmailedToEvernote->setData(0, Qt::UserRole, SOURCE_EMAILED_TO_EVERNOTE);
    this->sourceRoot->addChild(sourceEmailedToEvernote);

    this->sourceEmail->setText(0, tr("Email"));
    this->sourceEmail->setData(0, Qt::UserRole, SOURCE_EMAIL);
    this->sourceRoot->addChild(sourceEmail);

    this->sourceWebPage->setText(0, tr("Web page"));
    this->sourceWebPage->setData(0, Qt::UserRole, SOURCE_WEB_PAGE);
    this->sourceRoot->addChild(sourceWebPage);

    this->sourceMobile->setText(0, tr("Mobile"));
    this->sourceMobile->setData(0, Qt::UserRole, SOURCE_MOBILE);
    this->sourceRoot->addChild(sourceMobile);

    this->sourceAnotherApplication->setText(0, tr("Another application"));
    this->sourceAnotherApplication->setData(0, Qt::UserRole, SOURCE_ANOTHER_APPLICATION);
    this->sourceRoot->addChild(sourceAnotherApplication);


    // Add the options to the root
    root->addChild(createdRoot);
    root->addChild(lastUpdatedRoot);
    root->addChild(containsRoot);
    root->addChild(sourceRoot);
    root->setExpanded(true);

    this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    this->setFrameShape(QFrame::NoFrame);
    expandedImage = new QImage(":expandedIcon");
    collapsedImage = new QImage(":collapsedIcon");
}
Beispiel #7
0
// Constructor
NTagView::NTagView(QWidget *parent) :
    QTreeWidget(parent)
{
    accountFilter = 0;
    this->setFont(global.getGuiFont(font()));

    filterPosition = 0;
    maxCount = 0;
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::ExtendedSelection);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(false);
    this->header()->setVisible(false);
    //this->setStyleSheet("QTreeWidget { background:transparent; border:none; margin:0px; padding: 0px; }");

    // Build the root item
    root = new NTagViewItem(this);
    root->setIcon(NAME_POSITION,global.getIconResource(":tagIcon"));
    root->setData(NAME_POSITION, Qt::UserRole, "root");
    root->setData(NAME_POSITION, Qt::DisplayRole, tr("Tags from Personal"));
    root->setExpanded(true);
    QFont rootFont = root->font(NAME_POSITION);
    rootFont.setBold(true);
    root->setFont(NAME_POSITION, rootFont);

    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    this->rebuildTagTreeNeeded = true;
    this->loadData();
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));

    setAcceptDrops(true);
    setDragEnabled(true);

    global.settings->beginGroup("SaveState");
    hideUnassigned = global.settings->value("hideUnassigned", false).toBool();
    global.settings->endGroup();


    addAction = context.addAction(tr("Create New Tag"));
    addAction->setShortcut(QKeySequence(Qt::Key_Insert));
    addAction->setShortcutContext(Qt::WidgetShortcut);

    addShortcut = new QShortcut(this);
    addShortcut->setKey(QKeySequence(Qt::Key_Insert));
    addShortcut->setContext(Qt::WidgetShortcut);

    context.addSeparator();
    deleteAction = context.addAction(tr("Delete"));
    deleteAction->setShortcut(QKeySequence(Qt::Key_Delete));

    deleteShortcut = new QShortcut(this);
    deleteShortcut->setKey(QKeySequence(Qt::Key_Delete));
    deleteShortcut->setContext(Qt::WidgetShortcut);

    renameAction = context.addAction(tr("Rename"));
    renameAction->setShortcutContext(Qt::WidgetShortcut);

    mergeAction = context.addAction(tr("Merge"));

    context.addSeparator();
    hideUnassignedAction = context.addAction(tr("Hide Unassigned"));
    hideUnassignedAction->setCheckable(true);
    hideUnassignedAction->setChecked(hideUnassigned);
    connect(hideUnassignedAction, SIGNAL(triggered()), this, SLOT(hideUnassignedTags()));

    context.addSeparator();
    propertiesAction = context.addAction(tr("Properties"));

    connect(addAction, SIGNAL(triggered()), this, SLOT(addRequested()));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested()));
    connect(renameAction, SIGNAL(triggered()), this, SLOT(renameRequested()));
    connect(propertiesAction, SIGNAL(triggered()), this, SLOT(propertiesRequested()));
    connect(mergeAction, SIGNAL(triggered()), this, SLOT(mergeRequested()));
    connect(addShortcut, SIGNAL(activated()), this, SLOT(addRequested()));
    connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested()));

    this->setItemDelegate(new NTagViewDelegate());
    this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    this->setFrameShape(QFrame::NoFrame);
    expandedImage = new QImage(":expandedIcon");
    collapsedImage = new QImage(":collapsedIcon");
}
Beispiel #8
0
// Constructor
NNotebookView::NNotebookView(QWidget *parent) :
    QTreeWidget(parent)
{
    stackStore.clear();
    dataStore.clear();
    this->setFont(global.getGuiFont(font()));

    filterPosition = -1;
    maxCount = 0;  // Highest count of any notebook.  Used in calculating column width
    // setup options
    this->setEditTriggers(QAbstractItemView::NoEditTriggers);
    this->setSelectionBehavior(QAbstractItemView::SelectRows);
    this->setSelectionMode(QAbstractItemView::SingleSelection);
    this->setRootIsDecorated(true);
    this->setSortingEnabled(false);
    this->header()->setVisible(false);
    this->setStyleSheet("QTreeView {border-image:none; image:none;} ");
    root = new NNotebookViewItem(0);
    root->setType(NNotebookViewItem::Stack);
    root->setData(NAME_POSITION, Qt::UserRole, "rootsynchronized");
    root->setData(NAME_POSITION, Qt::DisplayRole, tr("Notebooks"));
    QFont rootFont = root->font(NAME_POSITION);
    rootFont.setBold(true);
    root->setFont(NAME_POSITION, rootFont);

    root->setRootColor(false);

    this->setMinimumHeight(1);
    this->addTopLevelItem(root);
    this->rebuildNotebookTreeNeeded = true;
    this->loadData();
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(calculateHeight()));
    connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(buildSelection()));

    addAction = context.addAction(tr("Create New Notebook"));
    addAction->setShortcut(QKeySequence(Qt::Key_Insert));
    addAction->setShortcutContext(Qt::WidgetShortcut);

    addShortcut = new QShortcut(this);
    addShortcut->setKey(QKeySequence(Qt::Key_Insert));
    addShortcut->setContext(Qt::WidgetShortcut);

    context.addSeparator();
    deleteAction = context.addAction(tr("Delete"));
    deleteAction->setShortcut(QKeySequence(Qt::Key_Delete));

    deleteShortcut = new QShortcut(this);
    deleteShortcut->setKey(QKeySequence(Qt::Key_Delete));
    deleteShortcut->setContext(Qt::WidgetShortcut);

    // Start building the stack menu
    stackMenu = context.addMenu(tr("Add to stack"));
    QAction *newAction;
    NotebookTable table(global.db);
    QStringList stacks;
    table.getStacks(stacks);
    for (int i=0; i<stacks.size(); i++) {
        newAction = stackMenu->addAction(stacks[i]);
        connect(newAction, SIGNAL(triggered()), this, SLOT(moveToStackRequested()));
    }
    sortStackMenu();
    if (stacks.size() > 0) {
        stackMenu->addSeparator();
    }
    newStackAction = stackMenu->addAction(tr("New stack"));
    connect(newStackAction, SIGNAL(triggered()), this, SLOT(moveToNewStackRequested()));

    removeFromStackAction = context.addAction(tr("Remove from stack"));
    removeFromStackAction->setShortcutContext(Qt::WidgetShortcut);
    removeFromStackAction->setVisible(false);

    renameAction = context.addAction(tr("Rename"));
    renameAction->setShortcutContext(Qt::WidgetShortcut);

    //renameShortcut = new QShortcut(this);
    //renameShortcut->setKey(QKeySequence(Qt::Key_F2));
    //renameShortcut->setContext(Qt::WidgetShortcut);

    context.addSeparator();
    propertiesAction = context.addAction(tr("Properties"));

    connect(addAction, SIGNAL(triggered()), this, SLOT(addRequested()));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteRequested()));
    connect(renameAction, SIGNAL(triggered()), this, SLOT(renameRequested()));
    connect(propertiesAction, SIGNAL(triggered()), this, SLOT(propertiesRequested()));

    connect(addShortcut, SIGNAL(activated()), this, SLOT(addRequested()));
    connect(deleteShortcut, SIGNAL(activated()), this, SLOT(deleteRequested()));
    //connect(renameShortcut, SIGNAL(activated()), this, SLOT(renameRequested()));
    connect(removeFromStackAction, SIGNAL(triggered()), this, SLOT(removeFromStackRequested()));

    this->setAcceptDrops(true);
    this->setItemDelegate(new NNotebookViewDelegate());
    root->setExpanded(true);
    this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
    this->setFrameShape(QFrame::NoFrame);


    //setStyle(new MyStyle("QTreeView"));
//    setStyle(new QCleanlooksStyle);
    //setStyleSheet("::branches {image: url(:right-arrow.png);}");

//    setStyleSheet("QTreeView::branch { image: url(:right-arrow.png); }");

    expandedImage = new QImage(":expandedIcon");
    collapsedImage = new QImage(":collapsedIcon");
}