/*
* This file is part of OctoXBPS, an open-source GUI for XBPS.
* Copyright (C) 2015 Alexandre Albuquerque Arnt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*/

#ifndef UTILS_H
#define UTILS_H

#include <QObject>
#include <QTimer>
#include <QStandardItemModel>
#include <QModelIndex>
#include <QProcess>
#include "constants.h"

class QTextEdit;
class QTextBrowser;
class SearchBar;

namespace utils{

QString showFullPathOfItem( const QModelIndex &index );
QList<QModelIndex> * findFileInTreeView( const QString& name, const QStandardItemModel *sim);
QString retrieveDistroNews(bool searchForLatestNews);
QString parseDistroNews();

//QTextBrowser related
bool strInQTextEdit(QTextBrowser *text, const QString& findText);
void positionTextEditCursorAtEnd(QTextEdit *textEdit);
void writeToTextBrowser(QTextBrowser* text, const QString &str, TreatURLLinks treatURLLinks = ectn_TREAT_URL_LINK);

//SearchBar related
void positionInFirstMatch(QTextBrowser *tb, SearchBar *sb);
void searchBarTextChangedInTextBrowser(QTextBrowser *tb, SearchBar *sb, const QString textToSearch);
void searchBarFindNextInTextBrowser(QTextBrowser *tb, SearchBar *sb);
void searchBarFindPreviousInTextBrowser(QTextBrowser *tb, SearchBar *sb);
void searchBarClosedInTextBrowser(QTextBrowser *tb, SearchBar *sb);

//QDialog related
#if QT_VERSION >= 0x050000
  void positionWindowAtScreenCenter(QWidget *w);
#endif

} //namespace utils

#endif // UTILS_H
